/* ==========================================================================
   SwiftBus - Core Design System & Shared Layout Styles (With Dark Mode)
   ========================================================================== */

:root {
  --primary: #d84e55;
  --primary-dark: #b9383f;
  --primary-light: #fdf2f3;
  --secondary: #1e293b;
  --accent: #f59e0b;
  --primo: #7c3aed;
  --primo-bg: #f5f3ff;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --info: #3b82f6;
  --info-bg: #eff6ff;

  --ladies: #ec4899;
  --ladies-bg: #fdf2f8;
  --gents: #3b82f6;
  --gents-bg: #eff6ff;

  --bg-body: #f4f6f9;
  --bg-card: #ffffff;
  --bg-muted: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font-sans: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body.dark-theme {
  --bg-body: #0b1120;
  --bg-card: #111827;
  --bg-muted: #1e293b;
  --border: #263248;
  --border-strong: #374151;
  --text-main: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --primary-light: rgba(216, 78, 85, 0.16);
  --success-bg: rgba(16, 185, 129, 0.15);
  --warning-bg: rgba(245, 158, 11, 0.15);
  --danger-bg: rgba(239, 68, 68, 0.15);
  --info-bg: rgba(59, 130, 246, 0.15);
  --primo-bg: rgba(124, 58, 237, 0.18);
  --ladies-bg: rgba(236, 72, 153, 0.15);
  --gents-bg: rgba(59, 130, 246, 0.15);
}

body.dark-theme .site-header,
body.dark-theme .modal-card,
body.dark-theme .modal-header,
body.dark-theme .search-widget,
body.dark-theme .city-dropdown,
body.dark-theme .faq-item,
body.dark-theme .ticket-sheet,
body.dark-theme .qr-box {
  background: var(--bg-card);
  color: var(--text-main);
}

body.dark-theme .form-control,
body.dark-theme .sort-pill,
body.dark-theme .btn-outline,
body.dark-theme .seat-btn:not(.booked):not(.selected) {
  background: var(--bg-muted);
  color: var(--text-main);
  border-color: var(--border-strong);
}

body.dark-theme .section[style*="background:#fff"] {
  background: #0f172a !important;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg-body);
  color: var(--text-main);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
ul { list-style: none; }
img { max-width: 100%; display: block; }

.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 20px; }
.main-content { flex: 1; }
.section { padding: 52px 0; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}

.section-title { font-size: 1.65rem; font-weight: 800; color: var(--text-main); letter-spacing: -0.02em; }
.section-subtitle { color: var(--text-muted); font-size: 0.95rem; margin-top: 4px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.3;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-primo { background: var(--primo-bg); color: var(--primo); border: 1px solid rgba(124, 58, 237, 0.25); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: #b45309; }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--bg-muted); color: var(--text-secondary); border: 1px solid var(--border); }

.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }
.fw-bold { font-weight: 700; }
.hidden { display: none !important; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 0.92rem; cursor: pointer; transition: var(--transition); white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(216, 78, 85, 0.28); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover:not(:disabled) { background: #0f172a; }
.btn-outline { background: #fff; border-color: var(--border-strong); color: var(--text-main); }
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-muted); color: var(--text-main); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-lg { padding: 13px 26px; font-size: 1rem; }

/* Cards & Forms */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-label { font-size: 0.84rem; font-weight: 600; color: var(--text-secondary); }
.form-control {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: #fff; color: var(--text-main); font-size: 0.94rem; transition: var(--transition);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(216, 78, 85, 0.14); }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

/* Header & Navigation */
.site-header {
  position: sticky; top: 0; z-index: 900;
  background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 70px; }
.brand-logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.32rem; letter-spacing: -0.02em; color: var(--text-main); }
.brand-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #b9383f); color: #fff;
  display: grid; place-items: center; font-size: 1.2rem; box-shadow: 0 4px 10px rgba(216, 78, 85, 0.3);
}
.brand-logo span em { font-style: normal; color: var(--primary); }
.nav-links { display: flex; align-items: center; gap: 2px; }
.nav-link { padding: 7px 10px; border-radius: var(--radius-sm); font-size: 0.87rem; font-weight: 600; color: var(--text-secondary); transition: var(--transition); white-space: nowrap; }
.nav-link:hover, .nav-link.active { color: var(--primary); background: var(--primary-light); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-select { padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-muted); font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.theme-toggle-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-muted); cursor: pointer; display: grid; place-items: center; font-size: 0.95rem; }
.mobile-menu-btn { display: none; background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 10px; font-size: 1.2rem; cursor: pointer; color: var(--text-main); }
.user-pill { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 5px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg-card); font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.user-pill:hover { border-color: var(--primary); }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 0.78rem; font-weight: 700; }

/* Footer */
.site-footer { background: #0f172a; color: #cbd5e1; padding: 52px 0 24px; margin-top: 60px; }
.footer-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1.2fr; gap: 32px; margin-bottom: 36px; }
.footer-brand { color: #fff; font-size: 1.35rem; font-weight: 800; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.footer-desc { font-size: 0.9rem; color: #94a3b8; line-height: 1.6; margin-bottom: 16px; }
.footer-title { color: #fff; font-size: 0.95rem; font-weight: 700; margin-bottom: 14px; }
.footer-links li { margin-bottom: 9px; }
.footer-links a { font-size: 0.88rem; color: #94a3b8; transition: var(--transition); }
.footer-links a:hover { color: #fff; padding-left: 4px; }
.social-row { display: flex; gap: 10px; margin-top: 12px; }
.social-btn { width: 36px; height: 36px; border-radius: 8px; background: rgba(255, 255, 255, 0.08); color: #e2e8f0; display: grid; place-items: center; font-size: 0.9rem; font-weight: 700; transition: var(--transition); }
.social-btn:hover { background: var(--primary); color: #fff; }
.footer-bottom { border-top: 1px solid rgba(255, 255, 255, 0.1); padding-top: 20px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; font-size: 0.84rem; color: #94a3b8; }

/* Modals & Toasts */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.65); backdrop-filter: blur(4px); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-card { background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 680px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: modalIn 0.2s ease-out; }
.modal-lg { max-width: 960px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #fff; z-index: 5; }
.modal-title { font-size: 1.15rem; font-weight: 700; }
.modal-close { background: var(--bg-muted); color: var(--text-main); border: none; width: 32px; height: 32px; border-radius: 50%; font-size: 1.1rem; cursor: pointer; display: grid; place-items: center; }
.modal-body { padding: 24px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 1200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--secondary); color: #fff; padding: 12px 18px; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); font-size: 0.9rem; font-weight: 500; display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 400px; animation: slideIn 0.22s ease; }
.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-info { border-left: 4px solid var(--info); }
@keyframes slideIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }

/* Tables & Tabs */
.tabs-bar { display: flex; gap: 6px; border-bottom: 2px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab-btn { padding: 10px 18px; background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px; font-weight: 600; font-size: 0.92rem; color: var(--text-muted); cursor: pointer; white-space: nowrap; transition: var(--transition); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { background: var(--bg-muted); font-weight: 700; color: var(--text-secondary); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.data-table tr:hover td { background: var(--bg-muted); }

/* ==========================================================================
   Multilingual Layout Safeguards (EN / HI / TE / TA / KN / ML)
   ========================================================================== */
:lang(hi), :lang(te), :lang(ta), :lang(kn), :lang(ml) {
  line-height: 1.65;
  overflow-wrap: break-word;
}

:lang(ta), :lang(ml) {
  line-height: 1.7;
  letter-spacing: -0.01em;
}

:lang(hi) .section-title, :lang(te) .section-title, :lang(ta) .section-title, :lang(kn) .section-title, :lang(ml) .section-title,
:lang(hi) .hero-title, :lang(te) .hero-title, :lang(ta) .hero-title, :lang(kn) .hero-title, :lang(ml) .hero-title {
  line-height: 1.32;
  overflow-wrap: break-word;
}

:lang(ta) .form-label, :lang(ml) .form-label {
  font-size: 0.78rem;
  line-height: 1.35;
}

:lang(hi) .btn, :lang(te) .btn, :lang(ta) .btn, :lang(kn) .btn, :lang(ml) .btn,
:lang(hi) .badge, :lang(te) .badge, :lang(ta) .badge, :lang(kn) .badge, :lang(ml) .badge {
  white-space: normal;
  text-align: center;
  line-height: 1.35;
}

:lang(ta) .tab-btn, :lang(ml) .tab-btn {
  flex-shrink: 0;
  font-size: 0.85rem;
  padding: 10px 14px;
}

/* ==========================================================================
   1. Large Desktop Media Queries (>= 1360px)
   ========================================================================== */
@media (min-width: 1360px) {
  .container { max-width: 1340px; }
  .section { padding: 60px 0; }
  .section-title { font-size: 1.75rem; }
  :lang(hi) .nav-link, :lang(te) .nav-link, :lang(kn) .nav-link {
    font-size: 0.81rem;
    padding: 6px 8px;
  }
  :lang(ta) .nav-link, :lang(ml) .nav-link {
    font-size: 0.77rem;
    padding: 6px 7px;
  }
}

/* ==========================================================================
   2. Laptop Media Queries (1025px - 1359px)
   ========================================================================== */
@media (max-width: 1359px) and (min-width: 1025px) {
  .container { max-width: 1180px; padding: 0 18px; }
  .header-inner { gap: 10px; }
  .brand-logo { font-size: 1.2rem; gap: 8px; }
  .nav-link { padding: 6px 8px; font-size: 0.82rem; }
  .header-select { padding: 5px 6px; font-size: 0.78rem; }
  .footer-grid { grid-template-columns: 1.3fr 1fr 1fr 1.1fr; gap: 24px; }
  :lang(ta) .btn, :lang(ml) .btn { font-size: 0.84rem; padding: 8px 12px; }
}

/* Collapse Tamil & Malayalam nav to drawer on laptops <= 1300px (longest multi-syllable nav labels) */
@media (max-width: 1300px) {
  :lang(ta) .nav-links, :lang(ml) .nav-links {
    display: none;
    position: absolute;
    top: 70px;
    left: 0;
    right: 0;
    background: var(--bg-card);
    flex-direction: column;
    align-items: stretch;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    z-index: 950;
  }
  :lang(ta) .nav-links.open, :lang(ml) .nav-links.open { display: flex; }
  :lang(ta) .mobile-menu-btn, :lang(ml) .mobile-menu-btn { display: inline-flex; }
}

/* Collapse remaining Indic-language navs to drawer on narrower laptops (<= 1240px) */
@media (max-width: 1240px) {
  :lang(hi) .nav-links, :lang(te) .nav-links, :lang(kn) .nav-links {
    display: none;
    position: absolute;
    top: 70px;
    left: 0;
    right: 0;
    background: var(--bg-card);
    flex-direction: column;
    align-items: stretch;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    z-index: 950;
  }
  :lang(hi) .nav-links.open, :lang(te) .nav-links.open, :lang(kn) .nav-links.open { display: flex; }
  :lang(hi) .mobile-menu-btn, :lang(te) .mobile-menu-btn, :lang(kn) .mobile-menu-btn { display: inline-flex; }
}

/* ==========================================================================
   3. Tablet Media Queries (<= 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
  .container { padding: 0 16px; }
  .nav-links {
    display: none;
    position: absolute;
    top: 70px;
    left: 0;
    right: 0;
    background: var(--bg-card);
    flex-direction: column;
    align-items: stretch;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    z-index: 950;
  }
  .nav-links.open { display: flex; }
  .mobile-menu-btn { display: inline-flex; }
  .footer-grid { grid-template-columns: repeat(2, 1fr); gap: 24px; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .modal-lg { max-width: 94vw; }
  :lang(ta) .section-title, :lang(ml) .section-title { font-size: 1.42rem; }
  :lang(ta) .btn, :lang(ml) .btn { font-size: 0.84rem; padding: 8px 13px; }
}

/* ==========================================================================
   4. Mobile Media Queries (<= 768px, <= 480px, <= 390px)
   ========================================================================== */
@media (max-width: 768px) {
  .header-inner { height: 62px; gap: 8px; }
  .nav-links,
  :lang(hi) .nav-links, :lang(te) .nav-links, :lang(ta) .nav-links, :lang(kn) .nav-links, :lang(ml) .nav-links {
    top: 62px;
  }
  .brand-logo { font-size: 1.15rem; gap: 7px; }
  .brand-icon { width: 32px; height: 32px; font-size: 1rem; }
  .header-actions { gap: 6px; }
  .header-select { padding: 4px 6px; font-size: 0.74rem; max-width: 96px; }
  .user-pill { padding: 3px 8px 3px 4px; font-size: 0.78rem; }
  .user-avatar { width: 24px; height: 24px; font-size: 0.72rem; }

  .section { padding: 36px 0; }
  .section-title { font-size: 1.38rem; }
  :lang(hi) .section-title, :lang(te) .section-title, :lang(kn) .section-title { font-size: 1.24rem; }
  :lang(ta) .section-title, :lang(ml) .section-title { font-size: 1.18rem; line-height: 1.35; }
  :lang(ta) .section-subtitle, :lang(ml) .section-subtitle { font-size: 0.86rem; }
  .grid-2, .grid-3, .grid-4, .footer-grid { grid-template-columns: 1fr; }

  .modal-backdrop { padding: 10px; }
  .modal-header { padding: 14px 16px; }
  .modal-body { padding: 16px; }
  .toast-container { left: 12px; right: 12px; bottom: 14px; }
  .toast { min-width: 0; max-width: 100%; }
  .data-table th, .data-table td { padding: 9px 10px; font-size: 0.82rem; }
}

@media (max-width: 480px) {
  .container { padding: 0 12px; }
  .btn-lg { padding: 11px 18px; font-size: 0.94rem; }
  :lang(ta) .btn-lg, :lang(ml) .btn-lg { font-size: 0.88rem; padding: 10px 14px; }
  .header-select { max-width: 74px; font-size: 0.7rem; padding: 3px 4px; }
  .user-pill { padding: 3px; }
  .user-pill span:last-child { display: none; }
}

@media (max-width: 390px) {
  .brand-logo { font-size: 1.02rem; }
  .brand-icon { width: 28px; height: 28px; font-size: 0.9rem; }
  .theme-toggle-btn { width: 28px; height: 28px; font-size: 0.82rem; }
  .header-select { max-width: 62px; font-size: 0.66rem; }
  :lang(ta) .section-title, :lang(ml) .section-title { font-size: 1.08rem; }
}

@media print {
  body * { visibility: hidden; }
  #printable-ticket, #printable-ticket * { visibility: visible; }
  #printable-ticket { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none !important; border: 1px solid #cbd5e1 !important; }
  .no-print { display: none !important; }
}
