/* ==========================================================================
   INSTITUTIONAL CONDOMINIUM OPERATIONS SYSTEM - PORTAL CSS
   Bootstrap 5 + Custom Institutional Slate Design System (Pure CSS)
   ========================================================================== */

:root {
  /* Surfaces & Containers */
  --surface: #f8f9ff;
  --surface-dim: #cbdbf5;
  --surface-bright: #f8f9ff;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #eff4ff;
  --surface-container: #e5eeff;
  --surface-container-high: #dce9ff;
  --surface-container-highest: #d3e4fe;
  --surface-variant: #d3e4fe;
  --surface-tint: #545f73;

  /* Text & On-Colors */
  --on-surface: #0b1c30;
  --on-surface-variant: #45474c;
  --inverse-surface: #213145;
  --inverse-on-surface: #eaf1ff;
  --outline: #75777d;
  --outline-variant: #c5c6cd;

  /* Primary Brand (Institutional Slate / Deep Navy) */
  --primary: #091426;
  --on-primary: #ffffff;
  --primary-container: #1e293b;
  --on-primary-container: #8590a6;
  --inverse-primary: #bcc7de;
  --primary-fixed: #d8e3fb;
  --primary-fixed-dim: #bcc7de;
  --on-primary-fixed: #111c2d;
  --on-primary-fixed-variant: #3c475a;

  /* Secondary (Interactive Indigo / Electric Blue) */
  --secondary: #4b41e1;
  --on-secondary: #ffffff;
  --secondary-container: #645efb;
  --on-secondary-container: #fffbff;
  --secondary-fixed: #e2dfff;
  --secondary-fixed-dim: #c3c0ff;
  --on-secondary-fixed: #0f0069;
  --on-secondary-fixed-variant: #3323cc;

  /* Tertiary (Affirmative Emerald / Green) */
  --tertiary: #00190e;
  --on-tertiary: #ffffff;
  --tertiary-container: #00301e;
  --on-tertiary-container: #00a472;
  --tertiary-fixed: #6ffbbe;
  --tertiary-fixed-dim: #4edea3;
  --on-tertiary-fixed: #002113;
  --on-tertiary-fixed-variant: #005236;

  /* Error / Alert (Crimson) */
  --error: #ba1a1a;
  --on-error: #ffffff;
  --error-container: #ffdad6;
  --on-error-container: #93000a;

  /* Background Canvas */
  --background: #f8f9ff;
  --on-background: #0b1c30;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  /* Radii */
  --radius-xs: 0.25rem;
  --radius-sm: 0.375rem;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;

  /* Spacings */
  --space-2xs: 0.125rem;
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --gutter: 1.5rem;
  --gutter-dense: 1rem;
  --margin: 2rem;

  /* Elevations */
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.05), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
}

/* ==========================================================================
   RESET & BASE OVERRIDES
   ========================================================================== */
html, body {
  font-family: var(--font-family);
  background-color: var(--background);
  color: var(--on-surface);
  line-height: 1.5;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

[hidden] {
  display: none !important;
}

::-webkit-scrollbar {
  display: none;
}

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
  vertical-align: middle;
  line-height: 1;
  user-select: none;
}

/* ==========================================================================
   TYPOGRAPHY
   ========================================================================== */
.font-headline-xl {
  font-size: 36px;
  line-height: 44px;
  letter-spacing: -0.025em;
  font-weight: 700;
}

.font-headline-lg {
  font-size: 28px;
  line-height: 36px;
  letter-spacing: -0.02em;
  font-weight: 600;
}

.font-headline-md {
  font-size: 22px;
  line-height: 28px;
  letter-spacing: -0.015em;
  font-weight: 600;
}

.font-headline-sm {
  font-size: 18px;
  line-height: 24px;
  letter-spacing: -0.01em;
  font-weight: 600;
}

.font-body-lg {
  font-size: 16px;
  line-height: 24px;
  letter-spacing: -0.005em;
  font-weight: 400;
}

.font-body-md {
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0em;
  font-weight: 400;
}

.font-body-sm {
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0em;
  font-weight: 400;
}

.font-label-md {
  font-size: 13px;
  line-height: 16px;
  letter-spacing: 0.01em;
  font-weight: 600;
}

.font-label-sm {
  font-size: 11px;
  line-height: 14px;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.font-tabular-mono {
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0em;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.text-on-surface { color: var(--on-surface) !important; }
.text-on-surface-variant { color: var(--on-surface-variant) !important; }
.text-outline { color: var(--outline) !important; }
.text-secondary { color: var(--secondary) !important; }
.text-tertiary { color: var(--on-tertiary-container) !important; }
.text-error { color: var(--error) !important; }
.text-on-primary { color: var(--on-primary) !important; }

/* ==========================================================================
   LAYOUT STRUCTURE: SIDEBAR & HEADER & MAIN
   ========================================================================== */
.portal-container {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* SIDEBAR */
.portal-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  background-color: var(--primary);
  color: var(--on-primary);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.08);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-scroll {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-brand-box {
  height: 64px;
  padding: 0 var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background-color: var(--primary);
}

.sidebar-brand-box img {
  height: 32px;
  width: auto;
  object-fit: contain;
}

.sidebar-resident-card {
  margin: var(--space-sm) var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background-color: var(--primary-container);
  border-radius: var(--radius-lg);
}

.sidebar-nav-heading {
  padding: var(--space-xs) var(--space-md);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--on-primary-container);
}

.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 var(--space-md);
}

.sidebar-nav-btn {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 8px 14px;
  border-radius: var(--radius-lg);
  color: var(--primary-fixed-dim);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}

.sidebar-nav-btn:hover {
  background-color: var(--primary-container);
  color: var(--on-primary);
}

.sidebar-nav-btn.active {
  background-color: var(--secondary);
  color: var(--on-secondary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.sidebar-footer {
  padding: var(--space-md);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* MAIN CONTENT WRAPPER */
.portal-main-area {
  margin-left: 280px;
  width: calc(100% - 280px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--background);
}

/* HEADER */
.portal-header {
  position: fixed;
  top: 0;
  left: 280px;
  right: 0;
  height: 64px;
  background-color: rgba(248, 249, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 1030;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.04);
  border-bottom: 1px solid rgba(197, 198, 205, 0.35);
}

.header-search-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background-color: var(--surface-container-low);
  padding: 6px 14px;
  border-radius: var(--radius);
  flex: 1;
  max-width: 480px;
  transition: background-color 0.15s ease;
}

.header-search-wrap:focus-within {
  background-color: var(--surface-container-lowest);
  box-shadow: 0 0 0 2px rgba(75, 65, 225, 0.2);
}

.header-search-wrap input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: var(--on-surface);
  width: 100%;
}

.header-unit-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background-color: var(--surface-container-low);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface);
  white-space: nowrap;
}

.header-profile {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding-left: var(--space-sm);
}

.header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--surface-dim);
}

/* MAIN VIEW CANVAS */
.portal-canvas {
  margin-top: 64px;
  padding: var(--space-lg);
  padding-bottom: var(--margin);
  flex: 1;
}

.view-pane {
  display: flex;
  flex-direction: column;
  gap: var(--gutter);
  animation: viewFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   CARDS & CONTAINERS
   ========================================================================== */
.pr-card {
  background-color: var(--surface-container-lowest);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(197, 198, 205, 0.4);
  position: relative;
  overflow: hidden;
}

.pr-card-compact {
  padding: var(--space-md);
}

.pr-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.pr-card-recessed {
  margin: var(--space-sm) calc(-1 * var(--space-md)) calc(-1 * var(--space-md));
  padding: var(--space-sm) var(--space-md);
  background-color: var(--surface-container-low);
  border-bottom-left-radius: var(--radius-xl);
  border-bottom-right-radius: var(--radius-xl);
}

/* ==========================================================================
   CUSTOM BUTTONS
   ========================================================================== */
.btn-pr-primary {
  background-color: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  transition: all 0.15s ease;
}

.btn-pr-primary:hover {
  background-color: var(--primary-container);
  color: var(--on-primary);
}

.btn-pr-secondary {
  background-color: var(--secondary);
  color: var(--on-secondary);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 18px;
  border-radius: var(--radius);
  border: none;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  transition: all 0.15s ease;
}

.btn-pr-secondary:hover {
  background-color: var(--on-secondary-fixed-variant);
  color: var(--on-secondary);
}

.btn-pr-surface {
  background-color: var(--surface-container-low);
  color: var(--on-surface);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  transition: all 0.15s ease;
}

.btn-pr-surface:hover {
  background-color: var(--surface-container);
  color: var(--on-surface);
}

.btn-pr-danger {
  background-color: var(--error);
  color: var(--on-error);
  font-weight: 600;
  font-size: 13px;
  padding: 12px 18px;
  border-radius: var(--radius-xl);
  border: none;
  transition: all 0.15s ease;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-pr-danger:hover {
  background-color: var(--on-error-container);
  color: var(--on-error);
}

/* ==========================================================================
   BADGES & CHIPS
   ========================================================================== */
.pr-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
}

.pr-badge-success {
  background-color: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.pr-badge-info {
  background-color: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.pr-badge-warning {
  background-color: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.pr-badge-error {
  background-color: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.pr-badge-error .material-symbols-outlined {
  color: #dc2626;
}

.pr-badge-neutral {
  background-color: var(--surface-container);
  color: var(--on-surface-variant);
}

.pr-badge-tertiary {
  background-color: rgba(0, 164, 114, 0.12);
  color: var(--on-tertiary-container);
}

/* ==========================================================================
   TABLES
   ========================================================================== */
.pr-table-box {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(197, 198, 205, 0.35);
  background-color: var(--surface-container-lowest);
}

.pr-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  margin-bottom: 0;
}

.pr-table thead tr {
  background-color: var(--surface-container-low);
  height: 40px;
}

.pr-table th {
  padding: 10px var(--space-md);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--outline);
  border: none;
}

.pr-table tbody tr {
  height: 52px;
  border-bottom: 1px solid var(--surface-container);
  transition: background-color 0.12s ease;
}

.pr-table tbody tr:hover {
  background-color: var(--surface-container-low);
}

.pr-table td {
  padding: 10px var(--space-md);
  font-size: 13px;
  color: var(--on-surface);
  vertical-align: middle;
  border: none;
}

/* ==========================================================================
   TABS & FILTERS
   ========================================================================== */
.pr-tab-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: var(--surface-container-low);
  padding: 4px;
  border-radius: var(--radius-xl);
}

.pr-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface-variant);
  border: none;
  background: none;
  transition: all 0.15s ease;
}

.pr-tab-btn:hover {
  color: var(--on-surface);
}

.pr-tab-btn.active {
  background-color: var(--surface-container-lowest);
  color: var(--on-surface);
  box-shadow: var(--shadow-sm);
}

/* CHIPS FOR VISIT TYPE / VALIDITY */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.pr-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  background-color: var(--surface-container-low);
  color: var(--on-surface);
  border: none;
  transition: all 0.15s ease;
  cursor: pointer;
}

.pr-chip:hover {
  background-color: var(--surface-container);
}

.pr-chip.active {
  background-color: var(--secondary);
  color: var(--on-secondary);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   CCTV FEEDS & OSD
   ========================================================================== */
.pr-cctv-frame {
  position: relative;
  background-color: var(--primary);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  aspect-ratio: 16 / 9;
}

.pr-cctv-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.88;
  transition: transform 0.4s ease, opacity 0.3s ease;
}

.pr-cctv-frame:hover .pr-cctv-img {
  transform: scale(1.02);
  opacity: 1;
}

.pr-cctv-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(9, 20, 38, 0.95) 0%, transparent 45%, rgba(9, 20, 38, 0.75) 100%);
  pointer-events: none;
}

.pr-cctv-top {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--on-primary);
  z-index: 2;
}

.pr-cctv-rec {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background-color: var(--error);
  color: var(--on-error);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  letter-spacing: 0.05em;
}

.pr-cctv-bottom {
  position: absolute;
  bottom: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  color: var(--on-primary);
  z-index: 2;
}

.hud-crosshair {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0.3;
}

/* ==========================================================================
   TICKETS PROGRESS STEPPER & TIMELINE
   ========================================================================== */
.ticket-step-track {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-xs);
  text-align: center;
  margin-top: var(--space-md);
}

.step-node-bubble {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.step-node-bubble.done {
  background-color: var(--secondary);
  color: var(--on-secondary);
}

.step-node-bubble.current {
  background-color: var(--surface-container-highest);
  color: var(--secondary);
}

.step-node-bubble.pending {
  background-color: var(--surface-container);
  color: var(--outline);
}

.step-track-bar {
  height: 6px;
  width: 100%;
  background-color: var(--surface-container);
  border-radius: var(--radius-full);
  margin-top: 10px;
  overflow: hidden;
}

.step-track-progress {
  height: 100%;
  background-color: var(--secondary);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* ==========================================================================
   LOGIN SPLIT VIEW
   ========================================================================== */
.login-split-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  background-color: var(--background);
}

.login-hero {
  position: relative;
  background-color: var(--primary);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  overflow: hidden;
}

.login-hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.4;
}

.login-hero-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(9, 20, 38, 0.95) 0%, rgba(30, 41, 59, 0.82) 100%);
}

.login-hero-content {
  position: relative;
  z-index: 2;
  color: #ffffff;
}

.login-form-area {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px clamp(24px, 5vw, 72px);
  background-color: var(--surface-container-lowest);
}

.login-switch {
  display: inline-flex;
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-lg);
  width: fit-content;
}

.login-switch-btn {
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  background-color: var(--surface-container-lowest);
  color: var(--on-surface-variant);
  border: none;
  transition: all 0.15s ease;
}

.login-switch-btn.active {
  background-color: var(--secondary);
  color: var(--on-secondary);
}

/* ==========================================================================
   MEDIA QUERIES
   ========================================================================== */
@media (max-width: 1024px) {
  .portal-sidebar {
    transform: translateX(-100%);
  }

  .portal-sidebar.show-mobile {
    transform: translateX(0);
  }

  .portal-main-area {
    margin-left: 0;
    width: 100%;
  }

  .portal-header {
    left: 0;
  }

  .login-split-view {
    grid-template-columns: 1fr;
  }

  .login-hero {
    display: none;
  }
}

@media (max-width: 640px) {
  .header-search-wrap {
    display: none;
  }

  .portal-canvas {
    padding: var(--space-md);
  }
}
