/* ===== SISTEMA DE GESTIÓN I.E.S.T.P. LIBERTAD — Hoja de estilos ===== */
:root {
  --sidebar-bg: #0d1f3c;
  --sidebar-hover: #1a3560;
  --sidebar-text: #eef2f8;
  --sidebar-text-dim: #9fb0cc;
  --accent-green: #4CAF50;
  --accent-green-hover: #388E3C;
  --danger: #e53935;
  --warning: #FF9800;
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --text: #212121;
  --text-dim: #666666;
  --border: #e0e0e0;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 10px;
  --font-scale: 1;
}

[data-theme="dark"] {
  --sidebar-bg: #1a1a2e;
  --sidebar-hover: #16213e;
  --sidebar-text: #eef2f8;
  --sidebar-text-dim: #8892b0;
  --bg: #121212;
  --card-bg: #1e1e1e;
  --text: #e0e0e0;
  --text-dim: #a0a0a0;
  --border: #2e2e2e;
  --shadow: 0 2px 8px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }

html { font-size: calc(15px * var(--font-scale)); }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background .2s, color .2s;
}

a { color: inherit; text-decoration: none; }

.app-shell { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-header .logo-svg { width: 42px; height: 52px; flex-shrink: 0; }
.sidebar-header .titulo { font-size: .95rem; font-weight: 700; line-height: 1.15; }
.sidebar-header .subtitulo { font-size: .68rem; color: var(--sidebar-text-dim); }

.sidebar-nav { flex: 1; padding: 8px 0; }
.nav-group-label {
  font-size: .68rem;
  letter-spacing: .08em;
  color: var(--sidebar-text-dim);
  padding: 14px 18px 4px;
  font-weight: 700;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  font-size: .88rem;
  color: var(--sidebar-text);
  border-left: 3px solid transparent;
  cursor: pointer;
}
.nav-item:hover { background: var(--sidebar-hover); }
.nav-item.active { background: var(--sidebar-hover); border-left-color: var(--accent-green); font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.btn-logout {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  width: 100%; padding: 9px; border-radius: 8px; border: none;
  background: var(--danger); color: #fff; font-weight: 600; font-size: .85rem;
  cursor: pointer; margin-bottom: 12px;
}
.btn-logout:hover { background: #c62828; }
.opra-credit { text-align: center; }
.opra-credit .opra-svg { width: 70px; margin: 0 auto 4px; display: block; }
.opra-credit .l1 { font-size: .72rem; color: var(--sidebar-text); }
.opra-credit .l2 { font-size: .62rem; color: var(--sidebar-text-dim); }

/* ===== TOPBAR ===== */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 22px; background: var(--card-bg); box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 20;
}
.topbar .search-box { flex: 1; max-width: 480px; position: relative; }
.topbar .search-box input {
  width: 100%; padding: 9px 14px 9px 36px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: .88rem;
}
.topbar .search-box .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); opacity: .6; }
.search-results {
  position: absolute; top: 110%; left: 0; right: 0; background: var(--card-bg);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
  max-height: 320px; overflow-y: auto; z-index: 30; display: none;
}
.search-results.show { display: block; }
.search-results .item { padding: 9px 14px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: .85rem; }
.search-results .item:hover { background: var(--bg); }
.search-results .item .sub { font-size: .75rem; color: var(--text-dim); }

.periodo-badge {
  background: var(--sidebar-bg); color: #fff; padding: 6px 12px; border-radius: 6px; font-size: .78rem; font-weight: 600;
}
.theme-toggle {
  background: none; border: 1px solid var(--border); border-radius: 20px; width: 38px; height: 38px;
  cursor: pointer; font-size: 1.1rem; display: flex; align-items: center; justify-content: center; color: var(--text);
}
.user-chip { font-size: .82rem; color: var(--text-dim); white-space: nowrap; }

/* ===== MAIN CONTENT ===== */
.main-content { flex: 1; min-width: 0; padding: 22px; }

.breadcrumb { font-size: .82rem; color: var(--text-dim); margin-bottom: 14px; }
.breadcrumb a:hover { text-decoration: underline; color: var(--accent-green); }
.breadcrumb .sep { margin: 0 6px; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.page-header h1 { font-size: 1.35rem; margin: 0; }

.btn-volver {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--card-bg); color: var(--text); cursor: pointer; font-size: .85rem;
  margin-bottom: 14px;
}
.btn-volver:hover { background: var(--bg); }

/* ===== CARDS ===== */
.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card h2, .card h3 { margin-top: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
  display: flex; align-items: center; gap: 12px; cursor: pointer; border-left: 4px solid var(--accent-green);
  transition: transform .15s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card .emoji { font-size: 1.8rem; }
.stat-card .num { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.stat-card .label { font-size: .78rem; color: var(--text-dim); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: none;
  font-size: .86rem; font-weight: 600; cursor: pointer; transition: background .15s;
}
.btn-primary { background: var(--accent-green); color: #fff; }
.btn-primary:hover { background: var(--accent-green-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c62828; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-cambios-pendientes { box-shadow: 0 0 0 3px rgba(76,175,80,.35); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== FORMS ===== */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field label { font-size: .82rem; font-weight: 600; color: var(--text-dim); }
.form-field label .req { color: var(--danger); }
.form-field input, .form-field select, .form-field textarea {
  padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-size: .88rem; font-family: inherit;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: 2px solid var(--accent-green); outline-offset: 1px;
}
.form-field input.invalid, .form-field select.invalid { border-color: var(--danger); background: rgba(229,57,53,.06); }
.form-field .error-msg { color: var(--danger); font-size: .75rem; display: none; }
.form-field.has-error .error-msg { display: block; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }

/* ===== TABLES ===== */
.table-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.table-toolbar input[type=search] {
  padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); min-width: 220px;
}
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.data-table th, table.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
table.data-table th { cursor: pointer; user-select: none; color: var(--text-dim); font-weight: 700; position: sticky; top: 0; background: var(--card-bg); }
table.data-table th:hover { color: var(--text); }
table.data-table th .arrow { font-size: .7rem; opacity: .6; }
table.data-table tbody tr:hover { background: var(--bg); }
.pagination { display: flex; gap: 6px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.pagination button {
  padding: 5px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--card-bg); color: var(--text); cursor: pointer; font-size: .8rem;
}
.pagination button.active { background: var(--accent-green); color: #fff; border-color: var(--accent-green); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 12px; font-size: .72rem; font-weight: 700; }
.badge-verde { background: rgba(76,175,80,.15); color: #2e7d32; }
.badge-amarillo { background: rgba(255,152,0,.18); color: #e65100; }
.badge-rojo { background: rgba(229,57,53,.15); color: #c62828; }
.badge-azul { background: rgba(33,150,243,.15); color: #1565c0; }
.badge-naranja { background: rgba(255,152,0,.18); color: #e65100; }
.badge-gris { background: rgba(120,120,120,.15); color: #555; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot-verde { background: #4CAF50; }
.dot-amarillo { background: #FF9800; }
.dot-rojo { background: #e53935; }
.dot-azul { background: #2196F3; }
.dot-naranja { background: #FF9800; }

/* ===== ALERTS / FLASH ===== */
.flash-wrap { position: sticky; top: 0; z-index: 40; padding: 0 0 6px; }
.flash { padding: 11px 16px; border-radius: 8px; margin-bottom: 8px; font-size: .87rem; display: flex; justify-content: space-between; align-items: center; }
.flash-exito { background: rgba(76,175,80,.15); color: #2e7d32; border: 1px solid rgba(76,175,80,.4); }
.flash-error { background: rgba(229,57,53,.15); color: #c62828; border: 1px solid rgba(229,57,53,.4); }
.flash-info { background: rgba(33,150,243,.15); color: #1565c0; border: 1px solid rgba(33,150,243,.4); }
.flash-advertencia { background: rgba(255,152,0,.18); color: #e65100; border: 1px solid rgba(255,152,0,.4); }
.flash button { background: none; border: none; cursor: pointer; font-size: 1rem; color: inherit; }

/* ===== TABS ===== */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tab-btn { padding: 9px 16px; border: none; background: none; cursor: pointer; font-size: .86rem; color: var(--text-dim); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab-btn.active { color: var(--accent-green); border-bottom-color: var(--accent-green); font-weight: 700; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); display: none; align-items: center; justify-content: center; z-index: 100;
}
.modal-overlay.show { display: flex; }
.modal-box { background: var(--card-bg); border-radius: var(--radius); padding: 22px; max-width: 480px; width: 90%; box-shadow: var(--shadow); }
.modal-box h3 { margin-top: 0; }

/* ===== MISC ===== */
.text-dim { color: var(--text-dim); }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.progress-bar { background: var(--border); border-radius: 20px; height: 14px; overflow: hidden; }
.progress-bar .fill { background: var(--accent-green); height: 100%; transition: width .3s; }
.tooltip { position: relative; }
.tooltip:hover::after {
  content: attr(data-tip); position: absolute; bottom: 120%; left: 50%; transform: translateX(-50%);
  background: #222; color: #fff; padding: 4px 8px; border-radius: 5px; font-size: .72rem; white-space: nowrap; z-index: 50;
}
.checklist-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.icon-ok { color: #2e7d32; }
.icon-no { color: #c62828; }
.doc-preview { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.doc-list-item { display: flex; align-items: center; justify-content: space-between; padding: 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; }

/* ===== LOGIN ===== */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: #0d1f3c; background: radial-gradient(circle at top, #16305c, #0d1f3c 70%);
}
.login-box { background: #fff; border-radius: 16px; padding: 40px 36px; width: 360px; box-shadow: 0 10px 40px rgba(0,0,0,.4); text-align: center; }
.login-box .logo-svg { width: 90px; height: 110px; margin: 0 auto 14px; display: block; }
.login-box h1 { font-size: 1.15rem; color: #0d1f3c; margin: 6px 0 2px; }
.login-box .sub { font-size: .78rem; color: #666; margin-bottom: 22px; }
.login-box form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.login-box input { padding: 11px 13px; border-radius: 8px; border: 1px solid #ccc; font-size: .92rem; }
.login-box .btn-primary { padding: 11px; font-size: .92rem; justify-content: center; margin-top: 6px; }
.login-box .user-fixed { font-size: .82rem; color: #0d1f3c; font-weight: 600; background: #eef2f8; padding: 8px 10px; border-radius: 8px; }

/* ===== RECEIPT PRINT (80mm) ===== */
.ticket {
  width: 76mm;
  margin: 0 auto;
  font-family: "Courier New", Courier, monospace;
  font-size: 12px;
  font-weight: 700;
  color: #000000;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  color-adjust: exact;
}
.ticket, .ticket * { font-weight: 700 !important; color: #000000 !important; }
.ticket .logo-svg { width: 34px; height: 42px; display: block; margin: 0 auto 4px; }
.ticket .center { text-align: center; }
.ticket hr { border: none; border-top: 1px dashed #000; margin: 5px 0; }
.ticket .sep { text-align: center; letter-spacing: 1px; margin: 5px 0; font-size: 12px; white-space: pre; }
.ticket table { width: 100%; border-collapse: collapse; font-size: 12px; }
.ticket table th, .ticket table td { text-align: left; padding: 3px 0; }
.ticket .right { text-align: right; }
.ticket .bold { font-weight: 700; }
.ticket .ticket-institucion { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.ticket .ticket-titulo { font-size: 14px; font-weight: 700; }
.ticket .ticket-total { font-size: 18px; font-weight: 700; margin: 3px 0; }

@media print {
  .no-print { display: none !important; }
  body {
    background: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    color-adjust: exact;
  }
  .ticket, .ticket * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }
  .ticket-page { display: flex; justify-content: center; }
  @page { size: 80mm auto; margin: 3mm; }
}

@media (max-width: 900px) {
  .sidebar { position: fixed; left: -280px; z-index: 60; transition: left .2s; }
  .sidebar.open { left: 0; }
  .main-content { padding: 14px; }
}
