/* ==========================================================================
   GLOBAL.CSS - Unified Stylesheet
   Sections: Variables, Reset, Base, Utilities, Layout, Components, Dark Mode
   ========================================================================== */

/* --- 1. VARIABLES & THEME TOKENS ---
   Aligned to the official Design Bible color system. Naming note: the
   Design Bible calls the dark navy "Primary" — this codebase already had
   --brand-navy for that and --primary for the orange accent/CTA color
   (which the Design Bible calls "Accent"). Kept as-is since it's just a
   naming difference, not a value conflict — the actual hex values match. */
:root {
    /* Brand Colors */
    --primary: #FF6B00;        /* Design Bible: Accent */
    --primary-hover: #E05F00;
    --brand-navy: #0F172A;      /* Design Bible: Primary */
    --brand-navy-secondary: #1E293B; /* Design Bible: Secondary */
    --brand-green: #16A34A;

    /* Backgrounds & Surfaces */
    --bg-main: #F8FAFC;
    --card-bg: #ffffff;
    --secondary: #F1F5F9; /* UI hover/utility surface — distinct from brand-navy-secondary above */

    /* Typography Colors */
    --text-main: #0F172A;       /* Design Bible: Text Primary */
    --text-dark: var(--text-main);
    --text-muted: #64748B;      /* Design Bible: Text Secondary */
    --text-faint: #94A3B8;      /* Design Bible: Muted */

    /* Status & Borders */
    --error: #DC2626;           /* Design Bible: Danger */
    --success: #16A34A;
    --warning: #F59E0B;
    --info: #2563EB;
    --border: #E2E8F0;

    /* Layout Variables */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --radius: 12px;             /* Buttons, Inputs */
    --radius-card: 20px;
    --radius-dialog: 24px;
    --radius-image: 20px;
    --radius-hero-image: 32px;
    --max-width: 1440px;

    /* 8px spacing scale — available for new/updated components. Not yet
       retrofitted across every existing hardcoded margin/padding value
       in this codebase; that's a real, separate sweep, not done here. */
    --space-1: 8px;
    --space-2: 16px;
    --space-3: 24px;
    --space-4: 32px;
    --space-5: 40px;
    --space-6: 48px;
    --space-8: 64px;
    --space-10: 80px;
    --space-12: 96px;
}

/* --- 2. RESET & BASE STYLES --- */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
    font-family: 'Sora', 'Segoe UI', Tahoma, sans-serif; 
}

body { 
    background-color: var(--bg-main); 
    color: var(--text-main); 
    line-height: 1.5; 
    min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
h2 { color: var(--text-main); margin-bottom: 1.5rem; }

/* --- 3. UTILITIES --- */
.hidden { display: none !important; }
.message { padding: 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.875rem; text-align: center; }
.message.error { background: #FEE2E2; color: var(--error); border: 1px solid #F87171; }
.message.success { background: #D1FAE5; color: var(--success); border: 1px solid #34D399; }

/* --- 4. BUTTONS & INPUTS --- */
button { 
    cursor: pointer; 
    border: none; 
    font-weight: 500; 
    border-radius: var(--radius); 
    transition: all 0.2s; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
}

/* Buttons and links styled as buttons look the same everywhere. */
.btn-primary, .btn-secondary {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    font-weight: 600; line-height: 1.2; text-align: center;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.1s;
}
.btn-primary:active, .btn-secondary:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: white; padding: 1rem 1.5rem; border-radius: var(--radius); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--card-bg); color: var(--text-main); padding: 0.55rem 1.1rem; border: 1px solid var(--border); border-radius: 999px; min-height: 40px; }
.btn-secondary:hover { background: var(--secondary); border-color: var(--text-faint); }

/* "← Dashboard" link at the top of inner pages. */
.back-link {
    display: inline-flex; align-items: center; gap: 0.4rem; min-height: 40px;
    padding: 0.5rem 1rem; border-radius: 999px; font-weight: 600; font-size: 0.9rem;
    background: var(--card-bg); color: var(--text-main); border: 1px solid var(--border);
    box-shadow: var(--shadow-sm); transition: background 0.2s, border-color 0.2s;
}
.back-link:hover { background: var(--secondary); border-color: var(--text-faint); }

/* Account switcher (accounts.js): name with a chevron, opens a bottom sheet. */
.acct-trigger { display: inline-flex; align-items: center; gap: 0.5rem; margin-top: 0.75rem; padding: 0.3rem 0.8rem 0.3rem 0.3rem; border-radius: 999px; background: rgba(148, 163, 184, 0.16); color: inherit; font-weight: 600; font-size: 0.9rem; width: auto; }
.acct-trigger:hover { background: rgba(148, 163, 184, 0.28); }
#dashboard-container .acct-trigger { background: rgba(255, 255, 255, 0.12); color: #fff; width: auto; padding: 0.3rem 0.8rem 0.3rem 0.3rem; font-size: 0.9rem; }
.acct-avatar { width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--primary); color: #fff; font-weight: 700; object-fit: cover; }
.acct-sheet { margin: auto auto 0; width: min(480px, 100%); max-width: 100%; border: none; border-radius: var(--radius-dialog) var(--radius-dialog) 0 0; padding: 0.75rem 1rem calc(1.25rem + env(safe-area-inset-bottom)); background: var(--card-bg); color: var(--text-main); box-shadow: 0 -10px 40px rgba(15, 23, 42, 0.25); }
.acct-sheet::backdrop { background: rgba(15, 23, 42, 0.5); }
.acct-sheet[open] { animation: acct-up 0.22s ease-out; }
@keyframes acct-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .acct-sheet[open] { animation: none; } }
.acct-sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--border); margin: 0 auto 0.75rem; }
.acct-sheet h3 { text-align: center; font-size: 1rem; margin-bottom: 0.5rem; }
.acct-row { display: flex !important; align-items: center; gap: 0.75rem; width: 100% !important; padding: 0.7rem 0.5rem !important; border-radius: 14px; background: transparent !important; color: var(--text-main) !important; text-align: left; font-weight: 400; }
.acct-row:hover { background: var(--secondary) !important; }
.acct-row-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.acct-row-text strong { font-size: 0.95rem; }
.acct-row-text small { color: var(--text-muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-check { color: var(--primary); font-weight: 800; font-size: 1.1rem; }
.acct-add .acct-avatar { background: var(--secondary); color: var(--text-main); border: 1px solid var(--border); }
#saved-accounts { margin-bottom: 1rem; }
#saved-accounts .acct-row { border: 1px solid var(--border); margin-bottom: 0.5rem; }
.acct-or { text-align: center; color: var(--text-muted); font-size: 0.85rem; margin-top: 0.5rem; }

/* Nothing may push a page wider than the screen. */
html { overflow-x: clip; }
body { overflow-wrap: break-word; }
video, iframe, table, pre { max-width: 100%; }

/* Auth Buttons */
#auth-container button:not(.btn-primary):not(.btn-secondary):not(.btn-link), #dashboard-container button:not(.btn-primary):not(.btn-secondary):not(.btn-link) { 
    background: var(--primary); color: white; padding: 1rem; width: 100%; font-size: 1rem; font-weight: 600; 
}
#auth-container button:hover:not(.btn-primary):not(.btn-secondary):not(.btn-link), #dashboard-container button:hover:not(.btn-primary):not(.btn-secondary):not(.btn-link) { background: var(--primary-hover); }
#auth-container button:disabled { background: var(--border); cursor: not-allowed; }
#dashboard-container button.secondary-btn { background: var(--text-muted); width: auto; padding: 0.5rem 1rem; }
#dashboard-container button.secondary-btn:hover { background: var(--text-main); }

/* Inputs */
input { 
    padding: 1rem; 
    border: 1px solid var(--border); 
    border-radius: var(--radius); 
    font-size: 1rem; 
    outline: none; 
    transition: border-color 0.2s; 
}
input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.15); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent); }

/* --- 5. LAYOUT & CONTAINERS --- */
/* Auth & Dashboard Container Styling */
div.container { 
    background: var(--card-bg); 
    padding: 2.5rem; 
    border-radius: var(--radius); 
    box-shadow: var(--shadow-md); 
    width: 100%; 
}

/* Specific Auth Centering — scoped to body.auth-page (login.html) only,
   so it doesn't affect other pages' layouts. Uses flexbox instead of
   position:absolute + top:50%, because that older approach cut off the
   top of any form taller than the viewport (it centers by pushing half
   the content above y=0, which browsers won't let you scroll up into). */
body.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1rem;
}
#auth-container {
    max-width: 400px;
    width: 100%;
    position: static;
}
#auth-container h2 { text-align: center; }

/* Dashboard Centering */
#dashboard-container { max-width: 800px; margin: 4rem auto; }

/* Homepage Main Layout Container */
main.container { max-width: var(--max-width); margin: 0 auto; padding: 2rem 1.5rem; background: transparent; box-shadow: none; border-radius: 0; }

/* --- 6. AUTH & DASHBOARD COMPONENTS --- */
.input-group { margin-bottom: 1.25rem; display: flex; flex-direction: column; }
.checkbox-group { flex-direction: row; align-items: center; gap: 0.5rem; }
.checkbox-group input { width: auto; }
label { font-size: 0.875rem; font-weight: 500; margin-bottom: 0.5rem; color: var(--text-main); }
.hint { font-size: 0.75rem; margin-top: 0.25rem; color: var(--text-muted); }
.hint.error { color: var(--error); }
.hint.success { color: var(--success); }
.toggle-text { text-align: center; margin-top: 1.5rem; font-size: 0.875rem; color: var(--text-muted); }
.link { color: var(--primary); cursor: pointer; font-weight: 500; }
.link:hover { text-decoration: underline; }

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

/* --- 7. HOMEPAGE COMPONENTS --- */
/* Navbar */
.navbar { position: sticky; top: 0; background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); z-index: 100; padding: 1rem 0; }
.nav-container { max-width: var(--max-width); margin: 0 auto; padding: 0 1.5rem; display: flex; justify-content: space-between; align-items: center; }
.brand { font-size: 1.5rem; font-weight: 800; color: var(--text-main); display: inline-flex; align-items: center; gap: 0.5rem; }
.brand span { color: var(--primary); }
.brand-icon { flex-shrink: 0; }
.nav-links { display: flex; gap: 0.5rem 1.5rem; align-items: center; font-weight: 500; color: var(--text-muted); flex-wrap: wrap; justify-content: flex-end; min-width: 0; /* wraps instead of pushing off-screen, whatever the device width */ }
.nav-container { gap: 1rem; }
.nav-container .brand { flex-shrink: 0; }
.nav-links a:hover { color: var(--text-main); }
.user-badge { background: var(--secondary); color: var(--primary); padding: 0.5rem 1rem; border-radius: 99px; font-weight: 600; font-size: 0.875rem; border: 1px solid var(--border); }

/* Hero */
.hero { background: var(--brand-navy, #0F172A); padding: 5rem 1.5rem; text-align: center; border-bottom: none; }
.hero-content { max-width: 800px; margin: 0 auto; }
.hero h1 { font-size: 2.75rem; font-weight: 800; margin-bottom: 1rem; line-height: 1.2; color: #fff; }
.hero p { font-size: 1.1rem; color: #CBD5E1; margin-bottom: 2.25rem; }
.hero-search { display: flex; max-width: 600px; margin: 0 auto; background: var(--card-bg); padding: 0.5rem; border-radius: 14px; box-shadow: 0 12px 30px -8px rgba(0,0,0,0.5); }
.hero-search input { flex-grow: 1; min-width: 0; /* lets it shrink on small phones instead of pushing Search off-screen */ border: none; font-size: 1rem; padding: 1rem; border-radius: var(--radius); background: transparent; color: var(--text-main); }
.hero-search button { flex-shrink: 0; }
.hero-search input:focus { box-shadow: inset 0 0 0 2px var(--primary); border-color: transparent; }

/* Tag Navigation */
.tag-navigation { margin-bottom: 2rem; position: relative; }
.tag-scroller { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 1rem; scrollbar-width: none; }
.tag-scroller::-webkit-scrollbar { display: none; }
.tag { white-space: nowrap; padding: 0.5rem 1.25rem; border-radius: 99px; border: 1px solid var(--border); font-size: 0.875rem; font-weight: 500; cursor: pointer; transition: all 0.2s; background: var(--card-bg); font-family: inherit; color: var(--text-main); }
.tag.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tag:hover { border-color: var(--text-main); }
/* Toolbar */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.toolbar h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 0; }
.controls { display: flex; gap: 1rem; }

/* Cards (Unified Base) */
.card { background: var(--card-bg); border-radius: var(--radius-card); border: 1px solid var(--border); overflow: hidden; }

/* Dashboard Card Specifics */
#dashboard-container .card { padding: 1.5rem; background: #FAFAFA; }
#dashboard-container .card p { margin-bottom: 0.75rem; }

/* My Listings (dashboard) */
/* flex-wrap added: rows here can now carry 2-4 action buttons
   (inspection confirm/decline/complete/cancel) plus longer description
   text (view counts, verified badges, scheduled-date text) — without
   wrapping, this squishes unreadably on a narrow phone screen instead of
   dropping the button group to its own line. */
.my-listing-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.my-listing-row:last-child { border-bottom: none; }
.section-description { color: var(--text-muted); font-size: 0.9rem; }

/* Listing Card Specifics */
.listings-grid .card, .listings-list .card { transition: transform 0.2s, box-shadow 0.2s; display: flex; flex-direction: column; cursor: pointer; }
.listings-grid .card:hover, .listings-list .card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.card-image-wrapper { position: relative; height: 200px; }
.card-image-wrapper img { width: 100%; height: 100%; object-fit: cover; }
.badge { position: absolute; top: 12px; left: 12px; background: rgba(0,0,0,0.7); color: white; padding: 8px; border-radius: 6px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;}
.badge.badge-example { background: var(--info); top: 48px; }
.badge.badge-verified { background: var(--success, #16A34A); top: 48px; }
.save-btn { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 50%; border: none; background: rgba(255,255,255,0.9); color: var(--error); font-size: 1.1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 2; transition: transform 0.15s; }
.save-btn:hover { transform: scale(1.1); }
.save-btn.saved { background: var(--error); color: white; }
.btn-secondary.save-btn-modal.saved { background: var(--error); color: white; border-color: var(--error); }
.card-content { padding: 1.5rem; flex-grow: 1; display: flex; flex-direction: column;}
.card-price { font-size: 1.25rem; font-weight: 700; color: var(--text-main); margin-bottom: 0.25rem; }
.card-title { font-size: 1rem; font-weight: 500; margin-bottom: 0.5rem; color: var(--text-main); }
.card-location { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 1rem; flex-grow: 1;}
.card-footer { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-muted); border-top: 1px solid var(--border); padding-top: 0.75rem; }

/* Listing cards (property/marketplace grid) styled closer to a
   borderless, photo-first layout — no card box/border, image rounded
   on all 4 corners, text sitting directly below rather than inside a
   bordered footer. Every existing feature (save button, compare
   checkbox, badges, click-to-open) is untouched — this is purely the
   visual treatment. */
.listing-card {
    background: transparent;
    border: none;
    border-radius: 0;
}
.listing-card .card-image-wrapper {
    border-radius: var(--radius-image);
    overflow: hidden;
}
.listing-card .card-content {
    padding: 0.85rem 0.1rem 0;
}
.listing-card .card-footer {
    border-top: none;
    padding-top: 0.35rem;
    color: var(--text-faint);
}

/* Listing Layout Toggles */
.listings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 2rem; }
.listings-list { display: flex; flex-direction: column; gap: 1.5rem; }
.listings-list .card { flex-direction: row; height: 200px; }
.listings-list .card-image-wrapper { width: 300px; height: 100%; flex-shrink: 0; }
.listings-list .card-content { justify-content: center; }

/* --- 8. LOADERS & SKELETONS --- */
.full-screen-loader, #home-auth-loader { position: fixed; inset: 0; background: var(--bg-main); display: flex; justify-content: center; align-items: center; z-index: 9999; transition: opacity 0.3s ease;}
.spinner { width: 24px; height: 24px; border: 3px solid rgba(255,255,255,0.3); border-radius: 50%; border-top-color: #fff; animation: spin 1s linear infinite; }
.full-screen-loader .spinner, #home-auth-loader .spinner { width: 48px; height: 48px; border-color: var(--border); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Skeletons */
.skeleton { pointer-events: none; }
.skeleton .skeleton-img, .skeleton .skeleton-text { border-radius: 4px; background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; }
.skeleton .skeleton-img { width: 100%; height: 100%; border-radius: 0; }
.skeleton .skeleton-text { height: 1rem; margin-bottom: 0.5rem; }
.skeleton .skeleton-title { width: 80%; height: 1.25rem; }
.skeleton .skeleton-price { width: 40%; height: 1.5rem; margin-bottom: 1rem; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* --- 8a-1. STAT CARDS — shared by dashboard.html and wallet.html.
   Previously duplicated locally in each page's own <style> block; only
   dashboard.html's copy had a mobile-size reduction, so wallet.html
   rendered these at full desktop size (1.75rem/800-weight) on a narrow
   phone screen. One definition now, so both pages (and anything else
   that uses this component later) get the same responsive behavior. --- */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--card-bg); border-radius: var(--radius-card); padding: 1.5rem; box-shadow: var(--shadow-md); border: 1px solid var(--border); }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 800; color: var(--text-main); line-height: 1; }
.stat-card .stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.4rem; }
@media (max-width: 600px) {
    .stats-row { gap: 0.75rem; margin-bottom: 1.25rem; }
    .stat-card { padding: 1.1rem; }
    .stat-card .stat-value { font-size: 1.4rem; }
}

/* --- 8a-2. CALENDAR (Src/calendar.js) --- */
.cal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.cal-header strong { color: var(--text-main); }
.cal-nav { background: var(--secondary); border: none; width: 32px; height: 32px; border-radius: 50%; font-size: 1.1rem; cursor: pointer; color: var(--text-main); display: flex; align-items: center; justify-content: center; }
.cal-nav:hover { background: var(--secondary); background: color-mix(in srgb, var(--primary) 15%, var(--secondary)); }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.4rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-day { aspect-ratio: 1; border: none; background: var(--secondary); border-radius: 8px; cursor: pointer; font-size: 0.85rem; color: var(--text-main); font-family: inherit; }
.cal-day:hover:not([disabled]) { background: rgba(255, 107, 0, 0.2); background: color-mix(in srgb, var(--primary) 20%, transparent); }
.cal-day[disabled] { opacity: 0.3; cursor: not-allowed; }
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--primary); }
.cal-day.selected { background: var(--primary); color: #fff; font-weight: 700; }

/* --- 8b. LISTING DETAILS MODAL --- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 1.5rem; }
.modal-box { position: relative; background: var(--card-bg); border-radius: var(--radius-dialog); max-width: 640px; width: 100%; max-height: 85vh; overflow-y: auto; padding: 1.5rem; }
.modal-close { position: absolute; top: 1rem; right: 1rem; background: var(--secondary); color: var(--text-main); border: none; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 1rem; line-height: 1; }
.modal-gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.5rem; margin-bottom: 1rem; }
.modal-gallery-img { width: 100%; height: 140px; object-fit: cover; border-radius: var(--radius-image); }
.modal-price { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.modal-title { margin: 0.5rem 0; color: var(--text-main); }
.modal-description { color: var(--text-main); margin: 1rem 0; line-height: 1.6; white-space: pre-wrap; }

/* --- 9. DARK MODE OVERRIDES --- */
:root.dark-mode {
    --bg-main: #0F172A;
    --card-bg: #1E293B;
    --text-main: #F9FAFB;
    --text-muted: #9CA3AF;
    --text-faint: #64748B;
    --border: #374151;
    --secondary: #374151;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.8);
}

/* Dark Mode Component Fixes */
body, .container, .card, input, .dashboard-header, .hero, .navbar, .tag { transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease; }
:root.dark-mode .hero { background: #1F2937; border-bottom-color: var(--border); }
:root.dark-mode .hero-search { background: var(--bg-main); box-shadow: var(--shadow-md); }
:root.dark-mode .hero-search input { background: transparent; color: var(--text-main); }
:root.dark-mode .navbar { background: rgba(17, 24, 39, 0.95); }
:root.dark-mode .tag { background: var(--card-bg); color: var(--text-main); }
:root.dark-mode .tag:hover { border-color: var(--text-main); }
:root.dark-mode input { background-color: var(--border); color: var(--text-main); }
:root.dark-mode input:focus { background-color: #4B5563; }
:root.dark-mode #dashboard-container .card { background: #1F2937; }
:root.dark-mode .spinner { border-color: rgba(255, 255, 255, 0.1); border-top-color: var(--primary); }

/* Floating Theme Toggle */
.theme-toggle { position: fixed; bottom: 24px; right: 24px; background: #1F2937; border: 1px solid #374151; color: #F9FAFB; width: 48px; height: 48px; border-radius: 50%; cursor: pointer; display: flex; justify-content: center; align-items: center; font-size: 1.25rem; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3); z-index: 1000; transition: transform 0.2s ease, background-color 0.3s ease; }
.theme-toggle:hover { transform: scale(1.1); background: #374151; }
:root:not(.dark-mode) .theme-toggle { background: #FFFFFF; border-color: #D1D5DB; color: #1F2937; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
:root:not(.dark-mode) .theme-toggle:hover { background: #F3F4F6; }

/* --- 10. RESPONSIVE DESIGN --- */
/* Mobile menu button — injected by theme.js into every .navbar, shown
   only below 768px where .nav-links collapses into a dropdown. */
.nav-menu-toggle { display: none; }

/* Up to 1100px, not 768px: signed-in menus have 8+ links, which don't
   fit on tablets and used to stretch the page wider than the screen. */
@media (max-width: 1100px) {
    .nav-links { display: none; }
    .nav-links.nav-links-inline { display: flex; }
    .nav-container { flex-wrap: wrap; }
    .nav-menu-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        width: 44px; height: 44px; /* comfortable touch target */
        border: 1px solid var(--border); border-radius: 12px;
        background: transparent; color: var(--text-main); cursor: pointer;
        transition: background-color 0.2s ease;
    }
    .nav-menu-toggle:hover, .nav-menu-toggle:focus-visible { background: var(--secondary); }
    .nav-menu-toggle svg { pointer-events: none; }
    .navbar.nav-open .nav-links {
        display: flex; flex-direction: column; align-items: stretch;
        width: 100%; gap: 0; padding-top: 0.75rem;
        animation: navDrop 0.18s ease-out;
    }
    .navbar.nav-open .nav-links > a,
    .navbar.nav-open .nav-links > span {
        padding: 0.875rem 0.25rem; border-top: 1px solid var(--border);
        color: var(--text-main); font-size: 1rem;
    }
    .navbar.nav-open .nav-links > button,
    .navbar.nav-open .nav-links .btn-primary {
        width: 100%; margin-top: 0.75rem; padding: 0.875rem; font-size: 1rem;
    }
}

@media (max-width: 768px) {
    .hero h1 { font-size: 2rem; }
    .listings-list .card { flex-direction: column; height: auto; }
    .listings-list .card-image-wrapper { width: 100%; height: 200px; }
}

@keyframes navDrop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .navbar.nav-open .nav-links { animation: none; } }

/* Phone-specific tightening — added after reviewing real device
   screenshots (not guessed): the generic auth/dashboard container
   padding and the dashboard's navy header were noticeably oversized
   relative to a real phone viewport. This is a first pass on the most
   evidenced issues (container spacing, header height, icon
   consistency) — a full page-by-page mobile redesign is a larger,
   ongoing effort, not something one breakpoint block solves. */
@media (max-width: 600px) {
    div.container { padding: 1.5rem; }
    #dashboard-container { margin: 1.5rem auto; }
    #auth-container { padding: 1.75rem 1.5rem; }

    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.15rem; margin-bottom: 1rem; }

    /* Slightly smaller than dashboard.html's base .qa-icon badge (44px,
       color and shape defined there) — this just tightens the size for
       phone width, no separate color definition to avoid two competing
       rules for the same selector. */
    .quick-action .qa-icon {
        width: 40px;
        height: 40px;
        font-size: 1.15rem;
    }

    /* The hero's fixed 5rem top/bottom padding plus a large
       heading/search-bar stack could consume 300-400px of a ~700px
       mobile viewport before any real listing ever appeared. The
       toolbar's search input + 2 buttons crammed into one row also had
       no room to breathe on a narrow screen. */
    .hero { padding: 2rem 1.25rem; }
    .hero h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
    .hero p { font-size: 0.95rem; margin-bottom: 1.25rem; }
    .hero-search { padding: 0.35rem; border-radius: 12px; }
    /* font-size stays at 1rem (16px) even on mobile — anything smaller
       makes iOS Safari auto-zoom the whole page on focus, which is
       exactly the kind of "everything jumps out of proportion" mobile
       bug that's easy to introduce by just shrinking text to fit. */
    .hero-search input { padding: 0.75rem; font-size: 1rem; }

    .toolbar { flex-direction: column; align-items: stretch; gap: 0.75rem; margin-bottom: 1.25rem; }
    .controls { flex-direction: column; gap: 0.6rem; }
    .controls > * { width: 100%; }

    /* One deliberate full-width column with a taller, more prominent
       image — matches how a mobile browsing feed actually reads,
       rather than an accidental single column left over from a
       desktop auto-fill grid hitting its minimum width. */
    .listings-grid { grid-template-columns: 1fr; gap: 1.5rem; }
    .listing-card .card-image-wrapper { height: 240px; }
}
/* ==========================================
   ROOMMATE FINDER
========================================== */

.roommate-card {
    padding: 32px;
}

.roommate-card h3 {
    margin-bottom: 10px;
}

.section-description {
    color: var(--text-muted);
    margin-bottom: 25px;
}

.roommate-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 8px;
    font-weight: 600;
}

.roommate-form input,
.roommate-form select,
.roommate-form textarea {
    width: 100%;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    color: var(--text-main);
    font-size: 15px;
    transition: .25s;
}

.roommate-form textarea {
    resize: vertical;
    min-height: 120px;
}

.roommate-form input:focus,
.roommate-form select:focus,
.roommate-form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.roommate-form button {
    align-self: flex-start;
    margin-top: 10px;
}

.roommate-empty {
    text-align: center;
    padding: 40px 16px;
    color: var(--text-muted);
}

.roommate-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit,minmax(300px,1fr));
    gap: 16px;
}

.roommate-item {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    background: var(--card-bg);
    transition: .25s;
}

.roommate-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.roommate-item h4 {
    margin-bottom: 10px;
}

.roommate-item p {
    margin-bottom: 8px;
}

@media (max-width:768px){

    .roommate-card{
        padding:20px;
    }

    .roommate-form button{
        width:100%;
    }

}
/* --- Toasts (toast.js): short messages that pop up and go --- */
#toast-stack { position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 0.5rem; width: min(440px, calc(100vw - 2rem)); pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.85rem 0.85rem 0.85rem 1rem; border-radius: 14px; background: #0F172A; color: #F8FAFC; box-shadow: 0 10px 30px -8px rgba(0,0,0,0.45); font-size: 0.92rem; line-height: 1.4; pointer-events: auto; opacity: 0; transform: translateY(10px); transition: opacity 0.2s ease, transform 0.2s ease; }
.toast.toast-in { opacity: 1; transform: none; }
.toast span { flex: 1; }
.toast-success { border-left: 4px solid var(--success, #16A34A); }
.toast-error { border-left: 4px solid var(--error, #DC2626); }
.toast-info { border-left: 4px solid var(--primary); }
.toast .toast-close { background: none; border: 0; color: inherit; opacity: 0.7; cursor: pointer; font-size: 0.9rem; padding: 0.15rem 0.35rem; line-height: 1; width: auto; }
.toast .toast-close:hover { opacity: 1; }
:root.dark-mode .toast { background: #F8FAFC; color: #0F172A; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* Phones: two cards per row for houses, items, services, rooms and
   profiles, like a shop feed, instead of one long column. Very narrow
   phones (under 340px) keep one column so text stays readable. */
@media (max-width: 600px) {
    body .listings-grid, body .rm-card-grid, body .directory-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
    .listings-grid .listing-card .card-image-wrapper { height: 130px; }
    .listings-grid .card-content { padding: 0.7rem 0.75rem; }
    .listings-grid .card-price { font-size: 0.95rem; }
    .listings-grid .card-title { font-size: 0.85rem; margin-bottom: 0.25rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    .listings-grid .card-location { font-size: 0.75rem; margin-bottom: 0.4rem; }
    .listings-grid .card-footer { font-size: 0.7rem; flex-wrap: wrap; gap: 0.25rem; }
    body .rm-card-grid > *, body .directory-grid > * { padding: 0.85rem; }
}
@media (max-width: 340px) {
    body .listings-grid, body .rm-card-grid, body .directory-grid { grid-template-columns: 1fr; }
}

/* Property pop-up: action buttons in one even row, wrapping on phones. */
.modal-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.modal-actions > * { flex: 1 1 160px; padding: 0.85rem 1rem; border-radius: var(--radius); min-height: 48px; }
.before-you-pay { margin-top: 1rem; padding: 0.85rem 1rem; border-radius: var(--radius); background: color-mix(in srgb, var(--warning) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent); text-align: left; }
.before-you-pay strong { display: block; margin-bottom: 0.25rem; }
.before-you-pay p { font-size: 0.85rem; color: var(--text-main); }
