/* ========================================
   CSOH Finanzas - Custom Styles
   ======================================== */

:root {
  --sidebar-width: 260px;
  --sidebar-bg: #1a3a5c;
  --sidebar-hover: #2980b9;
  --sidebar-active: #3498db;
  --topbar-height: 60px;
  --primary: #2980b9;
  --primary-dark: #1a3a5c;
  --success: #27ae60;
  --warning: #f39c12;
  --danger: #e74c3c;
  --orange: #e67e22;
  --body-bg: #f0f4f8;
  --card-radius: 12px;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-family);
  background: var(--body-bg);
  color: #2c3e50;
  min-height: 100vh;
}

/* ========================================
   SIDEBAR
   ======================================== */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  z-index: 1030;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1029;
}

.sidebar-overlay.show { display: block; }

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.sidebar-logo i {
  font-size: 2rem;
  color: #3498db;
}

.sidebar-logo-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.sidebar-logo-sub {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.sidebar-close:hover { background: rgba(255,255,255,0.1); color: #fff; }

.sidebar-menu {
  list-style: none;
  padding: 16px 12px;
  margin: 0;
  flex: 1;
}

.sidebar-menu-item { margin-bottom: 4px; }

.sidebar-menu-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.sidebar-menu-link i { font-size: 1.1rem; min-width: 20px; }

.sidebar-menu-link:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.sidebar-menu-link.active {
  background: var(--sidebar-active);
  color: #fff;
  box-shadow: 0 4px 12px rgba(52,152,219,0.3);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  background: var(--sidebar-active);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: 0.85rem;
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.5);
}

.btn-logout {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: all 0.2s;
}

.btn-logout:hover { background: rgba(231,76,60,0.3); color: #e74c3c; }

/* ========================================
   TOP NAVBAR
   ======================================== */

.top-navbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e8ecf0;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 1020;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.navbar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: #2c3e50;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.navbar-toggle:hover { background: var(--body-bg); }

.navbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: #2c3e50;
  flex: 1;
}

/* ========================================
   MAIN CONTENT
   ======================================== */

.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  padding: 28px 24px;
  min-height: calc(100vh - var(--topbar-height));
}

/* ========================================
   KPI CARDS
   ======================================== */

.kpi-card {
  background: #fff;
  border-radius: var(--card-radius);
  padding: 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  border-left: 4px solid transparent;
  transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

.kpi-card.kpi-primary { border-left-color: var(--primary); }
.kpi-card.kpi-success { border-left-color: var(--success); }
.kpi-card.kpi-warning { border-left-color: var(--warning); }
.kpi-card.kpi-danger  { border-left-color: var(--danger); }

.kpi-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}

.kpi-primary .kpi-icon { background: rgba(41,128,185,0.12); color: var(--primary); }
.kpi-success .kpi-icon { background: rgba(39,174,96,0.12); color: var(--success); }
.kpi-warning .kpi-icon { background: rgba(243,156,18,0.12); color: var(--warning); }
.kpi-danger  .kpi-icon { background: rgba(231,76,60,0.12); color: var(--danger); }

.kpi-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #7f8c8d;
  font-weight: 600;
}

.kpi-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: #2c3e50;
  line-height: 1.2;
}

.kpi-sub {
  font-size: 0.78rem;
  color: #95a5a6;
}

/* ========================================
   STATUS CARDS
   ======================================== */

.status-card {
  background: #fff;
  border-radius: var(--card-radius);
  padding: 18px;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  border-top: 4px solid transparent;
  transition: transform 0.2s;
}

.status-card:hover { transform: translateY(-2px); }
.status-current { border-top-color: var(--success); }
.status-1       { border-top-color: var(--warning); }
.status-2       { border-top-color: var(--orange); }
.status-3       { border-top-color: var(--danger); }

.status-icon { font-size: 1.5rem; margin-bottom: 6px; }
.status-current .status-icon { color: var(--success); }
.status-1 .status-icon       { color: var(--warning); }
.status-2 .status-icon        { color: var(--orange); }
.status-3 .status-icon        { color: var(--danger); }

.status-count { font-size: 2.2rem; font-weight: 800; color: #2c3e50; }
.status-label { font-size: 0.82rem; color: #7f8c8d; font-weight: 500; }

/* ========================================
   CARDS
   ======================================== */

.card {
  border: none;
  border-radius: var(--card-radius);
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.card-header {
  background: #fff;
  border-bottom: 1px solid #e8ecf0;
  padding: 16px 20px;
  border-radius: var(--card-radius) var(--card-radius) 0 0 !important;
}

.card-title { font-weight: 600; font-size: 0.95rem; }

/* ========================================
   STUDENT AVATAR
   ======================================== */

.student-avatar {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #3498db, #2980b9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.student-avatar-lg {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #3498db, #2980b9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.student-avatar-sm {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #3498db, #2980b9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.72rem;
  flex-shrink: 0;
}

/* ========================================
   TABLES
   ======================================== */

.table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: #7f8c8d;
}

.table td { font-size: 0.9rem; }

/* ========================================
   BADGES
   ======================================== */

.bg-orange { background-color: var(--orange) !important; }

/* ========================================
   FLASH ALERTS
   ======================================== */

.alert-toast {
  border-radius: 10px;
  margin-bottom: 16px;
  border: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* ========================================
   LOGIN PAGE
   ======================================== */

.login-body {
  background: linear-gradient(135deg, #1a3a5c 0%, #2980b9 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-container {
  width: 100%;
  max-width: 440px;
}

.login-card {
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-header {
  background: linear-gradient(135deg, #1a3a5c, #2980b9);
  padding: 36px 32px 28px;
  text-align: center;
}

.login-icon {
  width: 72px;
  height: 72px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 2.2rem;
  color: #fff;
}

.login-title { color: #fff; font-weight: 800; font-size: 1.6rem; margin: 0; }
.login-subtitle { color: rgba(255,255,255,0.75); font-size: 0.85rem; margin-top: 4px; }

.login-body-content { padding: 28px 32px; }
.login-footer { padding: 12px 32px 24px; text-align: center; }

/* ========================================
   RECEIPT / COMPROBANTE
   ======================================== */

.receipt-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.receipt-header {
  background: linear-gradient(135deg, #1a3a5c, #2980b9);
  padding: 28px 32px 20px;
  text-align: center;
  color: #fff;
}

.receipt-school { font-size: 1.2rem; font-weight: 700; margin: 0; }
.receipt-address { font-size: 0.82rem; opacity: 0.8; margin: 4px 0; }
.receipt-contact { font-size: 0.82rem; opacity: 0.75; margin: 4px 0; }

.receipt-title {
  margin-top: 16px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  background: rgba(255,255,255,0.15);
  padding: 6px 16px;
  border-radius: 20px;
  display: inline-block;
}

.receipt-body { padding: 24px 32px; }

.receipt-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #7f8c8d;
  font-weight: 600;
  margin-bottom: 10px;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.receipt-label { color: #7f8c8d; flex-shrink: 0; margin-right: 12px; }
.receipt-value { font-weight: 500; text-align: right; }
.receipt-folio { font-family: monospace; font-size: 1rem; color: #2980b9; font-weight: 700; }
.receipt-divider { border-color: #e8ecf0; margin: 16px 0; }

.receipt-total {
  background: linear-gradient(135deg, #1a3a5c, #2980b9);
  color: #fff;
  border-radius: 10px;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  font-weight: 600;
}

.receipt-amount { font-size: 1.4rem; font-weight: 800; }

.receipt-signatures {
  display: flex;
  justify-content: space-around;
  padding: 24px 32px 16px;
  gap: 24px;
}

.receipt-signature { text-align: center; flex: 1; }
.receipt-sig-line {
  border-top: 2px solid #dee2e6;
  margin-bottom: 8px;
  padding-top: 40px;
}
.receipt-sig-label { font-size: 0.78rem; color: #7f8c8d; }

.receipt-footer {
  background: #f8f9fa;
  padding: 12px 32px;
  text-align: center;
  border-top: 1px solid #e8ecf0;
}

/* ========================================
   WHATSAPP BUTTON
   ======================================== */

.btn-whatsapp { color: #25D366 !important; border-color: #25D366 !important; }
.btn-whatsapp:hover { background: #25D366 !important; color: #fff !important; }

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .top-navbar {
    left: 0;
  }

  .main-content {
    margin-left: 0;
  }

  .navbar-toggle {
    display: block;
  }
}

@media (max-width: 767.98px) {
  .main-content { padding: 16px; }
  .top-navbar { padding: 0 16px; }
  .kpi-value { font-size: 1.4rem; }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  .sidebar, .top-navbar, .d-flex.gap-2.mb-3, .dropdown, form[action*="DELETE"] { display: none !important; }
  .main-content { margin: 0; padding: 0; }
  .receipt-card { box-shadow: none; border: 1px solid #ddd; }
}
