/* --- DESIGN SYSTEM & CSS VARIABLES --- */
:root {
    --bg-gradient: linear-gradient(135deg, #050b14 0%, #08162d 50%, #0c264c 100%);
    --bg-darker: #03070f;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --color-cyan: #00b4d8;
    --color-cyan-glow: rgba(0, 180, 216, 0.25);
    --color-blue: #0077b6;
    --color-blue-dark: #03045e;
    
    --status-success: #10b981;
    --status-warning: #f59e0b;
    --status-danger: #ef4444;
    --status-info: #3b82f6;

    --glass-bg: rgba(13, 27, 42, 0.45);
    --glass-border: rgba(255, 255, 255, 0.07);
    --glass-hover-border: rgba(0, 180, 216, 0.3);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.35);
    --glass-blur: blur(16px);
    
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* --- GENERAL RESET & BASE --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(3, 7, 15, 0.5);
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 180, 216, 0.3);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 180, 216, 0.6);
}

a {
    color: var(--color-cyan);
    text-decoration: none;
    transition: all 0.2s ease;
}
a:hover {
    color: #90e0ef;
}

.text-cyan { color: var(--color-cyan) !important; }
.mt-2 { margin-top: 0.5rem; }
.mb-4 { margin-bottom: 1.5rem; }
.flex-1 { flex: 1; }
.hide { display: none !important; }
.font-semibold { font-weight: 600; }
.text-right { text-align: right; }

/* --- APP LAYOUT --- */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Header */
.app-header {
    background: rgba(3, 7, 15, 0.6);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
}
.logo-icon {
    font-size: 1.85rem;
    filter: drop-shadow(0 0 8px var(--color-cyan-glow));
    animation: pulseWave 3s infinite ease-in-out;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-link {
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.nav-link:hover, .nav-link.active {
    color: var(--color-cyan);
}

/* Footer */
.app-footer {
    margin-top: auto;
    background: var(--bg-darker);
    border-top: 1px solid var(--glass-border);
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* --- GLASS CARD STYLING --- */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
    padding: 1.5rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.glass-card:hover {
    border-color: rgba(0, 180, 216, 0.15);
}

.card-header {
    margin-bottom: 1.25rem;
}
.card-header h2 {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
}
.card-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* --- BUTTONS --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.625rem 1.25rem;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-cyan) 0%, var(--color-blue) 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 180, 216, 0.25);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 180, 216, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-outline {
    background: transparent;
    border: 1px solid rgba(0, 180, 216, 0.4);
    color: var(--color-cyan);
}
.btn-outline:hover {
    background: rgba(0, 180, 216, 0.08);
    border-color: var(--color-cyan);
    color: #fff;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
}
.btn-danger:hover {
    background: var(--status-danger);
    color: #fff;
    border-color: var(--status-danger);
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 6px;
}

/* --- FORMS --- */
.form-group {
    margin-bottom: 1.25rem;
}
.form-row {
    display: flex;
    gap: 1rem;
}
.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}
.form-control, .form-select {
    width: 100%;
    background: rgba(3, 7, 15, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: all 0.25s ease;
}
.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--color-cyan);
    box-shadow: 0 0 0 3px var(--color-cyan-glow);
    background: rgba(3, 7, 15, 0.6);
}
.form-help {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}
.input-icon-wrapper {
    position: relative;
}
.input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.input-icon-wrapper .form-control {
    padding-left: 2.5rem;
}

.input-action-group {
    display: flex;
    gap: 0.5rem;
}

/* --- DASHBOARD GRID & MAIN VIEW --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Map Card */
.map-card-wrapper {
    position: sticky;
    top: 80px;
}
.map-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.map-container {
    height: 350px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: #111;
    z-index: 10;
}
/* Leaflet dark theme styling overrides */
.leaflet-container {
    background: #0d1b2a !important;
}

/* Station Details Content */
.station-details-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.info-card {
    border-left: 4px solid var(--color-cyan);
}
.station-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}
.station-title {
    font-family: var(--font-heading);
    font-size: 1.85rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    margin-bottom: 0.5rem;
}
.station-meta {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    background: rgba(0, 180, 216, 0.15);
    color: var(--color-cyan);
}
.badge-outline {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
}

.advice-box {
    background: rgba(0, 180, 216, 0.06);
    border: 1px solid rgba(0, 180, 216, 0.15);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
}
.advice-icon {
    font-size: 1.25rem;
    color: var(--color-cyan);
    margin-top: 0.1rem;
}
.advice-text {
    font-size: 0.925rem;
}
.advice-heading {
    display: block;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 0.15rem;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}

.metric-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    position: relative;
    overflow: hidden;
}

.metric-icon-wrapper {
    width: 55px;
    height: 55px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
}
.level-accent {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.3);
}
.temp-accent {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.metric-info {
    flex: 1;
}
.metric-label {
    display: block;
    font-size: 0.775rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}
.metric-value {
    font-family: var(--font-heading);
    font-size: 2.25rem;
    font-weight: 800;
    line-height: 1.1;
    margin: 0.15rem 0;
}
.metric-unit {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.metric-status {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    font-size: 0.675rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
}

/* Status Badges */
.level-status-badge, .temp-status-badge {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
}
.status-good {
    background: rgba(16, 185, 129, 0.15) !important;
    color: #34d399 !important;
}
.status-warn {
    background: rgba(245, 158, 11, 0.15) !important;
    color: #fbbf24 !important;
}
.status-danger {
    background: rgba(239, 68, 68, 0.15) !important;
    color: #f87171 !important;
}

/* Charts */
.chart-card {
    position: relative;
}
.chart-container {
    height: 320px;
    width: 100%;
}

/* Comments Section Layout */
.comments-section-layout {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 1.5rem;
    margin-top: 1rem;
}

@media (max-width: 768px) {
    .comments-section-layout {
        grid-template-columns: 1fr;
    }
}

.feed-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
}

.comments-list {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-right: 0.5rem;
}

.comment-bubble {
    background: rgba(3, 7, 15, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.comment-meta {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.comment-author-block {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.comment-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 180, 216, 0.2);
    border: 1px solid var(--color-cyan);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-cyan);
    font-size: 0.75rem;
}
.comment-author {
    font-weight: 600;
    font-size: 0.9rem;
}
.comment-craft {
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    color: var(--text-secondary);
}
.comment-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.badge-cond-excellent { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-cond-good { background: rgba(16, 185, 129, 0.1); color: #6ee7b7; }
.badge-cond-fair { background: rgba(245, 158, 11, 0.1); color: #fcd34d; }
.badge-cond-poor { background: rgba(239, 68, 68, 0.1); color: #fca5a5; }
.badge-cond-dangerous { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }

.comment-text {
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: pre-line;
}

.loading-state, .empty-state {
    text-align: center;
    padding: 2.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}
.loading-state i {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

/* --- ADMIN LAYOUT --- */
.admin-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 1.5rem;
}

@media (max-width: 992px) {
    .admin-grid {
        grid-template-columns: 1fr;
    }
}

.admin-form .form-group {
    margin-bottom: 1rem;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    margin-top: 0.5rem;
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.875rem;
}
.admin-table th {
    background: rgba(3, 7, 15, 0.5);
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--glass-border);
}
.admin-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    vertical-align: middle;
}
.admin-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}
.empty-table-message {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}
.cell-primary {
    font-weight: 600;
}
.cell-secondary {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}
.comment-text-cell {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- LOGIN VIEW --- */
.login-container {
    max-width: 450px;
    margin: 4rem auto;
    width: 100%;
}
.login-card {
    padding: 2.5rem;
}
.login-header {
    text-align: center;
    margin-bottom: 2rem;
}
.login-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    filter: drop-shadow(0 0 10px rgba(0, 180, 216, 0.4));
}
.login-header h2 {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}
.login-header p {
    color: var(--text-secondary);
    font-size: 0.85rem;
}
.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.875rem;
}

/* --- ALERTS & FLASH --- */
.flash-messages {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.flash {
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid transparent;
}
.flash-success {
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.2);
}
.flash-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.2);
}
.flash-info {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.2);
}

.alert-box {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-top: 0.75rem;
}
.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}
.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.weather-accent {
    background: rgba(0, 180, 216, 0.15);
    color: #00b4d8;
    border: 1px solid rgba(0, 180, 216, 0.3);
}

.weather-status-badge {
    background: rgba(0, 180, 216, 0.1) !important;
    color: #00b4d8 !important;
}

/* Weather Alerts Banner */
.weather-alerts-banner {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-left: 4px solid var(--status-danger);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.1);
}
.alert-banner-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--status-danger);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}
.pulse-icon {
    animation: pulseWarning 2s infinite ease-in-out;
}
@keyframes pulseWarning {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.1); }
}
.alert-banner-item {
    font-size: 0.875rem;
    color: var(--text-primary);
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.alert-banner-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.alert-instruction {
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.4;
}
.alert-expires {
    margin-top: 0.15rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* 7-Day Forecast Section */
.forecast-card {
    border-left: 4px solid var(--color-cyan);
}
.forecast-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}
.forecast-header-title h2 {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
}
.forecast-header-title p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}
.forecast-drawer {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease, margin-top 0.4s ease;
    opacity: 1;
}
.forecast-drawer.collapsed {
    max-height: 0px;
    opacity: 0;
    margin-top: 0;
    pointer-events: none;
}
.forecast-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.75rem;
    padding: 0.25rem 0;
}
@media (max-width: 1200px) {
    .forecast-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
@media (max-width: 768px) {
    .forecast-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 480px) {
    .forecast-grid {
        grid-template-columns: 1fr;
    }
}
.forecast-day-card {
    background: rgba(3, 7, 15, 0.25);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem 0.75rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.forecast-day-card:hover {
    transform: translateY(-2px);
    border-color: var(--glass-hover-border);
}
.today-highlight {
    background: rgba(0, 180, 216, 0.08);
    border-color: rgba(0, 180, 216, 0.3);
}
.forecast-day-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}
.today-highlight .forecast-day-name {
    color: var(--color-cyan);
}
.forecast-day-icon {
    font-size: 1.5rem;
    color: var(--color-cyan);
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.forecast-day-temp {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}
.temp-high {
    color: var(--text-primary);
}
.temp-low {
    color: var(--text-secondary);
    font-weight: 500;
}
.forecast-day-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.2;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.forecast-day-meta {
    display: flex;
    justify-content: space-between;
    width: 100%;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 0.5rem;
    margin-top: 0.25rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* --- KEYFRAME ANIMATIONS --- */

@keyframes pulseWave {
    0%, 100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    50% {
        transform: translateY(-3px) scale(1.05);
        opacity: 0.85;
    }
}
