/* ==========================================================================
   Tour & Travel SaaS — Design System
   Jewel-tone palette inspired by Northern Pakistan: deep alpine teal,
   antique gold, and terracotta clay — same premium-craft approach as the
   Salon SaaS (jewel rose/gold) and Clinic SaaS, adapted for a mountain/
   travel context. Mobile-first, RTL-ready via CSS logical properties.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Manrope:wght@400;500;600;700&family=Noto+Nastaliq+Urdu:wght@400;600&display=swap');

:root {
    /* Jewel tones */
    --color-teal-950: #062c2b;
    --color-teal-900: #0b3d3a;
    --color-teal-700: #0f766e;
    --color-teal-500: #14b8a6;
    --color-teal-100: #ccfbf1;

    --color-gold-700: #92702a;
    --color-gold-500: #c9973f;
    --color-gold-300: #e8c98a;
    --color-gold-100: #faf1de;

    --color-terracotta-600: #b5502f;
    --color-terracotta-400: #d97a56;

    --color-ink: #1c2523;
    --color-body: #4b5a57;
    --color-muted: #83938f;
    --color-surface: #ffffff;
    --color-bg: #f6f7f5;
    --color-border: #e3e7e4;

    --color-success: #0f9960;
    --color-warning: #c9973f;
    --color-danger: #c0392b;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;

    --font-heading: 'Playfair Display', serif;
    --font-body: 'Manrope', sans-serif;
    --font-urdu: 'Noto Nastaliq Urdu', serif;

    --shadow-card: 0 1px 3px rgba(6, 44, 43, 0.06), 0 8px 24px -12px rgba(6, 44, 43, 0.12);
}

* { box-sizing: border-box; }

html, body {
    overflow-x: hidden;
    max-width: 100%;
}

body {
    font-family: var(--font-body);
    color: var(--color-body);
    background: var(--color-bg);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

[dir="rtl"] body,
html[lang="ur"] body {
    font-family: var(--font-urdu);
}

h1, h2, h3, .font-heading {
    font-family: var(--font-heading);
    color: var(--color-ink);
    font-weight: 700;
    margin: 0 0 0.4em;
}

[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3 {
    font-family: var(--font-urdu);
}

a { color: var(--color-teal-700); text-decoration: none; }

/* ---------- Layout shell ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--color-teal-950), var(--color-teal-900));
    color: #eafaf7;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset-inline-start: 0;
    top: 0;
    bottom: 0;
    transition: transform .25s ease;
    z-index: 40;
}

.sidebar-brand {
    padding: 20px;
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.sidebar-brand span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.sidebar-nav { padding: 12px; flex: 1; overflow-y: auto; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: #cfe9e4;
    font-weight: 500;
    font-size: .92rem;
    margin-bottom: 2px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.sidebar-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-link.active { background: var(--color-gold-500); color: var(--color-teal-950); font-weight: 700; }

.main-content {
    margin-inline-start: 260px;
    flex: 1;
    min-width: 0;
}

.topbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 30;
}

.topbar h2 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.page-body { padding: 24px; max-width: 1400px; }



/* ---------- Cards & stats ---------- */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-card);
    padding: 20px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: var(--shadow-card);
    border-inline-start: 4px solid var(--color-teal-500);
}
.stat-card.gold { border-inline-start-color: var(--color-gold-500); }
.stat-card.terracotta { border-inline-start-color: var(--color-terracotta-600); }
.stat-card.danger { border-inline-start-color: var(--color-danger); }

.stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--color-muted); font-weight: 600; }
.stat-value { font-family: var(--font-heading); font-size: 1.8rem; color: var(--color-ink); margin-top: 4px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: .9rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: filter .15s ease, transform .05s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--color-teal-700); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-gold { background: var(--color-gold-500); color: var(--color-teal-950); }
.btn-gold:hover { filter: brightness(1.05); }
.btn-secondary { background: #fff; border-color: var(--color-border); color: var(--color-body); }
.btn-secondary:hover { background: var(--color-bg); }
.btn-danger { background: #fff; border-color: var(--color-danger); color: var(--color-danger); }
.btn-danger:hover { background: #fdf1f0; }
.btn-sm { padding: 6px 12px; font-size: .82rem; }
.btn-icon { padding: 8px; }

/* ---------- Forms ---------- */
.label { display: block; font-size: .82rem; font-weight: 600; color: var(--color-ink); margin-bottom: 6px; }
.input, select.input, textarea.input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .92rem;
    color: var(--color-ink);
    background: #fff;
}
.input:focus { outline: none; border-color: var(--color-teal-500); box-shadow: 0 0 0 3px var(--color-teal-100); }
.field-error { color: var(--color-danger); font-size: .78rem; margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th {
    text-align: start;
    padding: 10px 14px;
    background: var(--color-bg);
    color: var(--color-muted);
    font-weight: 600;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    border-bottom: 1px solid var(--color-border);
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.data-table tr:hover td { background: #fafbfa; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 700; }
.badge-active, .badge-confirmed, .badge-paid { background: #e6f7ef; color: var(--color-success); }
.badge-inactive, .badge-cancelled { background: #fbeceb; color: var(--color-danger); }
.badge-pending, .badge-partial { background: var(--color-gold-100); color: var(--color-gold-700); }
.badge-completed { background: var(--color-teal-100); color: var(--color-teal-700); }

/* ---------- Modal ---------- */
.modal-backdrop {
    display: none;
    position: fixed; inset: 0; background: rgba(6,44,43,.5);
    z-index: 50; align-items: center; justify-content: center; padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal-box {
    background: #fff; border-radius: var(--radius-lg); max-width: 640px; width: 100%;
    max-height: 90vh; overflow-y: auto; padding: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-close { cursor: pointer; background: none; border: none; font-size: 1.3rem; color: var(--color-muted); }

/* ---------- Toast ---------- */
#toast-container {
    position: fixed; bottom: 20px; inset-inline-end: 20px; z-index: 60;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    background: var(--color-ink); color: #fff; padding: 12px 18px; border-radius: var(--radius-sm);
    font-size: .88rem; box-shadow: 0 8px 24px rgba(0,0,0,.2); min-width: 220px;
    animation: toast-in .2s ease;
}
.toast.error { background: var(--color-danger); }
.toast.success { background: var(--color-success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Utility ---------- */
.flex { display: flex; flex-wrap: wrap; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--color-muted); }
.text-sm { font-size: .85rem; }
.w-full { width: 100%; }

/* Filter-bar inputs (search boxes, status/tour/category selects on list screens):
   full-width on narrow phones so 2-3 of them never force horizontal page
   scroll, fixed width from sm (576px) up where there's actually room. */
.filter-input { width: 100% !important; }
@media (min-width: 576px) {
    .filter-input { width: var(--fw, 200px) !important; }
}

/* Auth pages */
.auth-shell {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at 20% 20%, var(--color-teal-700), var(--color-teal-950));
    padding: 20px;
}
.auth-card { background: #fff; border-radius: var(--radius-lg); padding: 36px; max-width: 400px; width: 100%; box-shadow: 0 30px 80px rgba(0,0,0,.35); }

/* Voice widget (customer portal) */
.voice-fab {
    position: fixed; bottom: 24px; inset-inline-end: 24px; z-index: 45;
    width: 60px; height: 60px; border-radius: 50%;
    background: var(--color-gold-500); color: var(--color-teal-950);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 10px 30px rgba(0,0,0,.3); border: none; cursor: pointer; font-size: 1.4rem;
}
.voice-fab.recording { background: var(--color-terracotta-600); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(181,80,47,.5);} 50% { box-shadow: 0 0 0 16px rgba(181,80,47,0);} }

/* ---------- Customer Portal (public storefront) ---------- */
.portal-header {
    background: linear-gradient(135deg, var(--color-teal-950), var(--color-teal-700));
    color: #eafaf7;
    padding: 20px 24px;
}
.portal-header-inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }
.portal-brand { display: flex; align-items: center; gap: 12px; }
.portal-brand img { height: 44px; width: 44px; border-radius: 10px; object-fit: cover; background: #fff; }
.portal-brand-name { font-family: var(--font-heading); font-size: 1.3rem; font-weight: 700; }

.portal-hero {
    background: linear-gradient(180deg, var(--color-teal-900), var(--color-teal-950));
    color: #eafaf7;
    padding: 40px 24px 60px;
    text-align: center;
}
.portal-hero h1 { color: #fff; font-size: 1.8rem; }
.portal-hero p { color: #cfe9e4; max-width: 560px; margin: 0 auto; }

.portal-body { max-width: 1100px; margin: -32px auto 40px; padding: 0 20px; }

.tour-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.tour-card {
    background: #fff; border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-card);
    display: flex; flex-direction: column; transition: transform .15s ease;
}
.tour-card:hover { transform: translateY(-3px); }
.tour-card-image { height: 180px; background: var(--color-teal-100) center/cover no-repeat; }
.tour-card-body { padding: 18px; flex: 1; display: flex; flex-direction: column; }
.tour-card-title { font-family: var(--font-heading); font-size: 1.15rem; margin-bottom: 4px; }
.tour-card-meta { color: var(--color-muted); font-size: .85rem; margin-bottom: 10px; }
.tour-card-price { margin-top: auto; font-weight: 700; color: var(--color-terracotta-600); font-family: var(--font-heading); font-size: 1.1rem; }

.package-card {
    border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 16px;
    display: flex; flex-direction: column; gap: 8px; background: #fff;
}
.package-card.sold-out { opacity: .55; }

.itinerary-day { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--color-border); }
.itinerary-day-number {
    flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%; background: var(--color-gold-500);
    color: var(--color-teal-950); display: flex; align-items: center; justify-content: center; font-weight: 700;
}

.portal-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.portal-gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }

.voice-panel {
    position: fixed; bottom: 96px; inset-inline-end: 24px; width: 320px; max-width: calc(100vw - 40px);
    background: #fff; border-radius: var(--radius-lg); box-shadow: 0 20px 60px rgba(0,0,0,.3);
    display: none; flex-direction: column; max-height: 420px; z-index: 46; overflow: hidden;
}
.voice-panel.open { display: flex; }
.voice-panel-header { background: var(--color-teal-900); color: #fff; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; }
.voice-panel-body { padding: 14px; overflow-y: auto; flex: 1; }
.voice-msg { margin-bottom: 10px; padding: 8px 12px; border-radius: 10px; font-size: .88rem; max-width: 85%; }
.voice-msg.user { background: var(--color-teal-100); margin-inline-start: auto; }
.voice-msg.assistant { background: var(--color-bg); }

/* ==========================================================================
   Responsive breakpoints (mobile-first)
   xs: <576px (default, no query needed)   sm: >=576px   md: >=768px
   lg: >=992px   xl: >=1200px
   ========================================================================== */

.portal-back-link {
    display: inline-flex; align-items: center; gap: 6px;
    color: #eafaf7; font-weight: 600; font-size: .88rem; margin-bottom: 8px;
}
.portal-back-link:hover { color: var(--color-gold-300); }

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0; background: rgba(6,44,43,.45); z-index: 35;
}
.sidebar-overlay.open { display: block; }

/* --- xs (default) --- */
.page-body { padding: 14px; }
.stat-grid { grid-template-columns: 1fr; }
.form-grid { grid-template-columns: 1fr; }
.data-table { font-size: .82rem; }
.modal-box { padding: 18px; border-radius: var(--radius-md); }
.tour-grid { grid-template-columns: 1fr; }
.portal-hero { padding: 28px 16px 44px; }
.portal-hero h1 { font-size: 1.4rem; }
.voice-panel { width: calc(100vw - 24px); inset-inline-end: 12px; bottom: 84px; }
.voice-fab { width: 52px; height: 52px; bottom: 16px; inset-inline-end: 16px; }
.auth-card { padding: 24px; }

/* --- sm: >=576px --- */
@media (min-width: 576px) {
    .page-body { padding: 20px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: repeat(2, 1fr); }
    .tour-grid { grid-template-columns: repeat(2, 1fr); }
    .auth-card { padding: 32px; }
    #topbar-username { display: inline !important; }
}

/* --- md: >=768px --- */
@media (min-width: 768px) {
    .page-body { padding: 24px; }
    .stat-grid { grid-template-columns: repeat(3, 1fr); }
    .portal-hero h1 { font-size: 1.7rem; }
    .voice-panel { width: 320px; bottom: 96px; inset-inline-end: 24px; }
    .voice-fab { width: 60px; height: 60px; bottom: 24px; inset-inline-end: 24px; }
}

/* --- lg: >=992px (sidebar becomes permanent, not a drawer) --- */
@media (min-width: 992px) {
    .stat-grid { grid-template-columns: repeat(4, 1fr); }
    .form-grid { grid-template-columns: repeat(3, 1fr); }
    .tour-grid { grid-template-columns: repeat(3, 1fr); }
    .sidebar-overlay { display: none !important; }
}

/* --- xl: >=1200px --- */
@media (min-width: 1200px) {
    .tour-grid { grid-template-columns: repeat(4, 1fr); }
    .page-body { padding: 28px 32px; }
}

/* Mobile: sidebar becomes an off-canvas drawer (below lg) */
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    [dir="rtl"] .sidebar { transform: translateX(100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-inline-start: 0; }
    #sidebar-close-btn { display: block !important; }
}

@media (min-width: 992px) {
    #hamburger { display: none; }
}
