/* HENUA Agenda Pabellones — Design System */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@700;800&display=swap');

:root {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  --navy:   #10294b;
  --blue:   #1769e8;
  --blue2:  #eaf2ff;
  --muted:  #75849b;
  --line:   #e7edf5;
  --green:  #168b67;
  --amber:  #d7941e;
  --red:    #c94555;
  --shadow: 0 8px 28px rgba(28,52,88,.055);
  --bg:     #f4f7fb;
  --text:   #172b4d;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); min-height: 100vh; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }

/* ── Layout ─────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: 248px; flex: 0 0 248px;
  background: linear-gradient(165deg, #102949 0%, #0c203c 100%);
  color: #f8fbff;
  padding: 24px 14px 16px;
  display: flex; flex-direction: column; min-height: 100vh;
  position: fixed; top: 0; left: 0; height: 100vh;
  overflow-y: auto; z-index: 100;
}
.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 3px 10px 31px;
  color: #fff;
  font-family: Manrope, sans-serif; font-size: 17px; font-weight: 800; letter-spacing: .2px;
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 12px;
  background: #fff; color: #1465d9;
  display: grid; place-items: center; font-weight: 800; font-size: 20px;
  box-shadow: 0 4px 14px #0002; flex-shrink: 0;
}
.brand small { display: block; font: 600 9px 'DM Sans', sans-serif; letter-spacing: 1.3px; color: #9fb4d1; margin-top: 3px; }
.nav-caption { font-size: 9px; letter-spacing: 1.4px; color: #7890b0; padding: 0 13px 9px; font-weight: 700; }
.nav {
  display: flex; align-items: center; gap: 13px;
  padding: 11px 13px; margin: 3px 0; border-radius: 10px;
  color: #c5d2e4; font-size: 13px; font-weight: 500; transition: .15s;
  position: relative;
}
.nav:hover { background: #ffffff12; color: #fff; }
.nav.active { background: linear-gradient(90deg, #2272e8, #1b63d0); color: white; box-shadow: 0 5px 14px #06162f55; }
.nav-icon { width: 20px; text-align: center; font-size: 17px; color: #a8c6ed; }
.nav.active .nav-icon { color: #fff; }
.nav-label { flex: 1; }
.nav-badge {
  background: #e84343; color: white;
  font-size: 9px; font-weight: 800;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 4px;
}
.sidebar-spacer { flex: 1; }
.sidebar-user {
  border-top: 1px solid #ffffff20; padding: 15px 5px 4px;
  display: flex; gap: 10px; align-items: center; font-size: 12px; font-weight: 600;
}
.sidebar-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: #d8e8ff; color: #174c91; font-weight: 800; flex-shrink: 0;
}
.sidebar-user-info { flex: 1; }
.sidebar-user-info small { display: block; color: #9db0ca; font-size: 10px; font-weight: 400; margin-top: 3px; }
.sidebar-logout { color: #a7bad3; font-size: 15px; padding: 6px; }
.sidebar-logout:hover { color: #fff; }

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 248px; right: 0; height: 54px; z-index: 90;
  background: white; border-bottom: 1px solid #edf1f6;
  display: flex; align-items: center; justify-content: flex-end;
  gap: 4px; padding: 0 20px;
  box-shadow: 0 1px 8px rgba(28,52,88,.06);
}
.topbar-zoom { display: flex; align-items: center; gap: 4px; }
.topbar-btn {
  background: none; border: 1px solid #e0e8f0; color: #6b85a0;
  border-radius: 8px; width: 32px; height: 32px;
  display: grid; place-items: center;
  transition: background .15s, color .15s, border-color .15s;
}
.topbar-btn:hover { background: #f0f5ff; color: var(--blue); border-color: #c0d4f5; }
.topbar-zoom-label {
  font-size: 11px; font-weight: 700; color: #6b85a0;
  min-width: 36px; text-align: center; letter-spacing: .3px;
}
.topbar-divider { width: 1px; height: 24px; background: #e0e8f0; margin: 0 8px; }
.topbar-user { display: flex; align-items: center; gap: 8px; }
.topbar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: #d8e8ff; color: #174c91; font-weight: 800; font-size: 13px; flex-shrink: 0;
}
.topbar-user-info { line-height: 1.2; }
.topbar-user-info span { font-size: 13px; font-weight: 600; color: var(--navy); display: block; }
.topbar-user-info small { font-size: 10px; color: var(--muted); }
.topbar-logout {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 8px;
  color: #6b85a0; border: 1px solid #e0e8f0; margin-left: 4px;
  transition: background .15s, color .15s, border-color .15s;
}
.topbar-logout:hover { background: #fff0f0; color: var(--red); border-color: #fca5a5; }

/* ── Main ────────────────────────────────────────────────────── */
.main { flex: 1; margin-left: 248px; padding: 82px 32px 28px; min-height: 100vh; }

/* ── Page header ─────────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; gap: 16px; }
.page-title { font-family: Manrope, sans-serif; font-size: 22px; font-weight: 800; color: var(--navy); }
.page-subtitle { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ── Cards ───────────────────────────────────────────────────── */
.card { background: white; border: 1px solid #edf1f6; border-radius: 15px; padding: 21px; box-shadow: var(--shadow); overflow: visible; }

/* ── Stat cards ──────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { display: flex; align-items: center; gap: 14px; padding: 18px 20px; }
.stat-icon { display: grid; place-items: center; flex: 0 0 47px; height: 47px; border-radius: 50%; font-size: 22px; background: #e7f1ff; color: #2677db; }
.stat-green .stat-icon  { background: #e0f6ec; color: #13a073; }
.stat-amber .stat-icon  { background: #fff2d8; color: #d7941e; }
.stat-red   .stat-icon  { background: #ffe8e9; color: #dc5d65; }
.stat-purple .stat-icon { background: #f0ebff; color: #7c3aed; }
.stat-num { font-family: Manrope, sans-serif; font-size: 26px; font-weight: 800; color: var(--navy); line-height: 1; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Alert banner ────────────────────────────────────────────── */
.alert-banner {
  display: flex; align-items: center; gap: 14px;
  background: #fff8e1; border: 1px solid #f9c74f; border-left: 4px solid #d7941e;
  border-radius: 12px; padding: 14px 18px; margin-bottom: 20px;
}
.alert-banner-icon { font-size: 22px; flex-shrink: 0; }
.alert-banner-body { flex: 1; }
.alert-banner-title { font-weight: 700; font-size: 13px; color: #7c4f00; }
.alert-banner-sub { font-size: 12px; color: #a06500; margin-top: 2px; }

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 20px; }
.tab-btn {
  background: none; border: none; padding: 10px 18px; font: 600 13px 'DM Sans', sans-serif;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: .15s;
}
.tab-btn:hover { color: var(--navy); }
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Toggle switch ───────────────────────────────────────────── */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle {
  position: relative; width: 42px; height: 24px;
  background: #d1d5db; border-radius: 12px; cursor: pointer;
  transition: background .2s;
}
.toggle.on { background: var(--blue); }
.toggle::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; background: white; border-radius: 50%;
  box-shadow: 0 1px 4px #0002; transition: left .2s;
}
.toggle.on::after { left: 21px; }
.toggle-label { font-size: 13px; font-weight: 600; color: var(--text); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 0; background: var(--blue); color: white;
  padding: 10px 16px; border-radius: 9px;
  font: 600 12px 'DM Sans', sans-serif;
  box-shadow: 0 4px 10px #1769e822; transition: .15s;
}
.btn:hover { background: #0e55c1; transform: translateY(-1px); }
.btn.green { background: var(--green); box-shadow: 0 4px 10px #168b6722; }
.btn.green:hover { background: #0f7053; }
.btn.light { background: #edf4ff; color: #245b9c; box-shadow: none; }
.btn.light:hover { background: #d9eaff; transform: none; }
.btn.danger { background: var(--red); box-shadow: 0 4px 10px #c9455522; }
.btn.danger:hover { background: #a8364e; }
.btn.amber { background: #d7941e; box-shadow: 0 4px 10px #d7941e22; }
.btn.amber:hover { background: #b8780e; }
.btn.sm { padding: 7px 11px; font-size: 11px; gap: 5px; }
.btn.xs { padding: 5px 9px; font-size: 10px; gap: 4px; }

/* ── Badge / status ──────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge.programada { background: #e0f6ec; color: #0c6e4e; }
.badge.realizada  { background: #dbeafe; color: #1e40af; }
.badge.cancelada  { background: #ffe4e6; color: #9f1239; }
.badge.cancelada-reagendada { background: #fff0f0; color: #9f1239; border: 1px solid #fca5a5; }
.badge.pendiente   { background: #fff3cd; color: #92400e; }
.badge.agendada    { background: #d1fae5; color: #065f46; }
.badge.admin       { background: #dbeafe; color: #1e40af; }
.badge.callcenter  { background: #e0f2fe; color: #0369a1; }
.badge.ejecutivo   { background: #f0ebff; color: #5b21b6; }

/* ── Audit action badges ─────────────────────────────────────── */
.action-badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px; font-size: 10px; font-weight: 700; }
.action-badge.login     { background: #e0f6ec; color: #0c6e4e; }
.action-badge.logout    { background: #f3f4f6; color: #6b7280; }
.action-badge.create    { background: #dbeafe; color: #1e40af; }
.action-badge.edit      { background: #fff3cd; color: #92400e; }
.action-badge.cancel    { background: #ffe4e6; color: #9f1239; }
.action-badge.delete    { background: #fee2e2; color: #7f1d1d; }
.action-badge.backup    { background: #f0ebff; color: #5b21b6; }
.action-badge.password  { background: #cffafe; color: #164e63; }
.action-badge.agendar     { background: #d1fae5; color: #065f46; }
.action-badge.user_create { background: #dcfce7; color: #14532d; }
.action-badge.user_edit   { background: #fefce8; color: #713f12; }
.action-badge.user_delete { background: #fee2e2; color: #7f1d1d; }
.action-badge.device_register { background: #e0f2fe; color: #0369a1; }
.action-badge.device_remove   { background: #fff3cd; color: #92400e; }
.action-badge.device_blocked  { background: #fee2e2; color: #7f1d1d; }

/* ── Needs-review row ────────────────────────────────────────── */
.row-needs-review td { background: #fffbeb !important; }

/* ── Week nav controls ───────────────────────────────────────── */
.week-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.week-label { font-weight: 700; font-size: 14px; color: var(--navy); flex: 1; text-align: center; }

/* ── Week calendar ───────────────────────────────────────────── */
.week-grid-wrap { overflow-x: auto; }
.week-grid { display: grid; grid-template-columns: 50px repeat(7, 1fr); min-width: 800px; border: 1px solid var(--line); border-radius: 12px; background: white; overflow: hidden; }
.week-head { display: contents; }
.week-head-cell { padding: 10px 8px; font-size: 11px; font-weight: 700; text-align: center; background: #f8fafd; border-bottom: 1px solid var(--line); color: var(--muted); }
.week-head-cell.today { background: var(--blue2); color: var(--blue); }
.week-head-cell .dow { font-size: 13px; color: var(--navy); font-weight: 700; }
.week-head-cell .dnum { font-size: 20px; font-weight: 800; font-family: Manrope, sans-serif; color: var(--navy); }
.week-head-cell.today .dow, .week-head-cell.today .dnum { color: var(--blue); }
.week-body { display: contents; }
.week-time-col { display: flex; flex-direction: column; }
.week-time-slot { height: 60px; border-bottom: 1px solid #f0f4f8; display: flex; align-items: flex-start; justify-content: flex-end; padding: 4px 8px 0 0; font-size: 10px; color: var(--muted); font-weight: 500; }
.week-day-col { position: relative; border-left: 1px solid var(--line); }
.week-day-col .hour-line { position: absolute; left: 0; right: 0; border-top: 1px solid #f0f4f8; pointer-events: none; }
.week-event { position: absolute; left: 3px; right: 3px; border-radius: 7px; padding: 5px 7px; font-size: 11px; font-weight: 600; overflow: hidden; cursor: pointer; transition: filter .15s, transform .15s; z-index: 2; }
.week-event:hover { filter: brightness(.92); transform: scale(1.01); }
.week-event .ev-name { font-size: 10px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.week-event .ev-time { font-size: 9px; opacity: .8; margin-top: 2px; }

/* ── Month calendar ──────────────────────────────────────────── */
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--line); border-radius: 12px; background: white; overflow: hidden; }
.month-dow { padding: 10px 0; font-size: 10px; font-weight: 700; text-align: center; background: #f8fafd; border-bottom: 1px solid var(--line); color: var(--muted); letter-spacing: .5px; }
.month-cell { min-height: 90px; padding: 8px; border-right: 1px solid #f0f4f8; border-bottom: 1px solid #f0f4f8; transition: background .1s; }
.month-cell:hover { background: #f8fafd; }
.month-cell.today { background: var(--blue2); }
.month-cell.other-month { background: #fafbfc; }
.month-cell.other-month .month-day-num { color: #c0cad6; }
.month-day-num { font-size: 12px; font-weight: 700; color: var(--navy); width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; border-radius: 50%; margin-bottom: 4px; }
.month-cell.today .month-day-num { background: var(--blue); color: white; }
.month-ev { font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 4px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.month-ev-more { font-size: 10px; color: var(--muted); font-weight: 600; padding: 2px 0; cursor: pointer; }

/* ── Solicitudes table ───────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { text-align: left; padding: 10px 14px; background: #f8fafd; border-bottom: 2px solid var(--line); font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .4px; white-space: nowrap; }
tbody td { padding: 12px 14px; border-bottom: 1px solid #f3f6fa; vertical-align: middle; }
tbody tr:hover td { background: #f8fafd; }
tbody tr:last-child td { border-bottom: none; }
.td-pab { font-weight: 600; color: var(--navy); }
.td-cirugía { color: var(--muted); font-size: 12px; }

/* ── Filters ─────────────────────────────────────────────────── */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-select, .filter-input { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; font: 13px 'DM Sans', sans-serif; color: var(--text); background: white; outline: none; }
.filter-select:focus, .filter-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px #1769e820; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(16,41,75,.35); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; backdrop-filter: blur(2px); }
.modal-backdrop.hidden { display: none; }
.modal { background: white; border-radius: 16px; padding: 28px; width: 100%; max-width: 540px; box-shadow: 0 24px 60px rgba(16,41,75,.18); max-height: 90vh; overflow-y: auto; }
.modal-title { font-family: Manrope, sans-serif; font-size: 18px; font-weight: 800; color: var(--navy); margin-bottom: 20px; }
.modal-close { float: right; background: none; border: none; font-size: 20px; color: var(--muted); line-height: 1; }
.modal-close:hover { color: var(--text); }

/* ── Form ────────────────────────────────────────────────────── */
.form-row { margin-bottom: 16px; }
.form-label { display: block; font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .5px; margin-bottom: 6px; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 10px 13px; border: 1px solid var(--line); border-radius: 9px; font: 13px 'DM Sans', sans-serif; color: var(--text); transition: .15s; outline: none; }
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px #1769e820; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }
.form-section-divider { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--navy); opacity: .55; display: flex; align-items: center; gap: 10px; margin: 6px 0 2px; }
.form-section-divider::before, .form-section-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ── Detail view ─────────────────────────────────────────────── */
.detail-row { display: flex; align-items: baseline; gap: 8px; padding: 10px 0; border-bottom: 1px solid #f3f6fa; }
.detail-row:last-child { border-bottom: none; }
.detail-key { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .4px; min-width: 130px; flex-shrink: 0; }
.detail-val { font-size: 13px; color: var(--text); font-weight: 500; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: .3; }
.empty-title { font-size: 15px; font-weight: 700; color: var(--navy); margin-bottom: 6px; }
.empty-sub { font-size: 13px; color: var(--muted); }

/* ── Toast ───────────────────────────────────────────────────── */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: white; border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; box-shadow: 0 8px 24px rgba(28,52,88,.12); font-size: 13px; font-weight: 500; min-width: 240px; display: flex; align-items: center; gap: 10px; animation: toastIn .2s ease; }
.toast.success { border-left: 4px solid var(--green); }
.toast.error   { border-left: 4px solid var(--red); }
.toast.info    { border-left: 4px solid var(--blue); }
@keyframes toastIn { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:none; } }

/* ── Loading ─────────────────────────────────────────────────── */
.loading { display: flex; align-items: center; justify-content: center; padding: 60px; color: var(--muted); gap: 10px; font-size: 14px; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Respaldos ───────────────────────────────────────────────── */
.backup-progress-wrap { background: #f3f6fa; border-radius: 8px; overflow: hidden; height: 8px; margin: 8px 0; }
.backup-progress-bar { height: 100%; background: var(--blue); border-radius: 8px; transition: width .5s; }

/* ── Print ───────────────────────────────────────────────────── */
.print-preview {
  border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; background: white;
  font-size: 11px;
}
.print-preview-header {
  background: var(--navy); color: white;
  padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
}
.print-grid-wrap { overflow-x: auto; }
.print-grid { display: grid; min-width: 900px; border-top: 1px solid var(--line); }

@media print {
  @page { size: A4 landscape; margin: 10mm 8mm; }
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { position: fixed; inset: 0; background: white; padding: 10px; }
  .no-print { display: none !important; }
  .print-cell { font-size: 9px !important; }
  thead th, tbody td { padding: 5px 6px !important; font-size: 9px !important; }
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1100px) { .stats-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 800px) {
  .sidebar { width: 60px; padding: 16px 8px; }
  .sidebar .brand-text, .sidebar .nav-label, .sidebar .nav-caption { display: none; }
  .topbar { left: 60px; }
  .topbar-user-info { display: none; }
  .main { margin-left: 60px; padding: 70px 16px 20px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .form-grid-2 { grid-template-columns: 1fr; }
}
