/* ============================================================
   Sistema de Control Financiero Escolar – Hoja de estilos
   ============================================================ */

/* ---------- Variables de color ---------- */
:root {
  --azul:       #105ea9;
  --azul-claro: #5d88c3;
  --amarillo:   #fde70e;
  --azul-dark:  #0b4a87;
  --bg-grad:    linear-gradient(135deg, #e8f0fb 0%, #f0f6ff 100%);
  --sidebar-w:  240px;
  --radius:     10px;
  --shadow:     0 4px 20px rgba(16,94,169,.12);
  --font:       'Segoe UI', system-ui, sans-serif;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); font-size: .95rem; background: var(--bg-grad); color: #1e293b; min-height:100vh; }
a { text-decoration:none; color: inherit; }
img { max-width:100%; }

/* ---------- Layout ---------- */
.app-wrapper { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--azul);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  box-shadow: 4px 0 20px rgba(0,0,0,.15);
  transition: transform .25s ease;
}
.sidebar-logo {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo .icon { font-size:1.6rem; }
.sidebar-logo .title { font-size:1rem; font-weight:700; line-height:1.2; }
.sidebar-logo .sub   { font-size:.72rem; opacity:.7; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 20px;
  cursor: pointer;
  transition: background .15s;
  border-left: 3px solid transparent;
  font-size: .9rem;
}
.nav-item:hover  { background: rgba(255,255,255,.1); }
.nav-item.active { background: rgba(255,255,255,.15); border-left-color: var(--amarillo); font-weight:600; }
.nav-item .nav-icon { font-size:1.1rem; width:22px; text-align:center; }
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.12);
  font-size: .8rem;
  opacity: .75;
}
.sidebar-footer a { color:#fff; opacity:.9; }
.sidebar-footer a:hover { opacity:1; }

/* ---------- Main content ---------- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  background: #fff;
  border-bottom: 1px solid #e2eaf3;
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1.1rem; font-weight: 700; color: var(--azul); }
.topbar-user  { font-size: .85rem; color: #64748b; }

.page-content { padding: 28px; flex: 1; }

/* ---------- Secciones ---------- */
.section { display: none; }
.section.active { display: block; }

.section-header { margin-bottom: 20px; }
.section-header h2 { font-size: 1.35rem; font-weight: 700; color: var(--azul-dark); }
.section-header p  { color: #64748b; font-size: .88rem; margin-top:2px; }

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 1rem; font-weight: 700;
  color: var(--azul);
  border-bottom: 2px solid var(--amarillo);
  padding-bottom: 8px;
  margin-bottom: 20px;
}

/* ---------- Formularios ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: .82rem; font-weight: 600; color: #475569; }
.form-control {
  border: 1.5px solid #d1dbe8;
  border-radius: 7px;
  padding: 9px 12px;
  font-size: .9rem;
  font-family: var(--font);
  transition: border-color .15s, box-shadow .15s;
  background: #fafcff;
  outline: none;
  width: 100%;
}
.form-control:focus {
  border-color: var(--azul-claro);
  box-shadow: 0 0 0 3px rgba(93,136,195,.18);
  background: #fff;
}
.form-control[readonly] { background: #f1f5f9; color: #64748b; }
.form-control.is-invalid { border-color: #ef4444; }
.invalid-feedback { color:#ef4444; font-size:.78rem; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  font-size: .88rem;
  font-weight: 600;
  font-family: var(--font);
  transition: all .15s;
}
.btn-primary   { background: var(--azul); color: #fff; }
.btn-primary:hover { background: var(--azul-dark); }
.btn-success   { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-warning   { background: var(--amarillo); color: #1e293b; }
.btn-warning:hover { filter: brightness(.94); }
.btn-danger    { background: #dc2626; color: #fff; }
.btn-danger:hover  { background: #b91c1c; }
.btn-secondary { background: #e2e8f0; color: #334155; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-outline   { background: transparent; border: 1.5px solid var(--azul); color: var(--azul); }
.btn-outline:hover { background: var(--azul); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-icon { padding: 6px 8px; }

/* ---------- Buscador autocomplete ---------- */
.search-wrap { position: relative; }
.autocomplete-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: #fff;
  border: 1.5px solid #d1dbe8;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.1);
  z-index: 200;
  max-height: 220px;
  overflow-y: auto;
  display: none;
}
.autocomplete-list.open { display: block; }
.autocomplete-item {
  padding: 9px 14px;
  cursor: pointer;
  font-size: .88rem;
  border-bottom: 1px solid #f1f5f9;
  transition: background .1s;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: #eff6ff; }
.autocomplete-item .mat  { font-weight: 700; color: var(--azul); font-size:.8rem; }
.autocomplete-item .nom  { display: block; }

/* ---------- Tabla ---------- */
.table-wrap { overflow-x: auto; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: .87rem; }
thead th {
  background: var(--azul);
  color: #fff;
  padding: 11px 12px;
  text-align: left;
  font-weight: 600;
  font-size: .8rem;
  letter-spacing: .03em;
}
tbody tr { border-bottom: 1px solid #f0f4f9; transition: background .1s; }
tbody tr:hover { background: #f7faff; }
tbody td { padding: 10px 12px; vertical-align: middle; }

/* ---------- Badge ---------- */
.badge {
  display: inline-block; padding: 3px 9px;
  border-radius: 99px; font-size: .75rem; font-weight: 600;
}
.badge-efectivo     { background: #dcfce7; color: #15803d; }
.badge-deposito     { background: #dbeafe; color: #1d4ed8; }
.badge-transferencia{ background: #ede9fe; color: #7c3aed; }

/* ---------- Paginación ---------- */
.pagination { display: flex; gap: 6px; margin-top: 16px; justify-content: flex-end; flex-wrap: wrap; }
.page-btn {
  padding: 6px 12px; border-radius: 6px;
  border: 1.5px solid #d1dbe8;
  background: #fff; cursor: pointer;
  font-size: .82rem; font-weight: 600;
  transition: all .15s; color: #334155;
}
.page-btn:hover  { background: #eff6ff; border-color: var(--azul-claro); }
.page-btn.active { background: var(--azul); color: #fff; border-color: var(--azul); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Alertas ---------- */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: .88rem;
  display: flex; align-items: center; gap: 8px;
}
.alert-success { background: #f0fdf4; color: #15803d; border-left: 4px solid #22c55e; }
.alert-error   { background: #fef2f2; color: #b91c1c; border-left: 4px solid #ef4444; }
.alert-info    { background: #eff6ff; color: #1d4ed8; border-left: 4px solid #3b82f6; }

/* ---------- Total box ---------- */
.total-box {
  background: linear-gradient(135deg, var(--azul), var(--azul-claro));
  color: #fff;
  border-radius: 12px;
  padding: 18px 22px;
  display: flex; align-items: center; justify-content: space-between;
}
.total-box .label { font-size: .85rem; opacity: .85; }
.total-box .amount { font-size: 1.8rem; font-weight: 800; }

/* ---------- Stats ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--azul);
}
.stat-card.yellow { border-left-color: var(--amarillo); }
.stat-card.green  { border-left-color: #22c55e; }
.stat-card.light  { border-left-color: var(--azul-claro); }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 800; color: var(--azul-dark); }
.stat-card .stat-label { font-size: .78rem; color: #64748b; margin-top: 2px; }

/* ---------- Spinner ---------- */
.spinner {
  width: 28px; height: 28px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--azul);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 32px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   VOUCHER (solo pantalla)
   ============================================================ */
.voucher-preview-wrap {
  background: #f8fafc;
  border: 1px solid #d1dbe8;
  border-radius: 10px;
  padding: 16px;
  margin-top: 20px;
}

/* ============================================================
   PRINT STYLES – Voucher doble tamaño carta horizontal
   ============================================================ */
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  body, html { margin: 0; padding: 0; background: #fff; }

  /* Ocultar todo excepto voucher */
  .app-wrapper, .sidebar, .topbar, .page-content, .no-print { display: none !important; }

  #voucher-print-area { display: block !important; }

  /* Mostrar los divs de impresion */
  #voucher-print-half-1,
  #voucher-print-half-2,
  .cut-line { display: flex !important; }

  /* Ocultar la version pantalla */
  .voucher-screen-wrap { display: none !important; }

  @page {
    size: letter landscape;
    margin: 0;
  }

  #voucher-print-area {
    width: 100%;
    height: 100vh;
    display: flex !important;
    flex-direction: row;
    align-items: stretch;
    padding: 10mm;
    gap: 0;
    box-sizing: border-box;
    page-break-after: avoid;
  }

  .voucher-half {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 8mm 10mm;
    box-sizing: border-box;
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 9pt;
  }

  .voucher-half:first-child {
    border-right: 2px dashed #aaa;
    margin-right: 4mm;
    padding-right: 14mm;
  }

  .v-header {
    background: #105ea9 !important;
    color: #fff !important;
    padding: 6mm 4mm;
    border-radius: 4mm;
    margin-bottom: 4mm;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .v-header .v-inst { font-size: 11pt; font-weight: 700; }
  .v-header .v-sub  { font-size: 7.5pt; opacity: .85; }
  .v-header .v-folio { font-size: 13pt; font-weight: 800; color: #fde70e !important; }

  .v-body { flex: 1; }

  .v-row {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
    padding: 2mm 0;
    align-items: flex-start;
  }
  .v-row:last-child { border-bottom: none; }
  .v-label {
    width: 36mm; min-width: 36mm;
    font-size: 7.5pt; font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: .03em;
    padding-right: 3mm;
  }
  .v-val { font-size: 9pt; color: #1e293b; flex: 1; word-break: break-word; }
  .v-val.big { font-size: 13pt; font-weight: 800; color: #105ea9 !important; }

  .v-footer {
    margin-top: 4mm;
    border-top: 1.5px solid #105ea9;
    padding-top: 3mm;
    display: flex;
    justify-content: space-between;
    font-size: 7pt;
    color: #64748b;
  }

  .v-badge {
    display: inline-block;
    padding: 1mm 3mm;
    border-radius: 3mm;
    font-size: 7.5pt;
    font-weight: 700;
    background: #dbeafe !important;
    color: #1d4ed8 !important;
  }

  .cut-line {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 7pt;
    color: #aaa;
    align-self: center;
    margin: 0 2mm;
    letter-spacing: 2px;
  }
}

/* Voucher en pantalla */
#voucher-print-area {
  display: none;
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 9999;
  overflow: auto;
}

/* Los divs de impresion NUNCA se ven en pantalla, solo al imprimir */
#voucher-print-half-1,
#voucher-print-half-2,
.cut-line {
  display: none !important;
}
.voucher-screen-wrap {
  padding: 20px;
  max-width: 900px;
  margin: 0 auto;
}
.voucher-controls {
  display: flex; gap: 10px; margin-bottom: 20px;
  position: sticky; top: 0;
  background: #fff;
  padding: 12px 0;
  border-bottom: 1px solid #e2e8f0;
  z-index: 10;
}
.voucher-double {
  display: flex;
  gap: 0;
  border: 1px solid #ccc;
  border-radius: 8px;
  overflow: hidden;
}
.voucher-half-screen {
  flex: 1;
  padding: 20px;
  font-size: .85rem;
}
.voucher-half-screen:first-child {
  border-right: 2px dashed #bbb;
}
.v-header-screen {
  background: var(--azul);
  color: #fff;
  padding: 14px 16px;
  border-radius: 8px;
  margin-bottom: 12px;
  display: flex; justify-content: space-between; align-items: center;
}
.v-header-screen .v-folio { font-size: 1.1rem; font-weight: 800; color: var(--amarillo); }
.v-row-screen {
  display: flex;
  padding: 6px 0;
  border-bottom: 1px solid #f1f5f9;
}
.v-row-screen:last-child { border-bottom: none; }
.v-label-screen { width: 120px; min-width: 120px; font-size: .78rem; font-weight: 700; color: #64748b; text-transform: uppercase; }
.v-val-screen   { font-size: .88rem; flex: 1; }
.v-val-screen.big { font-size: 1.1rem; font-weight: 800; color: var(--azul); }
.v-footer-screen { margin-top: 12px; font-size: .75rem; color: #94a3b8; display:flex; justify-content:space-between; border-top: 1px solid var(--azul); padding-top: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
