/* ============================================
   SA HUNT FINDER — Sleek Slate & Sky Blue
   Aesthetic: Cool grey tones, light blue accents,
   clean modern feel
   ============================================ */

:root {
    /* Grey palette */
    --bg-deep: #0b0f14;
    --bg-primary: #111821;
    --bg-elevated: #1a2230;
    --bg-card: #1e2836;
    --bg-card-hover: #253242;
    --bg-surface: #151d28;

    /* Blue spectrum (replaces gold) */
    --gold: #64b5f6;
    --gold-bright: #90caf9;
    --gold-dim: #4a90c7;
    --gold-muted: #2d5a80;
    --gold-glow: rgba(100, 181, 246, 0.15);

    /* Accent cool tones */
    --sage: #6da89a;
    --rust: #e57373;
    --clay: #7baed4;
    --forest: #1e3a4a;
    --stone: #7e8a96;

    /* Text */
    --text-primary: #e0e6ed;
    --text-secondary: #8a9bb0;
    --text-muted: #556575;
    --text-inverse: #111821;

    /* System */
    --success: #66bb6a;
    --warning: #ffa726;
    --danger: #ef5350;
    --info: #64b5f6;

    /* Spacing */
    --header-height: 280px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Shadows */
    --shadow-card: 0 2px 12px rgba(0,0,0,0.4), 0 1px 3px rgba(0,0,0,0.3);
    --shadow-elevated: 0 8px 32px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
    --shadow-glow: 0 0 20px rgba(200, 169, 110, 0.1);
}

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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    min-height: 100vh;
    min-height: 100dvh;
}

/* Topographic background texture */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(100,181,246,0.03) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(30,58,74,0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(100,181,246,0.02) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Topo lines overlay */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    opacity: 0.015;
    background-image:
        repeating-conic-gradient(from 0deg at 50% 50%, transparent 0deg, rgba(100,181,246,0.5) 0.5deg, transparent 1deg);
    background-size: 120px 120px;
    pointer-events: none;
    z-index: 0;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--gold-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

/* ===== Typography ===== */
h1, h2, h3, h4 {
    font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* ===== Splash Screen ===== */
.splash-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

.splash-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

.splash-content {
    text-align: center;
    animation: splashReveal 0.8s ease-out;
}

@keyframes splashReveal {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.splash-icon {
    width: 120px;
    height: 120px;
    margin: 0 auto 1.5rem;
    animation: splashPulse 2s ease-in-out infinite;
}

@keyframes splashPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
}

.splash-icon svg { width: 100%; height: 100%; }

.splash-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 2rem;
    font-weight: 900;
    color: var(--gold);
    letter-spacing: 0.25em;
    margin-bottom: 0.5rem;
}

.splash-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 300;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: 2rem;
}

.splash-loader {
    width: 200px;
    height: 2px;
    background: var(--bg-card);
    border-radius: 2px;
    margin: 0 auto;
    overflow: hidden;
}

.splash-loader-bar {
    width: 40%;
    height: 100%;
    background: linear-gradient(90deg, var(--gold-dim), var(--gold), var(--gold-dim));
    border-radius: 2px;
    animation: splashLoad 1.2s ease-in-out infinite;
}

@keyframes splashLoad {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

/* ===== Install Banner ===== */
.install-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: linear-gradient(135deg, var(--forest), #152a38);
    border-bottom: 1px solid rgba(100,181,246,0.2);
    padding: 0.75rem 1rem;
    padding-top: calc(0.75rem + var(--safe-top));
    animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

.install-banner-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 600px;
    margin: 0 auto;
    gap: 0.75rem;
}

.install-text {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
}

.install-actions { display: flex; gap: 0.5rem; align-items: center; }

.btn-install {
    background: var(--gold);
    color: var(--text-inverse);
    border: none;
    padding: 0.4rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.05em;
    transition: transform 0.15s;
}

.btn-install:active { transform: scale(0.95); }

.btn-install-dismiss {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
}

/* ===== Header ===== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding-top: var(--safe-top);
}

.header-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg,
        var(--bg-primary) 0%,
        var(--bg-surface) 60%,
        transparent 100%
    );
    z-index: -1;
}

.header-bg::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold-muted), transparent);
}

.header-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem 1.25rem 1.25rem;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

/* Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.brand-icon svg { width: 100%; height: 100%; }

.brand-name {
    font-size: 1.35rem;
    font-weight: 900;
    color: var(--gold);
    letter-spacing: 0.15em;
    line-height: 1.1;
}

.brand-accent {
    color: var(--text-primary);
    font-weight: 700;
}

.brand-tagline {
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    font-weight: 500;
}

/* Notification button */
.btn-icon {
    position: relative;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid rgba(100,181,246,0.15);
    border-radius: 50%;
    color: var(--gold);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover { background: var(--bg-card-hover); border-color: var(--gold-dim); }

.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    background: var(--rust);
    color: white;
    border-radius: 9px;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--bg-primary);
}

/* Hero Stats */
.hero-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1.25rem;
    padding: 0.75rem 0;
}

.stat { text-align: center; }

.stat-number {
    display: block;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--gold);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 500;
}

.stat-divider {
    width: 1px;
    height: 32px;
    background: linear-gradient(180deg, transparent, var(--gold-muted), transparent);
}

/* Season Countdown */
.season-countdown {
    text-align: center;
    margin-bottom: 1rem;
    padding: 0.65rem 1rem;
    background: var(--bg-card);
    border: 1px solid rgba(100,181,246,0.1);
    border-radius: var(--radius-lg);
    animation: fadeIn 0.5s ease;
}

.countdown-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 500;
    margin-bottom: 0.4rem;
}

.countdown-timer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.countdown-segment {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 42px;
}

.countdown-value {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--gold);
    line-height: 1.2;
}

.countdown-unit {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 500;
}

.countdown-sep {
    font-size: 1.2rem;
    color: var(--gold-muted);
    font-weight: 700;
    margin-top: -0.6rem;
}

.season-open {
    border-color: rgba(102, 187, 106, 0.2);
    background: rgba(102, 187, 106, 0.08);
}

.season-open .countdown-label {
    color: var(--success);
    font-weight: 600;
}

.season-open-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--success);
    letter-spacing: 0.12em;
}

.season-open-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    margin-right: 0.4rem;
    animation: pulse-dot 1.5s ease-in-out infinite;
    vertical-align: middle;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

/* Search */
.search-container {
    position: relative;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 14px;
    color: var(--gold-dim);
    pointer-events: none;
    z-index: 1;
}

.search-input {
    width: 100%;
    padding: 0.85rem 2.5rem 0.85rem 2.8rem;
    background: var(--bg-card);
    border: 1px solid rgba(100,181,246,0.12);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 400;
    outline: none;
    transition: all 0.25s;
}

.search-input::placeholder { color: var(--text-muted); font-weight: 300; }

.search-input:focus {
    border-color: var(--gold-dim);
    box-shadow: 0 0 0 3px var(--gold-glow), var(--shadow-glow);
    background: var(--bg-card-hover);
}

.search-clear {
    position: absolute;
    right: 12px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border: none;
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.15s;
}

.search-clear:hover { background: var(--gold-muted); color: var(--text-primary); }

/* ===== Main Content ===== */
.main {
    position: relative;
    z-index: 1;
    max-width: 600px;
    margin: 0 auto;
    padding: 0 0 calc(2rem + var(--safe-bottom));
    min-height: 60vh;
}

/* ===== Province Filter Pills ===== */
.filter-section {
    position: sticky;
    top: 0;
    z-index: 50;
    background: linear-gradient(180deg, var(--bg-deep) 80%, transparent);
    padding: 0.75rem 0 0.5rem;
}

.filter-scroll {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0 1.25rem 0.5rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-snap-type: x proximity;
}

.filter-scroll::-webkit-scrollbar { display: none; }

.filter-pill {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.9rem;
    background: var(--bg-card);
    border: 1px solid rgba(100,181,246,0.1);
    border-radius: 100px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    scroll-snap-align: start;
    flex-shrink: 0;
}

.filter-pill:hover {
    background: var(--bg-card-hover);
    border-color: var(--gold-dim);
    color: var(--text-primary);
}

.filter-pill.active {
    background: linear-gradient(135deg, var(--gold), var(--clay));
    border-color: var(--gold);
    color: var(--text-inverse);
    font-weight: 600;
    box-shadow: 0 2px 12px rgba(100,181,246,0.25);
}

.pill-icon {
    font-size: 1rem;
    line-height: 1;
}

.pill-count {
    font-size: 0.7rem;
    opacity: 0.7;
    font-weight: 400;
}

.filter-pill.active .pill-count {
    opacity: 0.9;
}

/* Province-specific accent colors for pills */
.filter-pill[data-province="Eastern Cape"]:hover,
.filter-pill[data-province="Eastern Cape"].active { --pill-accent: #5b8a72; }
.filter-pill[data-province="Limpopo"]:hover,
.filter-pill[data-province="Limpopo"].active { --pill-accent: #8b6b3e; }

/* ===== View Controls ===== */
.view-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1.25rem 0.75rem;
}

.results-info {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 400;
}

.results-info span {
    color: var(--text-secondary);
    font-weight: 500;
}

.view-toggle {
    display: flex;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 3px;
    border: 1px solid rgba(100,181,246,0.08);
}

.view-btn {
    width: 36px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: calc(var(--radius-md) - 3px);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.view-btn.active {
    background: var(--gold);
    color: var(--text-inverse);
    box-shadow: 0 1px 4px rgba(100,181,246,0.3);
}

.view-btn:not(.active):hover {
    color: var(--text-secondary);
}

/* ===== Map View ===== */
.map-view {
    padding: 0 1.25rem;
    animation: fadeIn 0.3s ease;
}

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

.sa-map-container {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(100,181,246,0.1);
    padding: 1.5rem;
    margin-bottom: 1rem;
    overflow: hidden;
}

.sa-map {
    width: 100%;
    height: auto;
}

.map-province {
    fill: var(--bg-surface);
    stroke: var(--gold-muted);
    stroke-width: 1;
    cursor: pointer;
    transition: all 0.25s;
}

.map-province:hover {
    fill: var(--gold-glow);
    stroke: var(--gold);
    stroke-width: 1.5;
}

.map-province.active {
    fill: rgba(100,181,246,0.2);
    stroke: var(--gold);
    stroke-width: 2;
}

.map-label {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 11px;
    fill: var(--gold);
    text-anchor: middle;
    pointer-events: none;
    font-weight: 600;
}

.map-count {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 9px;
    fill: var(--text-muted);
    text-anchor: middle;
    pointer-events: none;
}

.map-province-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.map-province-card {
    background: var(--bg-card);
    border: 1px solid rgba(100,181,246,0.08);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.map-province-card:hover {
    border-color: var(--gold-dim);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
}

.map-province-card .province-abbr {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--gold);
    line-height: 1.2;
}

.map-province-card .province-name {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
    line-height: 1.2;
}

.map-province-card .province-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.35rem;
    font-weight: 600;
}

/* ===== Farm Cards ===== */
.farm-list {
    padding: 0 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.farm-card {
    background: var(--bg-card);
    border: 1px solid rgba(100,181,246,0.08);
    border-radius: var(--radius-lg);
    padding: 1rem 1.15rem;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    animation: cardSlideIn 0.35s ease-out both;
}

.farm-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--gold), var(--clay));
    opacity: 0;
    transition: opacity 0.25s;
}

.farm-card:hover {
    border-color: rgba(100,181,246,0.2);
    background: var(--bg-card-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-card);
}

.farm-card:hover::before { opacity: 1; }

.farm-card:active {
    transform: translateY(0);
    transition-duration: 0.1s;
}

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

.farm-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.farm-name {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    flex: 1;
}

.farm-province-tag {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--gold);
    background: var(--gold-glow);
    padding: 0.2rem 0.55rem;
    border-radius: 100px;
    white-space: nowrap;
    letter-spacing: 0.04em;
    border: 1px solid rgba(100,181,246,0.15);
    flex-shrink: 0;
}

.farm-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.farm-meta-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.farm-meta-item svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: var(--gold-dim);
}

.farm-meta-item a {
    color: var(--gold);
    text-decoration: none;
    font-weight: 500;
}

.farm-meta-item a:hover { text-decoration: underline; }

/* Quick actions on card */
.farm-quick-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.65rem;
    padding-top: 0.65rem;
    border-top: 1px solid rgba(100,181,246,0.06);
}

.quick-action {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.65rem;
    background: var(--bg-surface);
    border: 1px solid rgba(100,181,246,0.08);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.quick-action:hover {
    background: var(--gold-glow);
    color: var(--gold);
    border-color: var(--gold-dim);
}

.quick-action svg {
    width: 13px;
    height: 13px;
}

/* Stagger animation delays for cards */
.farm-card:nth-child(1) { animation-delay: 0ms; }
.farm-card:nth-child(2) { animation-delay: 30ms; }
.farm-card:nth-child(3) { animation-delay: 60ms; }
.farm-card:nth-child(4) { animation-delay: 90ms; }
.farm-card:nth-child(5) { animation-delay: 120ms; }
.farm-card:nth-child(6) { animation-delay: 150ms; }
.farm-card:nth-child(7) { animation-delay: 180ms; }
.farm-card:nth-child(8) { animation-delay: 210ms; }
.farm-card:nth-child(9) { animation-delay: 240ms; }
.farm-card:nth-child(10) { animation-delay: 270ms; }

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1.25rem;
    animation: fadeIn 0.4s ease;
}

.empty-icon { margin-bottom: 1rem; }

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===== Loading ===== */
.load-sentinel {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.load-sentinel.done { display: none; }

.loading-spinner {
    width: 28px;
    height: 28px;
    border: 2px solid var(--bg-card);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: modalBgIn 0.3s ease;
}

@keyframes modalBgIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-overlay.closing {
    animation: modalBgOut 0.25s ease forwards;
}

@keyframes modalBgOut {
    to { opacity: 0; }
}

.modal-sheet {
    background: var(--bg-elevated);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    animation: modalSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    border: 1px solid rgba(100,181,246,0.1);
    border-bottom: none;
}

.modal-overlay.closing .modal-sheet {
    animation: modalSlideDown 0.25s ease forwards;
}

@keyframes modalSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes modalSlideDown {
    to { transform: translateY(100%); }
}

.modal-handle {
    width: 36px;
    height: 4px;
    background: var(--gold-muted);
    border-radius: 2px;
    margin: 0.75rem auto 0;
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid rgba(100,181,246,0.15);
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.15s;
    z-index: 1;
}

.modal-close:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.modal-header {
    padding: 1.75rem 1.5rem 1.25rem;
    background: linear-gradient(180deg, rgba(100,181,246,0.06), transparent);
    border-bottom: 1px solid rgba(100,181,246,0.06);
}

.modal-province-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gold);
    background: var(--gold-glow);
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
    margin-bottom: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: 1px solid rgba(100,181,246,0.2);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: 0.35rem;
}

.modal-address {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.modal-body {
    padding: 1.25rem 1.5rem 2rem;
    padding-bottom: calc(2rem + var(--safe-bottom));
}

/* Modal Action Buttons */
.modal-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}

.modal-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 0.85rem 0.5rem;
    background: var(--bg-card);
    border: 1px solid rgba(100,181,246,0.1);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}

.modal-action-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--gold-dim);
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

.modal-action-btn svg {
    width: 22px;
    height: 22px;
    color: var(--gold);
}

.modal-action-btn span {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Modal Details */
.modal-details {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.detail-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid rgba(100,181,246,0.06);
}

.detail-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gold-glow);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.detail-icon svg {
    width: 18px;
    height: 18px;
    color: var(--gold);
}

.detail-content {
    flex: 1;
    min-width: 0;
}

.detail-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 500;
    margin-bottom: 0.15rem;
}

.detail-value {
    font-size: 0.9rem;
    color: var(--text-primary);
    word-break: break-word;
}

.detail-value a {
    color: var(--gold);
    text-decoration: none;
}

.detail-value a:hover { text-decoration: underline; }

/* ===== Toast Notifications ===== */
.toast-container {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: calc(100% - 2rem);
    max-width: 400px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.85rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid rgba(100,181,246,0.15);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-elevated);
    animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.toast.removing {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
    to { opacity: 0; transform: translateY(-20px) scale(0.95); }
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.success .toast-icon { color: var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.error .toast-icon { color: var(--danger); }
.toast.info { border-left: 3px solid var(--info); }
.toast.info .toast-icon { color: var(--info); }

/* ===== Utility ===== */
.hidden { display: none !important; }

/* ===== Responsive ===== */
@media (min-width: 640px) {
    .header-content { padding: 1.25rem 2rem 1.5rem; }
    .filter-scroll { padding: 0 2rem 0.5rem; }
    .view-controls { padding: 0.5rem 2rem 0.75rem; }
    .farm-list { padding: 0 2rem; }
    .map-view { padding: 0 2rem; }

    .map-province-list {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 768px) {
    .farm-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.6rem;
    }
}

/* ===== Print ===== */
@media print {
    .header, .filter-section, .view-controls, .modal-overlay,
    .toast-container, .install-banner, .splash-screen { display: none !important; }
    body { background: white; color: black; }
    .farm-card { border: 1px solid #ccc; break-inside: avoid; }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
