/* ============================================
   Campground Lead Dashboard — Design System
   Dark Glassmorphism Theme
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ===== CSS Variables ===== */
:root {
    --bg-primary: #0f0f23;
    --bg-secondary: #1a1a3e;
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-card-hover: rgba(255, 255, 255, 0.08);
    --border-glass: rgba(255, 255, 255, 0.1);
    --text-primary: #e8e8f0;
    --text-secondary: #a0a0c0;
    --text-muted: #6b6b8d;
    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --hot-color: #ef4444;
    --warm-color: #f59e0b;
    --cold-color: #3b82f6;
    --success-color: #10b981;
    --error-color: #ef4444;
    --sidebar-width: 400px;
    --header-height: 60px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.3);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
    width: 100%;
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ===== Animated Background ===== */
.animated-bg {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--bg-primary);
    overflow: hidden;
    z-index: 0;
}

.animated-bg::before,
.animated-bg::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: float 15s ease-in-out infinite;
}

.animated-bg::before {
    width: 500px; height: 500px;
    background: var(--accent-primary);
    top: -100px; left: -100px;
}

.animated-bg::after {
    width: 400px; height: 400px;
    background: var(--accent-secondary);
    bottom: -80px; right: -80px;
    animation-delay: -7s;
    animation-direction: reverse;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(50px, -50px) scale(1.1); }
    66% { transform: translate(-30px, 30px) scale(0.95); }
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    box-shadow: var(--shadow-glass);
    animation: slideUp 0.6s ease-out;
}

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

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .icon {
    font-size: 48px;
    margin-bottom: 12px;
    display: block;
}

.login-logo h1 {
    font-size: 22px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.login-logo p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 6px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

.form-group input:focus {
    border-color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.3px;
    margin-top: 8px;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.login-error {
    display: none;
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: var(--error-color);
    font-size: 13px;
    margin-bottom: 16px;
    animation: shake 0.4s ease;
}

.login-error.show {
    display: block;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    50% { transform: translateX(8px); }
    75% { transform: translateX(-4px); }
}

/* ============================================
   DASHBOARD PAGE
   ============================================ */

.dashboard-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

/* ----- Header ----- */
.dashboard-header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 2000;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-left .logo-icon {
    font-size: 24px;
}

.header-left h1 {
    font-size: 16px;
    font-weight: 600;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info {
    font-size: 13px;
    color: var(--text-secondary);
}

.user-info strong {
    color: var(--text-primary);
}

.btn-logout {
    padding: 8px 16px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: var(--error-color);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
}

/* ----- Main Content ----- */
.dashboard-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* ----- Sidebar ----- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100%;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    z-index: 1500;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-glass);
    flex-shrink: 0;
}

.sidebar-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 14px;
}

.search-box {
    width: 100%;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

.search-box:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.search-box::placeholder {
    color: var(--text-muted);
}

.filter-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.filter-select {
    flex: 1;
    padding: 9px 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-glass);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 11px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23a0a0c0' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
}

.filter-select:focus {
    border-color: var(--accent-primary);
}

.filter-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.result-count {
    padding: 10px 20px;
    font-size: 11px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-glass);
    flex-shrink: 0;
}

.result-count strong {
    color: var(--accent-primary);
}

/* ----- List Items ----- */
.sidebar-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-list::-webkit-scrollbar {
    width: 6px;
}

.sidebar-list::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.list-item {
    padding: 14px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: var(--transition);
}

.list-item:hover {
    background: var(--bg-card-hover);
    padding-left: 24px;
}

.list-item h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.4;
}

.list-item .item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.list-item p {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.badge-hot {
    background: rgba(239, 68, 68, 0.15);
    color: var(--hot-color);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-warm {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warm-color);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-cold {
    background: rgba(59, 130, 246, 0.15);
    color: var(--cold-color);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-default {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
}

.rating-text {
    font-size: 11px;
    color: var(--warm-color);
    font-weight: 600;
}

/* ----- Map Container ----- */
.map-container {
    flex: 1;
    position: relative;
}

.map-container #map {
    width: 100%;
    height: 100%;
}

/* Override Leaflet popup for dark theme */
.leaflet-popup-content-wrapper {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-glass) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-glass) !important;
}

.leaflet-popup-tip {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-glass) !important;
}

.leaflet-popup-close-button {
    color: var(--text-secondary) !important;
}

.popup-content h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.popup-content .popup-detail {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.popup-content .popup-detail b {
    color: var(--text-primary);
}

.popup-content hr {
    border: none;
    border-top: 1px solid var(--border-glass);
    margin: 8px 0;
}

.popup-content .popup-score {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
}

.popup-content a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
}

.popup-content a:hover {
    text-decoration: underline;
}

/* ----- Loading Overlay ----- */
.loading-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(15, 15, 35, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    transition: opacity 0.4s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ----- Empty State ----- */
.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.empty-state .empty-icon {
    font-size: 36px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ============================================
   SPA VIEWS & TABS
   ============================================ */
.view-section {
    display: none;
    width: 100%;
    height: 100%;
}
.view-section.active {
    display: flex;
}
#view-stats.active, #view-csv.active {
    display: block;
    overflow-y: auto;
    background: var(--bg-primary);
}

/* ----- Tab Navigation ----- */
.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}
.tab-nav {
    display: flex;
    background: rgba(255,255,255,0.05);
    border-radius: var(--radius-lg);
    padding: 4px;
}
.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}
.tab-btn:hover {
    color: var(--text-primary);
}
.tab-btn.active {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* ============================================
   STATS DASHBOARD VIEW
   ============================================ */
.stats-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}
.stats-header {
    margin-bottom: 32px;
}
.stats-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}
.text-muted {
    color: var(--text-muted);
    font-size: 14px;
}
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}
.stat-card:hover {
    transform: translateY(-4px);
    background: var(--bg-card-hover);
}
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}
.stat-card.total .stat-icon { background: rgba(102, 126, 234, 0.2); color: var(--accent-primary); }
.stat-card.hot .stat-icon { background: rgba(239, 68, 68, 0.2); color: var(--hot-color); }
.stat-card.warm .stat-icon { background: rgba(245, 158, 11, 0.2); color: var(--warm-color); }
.stat-card.cold .stat-icon { background: rgba(59, 130, 246, 0.2); color: var(--cold-color); }

.stat-info h3 {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.stat-info h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.chart-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 24px;
}
.chart-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--text-primary);
}
.canvas-wrapper {
    position: relative;
    height: 400px;
    width: 100%;
}

/* ============================================
   DATA TABLE VIEW
   ============================================ */
.table-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 24px;
}
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.btn-action {
    background: rgba(255,255,255,0.1);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}
.btn-action:hover {
    background: rgba(255,255,255,0.15);
}
.table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    overflow: hidden;
    overflow-x: auto;
}
#csv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
#csv-table th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-glass);
    white-space: nowrap;
}
#csv-table td {
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: var(--text-primary);
}
#csv-table tbody tr:hover {
    background: rgba(255,255,255,0.02);
}
#csv-table td.cell-address {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.table-input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    width: 100%;
    min-width: 150px;
    transition: var(--transition);
}
.table-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: rgba(0, 0, 0, 0.4);
}
.btn-save {
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.btn-save:hover {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}
.btn-save:disabled {
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}
.btn-save.saving {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ----- Buttons & Utilities ----- */
.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-icon:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.mobile-only {
    display: none;
}

/* ============================================
   RESPONSIVE (MOBILE)
   ============================================ */
@media (max-width: 768px) {
    .mobile-only {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .hide-mobile {
        display: none !important;
    }

    .dashboard-header {
        padding: 0 16px;
    }

    .header-left h1 {
        font-size: 14px;
    }
    
    .header-left .logo-icon {
        font-size: 20px;
    }

    .dashboard-content {
        position: relative;
    }

    .sidebar {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        max-width: 380px;
        height: 100%;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    /* Add overlay behind sidebar when open */
    .sidebar-overlay {
        position: absolute;
        top: 0; left: 0;
        width: 100%; height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 1400;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }
}
