/* ============================================================
   DanySoft Computación — Gestión de Abonos
   style.css  |  Colores: Rojo #CC1F36 · Navy #1E3670 · Azul #2E5AA8
   ============================================================ */

/* ---------- VARIABLES DARK (default) ---------- */
:root,
[data-theme="dark"] {
  --bg-page:        #0f1a2e;
  --bg-sidebar:     #1e3670;
  --bg-card:        #162550;
  --bg-card-hover:  #1d3060;
  --bg-input:       #0f1a2e;
  --border:         #2e4d8a;
  --text-primary:   #e8eeff;
  --text-secondary: #94aed8;
  --text-muted:     #5a7aaf;
  --primary:        #CC1F36;
  --primary-hover:  #a81830;
  --primary-light:  rgba(204,31,54,.18);
  --navy:           #1E3670;
  --blue:           #2E5AA8;
  --blue-light:     #4a7bca;
  --success:        #28a745;
  --success-bg:     rgba(40,167,69,.15);
  --warning:        #ffc107;
  --warning-bg:     rgba(255,193,7,.12);
  --danger:         #dc3545;
  --danger-bg:      rgba(220,53,69,.15);
  --info:           #17a2b8;
  --info-bg:        rgba(23,162,184,.12);
  --shadow:         0 2px 12px rgba(0,0,0,.45);
  --radius:         10px;
  --sidebar-width:  240px;
  --topbar-h:       56px;
}

/* ---------- VARIABLES LIGHT ---------- */
[data-theme="light"] {
  --bg-page:        #f0f4fb;
  --bg-sidebar:     #1E3670;
  --bg-card:        #ffffff;
  --bg-card-hover:  #f5f8ff;
  --bg-input:       #f8faff;
  --border:         #c8d6ef;
  --text-primary:   #1a2a4a;
  --text-secondary: #3a5080;
  --text-muted:     #7a9ac0;
  --primary:        #CC1F36;
  --primary-hover:  #a81830;
  --primary-light:  rgba(204,31,54,.10);
  --navy:           #1E3670;
  --blue:           #2E5AA8;
  --blue-light:     #4a7bca;
  --success:        #28a745;
  --success-bg:     rgba(40,167,69,.10);
  --warning:        #d97706;
  --warning-bg:     rgba(217,119,6,.10);
  --danger:         #dc3545;
  --danger-bg:      rgba(220,53,69,.10);
  --info:           #0891b2;
  --info-bg:        rgba(8,145,178,.10);
  --shadow:         0 2px 12px rgba(30,54,112,.12);
  --radius:         10px;
  --sidebar-width:  240px;
  --topbar-h:       56px;
}

/* ---------- RESET / BASE ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background .25s, color .25s;
}
a { color: var(--blue-light); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ---------- SIDEBAR ---------- */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex; flex-direction: column;
  z-index: 100;
  box-shadow: 2px 0 16px rgba(0,0,0,.35);
  transition: transform .25s;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-logo img {
  width: 44px; height: 44px; object-fit: contain; border-radius: 6px;
}
.sidebar-logo span {
  color: #fff; font-size: .85rem; line-height: 1.3;
}
.sidebar-logo strong { font-size: 1rem; }

.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 16px;
  color: rgba(255,255,255,.65);
  font-size: .88rem;
  transition: background .15s, color .15s;
  cursor: pointer;
  border-left: 3px solid transparent;
  text-decoration: none;
}
.nav-item:hover {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.9);
  text-decoration: none;
}
.nav-item.active {
  background: rgba(255,255,255,.13);
  color: #fff;
  border-left-color: var(--primary);
  font-weight: 600;
}
.nav-item.active .nav-icon { opacity: 1; }
.nav-icon { font-size: 1.15rem; width: 20px; text-align: center; opacity: .7; }
.nav-icon .ti { font-size: 18px; vertical-align: middle; }
.nav-label { flex: 1; }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.12);
  display: flex; align-items: center; justify-content: space-between;
  color: rgba(255,255,255,.7); font-size: .83rem;
}
.btn-logout {
  background: none; border: 1px solid rgba(255,255,255,.3);
  color: #fff; border-radius: 6px; padding: 4px 8px;
  cursor: pointer; font-size: 1rem; transition: background .18s;
  text-decoration: none; line-height: 1;
}
.btn-logout:hover { background: var(--primary); border-color: var(--primary); text-decoration: none; }

/* ---------- MAIN WRAP ---------- */
.main-wrap {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left .25s;
}

/* ---------- TOPBAR ---------- */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow);
}
.sidebar-toggle {
  background: none; border: none; color: var(--text-primary);
  font-size: 1.25rem; cursor: pointer; padding: 4px 8px;
  border-radius: 6px; display: none;
}
.topbar-title { flex: 1; font-size: 1.05rem; font-weight: 600; color: var(--text-primary); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-fecha { font-size: .85rem; color: var(--text-secondary); white-space: nowrap; padding-right: 4px; }

/* ---------- BACKUP BUTTON ---------- */
.btn-backup {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text-muted); text-decoration: none;
  transition: background .18s, color .18s, border-color .18s;
  font-size: 1.1rem;
}
.btn-backup:hover { background: var(--border); color: var(--text-primary); text-decoration: none; }
.btn-backup.backup-warn {
  background: rgba(220,53,69,.15);
  border-color: #dc3545;
  color: #dc3545;
  animation: pulse-warn 2s ease-in-out infinite;
}
@keyframes pulse-warn {
  0%,100% { box-shadow: 0 0 0 0 rgba(220,53,69,.3); }
  50%      { box-shadow: 0 0 0 5px rgba(220,53,69,0); }
}

/* ---------- THEME TOGGLE ---------- */
.theme-toggle {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: .9rem;
  color: var(--text-primary);
  transition: background .18s;
  display: flex; align-items: center; gap: 4px;
}
.theme-toggle:hover { background: var(--border); }
[data-theme="dark"]  .icon-sun  { display: none; }
[data-theme="dark"]  .icon-moon { display: inline; }
[data-theme="light"] .icon-sun  { display: inline; }
[data-theme="light"] .icon-moon { display: none; }

/* ---------- PAGE CONTENT ---------- */
.page-content { flex: 1; padding: 24px 28px; }

/* ---------- CARDS ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  transition: background .25s, border-color .25s;
}
.card-title {
  font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-muted); margin-bottom: 14px;
}

/* ---------- KPI GRID ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
  transition: transform .15s, box-shadow .15s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.kpi-card.blue   { border-left-color: var(--blue); }
.kpi-card.green  { border-left-color: var(--success); }
.kpi-card.orange { border-left-color: var(--warning); }
.kpi-card.red    { border-left-color: var(--danger); }
.kpi-icon  { font-size: 1.4rem; }
.kpi-value { font-size: 1.6rem; font-weight: 700; color: var(--text-primary); line-height: 1; }
.kpi-label { font-size: .78rem; color: var(--text-muted); font-weight: 500; }

/* ---------- TABLES ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
  background: var(--navy);
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}
[data-theme="light"] thead th { background: var(--navy); color: #fff; }
tbody tr { border-bottom: 1px solid var(--border); transition: background .12s; }
tbody tr:hover { background: var(--bg-card-hover); }
tbody td { padding: 10px 12px; color: var(--text-primary); vertical-align: middle; }

/* ---------- BADGES ---------- */
.badge {
  display: inline-block; padding: 3px 8px;
  border-radius: 12px; font-size: .73rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info    { background: var(--info-bg);    color: var(--info);    }
.badge-muted   { background: rgba(90,122,175,.15); color: var(--text-muted); }

/* Badge numérico en nav */
.nav-item .badge { margin-left: auto; }

/* ---------- ALERTS ---------- */
.alert {
  padding: 12px 16px; border-radius: 8px;
  margin-bottom: 16px; font-size: .9rem;
  display: flex; align-items: flex-start; gap: 10px;
}
.alert-error   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning); }
.alert-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid var(--info); }

/* ---------- VENCIMIENTO FILAS ---------- */
.row-critico  { background: rgba(220,53,69,.08) !important; }
.row-medio    { background: rgba(255,193,7,.08)  !important; }
.row-temprano { background: rgba(255,193,7,.04)  !important; }
.row-vencido  { background: rgba(100,100,100,.08) !important; color: var(--text-muted) !important; }

/* ---------- FORMS ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label {
  font-size: .8rem; font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: .04em;
}
.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 12px;
  color: var(--text-primary);
  font-size: .92rem;
  transition: border-color .18s, box-shadow .18s;
  width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--blue-light);
  box-shadow: 0 0 0 3px rgba(74,123,202,.2);
}
.form-group textarea { resize: vertical; min-height: 80px; }

/* Select options en dark */
select option { background: var(--bg-card); color: var(--text-primary); }

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 7px;
  font-size: .88rem; font-weight: 600; cursor: pointer;
  border: none; transition: background .18s, transform .1s;
  text-decoration: none; white-space: nowrap;
  line-height: 1.2;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn-primary  { background: var(--primary);  color: #fff; }
.btn-primary:hover  { background: var(--primary-hover); color: #fff; }
.btn-blue     { background: var(--blue);     color: #fff; }
.btn-blue:hover     { background: #2549a0;    color: #fff; }
.btn-success  { background: var(--success);  color: #fff; }
.btn-success:hover  { background: #1e8035;    color: #fff; }
.btn-warning  { background: var(--warning);  color: #1a1a1a; }
.btn-danger   { background: var(--danger);   color: #fff; }
.btn-danger:hover   { background: #b82d3a;    color: #fff; }
.btn-outline  {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.btn-sm { padding: 5px 11px; font-size: .8rem; }
.btn-full { width: 100%; justify-content: center; }

/* ---------- MODAL ---------- */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.65); z-index: 200;
  align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 28px;
  width: min(92vw, 680px);
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.05rem; font-weight: 700; }
.modal-close {
  background: none; border: none; font-size: 1.3rem;
  cursor: pointer; color: var(--text-muted);
  line-height: 1; padding: 2px 6px; border-radius: 4px;
}
.modal-close:hover { color: var(--text-primary); background: var(--border); }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 20px; padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ---------- SECTION HEADER ---------- */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 10px;
}
.section-header h2 { font-size: 1.1rem; font-weight: 700; }

/* ---------- SEARCH BAR ---------- */
.search-bar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 16px;
}
.search-bar input {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 7px; padding: 8px 12px;
  color: var(--text-primary); font-size: .88rem; min-width: 200px;
}
.search-bar input:focus { outline: none; border-color: var(--blue-light); }

/* ---------- CHART CONTAINER ---------- */
.chart-container { position: relative; height: 260px; }

/* ---------- LOGIN PAGE ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.login-wrap { width: 100%; max-width: 420px; position: relative; }
.login-theme-toggle { position: absolute; top: -50px; right: 0; }
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 32px;
  box-shadow: 0 8px 40px rgba(0,0,0,.4);
}
.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo img { height: 80px; object-fit: contain; }
.login-logo h1 { font-size: 1.3rem; margin-top: 12px; color: var(--text-primary); }
.login-logo p  { color: var(--text-muted); font-size: .85rem; margin-top: 2px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }

/* ---------- PAGINATION ---------- */
.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; }
.pagination a, .pagination span {
  display: inline-block; padding: 6px 12px; border-radius: 6px;
  font-size: .82rem; font-weight: 600;
  border: 1px solid var(--border); color: var(--text-secondary);
  text-decoration: none; transition: background .15s;
}
.pagination a:hover { background: var(--bg-card-hover); color: var(--text-primary); text-decoration: none; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- ESTADO DOTS ---------- */
.estado-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin-right: 6px;
}
.dot-activo   { background: var(--success); }
.dot-vencido  { background: var(--danger); }
.dot-renovado { background: var(--info); }
.dot-cancelado{ background: var(--text-muted); }

/* ---------- PROGRESS BAR ---------- */
.progress-wrap { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-bar  { height: 100%; border-radius: 3px; transition: width .4s; }

/* ---------- DIVIDER ---------- */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ---------- EMPTY STATE ---------- */
.empty-state {
  text-align: center; padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: .92rem; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  .sidebar { transform: translateX(-240px); width: 240px; }
  .sidebar.open { transform: translateX(0); --sidebar-width: 240px; }
  .main-wrap { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .page-content { padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
