/* ==========================================================================
   Conference Room Booking -- Design system
   Self-hosted, zero external dependencies (office networks often block
   third-party CDNs, which would otherwise silently break the whole UI).
   ========================================================================== */

@font-face {
  font-family: 'Public Sans';
  src: url('../fonts/public-sans-latin-400-normal.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Public Sans';
  src: url('../fonts/public-sans-latin-500-normal.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Public Sans';
  src: url('../fonts/public-sans-latin-600-normal.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Public Sans';
  src: url('../fonts/public-sans-latin-700-normal.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Public Sans';
  src: url('../fonts/public-sans-latin-800-normal.woff2') format('woff2');
  font-weight: 800; font-style: normal; font-display: swap;
}

:root {
  --ink: #16233d;
  --ink-2: #223256;
  --ink-3: #2f4470;
  --gold: #a8781f;
  --gold-bg: #faf1de;
  --surface: #f3f5f9;
  --card: #ffffff;
  --border: #dde3ee;
  --text: #1a2233;
  --text-muted: #5b6472;
  --success: #1f7a4d;
  --success-bg: #e4f3ea;
  --danger: #a6392b;
  --danger-bg: #fbeae7;
  --focus: #3f6fd6;
  --radius: 7px;
  --sidebar-w: 236px;
  /* Dashboard stat-icon accents -- used only for the icon chips on
     admin/dashboard.php, kept separate from the core UI palette above so
     the rest of the app stays disciplined while the dashboard gets to be
     a little more vivid, as requested. */
  --accent-blue: #2f6fed; --accent-blue-bg: #e8f0fe;
  --accent-teal: #0f9488; --accent-teal-bg: #e2f6f4;
  --accent-purple: #7c3aed; --accent-purple-bg: #f1e9fe;
  --accent-amber: #d97a06; --accent-amber-bg: #fdf0dc;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, h4 { font-weight: 700; color: var(--ink); margin: 0 0 .5em; line-height: 1.25; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
a { color: var(--ink-3); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .text-muted { color: var(--text-muted); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------- App shell: sidebar + content ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--ink);
  color: #dbe4f5;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
}
.sidebar-brand {
  font-weight: 800;
  font-size: 1.05rem;
  color: #fff;
  padding: 0 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.12);
  margin-bottom: .75rem;
}
.sidebar-brand span { display: block; font-weight: 500; font-size: .78rem; color: #93a5c9; margin-top: .15rem; }
.sidebar-nav { list-style: none; margin: 0; padding: 0; flex: 1; }
.sidebar-nav li a {
  display: flex; align-items: center; gap: .6rem;
  padding: .62rem 1.25rem;
  color: #c3cee5;
  font-weight: 500;
  font-size: .93rem;
  border-left: 3px solid transparent;
}
.sidebar-nav li a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.sidebar-nav li a.active { background: rgba(255,255,255,.09); border-left-color: var(--gold); color: #fff; }
.sidebar-nav li a .icon { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-nav .nav-badge {
  margin-left: auto; background: var(--gold); color: #fff; font-size: .68rem; font-weight: 700;
  border-radius: 999px; padding: .05rem .4rem; line-height: 1.4;
}
.sidebar-section-label { padding: 1rem 1.25rem .35rem; font-size: .72rem; color: #7b8bb0; font-weight: 600; }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex; align-items: center; justify-content: flex-end;
  gap: .75rem;
  padding: .85rem 1.75rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.content { padding: 1.75rem; max-width: 1600px; width: 100%; }

.mobile-nav-toggle {
  display: none;
  background: none; border: none; cursor: pointer; padding: .3rem;
  color: var(--ink); margin-right: auto;
}
.mobile-nav-toggle .icon { width: 22px; height: 22px; }

.sidebar-close {
  display: none;
  position: absolute; top: 1rem; right: 1rem; z-index: 1;
  background: none; border: none; cursor: pointer; padding: .3rem;
  color: #c3cee5;
}
.sidebar-close:hover { color: #fff; }
.sidebar-close .icon { width: 20px; height: 20px; }

@media (max-width: 900px) {
  .app-shell { position: relative; }
  .mobile-nav-toggle { display: block; }

  /* Off-canvas drawer instead of the old horizontal scroll-tabs -- slides
     in from the left over a dimmed backdrop. Closeable by tapping the
     backdrop, the X button below, or the hamburger again (see app.js). */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
    width: 82vw; max-width: 300px;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 8px 0 24px rgba(0,0,0,.25);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-brand, .sidebar-section-label { display: block; }
  .sidebar-close { display: block; }

  .content { padding: 1.1rem; }
  .topbar { padding: .6rem 1.1rem; }
}

/* Dimmed backdrop shown behind the open mobile drawer */
@media (max-width: 900px) {
  body:has(.sidebar.open)::before {
    content: ''; position: fixed; inset: 0; background: rgba(10,15,30,.45); z-index: 50;
  }
}

/* ---------- Loading overlay (shown while a form submits and the page
   is about to reload -- gives immediate feedback instead of the page
   just sitting there during the network round-trip) ---------- */
.loading-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 100;
  background: rgba(243,245,249,.88);
  flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
}
.loading-overlay.visible { display: flex; }
.loading-spinner {
  width: 44px; height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--ink-3);
  border-radius: 50%;
  animation: loading-spin .7s linear infinite;
}
.loading-overlay span { color: var(--ink); font-weight: 600; font-size: .95rem; }
@keyframes loading-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .loading-spinner { animation-duration: 1.4s; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: .55rem 1rem;
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.2;
}
.btn-primary { background: var(--ink-3); color: #fff; }
.btn-primary:hover { background: var(--ink-2); text-decoration: none; }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: #8f6519; text-decoration: none; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--surface); text-decoration: none; }
.btn-danger-outline { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger-outline:hover { background: var(--danger-bg); text-decoration: none; }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .icon { width: 16px; height: 16px; }
.icon { width: 20px; height: 20px; display: inline-block; vertical-align: middle; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .86rem; margin-bottom: .3rem; color: var(--ink); }
.field { margin-bottom: 1rem; }
.field-hint { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=time], input[type=number], input[type=search], select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .55rem .7rem;
  font-size: .92rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: var(--focus); }

.password-field { position: relative; }
.password-field input { padding-right: 2.6rem; }
.password-toggle {
  position: absolute; right: .4rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; padding: .3rem;
  color: var(--text-muted); display: flex;
}
.password-toggle:hover { color: var(--ink); }
.password-toggle svg { width: 19px; height: 19px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
.form-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; max-width: 440px; }
.form-card.wide { max-width: 100%; }
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--ink); padding: 1.5rem; }
.auth-card { background: #fff; border-radius: 10px; padding: 2.25rem; width: 100%; max-width: 420px; }
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand strong { display: block; font-size: 1.15rem; color: var(--ink); }
.auth-brand span { font-size: .82rem; color: var(--text-muted); }
.auth-foot { text-align: center; margin-top: 1.25rem; font-size: .88rem; }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1.1rem; font-size: .9rem; border: 1px solid transparent; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border-color: #f0c9c2; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: #bfe3cd; }

/* ---------- Cards / grid ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.stat { text-align: left; display: flex; align-items: flex-start; gap: 1rem; }
.stat .stat-body { flex: 1; }
.stat .num { font-size: 1.9rem; font-weight: 800; color: var(--ink); line-height: 1; }
.stat .label { font-size: .82rem; color: var(--text-muted); margin-top: .35rem; }
.icon-chip {
  width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.icon-chip .icon { width: 22px; height: 22px; }
.icon-chip.c-blue { background: var(--accent-blue-bg); color: var(--accent-blue); }
.icon-chip.c-teal { background: var(--accent-teal-bg); color: var(--accent-teal); }
.icon-chip.c-purple { background: var(--accent-purple-bg); color: var(--accent-purple); }
.icon-chip.c-amber { background: var(--accent-amber-bg); color: var(--accent-amber); }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }

/* ---------- Room status: color-blocked, status-first ---------- */
.room-card { border-left: 4px solid var(--success); }
.room-card.busy { border-left-color: var(--danger); }
.room-status-pill {
  display: inline-block; font-size: .78rem; font-weight: 700;
  padding: .2rem .55rem; border-radius: 999px;
}
.room-status-pill.free { background: var(--success-bg); color: var(--success); }
.room-status-pill.busy { background: var(--danger-bg); color: var(--danger); }
.slot-row { display: flex; gap: .6rem; align-items: baseline; padding: .35rem 0; border-top: 1px solid var(--border); font-size: .88rem; }
.slot-row:first-of-type { border-top: none; }
.slot-time { font-weight: 600; color: var(--ink); white-space: nowrap; }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: .1rem .45rem; border-radius: 4px; }
.tag-priority { background: var(--gold-bg); color: var(--gold); }
.tag-bumped { background: var(--gold-bg); color: var(--gold); }
.tag-cancelled { background: var(--surface); color: var(--text-muted); }
.tag-confirmed { background: var(--success-bg); color: var(--success); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: .89rem; }
th { text-align: left; font-size: .76rem; text-transform: none; color: var(--text-muted); font-weight: 600; padding: .5rem .6rem; border-bottom: 1px solid var(--border); }
td { padding: .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

/* ---------- Dropdowns (bell + user menu share this base) ---------- */
.dropdown-wrap { position: relative; }
.dropdown-trigger { background: none; border: none; cursor: pointer; position: relative; padding: .3rem; color: var(--ink); font-family: inherit; }
.dropdown-panel {
  display: none; position: absolute; right: 0; top: 130%; overflow-y: auto;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(20,30,60,.12);
  z-index: 40;
}
.dropdown-wrap.open .dropdown-panel { display: block; }

.bell-btn { font-size: 1.15rem; }
.bell-badge {
  position: absolute; top: -2px; right: -2px; background: var(--danger); color: #fff;
  font-size: .65rem; font-weight: 700; border-radius: 999px; padding: .05rem .35rem; line-height: 1.3;
}
.bell-panel { width: 320px; max-height: 380px; padding: .5rem; }
.bell-item { padding: .55rem .6rem; border-bottom: 1px solid var(--border); font-size: .85rem; }
.bell-item:last-child { border-bottom: none; }
.bell-item.unread { background: var(--surface); }
.bell-item .when { font-size: .74rem; color: var(--text-muted); margin-top: .2rem; }

.user-menu-btn { display: flex; align-items: center; gap: .4rem; font-size: .88rem; font-weight: 600; color: var(--ink); }
.user-menu-btn .icon { width: 26px; height: 26px; color: var(--ink-3); }
.user-menu-btn .chev { width: 15px; height: 15px; color: var(--text-muted); }
.user-menu-panel { width: 220px; padding: .4rem; }
.user-menu-header { padding: .6rem .7rem .5rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; }
.user-menu-header strong { display: block; font-size: .88rem; color: var(--ink); }
.user-menu-header span { font-size: .78rem; color: var(--text-muted); }
.user-menu-panel a {
  display: flex; align-items: center; gap: .55rem;
  padding: .55rem .7rem; border-radius: 5px; font-size: .88rem; color: var(--text);
}
.user-menu-panel a:hover { background: var(--surface); text-decoration: none; }
.user-menu-panel a .icon { width: 17px; height: 17px; color: var(--text-muted); }
.user-menu-panel a.danger { color: var(--danger); }
.user-menu-panel a.danger .icon { color: var(--danger); }

/* Dropdown panels (bell, user menu) are positioned relative to their
   small trigger button by default, which is fine on desktop but on a
   narrow phone puts a fixed-width panel dangerously close to (or past)
   the screen edge. Anchoring to the viewport instead of the trigger
   guarantees it always stays fully on-screen with even margins.
   This must appear AFTER .bell-panel/.user-menu-panel above (same
   specificity, so source order decides) -- !important on width is an
   extra safety net against that ordering breaking again later. */
@media (max-width: 900px) {
  .bell-panel, .user-menu-panel {
    position: fixed;
    top: 3.75rem;
    left: 1rem;
    right: 1rem;
    width: auto !important;
    max-width: none;
    max-height: 70vh;
  }
}

/* ---------- Utilization bars ---------- */
.util-row { margin-bottom: .8rem; }
.util-head { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: .3rem; }
.util-track { background: var(--surface); border-radius: 999px; height: 8px; overflow: hidden; }
.util-fill { background: var(--ink-3); height: 100%; border-radius: 999px; }

/* ---------- Simple bar chart (no JS charting lib) ---------- */
.bar-chart { display: flex; align-items: flex-end; gap: .6rem; height: 140px; padding-top: 1rem; }
.bar-chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-chart .bar { width: 100%; max-width: 34px; background: var(--ink-3); border-radius: 4px 4px 0 0; }
.bar-chart .bar-label { font-size: .72rem; color: var(--text-muted); margin-top: .4rem; }
.bar-chart .bar-count { font-size: .74rem; font-weight: 700; color: var(--ink); margin-bottom: .25rem; }

/* ---------- Calendar / week view ---------- */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.cal-grid { display: grid; grid-template-columns: 56px repeat(var(--days, 7), 1fr); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; }
.cal-corner, .cal-day-head { padding: .5rem; text-align: center; font-size: .78rem; font-weight: 700; color: var(--ink); background: var(--surface); border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); }
.cal-corner { border-left: none; }
.cal-day-head span { display: block; font-weight: 500; color: var(--text-muted); font-size: .72rem; }
.cal-day-head.today { background: var(--gold-bg); color: var(--gold); }
.cal-hour-col { border-left: none; }
.cal-hour-label { height: var(--hour-h); font-size: .7rem; color: var(--text-muted); text-align: right; padding: 0 .5rem; box-sizing: border-box; transform: translateY(-6px); }
.cal-day-col {
  position: relative;
  border-left: 1px solid var(--border);
  height: calc(var(--hours) * var(--hour-h));
  background-image: repeating-linear-gradient(to bottom, var(--border) 0, var(--border) 1px, transparent 1px, transparent var(--hour-h));
}
.cal-event {
  position: absolute; left: 2px; right: 2px; border-radius: 4px; padding: .2rem .4rem;
  font-size: .7rem; font-weight: 600; color: #fff; background: var(--ink-3); overflow: hidden;
  line-height: 1.3; cursor: default;
}
.cal-event.priority { background: var(--gold); }
.cal-event.mine { background: var(--success); }
.cal-legend { display: flex; gap: 1.2rem; margin-top: .9rem; font-size: .8rem; color: var(--text-muted); flex-wrap: wrap; }
.cal-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.cal-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
@media (max-width: 900px) {
  .cal-grid { font-size: .75rem; }
}

/* ---------- Print (usage report) ---------- */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .app-shell { display: block; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
}

.report-meta { color: var(--text-muted); font-size: .85rem; margin-bottom: 1.25rem; }

/* ---------- Responsive tables: collapse to cards below 700px ----------
   Each <td> needs a data-label="Column Name" attribute (added throughout
   the PHP templates) -- the ::before pseudo-element below is what turns
   that into a visible label once the table stops looking like a table. */
@media (max-width: 700px) {
  .table-wrap table, .table-wrap thead, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr {
    border: 1px solid var(--border); border-radius: var(--radius);
    margin-bottom: .75rem; padding: .3rem .9rem; background: #fff;
  }
  .table-wrap td {
    border-bottom: 1px solid var(--border);
    padding: .55rem 0;
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    text-align: right;
  }
  .table-wrap td:last-child { border-bottom: none; }
  .table-wrap td[data-label]::before {
    content: attr(data-label);
    font-weight: 600; font-size: .78rem; color: var(--text-muted);
    text-align: left; flex-shrink: 0;
  }
  .table-wrap td[data-label=""]::before { display: none; }
  .table-wrap td:empty { display: none; }
}

/* ---------- Pagination ---------- */
.pagination-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-top: 1rem; flex-wrap: wrap;
}
.pagination-bar .page-size { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--text-muted); }
.pagination-bar .page-size select { width: auto; padding: .3rem .5rem; }
.pagination-links { display: flex; gap: .4rem; align-items: center; }

/* ---------- Filter bar ---------- */
.filter-bar { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.filter-bar .field { margin-bottom: 0; min-width: 160px; flex: 1; }

/* ---------- SweetAlert2 theme overrides ----------
   buttonsStyling: false (set in app.js) hands button appearance to this
   app's own .btn classes; these overrides just bring the popup shell
   itself (font, radius, icon color) in line with the rest of the design
   system instead of SweetAlert2's stock look. */
.swal2-popup {
  font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
  border-radius: 12px !important;
}
.swal2-title { font-size: 1.15rem !important; color: var(--ink) !important; }
.swal2-html-container { font-size: .92rem !important; color: var(--text) !important; }
.swal2-icon.swal2-warning { border-color: var(--gold) !important; color: var(--gold) !important; }
.swal2-icon.swal2-error { border-color: var(--danger) !important; color: var(--danger) !important; }
.swal2-icon.swal2-success [class^=swal2-success-line] { background-color: var(--success) !important; }
.swal2-icon.swal2-success .swal2-success-ring { border-color: var(--success-bg) !important; }
.swal-actions-gap { gap: .6rem !important; }
