/* ===== VARIABLES ===== */
:root {
  --primary: #e65c00;
  --primary-dark: #bf4c00;
  --primary-light: #ff8534;
  --sidebar-bg: #1a1a2e;
  --sidebar-hover: #16213e;
  --sidebar-active: #e65c00;
  --sidebar-w: 240px;
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --text: #333;
  --text-muted: #888;
  --border: #e0e0e0;
  --topbar-h: 56px;
  --bottom-nav-h: 64px;
  --shadow: 0 2px 12px rgba(0,0,0,0.09);
}

/* ===== BASE ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); overflow-x: hidden; }
a { text-decoration: none; color: inherit; }

/* ===== SIDEBAR ===== */
#sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  z-index: 1000; transition: transform .3s ease;
  box-shadow: 3px 0 15px rgba(0,0,0,0.2);
}
.sidebar-header {
  padding: 20px 20px 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.logo-icon { font-size: 28px; }
.logo-text { color: #fff; font-size: 1.2rem; font-weight: 700; letter-spacing: .5px; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; color: rgba(255,255,255,0.7);
  transition: all .2s; font-size: .95rem;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active {
  background: rgba(230,92,0,0.15); color: var(--primary-light);
  border-left-color: var(--primary);
}
.nav-item i { width: 20px; text-align: center; font-size: 1rem; }
.sidebar-footer { padding: 12px 20px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-footer small { color: rgba(255,255,255,0.35); font-size: .75rem; }

/* ===== TOP BAR (mobile) ===== */
#topbar {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h); background: var(--sidebar-bg);
  align-items: center; justify-content: space-between;
  padding: 0 16px; z-index: 999;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
#topbar-title { color: #fff; font-weight: 600; font-size: 1.05rem; }
#sidebar-toggle { background: none; border: none; color: #fff; font-size: 1.3rem; cursor: pointer; padding: 8px; }

/* ===== MAIN WRAPPER ===== */
#wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh; padding: 24px;
  transition: margin .3s ease;
}
#page-content { max-width: 1200px; margin: 0 auto; }

/* ===== BOTTOM NAV (mobile) ===== */
#bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h); background: var(--sidebar-bg);
  justify-content: space-around; align-items: center;
  z-index: 1000; box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
}
.bn-item {
  display: flex; flex-direction: column; align-items: center;
  color: rgba(255,255,255,0.6); font-size: .65rem; gap: 3px;
  flex: 1; padding: 8px 4px; transition: color .2s;
}
.bn-item i { font-size: 1.1rem; }
.bn-item.active, .bn-item:hover { color: var(--primary-light); }

/* ===== SIDEBAR OVERLAY ===== */
#sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 999;
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-size: 1.5rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 10px; }
.page-title i { color: var(--primary); }

/* ===== STAT CARDS ===== */
.stat-card {
  background: var(--card-bg); border-radius: 14px;
  padding: 20px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
  transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.12); }
.stat-card-link { cursor: pointer; }
.stat-card-link:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(230,92,0,0.18); border-left: 3px solid var(--primary); }
.stat-icon {
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.stat-icon.orange { background: rgba(230,92,0,0.12); color: var(--primary); }
.stat-icon.blue   { background: rgba(37,99,235,0.1);  color: #2563eb; }
.stat-icon.green  { background: rgba(16,185,129,0.1); color: #10b981; }
.stat-icon.purple { background: rgba(139,92,246,0.1); color: #8b5cf6; }
.stat-icon.red    { background: rgba(239,68,68,0.1);  color: #ef4444; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 1.4rem; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-sub { font-size: .78rem; color: var(--text-muted); margin-top: 3px; }

/* ===== CARDS ===== */
.card-custom {
  background: var(--card-bg); border-radius: 14px;
  box-shadow: var(--shadow); border: none; overflow: hidden;
}
.card-custom .card-header-custom {
  padding: 16px 20px; font-weight: 600; font-size: 1rem;
  border-bottom: 1px solid var(--border); display: flex;
  align-items: center; justify-content: space-between;
}
.card-custom .card-body-custom { padding: 20px; }

/* ===== TABLES ===== */
.table-custom { width: 100%; border-collapse: collapse; }
.table-custom th {
  background: #f8f9fa; font-size: .78rem; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-muted); font-weight: 600;
  padding: 10px 14px; border-bottom: 2px solid var(--border);
}
.table-custom td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: .9rem; vertical-align: middle; }
.table-custom tbody tr { transition: background .15s; cursor: pointer; }
.table-custom tbody tr:hover { background: #fafafa; }
.table-custom tbody tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.badge-custom {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 20px; font-size: .75rem; font-weight: 600;
}
.badge-pagado    { background: rgba(16,185,129,0.12); color: #059669; }
.badge-pendiente { background: rgba(245,158,11,0.12); color: #d97706; }
.badge-parcial   { background: rgba(59,130,246,0.12); color: #2563eb; }
.badge-alta      { background: rgba(239,68,68,0.12);  color: #dc2626; }
.badge-media     { background: rgba(245,158,11,0.12); color: #d97706; }
.badge-baja      { background: rgba(16,185,129,0.12); color: #059669; }
.badge-completada{ background: rgba(16,185,129,0.12); color: #059669; }
.badge-en_progreso{ background: rgba(59,130,246,0.12); color: #2563eb; }
.badge-efectivo  { background: #f1f5f9; color: #475569; }
.badge-transferencia{ background: rgba(139,92,246,0.12); color: #7c3aed; }

/* ===== BUTTONS ===== */
.btn-primary-custom {
  background: var(--primary); color: #fff; border: none;
  padding: 10px 20px; border-radius: 10px; font-weight: 600;
  cursor: pointer; transition: background .2s, transform .1s;
  display: inline-flex; align-items: center; gap: 8px; font-size: .9rem;
}
.btn-primary-custom:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-icon {
  background: none; border: none; cursor: pointer;
  padding: 5px 8px; border-radius: 7px; transition: background .2s; font-size: .95rem;
}
.btn-icon.edit   { color: #2563eb; }
.btn-icon.delete { color: #ef4444; }
.btn-icon.view   { color: #059669; }
.btn-icon:hover  { background: #f1f5f9; }

/* ===== SEARCH & FILTERS ===== */
.filter-bar {
  background: var(--card-bg); border-radius: 12px;
  padding: 14px 16px; box-shadow: var(--shadow);
  margin-bottom: 16px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}
.filter-bar input, .filter-bar select {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-size: .88rem; outline: none;
  background: #fafafa; transition: border-color .2s; min-width: 0;
}
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--primary); }
.filter-bar input[type="text"] { flex: 1; min-width: 160px; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; border: 1.5px solid var(--border); border-radius: 9px;
  padding: 10px 12px; font-size: .9rem; transition: border-color .2s;
  background: #fafafa; outline: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary); background: #fff;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group-full { grid-column: 1 / -1; }

/* ===== PHOTO UPLOAD ===== */
.photo-upload-area {
  border: 2px dashed var(--border); border-radius: 12px;
  padding: 20px; text-align: center; cursor: pointer;
  transition: border-color .2s, background .2s;
  background: #fafafa;
}
.photo-upload-area:hover, .photo-upload-area.drag-over {
  border-color: var(--primary); background: rgba(230,92,0,0.03);
}
.photo-upload-area i { font-size: 2rem; color: var(--primary-light); margin-bottom: 8px; }
.photo-upload-area p { font-size: .85rem; color: var(--text-muted); margin: 0; }
.photo-preview {
  max-width: 100%; max-height: 200px; border-radius: 10px;
  object-fit: contain; margin-top: 10px;
}

/* ===== FOTO GALLERY ===== */
.foto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.foto-card {
  background: var(--card-bg); border-radius: 12px;
  overflow: hidden; box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}
.foto-card:hover { transform: translateY(-3px); box-shadow: 0 8px 25px rgba(0,0,0,0.12); }
.foto-card img {
  width: 100%; height: 160px; object-fit: cover;
  cursor: zoom-in; display: block;
}
.foto-card-body { padding: 10px 12px; }
.foto-card-title { font-weight: 600; font-size: .88rem; margin-bottom: 3px; }
.foto-card-meta { font-size: .75rem; color: var(--text-muted); }

/* ===== TAREAS ===== */
.tarea-item {
  background: var(--card-bg); border-radius: 12px;
  padding: 14px 16px; box-shadow: var(--shadow);
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 10px; border-left: 4px solid transparent;
  transition: transform .15s;
}
.tarea-item:hover { transform: translateX(2px); }
.tarea-item.alta    { border-left-color: #ef4444; }
.tarea-item.media   { border-left-color: #f59e0b; }
.tarea-item.baja    { border-left-color: #10b981; }
.tarea-item.completada { opacity: .55; }
.tarea-check { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--border); cursor: pointer; flex-shrink: 0; margin-top: 2px; }
.tarea-check.checked { background: var(--primary); border-color: var(--primary); }
.tarea-titulo { font-weight: 600; font-size: .92rem; margin-bottom: 3px; }
.tarea-titulo.tachada { text-decoration: line-through; }
.tarea-desc { font-size: .82rem; color: var(--text-muted); }
.tarea-actions { margin-left: auto; display: flex; gap: 4px; flex-shrink: 0; }

/* ===== LIGHTBOX ===== */
#lightbox {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.92); z-index: 9999;
  align-items: center; justify-content: center;
  cursor: zoom-out;
}
#lightbox.show { display: flex; }
#lightbox-img { max-width: 95vw; max-height: 90vh; object-fit: contain; border-radius: 8px; }
#lightbox-close {
  position: absolute; top: 20px; right: 24px;
  background: rgba(255,255,255,0.1); border: none; color: #fff;
  width: 44px; height: 44px; border-radius: 50%; font-size: 1.1rem;
  cursor: pointer; transition: background .2s;
}
#lightbox-close:hover { background: rgba(255,255,255,0.25); }

/* ===== TIMELINE ===== */
.timeline-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-dot {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; flex-shrink: 0; margin-top: 2px;
}
.timeline-dot.pago     { background: rgba(37,99,235,0.1); color: #2563eb; }
.timeline-dot.material { background: rgba(230,92,0,0.1);  color: var(--primary); }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state i { font-size: 3rem; margin-bottom: 12px; opacity: .4; display: block; }
.empty-state p { font-size: .95rem; }

/* ===== REPORTES CHARTS ===== */
.chart-container { position: relative; height: 280px; }

/* ===== TOAST ===== */
.toast-custom {
  min-width: 260px; border-radius: 12px; padding: 14px 18px;
  font-size: .9rem; font-weight: 500; box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  display: flex; align-items: center; gap: 10px; animation: slideIn .3s ease;
}
.toast-custom.success { background: #ecfdf5; color: #065f46; border-left: 4px solid #10b981; }
.toast-custom.error   { background: #fef2f2; color: #991b1b; border-left: 4px solid #ef4444; }
.toast-custom.info    { background: #eff6ff; color: #1e40af; border-left: 4px solid #3b82f6; }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== PERSONAS ===== */
.persona-card {
  background: var(--card-bg); border-radius: 14px;
  padding: 18px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 14px;
  cursor: pointer; transition: transform .2s, box-shadow .2s;
}
.persona-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.12); }
.persona-avatar {
  width: 50px; height: 50px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 700; flex-shrink: 0;
  background: rgba(230,92,0,0.1); color: var(--primary);
}
.persona-total { font-size: 1.1rem; font-weight: 700; color: var(--primary); }
.persona-tipo { font-size: .75rem; background: #f1f5f9; color: #475569; padding: 2px 8px; border-radius: 20px; display: inline-block; margin-top: 4px; }

/* ===== ANIMATIONS ===== */
.fade-in { animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  #sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
  #sidebar.open { transform: translateX(0); }
  #sidebar-overlay.show { display: block; }
  #topbar { display: flex; }
  #bottom-nav { display: flex; }
  #wrapper { margin-left: 0; padding: 12px; padding-top: calc(var(--topbar-h) + 12px); padding-bottom: calc(var(--bottom-nav-h) + 12px); }
  .form-row { grid-template-columns: 1fr; }
  .foto-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .foto-card img { height: 130px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.2rem; }
  .page-title { font-size: 1.2rem; }
  .table-responsive { overflow-x: auto; }
}

@media (min-width: 769px) {
  #topbar { display: none !important; }
  #bottom-nav { display: none !important; }
}
