/* 
    SAFARI | Foundation v1.0 
    Clean, Modern, Store-Quality Design.
*/

:root {
    --bg-dark: #121212;
    --bg-surface: #1E1E1E;
    --bg-elevated: #2C2C2C;
    --accent: #8A9A5B; /* Safari Sage */
    --text-primary: #FFFFFF;
    --text-soft: rgba(255, 255, 255, 0.6);
    --border: rgba(255, 255, 255, 0.08);
    --nav-height: 80px;
    --card-bg: rgba(255,255,255,0.03);
}

/* Master Button Styles */
.btn-primary, .btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    border: none;
    font-family: 'Inter', sans-serif;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: #a9ba7d;
    transform: translateY(-2px);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.05);
    border-color: var(--accent);
}

.ds-nav-action {
    color: var(--accent) !important;
    border: 1px solid rgba(138, 154, 91, 0.3) !important;
    background: rgba(138, 154, 91, 0.05) !important;
}

.ds-nav-action:hover {
    background: rgba(138, 154, 91, 0.15) !important;
    border-color: var(--accent) !important;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    overflow: hidden; /* Prevent body scroll, let views handle it */
    height: 100vh;
}

h1, h2, h3 { font-family: 'Outfit', sans-serif; }

/* Viewport Logic */
#app-viewport {
    height: calc(100vh - var(--nav-height));
    width: 100%;
    position: relative;
    overflow-y: auto;
    padding-bottom: 40px;
}

.page-view {
    display: none;
    min-height: 100%;
    padding: 30px 20px;
    animation: fadeIn 0.3s ease-out;
}

.page-view.active {
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* View Headers & Greeting */
.view-header { margin-bottom: 30px; }
.greeting-pre { font-size: 14px; font-weight: 600; color: var(--text-soft); }
.greeting-name { font-size: 36px; font-weight: 900; color: var(--text-primary); margin-top: -4px; }

/* Dashboard Stats */
.stats-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 40px;
}

.stat-box {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 24px 20px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
}

.stat-label { font-size: 10px; font-weight: 800; color: var(--text-soft); text-transform: uppercase; letter-spacing: 1px; }
.stat-value { font-size: 28px; font-weight: 900; color: var(--accent); margin-top: 4px; }

/* Section Headers */
.view-section { margin-bottom: 32px; }
.section-title { font-size: 18px; font-weight: 800; margin-bottom: 16px; color: var(--text-primary); }

/* Guide Tiles */
.guide-tiles { display: grid; gap: 16px; }

.guide-tile {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 20px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    cursor: pointer;
    transition: 0.3s;
}

.guide-tile:hover {
    transform: translateY(-4px);
    background: rgba(255,255,255,0.05);
    border-color: var(--accent);
}

.tile-icon {
    width: 60px; height: 60px;
    background: rgba(138, 154, 91, 0.1);
    color: var(--accent);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tile-icon i { width: 28px; height: 28px; }

.tile-info h3 { font-size: 18px; margin-bottom: 2px; }
.tile-info p { font-size: 12px; color: var(--text-soft); }

.recent-list-placeholder {
    padding: 40px;
    background: rgba(255,255,255,0.02);
    border: 1px dashed var(--border);
    border-radius: 20px;
    text-align: center;
    font-size: 13px;
    color: var(--text-soft);
}

/* Bottom Navigation Bar (Store Style) */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--bg-surface);
    border-top: 1px solid rgba(255,255,255,0.05);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 1000;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--text-soft);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: 0.2s;
    flex: 1;
}

.nav-btn i { width: 22px; height: 22px; }
.nav-btn span { font-size: 10px; font-weight: 600; }

.nav-btn.active {
    color: var(--accent);
}

.nav-btn.admin-link {
    color: #FFB74D; /* Distinct Admin Color */
}


/* === ONBOARDING GATEKEEPER v1.0 === */
.onboarding-overlay {
    position: fixed; inset: 0; background: #000; z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.8s cubic-bezier(0.19, 1, 0.22, 1), opacity 0.5s;
}

.onboarding-overlay.hidden {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

.onboarding-content { width: 100%; max-width: 500px; padding: 40px 24px; text-align: center; }

.onboarding-header h1 { font-size: 32px; margin-bottom: 12px; }
.onboarding-header p { font-size: 14px; color: var(--text-soft); line-height: 1.6; margin-bottom: 40px; }

.expedition-grid { display: flex; flex-direction: column; gap: 20px; }

.expedition-card {
    position: relative; height: 200px; border-radius: 24px; overflow: hidden;
    display: flex; align-items: flex-end; padding: 24px; cursor: pointer;
    transition: 0.3s; border: 1px solid rgba(255,255,255,0.1);
    background: #1a1a1a;
}

.expedition-card.active {
    background-image: url('https://images.unsplash.com/photo-1516426122078-c23e76319801?auto=format&fit=crop&q=80&w=800');
    background-size: cover; background-position: center;
}

.card-bg-overlay { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.9), transparent); }

.card-details { position: relative; z-index: 2; text-align: left; width: 100%; }
.card-tag { font-size: 10px; font-weight: 800; text-transform: uppercase; color: var(--accent); letter-spacing: 1px; }
.card-details h2 { font-size: 20px; margin: 4px 0 12px; }

.btn-select {
    background: var(--accent); color: white; border: none; padding: 8px 16px;
    border-radius: 50px; font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 8px;
}

.expedition-card.locked { opacity: 0.4; cursor: not-allowed; border-style: dashed; }


/* === TOAST NOTIFICATIONS === */
#toast-container {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    pointer-events: none;
}

.toast {
    background: #2C2C2C;
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    padding: 14px 20px;
    border-radius: 16px;
    font-size: 13px;
    min-width: 240px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    backdrop-filter: blur(12px);
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.toast strong { display: block; margin-bottom: 2px; font-size: 14px; }
.toast p { opacity: 0.7; margin: 0; }

.toast-success { border-left: 4px solid #8A9A5B; }
.toast-error { border-left: 4px solid #E57373; }
.toast-info { border-left: 4px solid #64B5F6; }

/* === EMPTY PLACEHOLDERS (Other pages) === */
.empty-placeholder {
    margin-top: 120px;
    text-align: center;
    color: var(--text-soft);
}

.empty-placeholder h1 {
    font-size: 28px;
    color: var(--accent);
    margin-bottom: 8px;
    font-family: 'Outfit', sans-serif;
}

.empty-placeholder p { font-size: 14px; }

/* ============================================================
   DESKTOP LAYOUT SYSTEM
   ============================================================ */

/* On desktop, the bottom nav hides and the sidebar appears */
@media (min-width: 900px) {
    .bottom-nav { display: none; }
    .mobile-only { display: none !important; }

    .desktop-layout {
        display: flex;
        height: 100vh;
        overflow: hidden;
    }

    /* Desktop Sidebar */
    .desktop-sidebar {
        width: 260px;
        min-width: 260px;
        background: var(--bg-surface);
        border-right: 1px solid var(--border);
        display: flex;
        flex-direction: column;
        padding: 32px 20px;
        gap: 32px;
    }

    .ds-brand {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 0 8px;
    }

    .ds-logo { font-size: 32px; }
    .ds-brand h2 { font-size: 20px; font-weight: 900; font-family: 'Outfit', sans-serif; }
    .ds-brand p { font-size: 11px; color: var(--accent); font-weight: 600; }

    .ds-nav {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .ds-nav-btn {
        background: none;
        border: none;
        color: var(--text-soft);
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 12px 16px;
        border-radius: 12px;
        cursor: pointer;
        font-size: 14px;
        font-weight: 600;
        font-family: 'Inter', sans-serif;
        transition: 0.2s;
        width: 100%;
        text-align: left;
    }

    .ds-nav-btn i { width: 18px; height: 18px; }

    .ds-nav-btn:hover {
        background: rgba(255,255,255,0.04);
        color: var(--text-primary);
    }

    .ds-nav-btn.active {
        background: rgba(138, 154, 91, 0.12);
        color: var(--accent);
    }

    .ds-nav-btn.admin-link { color: #FFB74D; }

    #app-viewport {
        flex: 1;
        overflow-y: auto;
        height: 100vh;
        padding: 0;
    }

    .page-view {
        padding: 36px 40px;
        min-height: 100%;
    }
}

/* On mobile: no desktop sidebar */
@media (max-width: 899px) {
    .desktop-sidebar { display: none; }
    .desktop-layout { display: block; }
}

/* ============================================================
   DASHBOARD HOME: 2-COLUMN LAYOUT (Map + Feed)
   ============================================================ */

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    height: calc(100vh - 120px);
}

@media (max-width: 899px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        height: auto;
    }
}

.dashboard-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.panel-header h2 { font-size: 16px; font-weight: 700; }

.live-badge {
    font-size: 10px;
    font-weight: 800;
    color: #81C784;
    animation: pulse-live 2s infinite;
}

@keyframes pulse-live {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.time-badge {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-soft);
    background: rgba(255,255,255,0.05);
    padding: 4px 10px;
    border-radius: 50px;
}

/* Map Container */
#kruger-map {
    flex: 1;
    min-height: 400px;
    z-index: 1;
}

/* Fix Leaflet z-index conflicts */
.leaflet-pane { z-index: 1 !important; }
.leaflet-top, .leaflet-bottom { z-index: 2 !important; }

/* Feed Panel */
.feed-panel { overflow-y: auto; }

.feed-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px;
    color: var(--text-soft);
    text-align: center;
}

.feed-empty i { width: 40px; height: 40px; opacity: 0.3; }
.feed-empty p { font-size: 14px; }
.feed-empty small { font-size: 12px; opacity: 0.6; }

/* ============================================================
   BIRD GUIDE PAGE
   ============================================================ */

.guide-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    gap: 20px;
    flex-wrap: wrap;
}

.guide-page-title {
    font-size: 26px;
    font-weight: 900;
    font-family: 'Outfit', sans-serif;
}

.guide-page-sub {
    font-size: 12px;
    color: var(--text-soft);
    margin-top: 2px;
}

.guide-search-bar {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
}

.guide-search-bar i { width: 16px; height: 16px; opacity: 0.5; flex-shrink: 0; }

.guide-search-bar input {
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    width: 100%;
    outline: none;
}

.guide-search-bar input::placeholder { color: var(--text-soft); }

/* THE GRID � 4 columns, explicit, no auto-fill */
.species-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

@media (max-width: 1100px) { .species-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 860px)  { .species-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 540px)  { .species-grid { grid-template-columns: 1fr; } }

/* Bird Card */
.bird-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.25s, border-color 0.25s;
    display: flex;
    flex-direction: column;
}

.bird-card:hover {
    transform: translateY(-6px);
    border-color: var(--accent);
}

.bird-card-img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    background: var(--bg-elevated);
    display: block;
}

.bird-card-body {
    padding: 14px 16px;
}

.bird-card-roberts {
    font-size: 10px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.bird-card-name {
    font-size: 15px;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    margin-bottom: 2px;
}

.bird-card-sci {
    font-size: 11px;
    font-style: italic;
    color: var(--text-soft);
}


/* ============================================================
   BIRD DETAIL DRAWER
   ============================================================ */

/* Backdrop overlay */
.bird-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
}

.bird-overlay.active { display: block; }

/* Modal - centered on screen */
.bird-drawer {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 90%;
    max-width: 580px;
    max-height: 85vh;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    z-index: 2001;
    transform: translate(-50%, -50%) scale(0.92);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.19, 1, 0.22, 1), opacity 0.3s;
    overflow: hidden;
    pointer-events: none;
}

.bird-drawer.active {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.bird-drawer-inner {
    height: 100%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
}

/* Close Button */
.drawer-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: 0.2s;
}

.drawer-close-btn:hover { background: rgba(255,255,255,0.1); }
.drawer-close-btn i { width: 16px; height: 16px; }

/* Drawer Content Layout */
.drawer-hero-img {
    width: 100%;
    height: 280px;
    object-fit: cover;
    display: block;
}

.drawer-body {
    padding: 24px;
}

.drawer-roberts {
    font-size: 11px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.drawer-name {
    font-size: 26px;
    font-weight: 900;
    font-family: 'Outfit', sans-serif;
    margin-bottom: 4px;
}

.drawer-sci {
    font-size: 14px;
    font-style: italic;
    color: var(--text-soft);
    margin-bottom: 24px;
}

.drawer-divider {
    height: 1px;
    background: var(--border);
    margin: 20px 0;
}

.drawer-section-title {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-soft);
    margin-bottom: 10px;
}

.drawer-description {
    font-size: 14px;
    line-height: 1.7;
    color: rgba(255,255,255,0.8);
}

.drawer-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.drawer-tag {
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 700;
    background: rgba(138, 154, 91, 0.15);
    color: var(--accent);
    border: 1px solid rgba(138, 154, 91, 0.3);
}

/* Modal is centered on all screen sizes */



.habitat-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px 2px 6px !important; /* Tighten up for icons */
}

.habitat-tag img {
    width: 14px;
    height: 14px;
    object-fit: contain;
    flex-shrink: 0;
}


.con-icon { width: 14px; height: 14px; }
.con-least_concern { color: #81C784; }
.con-near_threatened { color: #FFF176; }
.con-vulnerable { color: #FFB74D; }
.con-endangered { color: #E57373; }
.con-critically_endangered { color: #D32F2F; }
.con-extinct { color: #9E9E9E; }


.rarity-icon {
    width: 14px;
    height: 14px;
    color: #FFD54F; /* Safari Gold */
}


/* ============================================================
   ADMIN PORTAL & FORMS
   ============================================================ */

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
    padding-bottom: 60px;
}

.admin-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 30px;
}

.admin-card-title {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 4px;
}

.admin-card-sub {
    font-size: 13px;
    color: var(--text-soft);
    margin-bottom: 24px;
}

.admin-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

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

.form-group label {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-soft);
}

.form-group input, 
.form-group select, 
.form-group textarea {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus, 
.form-group select:focus, 
.form-group textarea:focus {
    border-color: var(--accent);
}

@media (max-width: 600px) {
    .form-row { grid-template-columns: 1fr; }
}

/* ADMIN LOGIN GATE */
.admin-login-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 50px;
    min-height: 400px;
}

.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 40px;
    max-width: 450px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.login-header i {
    width: 48px;
    height: 48px;
    color: var(--accent);
    margin-bottom: 20px;
}

.login-header h2 {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 12px;
}

.login-header p {
    color: var(--text-soft);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 30px;
}

/* DOSSIER MODAL EDITOR */
.admin-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(10px);
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.admin-modal-overlay.active { display: flex; }

.admin-modal-container {
    background: var(--bg-surface);
    width: 100%;
    max-width: 1000px;
    height: 90vh;
    border-radius: 30px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 30px 60px rgba(0,0,0,0.5);
}

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

.modal-header h2 { font-size: 24px; font-weight: 800; }

.modal-close {
    background: var(--bg-elevated);
    border: none;
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
}

.modal-body-layout {
    flex: 1;
    display: grid;
    grid-template-columns: 380px 1fr;
    overflow: hidden;
}

.modal-preview-pane {
    background: #000;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-right: 1px solid var(--border);
}

.preview-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--accent);
    letter-spacing: 2px;
    margin-bottom: 30px;
}

.modal-form-pane {
    padding: 40px;
    overflow-y: auto;
}

@media (max-width: 900px) {
    .modal-body-layout { grid-template-columns: 1fr; }
    .modal-preview-pane { display: none; }
}
