:root {
    --bg-dark: #0d0d1a;
    --bg-card: #1a1a2e;
    --bg-card-hover: #22223a;
    --bg-sidebar: #141428;
    --orange: #ff6b35;
    --orange-light: #ff8c5a;
    --orange-dark: #e55a2b;
    --purple: #7c3aed;
    --purple-light: #a78bfa;
    --green: #22c55e;
    --green-dark: #16a34a;
    --red: #ef4444;
    --yellow: #eab308;
    --text: #f1f1f1;
    --text-muted: #9ca3af;
    --text-dark: #6b7280;
    --border: #2d2d44;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Nosifer', cursive;
    --transition: 0.2s ease;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg-dark);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--orange); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--orange-light); }

img { max-width: 100%; height: auto; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; width: 100%; }

/* ===== NAVBAR ===== */
.navbar {
    background: rgba(13,13,26,0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 0;
}
.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}
.nav-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--orange);
    letter-spacing: 1px;
}
.nav-logo:hover { color: var(--orange-light); }
.logo-icon { font-size: 1.8rem; }
.nav-menu { display: flex; align-items: center; gap: 0.25rem; }
.nav-link {
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all var(--transition);
}
.nav-link:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.btn-nav {
    background: var(--orange);
    color: #fff !important;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-sm);
}
.btn-nav:hover { background: var(--orange-dark); }
.nav-user { display: flex; align-items: center; gap: 0.5rem; margin-left: 0.5rem; }
.nav-user-name { color: var(--text-muted); font-size: 0.85rem; }
.nav-logout { color: var(--red) !important; font-size: 0.85rem; }
.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}
.nav-toggle span {
    width: 24px; height: 2px;
    background: var(--text);
    transition: var(--transition);
}

/* ===== FLASH MESSAGES ===== */
.flash {
    padding: 0.75rem 0;
    font-weight: 500;
    font-size: 0.9rem;
}
.flash-success { background: rgba(34,197,94,0.15); color: var(--green); border-bottom: 1px solid rgba(34,197,94,0.3); }
.flash-error { background: rgba(239,68,68,0.15); color: var(--red); border-bottom: 1px solid rgba(239,68,68,0.3); }
.flash-info { background: rgba(124,58,237,0.15); color: var(--purple-light); border-bottom: 1px solid rgba(124,58,237,0.3); }

/* ===== MAIN / LAYOUT ===== */
main { flex: 1; padding: 2rem 0; }
body.full-width main { padding: 0; }

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: all var(--transition);
}
.card:hover { border-color: rgba(255,107,53,0.3); }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.card-title { font-size: 1.25rem; font-weight: 700; }

/* ===== HERO ===== */
.hero {
    text-align: center;
    padding: 3rem 1.5rem 2rem;
    background: linear-gradient(180deg, rgba(255,107,53,0.08) 0%, transparent 100%);
}
.hero h1 {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 3.5rem);
    color: var(--orange);
    margin-bottom: 0.75rem;
    letter-spacing: 2px;
}
.hero p {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

/* ===== HOME HERO (compact) ===== */
.home-hero {
    text-align: center;
    padding: 0.75rem 1rem;
    background: linear-gradient(180deg, rgba(255,107,53,0.1) 0%, transparent 100%);
}
.home-hero h1 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--orange);
    margin-bottom: 0.2rem;
    letter-spacing: 1px;
}
.home-hero p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

/* ===== SEARCH BAR ===== */
.search-bar {
    display: flex;
    max-width: 480px;
    margin: 0.4rem auto 0;
    position: relative;
}
.search-input {
    flex: 1;
    padding: 0.5rem 0.85rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    color: var(--text);
    font-size: 0.9rem;
    font-family: var(--font);
    outline: none;
    transition: border-color var(--transition);
}
.search-input:focus { border-color: var(--orange); }
.search-input::placeholder { color: var(--text-dark); }
.search-btn {
    padding: 0.5rem 0.85rem;
    background: var(--orange);
    border: 1px solid var(--orange);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    transition: background var(--transition);
    line-height: 1;
}
.search-btn:hover { background: var(--orange-dark); }
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 220px;
    overflow-y: auto;
    z-index: 600;
    display: none;
}
.search-results.show { display: block; }
.search-result-item {
    padding: 0.5rem 0.85rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: rgba(255,107,53,0.1); color: var(--text); }
.search-result-item strong { color: var(--orange); }

/* ===== MAP ===== */
.map-wrapper { position: relative; }
#map {
    width: 100%;
    height: calc(100vh - 64px - 62px);
    min-height: 300px;
    z-index: 1;
}

body.full-width .site-footer { display: none; }
body.full-width { overflow: hidden; }
.map-overlay {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 500;
    background: rgba(13,13,26,0.9);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    min-width: 220px;
}
.map-overlay h3 { font-size: 0.9rem; margin-bottom: 0.5rem; color: var(--orange); }
.map-overlay label { font-size: 0.85rem; color: var(--text-muted); display: block; margin-bottom: 0.25rem; }
.map-overlay input, .map-overlay select {
    width: 100%;
    padding: 0.4rem 0.5rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.85rem;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    font-family: var(--font);
    line-height: 1.4;
}
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); color: #fff; }
.btn-secondary { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--orange); color: var(--orange); }
.btn-success { background: var(--green-dark); color: #fff; }
.btn-success:hover { background: var(--green); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.95rem;
    font-family: var(--font);
    transition: border-color var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(255,107,53,0.15);
}
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-hint { font-size: 0.8rem; color: var(--text-dark); margin-top: 0.25rem; }
.form-error { color: var(--red); font-size: 0.85rem; margin-bottom: 1rem; font-weight: 500; }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; margin: -0.5rem; padding: 0.5rem; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
tr:hover td { background: rgba(255,255,255,0.02); }
.table-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.badge-success { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-warning { background: rgba(234,179,8,0.15); color: var(--yellow); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-secondary { background: rgba(156,163,175,0.15); color: var(--text-muted); }

/* ===== STAT CARDS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
}
.stat-card .stat-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--orange); }
.stat-card .stat-label { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ===== ADMIN LAYOUT ===== */
.admin-layout { display: flex; min-height: calc(100vh - 64px); }
.admin-sidebar {
    width: 250px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    flex-shrink: 0;
}
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 1.25rem 1.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
    font-weight: 700;
    font-size: 1.1rem;
}
.sidebar-icon { font-size: 1.5rem; }
.sidebar-nav { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.5rem 0.75rem; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
}
.sidebar-link:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.sidebar-link.active { background: rgba(255,107,53,0.12); color: var(--orange); }
.sidebar-divider { border: none; border-top: 1px solid var(--border); margin: 0.75rem 0; }
.admin-content { flex: 1; padding: 2rem; overflow-x: hidden; }

/* ===== AUTH PAGES ===== */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 64px - 80px);
    padding: 2rem;
}
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
}
.auth-card h2 {
    text-align: center;
    font-family: var(--font-display);
    color: var(--orange);
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    letter-spacing: 1px;
}
.auth-card .auth-sub {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 1.75rem;
    font-size: 0.9rem;
}
.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ===== POPUP (Leaflet) ===== */
.leaflet-popup-content-wrapper {
    background: var(--bg-card) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow) !important;
}
.leaflet-popup-tip { background: var(--bg-card) !important; }
.leaflet-popup-content { font-family: var(--font); font-size: 0.9rem; line-height: 1.5; }
.leaflet-popup-content h3 { color: var(--orange); margin-bottom: 0.5rem; font-size: 1.05rem; }
.leaflet-popup-content .popup-meta { color: var(--text-muted); font-size: 0.8rem; margin-bottom: 0.25rem; }
.leaflet-popup-content .popup-img { border-radius: var(--radius-sm); margin-top: 0.5rem; max-height: 120px; object-fit: cover; width: 100%; }
.leaflet-popup-close-button { color: var(--text-muted) !important; }

/* ===== FOOTER ===== */
.site-footer {
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    padding: 1.5rem 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: auto;
}

/* ===== CLUSTER MARKERS ===== */
.cluster-icon { background: none !important; border: none !important; }
.cluster-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    font-family: var(--font);
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    cursor: pointer;
    transition: transform 0.15s;
}
.cluster-circle:hover { transform: scale(1.15); }
.cluster-small {
    width: 36px; height: 36px; font-size: 0.85rem;
    background: var(--orange);
    border: 3px solid rgba(255,255,255,0.3);
}
.cluster-medium {
    width: 44px; height: 44px; font-size: 1rem;
    background: var(--orange-dark);
    border: 3px solid rgba(255,255,255,0.3);
}
.cluster-large {
    width: 52px; height: 52px; font-size: 1.15rem;
    background: #c0392b;
    border: 4px solid rgba(255,255,255,0.3);
}

/* ===== ADMIN MAP ===== */
#admin-map { width: 100%; height: 450px; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 1rem; }

/* ===== APPLY FORM ===== */
.apply-wrapper { max-width: 800px; margin: 0 auto; }
.apply-intro { text-align: center; margin-bottom: 2rem; }
.apply-intro h2 { font-family: var(--font-display); color: var(--orange); font-size: 2rem; letter-spacing: 1px; margin-bottom: 0.5rem; }

/* ===== DRAW HELP ===== */
.draw-help {
    background: rgba(255,107,53,0.06);
    border: 1px solid rgba(255,107,53,0.2);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
}
.draw-help-steps { display: flex; flex-direction: column; gap: 0.6rem; }
.draw-help-step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.4;
}
.draw-help-step strong { color: var(--text); }
.draw-help-num {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--orange);
    color: #fff;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
}
.draw-help-icon {
    display: inline-block;
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0 0.3rem;
    font-size: 0.85rem;
    vertical-align: middle;
}

/* ===== PAGINATION ===== */
.pagination { display: flex; gap: 0.25rem; justify-content: center; margin-top: 1.5rem; }
.pagination a, .pagination span {
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.pagination a:hover { border-color: var(--orange); color: var(--orange); }
.pagination .active { background: var(--orange); color: #fff; border-color: var(--orange); }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { color: var(--text); margin-bottom: 0.5rem; }

/* ===== CONFIRM MODAL ===== */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}
.modal-backdrop.show { display: flex; }
.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
}
.modal-box h3 { margin-bottom: 1rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: center; margin-top: 1.5rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .nav-toggle { display: flex; }
    .nav-menu {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: rgba(13,13,26,0.98);
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        padding: 1rem;
        gap: 0.25rem;
    }
    .nav-menu.active { display: flex; }
    .nav-user { flex-direction: column; align-items: flex-start; margin-left: 0; }

    .admin-layout { flex-direction: column; }
    .admin-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 1rem 0;
    }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; gap: 0.25rem; }
    .admin-content { padding: 1rem; }

    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    #map { height: calc(100vh - 64px - 54px); }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .table-wrap { font-size: 0.8rem; }
    th, td { padding: 0.5rem; }
}
