/* assets/css/style.css - Main Design System & Dashboard Styles */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Montserrat:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,400;1,600;1,700&display=swap');

:root {
  --font-main: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Roboto, sans-serif;
  --font-heading: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  /* Primary Palette */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-dark: #1e40af;
  --secondary: #0ea5e9;
  --accent: #f59e0b;

  /* Neutrals */
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --border-color: #e2e8f0;
  --border-subtle: #f1f5f9;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-white: #ffffff;

  /* Functional */
  --success: #10b981;
  --success-bg: #ecfdf5;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --info: #3b82f6;
  --info-bg: #eff6ff;

  /* Elevations */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.04);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.03);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.05), 0 4px 6px -4px rgb(0 0 0 / 0.02);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.07), 0 8px 10px -6px rgb(0 0 0 / 0.03);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.55;
  letter-spacing: -0.012em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  letter-spacing: -0.022em;
  font-weight: 750;
  color: var(--text-main);
}

button, input, select, textarea, optgroup {
  font-family: inherit;
  font-size: inherit;
}

.stat-value, .custom-table td, .table td, .badge, .status-badge, .badge-pill, [data-tabular] {
  font-variant-numeric: tabular-nums;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--primary-hover);
}

/* ==============================================================
   DASHBOARD LAYOUT (Sidebar + Main View)
   ============================================================== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
  position: relative;
}

/* Sidebar */
.app-sidebar {
  width: 270px;
  background-color: var(--bg-sidebar);
  color: #334155;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  border-right: 1px solid var(--border-color);
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.03);
  transition: var(--transition);
}

.sidebar-header {
  padding: 1.25rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 1.2rem;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.brand-text h2 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.brand-text span {
  font-size: 0.725rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: block;
}

.sidebar-menu {
  flex: 1;
  padding: 1rem 0.75rem;
  overflow-y: auto;
  list-style: none;
}

.menu-label {
  font-size: 0.675rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  padding: 0.75rem 0.75rem 0.35rem;
}

.menu-item {
  margin-bottom: 0.2rem;
}

.menu-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.625rem 0.85rem;
  border-radius: var(--radius-md);
  color: #475569;
  font-weight: 500;
  font-size: 0.875rem;
  transition: var(--transition);
}

.menu-link:hover {
  color: var(--primary);
  background: #f8fafc;
  transform: translateX(2px);
}

.menu-link.active {
  background: #eff6ff;
  color: #2563eb;
  font-weight: 600;
  border-left: 3px solid #2563eb;
}

.menu-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  background: #f8fafc;
}

.user-profile-mini {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.user-details {
  flex: 1;
  overflow: hidden;
}

.user-details .name {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-details .role-badge {
  font-size: 0.7rem;
  color: #2563eb;
  font-weight: 600;
  text-transform: capitalize;
}

/* Main Area */
.app-main {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  margin-left: 270px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Top Navigation Bar */
.app-topbar {
  background: var(--bg-card);
  height: 70px;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.page-title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.portal-badge {
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.portal-admin { background: #fee2e2; color: #991b1b; }
.portal-staff { background: #fef3c7; color: #92400e; }
.portal-student { background: #dbeafe; color: #1e40af; }

/* Notification Center & Header Dropdown */
.header-notif-pill {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  border-radius: 999px;
  text-align: center;
  padding: 0 4px;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
  animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.notification-dropdown-panel {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 360px;
  max-width: 90vw;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 12px 30px -5px rgba(0, 0, 0, 0.15), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  z-index: 1000;
  overflow: hidden;
}

.notification-dropdown-panel.show {
  display: block;
  animation: fadeInDown 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.notif-dropdown-header {
  padding: 0.85rem 1rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.notif-dropdown-list {
  max-height: 380px;
  overflow-y: auto;
}

.notif-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 0.15s ease;
  background: #ffffff;
}

.notif-item:hover {
  background: #f8fafc;
}

.notif-item.unread {
  background: #eff6ff;
}

.notif-item.unread:hover {
  background: #dbeafe;
}

.notif-dropdown-footer {
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  text-align: center;
}

/* Content Wrapper */
.content-area {
  padding: 2rem;
  flex: 1;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

/* ==============================================================
   COMPONENTS: CARDS, STATS, TABLES, BUTTONS, MODALS
   ============================================================== */

/* Metrics Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card, #ffffff);
  padding: 1.25rem 1.35rem;
  border-radius: var(--radius-lg, 14px);
  border: 1px solid var(--border-color, #e2e8f0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
  border-color: #cbd5e1;
}

.stat-info {
  flex: 1;
  min-width: 0;
}

.stat-info .stat-label {
  font-size: 0.75rem;
  font-weight: 750;
  text-transform: uppercase;
  color: var(--text-muted, #64748b);
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.stat-info .stat-value {
  font-family: var(--font-heading);
  font-size: 1.85rem;
  font-weight: 850;
  color: var(--text-main, #0f172a);
  line-height: 1.15;
  margin: 0.2rem 0;
}

.stat-info .stat-subtitle {
  font-size: 0.775rem;
  color: var(--text-muted, #64748b);
  font-weight: 500;
  margin-top: 0.25rem;
  line-height: 1.35;
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon i,
.stat-icon svg {
  width: 22px;
  height: 22px;
}

.icon-purple { background: #f5f3ff; color: #7c3aed; }
.icon-blue { background: #eff6ff; color: #2563eb; }
.icon-emerald { background: #ecfdf5; color: #059669; }
.icon-amber { background: #fffbeb; color: #d97706; }
.icon-rose { background: #fef2f2; color: #e11d48; }
.icon-cyan { background: #ecfeff; color: #0891b2; }
.icon-indigo { background: #e0e7ff; color: #4f46e5; }

/* Robustness & safety fallback for stat-cards */
.card.stat-card {
  margin-bottom: 0 !important;
}

.stat-card > div:only-child {
  width: 100%;
}

.stat-card > .card-body {
  padding: 0 !important;
  width: 100%;
  margin: 0;
}

/* Content Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.75rem;
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafafa;
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.card-body {
  padding: 1.5rem;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  display: block;
}

.table-responsive::-webkit-scrollbar {
  height: 6px;
}
.table-responsive::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.custom-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
}

.table-tenants {
  min-width: 1080px;
}

.table-wide {
  min-width: 920px;
}

.custom-table th {
  background: #f8fafc;
  padding: 0.85rem 1.25rem;
  font-family: var(--font-heading);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  border-bottom: 1px solid var(--border-color);
}

.custom-table td {
  padding: 1rem 1.25rem;
  font-size: 0.875rem;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.custom-table tr:hover td {
  background-color: #f8fafc;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.15rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.25);
}
.btn-primary:hover {
  background: var(--primary-hover);
  color: #fff;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.35);
}

.btn-secondary {
  background: #f1f5f9;
  color: var(--text-main);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: #dc2626;
}

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover {
  background: #059669;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

/* Banner / Hero Buttons (on dark/gradient backgrounds) */
.btn-banner-primary {
  background: #ffffff !important;
  color: #1e3a8a !important;
  border: 1px solid #ffffff !important;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease-in-out;
}
.btn-banner-primary:hover {
  background: #f1f5f9 !important;
  color: #1d4ed8 !important;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}
.btn-banner-primary i {
  stroke: #1e3a8a !important;
}

.btn-banner-outline {
  background: rgba(255, 255, 255, 0.12) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.4) !important;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all 0.2s ease-in-out;
}
.btn-banner-outline:hover {
  background: #ffffff !important;
  color: #1e3a8a !important;
  border-color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}
.btn-banner-outline i {
  stroke: currentColor;
}
.btn-banner-outline:hover i {
  stroke: #1e3a8a !important;
}


/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.form-control, .form-select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.95rem;
  font-size: 0.875rem;
  color: var(--text-main);
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: var(--transition);
  outline: none;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Enhanced Select Dropdowns (Desktop & Mobile) */
select.form-control, 
select.form-select, 
select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  cursor: pointer;
  line-height: 1.45;
  vertical-align: middle;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: #ffffff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 15px 11px;
  padding-right: 2.35rem !important;
}

select.form-control:disabled,
select.form-select:disabled,
select:disabled {
  background-color: #f1f5f9;
  color: #94a3b8;
  cursor: not-allowed;
  opacity: 0.8;
}

/* Custom Select Option Styling */
select option {
  padding: 8px 12px;
  font-size: 0.875rem;
  color: var(--text-main, #0f172a);
  background: #ffffff;
}

select option:checked {
  background: #eff6ff linear-gradient(0deg, #eff6ff 0%, #eff6ff 100%);
  color: #1d4ed8;
  font-weight: 700;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.725rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge-success { background: var(--success-bg); color: #065f46; }
.badge-danger { background: var(--danger-bg); color: #991b1b; }
.badge-warning { background: var(--warning-bg); color: #92400e; }
.badge-info { background: var(--info-bg); color: #1e40af; }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-secondary { background: #f1f5f9; color: #475569; }

/* Alerts / Flash Messages */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.alert-success { background: var(--success-bg); color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: var(--danger-bg); color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-bg); color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: var(--info-bg); color: #1e40af; border: 1px solid #bfdbfe; }

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 2.25rem 1.25rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: #fff;
  width: 100%;
  max-width: 550px;
  border-radius: 18px;
  box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.35), 0 0 0 1px rgba(15, 23, 42, 0.06);
  overflow: hidden;
  transform: translateY(16px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: min(92vh, calc(100vh - 2.5rem));
  max-height: min(92dvh, calc(100dvh - 2.5rem));
  margin: auto;
  position: relative;
}

.modal-overlay.active .modal-dialog {
  transform: translateY(0);
}

.modal-header {
  padding: 1.15rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Modal Popup Close Button */
.btn-close,
.modal-close,
.modal-header > button:not(.btn):not(.btn-primary):not(.btn-secondary) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0 0 2px 0;
  margin: 0;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 50%;
  color: #64748b;
  font-family: Arial, sans-serif;
  font-size: 1.35rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  outline: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  user-select: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.btn-close:hover,
.modal-close:hover,
.modal-header > button:not(.btn):not(.btn-primary):not(.btn-secondary):hover {
  background: #fee2e2 !important;
  border-color: #fca5a5 !important;
  color: #ef4444 !important;
  transform: rotate(90deg) scale(1.08);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2) !important;
}

.btn-close:active,
.modal-close:active,
.modal-header > button:not(.btn):not(.btn-primary):not(.btn-secondary):active {
  transform: scale(0.92);
  background: #fecaca !important;
}

.btn-close:focus-visible,
.modal-close:focus-visible,
.modal-header > button:not(.btn):not(.btn-primary):not(.btn-secondary):focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25) !important;
}

.modal-body {
  padding: 1.25rem 1.5rem;
  max-height: calc(88vh - 190px);
  max-height: calc(88dvh - 190px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.modal-footer {
  padding: 0.95rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.85rem;
  background: #f8fafc;
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 18px;
  position: relative;
  z-index: 5;
  box-sizing: border-box;
}

/* Seat Booking Grid */
.seat-map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1rem;
}

.seat-box {
  background: #fff;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.seat-box.available:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: scale(1.02);
}

.seat-box.occupied {
  background: #fef2f2;
  border-color: #fca5a5;
  cursor: not-allowed;
  opacity: 0.75;
}

.seat-number {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
}

/* ID Card Printable Styles */
.id-card-container {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: 0 10px 25px rgba(30, 27, 75, 0.35);
  position: relative;
  overflow: hidden;
}

.id-card-watermark {
  position: absolute;
  right: -20px;
  bottom: -20px;
  font-size: 8rem;
  font-weight: 900;
  opacity: 0.04;
  pointer-events: none;
}

.barcode-strip {
  background: #fff;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  display: inline-block;
  color: #000;
  font-family: monospace;
  font-size: 0.85rem;
  letter-spacing: 2px;
  font-weight: bold;
}

/* Responsive & Mobile Drawer */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1040;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sidebar-overlay.show {
  display: block;
  opacity: 1;
}

.mobile-menu-btn {
  display: none;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.45rem;
  color: var(--text-main);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  margin-right: 0.75rem;
}

.mobile-menu-btn:hover {
  background: #f1f5f9;
}

.mobile-menu-btn svg {
  width: 20px;
  height: 20px;
}

#closeSidebarBtn {
  display: none;
}

/* Helper visibility classes */
.hide-desktop { display: none !important; }
.show-mobile { display: none !important; }

/* Tablets and below (max-width: 1024px) */
@media (max-width: 1024px) {
  .app-sidebar {
    width: 280px;
    max-width: 85vw;
    transform: translateX(-100%);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1050;
    box-shadow: 12px 0 35px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

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

  .app-main {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
  }

  .mobile-menu-btn {
    display: inline-flex !important;
  }

  #closeSidebarBtn {
    display: inline-flex !important;
  }

  .app-topbar {
    padding: 0 1.25rem;
  }

  .content-area {
    padding: 1.25rem !important;
  }
}

/* Tablets and Mobile Phones (max-width: 768px) */
@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }
  .show-mobile {
    display: block !important;
  }

  /* Topbar */
  .app-topbar {
    height: 60px;
    padding: 0 0.85rem;
  }

  .page-title {
    font-size: 1.05rem;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-left {
    gap: 0.5rem;
    min-width: 0;
  }

  .topbar-right {
    gap: 0.5rem;
  }

  .portal-badge {
    display: none;
  }

  /* Cards & Headers */
  .card {
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
  }

  .card-header {
    padding: 0.85rem 1rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .card-header > div {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .card-header input[type="text"],
  .card-header select,
  .card-header .form-control {
    max-width: 100% !important;
    width: 100% !important;
  }

  .card-body {
    padding: 1rem;
  }

  /* Tables */
  .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
    margin-bottom: 0.25rem;
  }

  .custom-table {
    min-width: 620px;
  }

  .custom-table th, .custom-table td {
    padding: 0.65rem 0.75rem;
    font-size: 0.825rem;
  }

  /* Modals */
  .modal-overlay {
    padding: 1rem 0.85rem !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .modal-dialog {
    max-width: 100% !important;
    width: 100% !important;
    max-height: calc(100vh - 2.5rem) !important;
    border-radius: 18px !important;
    margin: auto !important;
    box-shadow: 0 20px 40px -10px rgba(15, 23, 42, 0.4) !important;
  }

  .modal-header {
    padding: 1rem 1.25rem;
  }

  .modal-body {
    padding: 1rem 1.25rem 2rem 1.25rem !important;
    max-height: calc(100vh - 170px) !important;
  }

  .modal-footer {
    padding: 1rem 1.25rem 1.15rem 1.25rem !important;
    flex-wrap: wrap;
    gap: 0.65rem;
    border-bottom-left-radius: 18px !important;
    border-bottom-right-radius: 18px !important;
  }

  .modal-footer .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  /* Form row grids & Modal side-by-side inputs */
  .form-row,
  .modal-dialog div[style*="grid-template-columns"],
  .modal-body div[style*="grid-template-columns"],
  div[style*="grid-template-columns:1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns:2fr 1fr"],
  div[style*="grid-template-columns: 2fr 1fr"],
  div[style*="grid-template-columns:1fr 1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr 1fr"],
  div[style*="grid-template-columns:repeat(3, 1fr)"],
  div[style*="grid-template-columns: repeat(3, 1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  /* Stats grid */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
    margin-bottom: 1.25rem;
  }

  .stat-card {
    padding: 1rem 1.15rem;
    min-height: auto;
  }

  .stat-card .stat-value {
    font-size: 1.6rem;
  }

  .stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
  }

  .stat-card .stat-icon i,
  .stat-card .stat-icon svg {
    width: 20px;
    height: 20px;
  }

  /* Notification dropdown panel */
  .notification-dropdown-panel {
    position: fixed;
    top: 65px;
    left: 10px;
    right: 10px;
    width: auto;
    max-width: none;
    border-radius: 12px;
  }

  /* Alerts */
  .alert {
    padding: 0.85rem 1rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .alert .btn {
    align-self: flex-start;
  }
}

/* Small smartphones (max-width: 480px) */
@media (max-width: 480px) {
  .content-area {
    padding: 0.75rem !important;
  }

  .page-title {
    max-width: 140px;
    font-size: 1rem;
  }

  .btn {
    padding: 0.5rem 0.85rem;
    font-size: 0.825rem;
  }

  .btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
  }

  .seat-map-grid {
    grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
    gap: 0.5rem;
  }

  .seat-box, .seat-card-item {
    padding: 0.65rem 0.4rem !important;
  }

  .seat-number {
    font-size: 1.1rem;
  }

  .id-card-container {
    padding: 1.25rem;
  }
}

/* =========================================================
   RESPONSIVE LAYOUT & MOBILE CARD UTILITIES (ALL PANELS)
   ========================================================= */

/* Header row with actions */
.page-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-header-title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.page-header-desc {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0;
}

.page-header-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  align-items: center;
}

/* View Mode Switcher */
.view-mode-toggle {
  display: inline-flex;
  align-items: center;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}

.view-mode-btn {
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
}

.view-mode-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  font-weight: 700;
}

/* Form Responsive Grids */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

/* Modern Responsive Tenant Cards Grid - Exactly 2 Cards per Row */
.tenant-cards-container {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.15rem;
  padding: 1.15rem;
  background: #f8fafc;
  box-sizing: border-box;
}

.tenant-cards-container.active-grid,
.tenant-cards-container[style*="display: block"],
.tenant-cards-container[style*="display: grid"] {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 1.15rem !important;
}

@media (max-width: 768px) {
  .tenant-cards-container,
  .tenant-cards-container.active-grid,
  .tenant-cards-container[style*="display: block"],
  .tenant-cards-container[style*="display: grid"] {
    grid-template-columns: 1fr !important;
    gap: 0.85rem !important;
    padding: 0.75rem !important;
  }
}

.tenant-mobile-card {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  margin-bottom: 0;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  box-sizing: border-box;
  overflow: hidden;
  min-width: 0;
}

.tenant-mobile-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px -4px rgba(15, 23, 42, 0.1);
  border-color: #94a3b8;
}

.tenant-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e2e8f0;
}

.tenant-card-identity {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  min-width: 0;
}

.tenant-brand-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}

.tenant-card-title {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.3;
  word-break: break-word;
}

.tenant-card-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  word-break: break-word;
}

.tenant-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
  margin-bottom: 0.85rem;
  background: #f8fafc;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  font-size: 0.825rem;
}

.tenant-card-metric-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  margin-bottom: 3px;
  white-space: nowrap;
}

.tenant-card-metric-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  word-break: break-word;
}

.tenant-card-metric-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.tenant-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px dashed #e2e8f0;
}

.tenant-card-actions .btn {
  font-size: 0.78rem;
  padding: 0.42rem 0.75rem;
  border-radius: 6px;
  flex: 1 1 auto;
  min-height: 32px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.tenant-card-actions a.btn-danger {
  flex: 0 0 36px !important;
  padding: 0.42rem 0 !important;
  text-align: center;
  justify-content: center;
}

@media (max-width: 520px) {
  .tenant-card-actions .btn {
    flex: 1 1 calc(50% - 0.35rem);
  }
  .tenant-card-actions a.btn-danger {
    flex: 1 1 100% !important;
  }
}

/* Horizontal scroll indicators */
.table-scroll-hint {
  display: none;
  font-size: 0.725rem;
  color: #64748b;
  padding: 0.35rem 0.85rem;
  background: #f8fafc;
  border-bottom: 1px solid #f1f5f9;
  align-items: center;
  gap: 0.4rem;
}

@media (max-width: 768px) {
  .page-header-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .page-header-actions {
    width: 100%;
    flex-direction: column;
    gap: 0.5rem;
  }

  .page-header-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  .table-scroll-hint {
    display: flex;
  }

  .dashboard-grid-2 {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }

  /* Automatically collapse side-by-side dashboard cards on tablet/mobile */
  div[style*="grid-template-columns:1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

/* ========================================================
   UNIVERSAL TABLE TO CARDS SYSTEM (MOBILE & DESKTOP)
   ======================================================== */

.table-view-switcher {
  display: inline-flex;
  align-items: center;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
  user-select: none;
  flex-shrink: 0;
}

.table-view-btn {
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.table-view-btn svg, .table-view-btn i {
  width: 13px;
  height: 13px;
}

.table-view-btn:hover {
  color: var(--text-main, #0f172a);
}

.table-view-btn.active {
  background: #ffffff;
  color: var(--primary, #2563eb);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.table-view-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0.65rem 1rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  gap: 0.75rem;
}

/* CARDS VIEW MODE TRANSFORMATION */
.table-cards-mode {
  padding: 1rem !important;
  background: #f8fafc !important;
  overflow-x: visible !important;
  display: block !important;
}

.table-cards-mode .table-scroll-hint {
  display: none !important;
}

.table-cards-mode .custom-table,
.table-cards-mode table {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 1.15rem !important;
  width: 100% !important;
  min-width: 0 !important;
  border: none !important;
  background: transparent !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

@media (max-width: 768px) {
  .table-cards-mode {
    padding: 0.75rem 0.5rem !important;
  }
  .table-cards-mode .custom-table,
  .table-cards-mode table {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }
}

.table-cards-mode thead {
  display: none !important;
}

.table-cards-mode tbody {
  display: contents !important;
}

/* Each TR becomes an elevated Card */
.table-cards-mode tbody tr {
  display: flex !important;
  flex-direction: column !important;
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 12px !important;
  padding: 0.95rem 1.05rem !important;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04) !important;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease !important;
  gap: 0.55rem !important;
  margin-bottom: 0 !important;
  position: relative !important;
  box-sizing: border-box !important;
  max-width: 100% !important;
  overflow: hidden !important;
}

.table-cards-mode tbody tr:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 20px -4px rgba(15, 23, 42, 0.1) !important;
  border-color: #94a3b8 !important;
}

/* Empty state handling (colspan) */
.table-cards-mode tbody tr td[colspan] {
  grid-column: 1 / -1 !important;
  display: block !important;
  text-align: center !important;
  border: none !important;
  padding: 2.5rem 1rem !important;
  width: 100% !important;
}
.table-cards-mode tbody tr td[colspan]::before {
  display: none !important;
}

/* Card Field Rows (TDs) */
.table-cards-mode tbody td {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  padding: 0.45rem 0 !important;
  border: none !important;
  border-bottom: 1px dashed #e2e8f0 !important;
  font-size: 0.86rem !important;
  min-width: 0 !important;
  background: transparent !important;
  color: var(--text-main, #1e293b) !important;
  flex-wrap: wrap !important;
  gap: 0.4rem 0.75rem !important;
  text-align: right !important;
  box-sizing: border-box !important;
}

/* Field Label */
.table-cards-mode tbody td.card-cell-field::before {
  content: attr(data-col-title);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  flex-shrink: 0;
  text-align: left;
}

/* Card Header (First Primary Content TD) */
.table-cards-mode tbody td.card-cell-header {
  border-bottom: 1.5px solid #e2e8f0 !important;
  padding-bottom: 0.75rem !important;
  margin-bottom: 0.25rem !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  text-align: left !important;
  width: 100% !important;
}

.table-cards-mode tbody td.card-cell-header::before {
  display: none !important;
}

/* Checkbox Column */
.table-cards-mode tbody td.card-cell-checkbox {
  position: absolute !important;
  top: 1rem !important;
  right: 1rem !important;
  border: none !important;
  padding: 0 !important;
  width: auto !important;
  margin: 0 !important;
}
.table-cards-mode tbody td.card-cell-checkbox::before {
  display: none !important;
}

/* Card Action Buttons (Footer TD) - Never Overflow */
.table-cards-mode tbody td.card-cell-actions,
.table-cards-mode tbody td:last-child {
  border-bottom: none !important;
  border-top: 1.5px solid #e2e8f0 !important;
  padding-top: 0.75rem !important;
  margin-top: 0.35rem !important;
  justify-content: flex-end !important;
  align-items: center !important;
  width: 100% !important;
  gap: 0.45rem !important;
  text-align: right !important;
  box-sizing: border-box !important;
}

.table-cards-mode tbody td.card-cell-actions::before,
.table-cards-mode tbody td:last-child::before {
  display: none !important;
}

/* Any inner div or wrapper inside actions cell MUST wrap and never exceed width */
.table-cards-mode tbody td.card-cell-actions > div,
.table-cards-mode tbody td:last-child > div {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 0.4rem !important;
  width: 100% !important;
  justify-content: flex-end !important;
  align-items: center !important;
  box-sizing: border-box !important;
}

.table-cards-mode tbody td.card-cell-actions .btn,
.table-cards-mode tbody td:last-child .btn,
.table-cards-mode tbody td.card-cell-actions > div .btn,
.table-cards-mode tbody td:last-child > div .btn {
  padding: 0.38rem 0.65rem !important;
  font-size: 0.78rem !important;
  flex: 0 1 auto !important;
  box-sizing: border-box !important;
  max-width: 100% !important;
}

@media (max-width: 540px) {
  .table-cards-mode tbody td.card-cell-actions > div,
  .table-cards-mode tbody td:last-child > div {
    justify-content: stretch !important;
  }
  .table-cards-mode tbody td.card-cell-actions .btn,
  .table-cards-mode tbody td:last-child .btn,
  .table-cards-mode tbody td.card-cell-actions > div .btn,
  .table-cards-mode tbody td:last-child > div .btn {
    flex: 1 1 calc(50% - 0.4rem) !important;
    text-align: center !important;
    justify-content: center !important;
  }
}

/* Live Real-time Table & Card Search - Hide Non-matching Items */
.hidden-row,
tr.hidden-row,
tbody tr.hidden-row,
.custom-table tbody tr.hidden-row,
.table-cards-mode tbody tr.hidden-row,
.tenant-mobile-card.hidden-card {
  display: none !important;
}

/* ==============================================================
   RESPONSIVE MODAL & DROPDOWN LAYOUT RULES (Mobile & Desktop)
   ============================================================== */

/* Modal Dialog Sizing & Constraints */
.modal-dialog {
  max-width: 95vw;
  box-sizing: border-box;
}

@media (min-width: 641px) {
  .modal-dialog {
    max-width: 640px;
  }
  .modal-dialog[style*="max-width:720px"],
  .modal-dialog[style*="max-width: 720px"],
  .modal-dialog[style*="max-width:680px"],
  .modal-dialog[style*="max-width: 680px"],
  .modal-dialog.modal-lg {
    max-width: 720px;
  }
}

@media (max-width: 640px) {
  /* On mobile screens, collapse multi-column form grids in modals to full width */
  .modal-dialog [style*="grid-template-columns:1fr 1fr"],
  .modal-dialog [style*="grid-template-columns: 1fr 1fr"],
  .modal-dialog [style*="grid-template-columns:1fr 1fr 1fr"],
  .modal-dialog [style*="grid-template-columns: 1fr 1fr 1fr"],
  .modal-dialog [style*="grid-template-columns:2fr 1fr"],
  .modal-dialog [style*="grid-template-columns: 2fr 1fr"],
  .modal-dialog .form-grid-2,
  .modal-dialog .form-grid-3,
  .modal-dialog .form-row {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  .modal-overlay {
    padding: 0.5rem !important;
    align-items: center !important;
  }

  .modal-dialog {
    width: calc(100% - 0.75rem) !important;
    max-width: 100% !important;
    margin: auto !important;
    border-radius: 14px !important;
    max-height: calc(100vh - 1rem) !important;
    max-height: calc(100dvh - 1rem) !important;
  }

  .modal-header {
    padding: 0.85rem 1rem !important;
  }

  .modal-header h3 {
    font-size: 1.05rem !important;
    line-height: 1.3 !important;
  }

  .modal-body {
    padding: 0.95rem 1rem !important;
    max-height: calc(100vh - 165px) !important;
    max-height: calc(100dvh - 165px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .modal-footer {
    padding: 0.75rem 1rem !important;
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
  }

  /* Prevent iOS automatic zoom by maintaining 16px font-size on mobile inputs */
  .modal-dialog select.form-control,
  .modal-dialog input.form-control,
  .modal-dialog .form-select,
  select.form-control,
  input.form-control {
    font-size: 16px !important;
    min-height: 42px;
  }

  /* Table search & filter dropdown bar on mobile screens */
  .card-header > div[style*="flex-wrap:wrap"] {
    width: 100% !important;
    max-width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.5rem !important;
  }

  .card-header select.form-control,
  .card-header input.form-control,
  .table-filters select,
  .table-filters input {
    max-width: 100% !important;
    width: 100% !important;
    flex: 1 1 100% !important;
  }
}

/* ==============================================================
   RESPONSIVE FORM GRIDS (Stack cleanly on mobile screens)
   ============================================================== */
.responsive-form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.responsive-form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

@media (max-width: 680px) {
  .responsive-form-grid-2,
  .responsive-form-grid-3 {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }
}

/* ==============================================================
   CUSTOM CARD DROPDOWNS (Full Text Wrapping & Overflow-Proof)
   ============================================================== */
.custom-card-select-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.custom-card-select-trigger {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.95rem;
  font-size: 0.875rem;
  font-family: inherit;
  font-weight: 600;
  color: var(--text-main, #0f172a);
  background: #ffffff;
  border: 1.5px solid var(--border-color, #cbd5e1);
  border-radius: var(--radius-md, 10px);
  cursor: pointer;
  outline: none;
  text-align: left;
  transition: all 0.2s ease;
  min-height: 42px;
}

.custom-card-select-trigger:focus,
.custom-card-select-wrap.active .custom-card-select-trigger {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.custom-card-select-trigger-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 0.5rem;
}

.custom-card-select-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background: #ffffff;
  border: 1.5px solid #2563eb;
  border-radius: 12px;
  box-shadow: 0 12px 30px -4px rgba(15, 23, 42, 0.18), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  z-index: 2210 !important;
  overflow: hidden;
}

.custom-card-select-wrap.active {
  z-index: 2200 !important;
}

.custom-card-select-wrap.active .custom-card-select-menu {
  display: block;
}

.custom-card-select-wrap.open-upward .custom-card-select-menu {
  top: auto;
  bottom: calc(100% + 4px);
  box-shadow: 0 -12px 30px -4px rgba(15, 23, 42, 0.18), 0 -4px 6px -2px rgba(0, 0, 0, 0.05);
}

.custom-card-select-hidden {
  position: absolute !important;
  opacity: 0 !important;
  pointer-events: none !important;
  width: 1px !important;
  height: 1px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  clip: rect(0 0 0 0) !important;
}

.custom-card-select-chevron {
  font-size: 0.725rem;
  color: #64748b;
  margin-left: auto;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.custom-card-select-wrap.active .custom-card-select-chevron {
  transform: rotate(180deg);
  color: #2563eb;
}

.custom-card-select-empty {
  padding: 1.15rem 1rem;
  text-align: center;
  color: #94a3b8;
  font-size: 0.825rem;
  font-weight: 500;
}

.custom-card-select-search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.custom-card-select-search-box input {
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.825rem;
  font-family: inherit;
  color: #0f172a;
}

.custom-card-select-list {
  max-height: 250px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.25rem 0;
}

.custom-card-select-list::-webkit-scrollbar {
  width: 6px;
}
.custom-card-select-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.custom-card-select-list::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Individual Card Items inside dropdown with FULL TEXT WRAPPING */
.custom-card-item {
  padding: 0.65rem 0.95rem;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 0.15s ease;
  white-space: normal !important;
  word-break: break-word !important;
  text-align: left;
}

.custom-card-item:last-child {
  border-bottom: none;
}

.custom-card-item:hover {
  background: #f8fafc;
}

.custom-card-item.selected {
  background: #eff6ff;
  border-left: 3px solid #2563eb;
}

.custom-card-item-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-weight: 750;
  font-size: 0.875rem;
  color: #0f172a;
  line-height: 1.35;
}

.custom-card-item-desc {
  font-size: 0.775rem;
  color: #64748b;
  margin-top: 0.2rem;
  line-height: 1.4;
  white-space: normal !important;
  word-break: break-word !important;
}

.custom-card-item-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 9999px;
  white-space: nowrap;
}

.custom-card-item-badge.badge-avail {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.custom-card-item-badge.badge-shared {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

/* ==============================================================
   SEAT MATRIX FILTERS ROW (1 Horizontal Row & Fully Responsive)
   ============================================================== */
.seat-filters-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  width: 100%;
  align-items: center;
}

.seat-filter-col {
  width: 100%;
  min-width: 0;
}

.seat-filter-col .form-control {
  width: 100% !important;
  max-width: 100% !important;
}

@media (max-width: 992px) {
  .seat-filters-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 576px) {
  .seat-filters-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
}

/* ==============================================================
   ADMISSIONS & DIRECTORY FILTERS ROW (1 Horizontal Row & Responsive)
   ============================================================== */
.admissions-filters-row {
  display: grid;
  grid-template-columns: minmax(240px, 2.2fr) minmax(140px, 1fr) minmax(120px, 0.9fr) minmax(150px, 1.1fr);
  gap: 0.75rem;
  width: 100%;
  align-items: center;
}

.notices-filters-row {
  display: grid;
  grid-template-columns: minmax(200px, 2fr) minmax(170px, 1.5fr) minmax(130px, 1fr) minmax(120px, 1fr) auto;
  gap: 0.75rem;
  width: 100%;
  align-items: center;
}

.filter-col-search,
.filter-col-item {
  width: 100%;
  min-width: 0;
}

.filter-col-search .form-control,
.filter-col-item .form-control {
  width: 100% !important;
  max-width: 100% !important;
}

@media (max-width: 1024px) {
  .admissions-filters-row {
    grid-template-columns: 1fr 1fr;
  }
  .notices-filters-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 576px) {
  .admissions-filters-row,
  .notices-filters-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
}









