/* ==========================================================
   AI Weather and Environmental Monitoring System - CSS
   Modern Glassmorphic Dark UI Theme
   ========================================================== */

:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.75);
    --bg-card-hover: rgba(31, 41, 55, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(59, 130, 246, 0.3);
    
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --accent-indigo: #6366f1;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --accent-purple: #8b5cf6;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background: radial-gradient(circle at 10% 20%, #172554 0%, var(--bg-primary) 60%),
                radial-gradient(circle at 90% 80%, #064e3b 0%, var(--bg-primary) 70%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ==========================================================
   Navigation Bar
   ========================================================== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    padding: 0.85rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #60a5fa, #34d399);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-brand .brand-icon {
    font-size: 1.6rem;
    -webkit-text-fill-color: initial;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    list-style: none;
}

.nav-links a {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.nav-links a:hover,
.nav-links a.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.nav-status {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
}

.status-indicator.offline {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #10b981;
    box-shadow: 0 0 10px #10b981;
    animation: pulse-dot 1.8s infinite;
}

.status-indicator.offline .status-dot {
    background-color: #ef4444;
    box-shadow: 0 0 8px #ef4444;
    animation: none;
}

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

/* ==========================================================
   Main Layout Container
   ========================================================== */
.container {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 1.75rem 2rem;
    flex: 1;
}

/* ==========================================================
   Header Section
   ========================================================== */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1.25rem;
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.header-title h1 {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.header-title p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.time-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 0.45rem 1rem;
    border-radius: var(--radius-md);
    text-align: right;
}

.time-box .current-time {
    font-size: 1rem;
    font-weight: 700;
    color: #60a5fa;
    font-variant-numeric: tabular-nums;
}

.time-box .current-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.1rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
    color: #fff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-simulate {
    background: linear-gradient(135deg, #8b5cf6, #ec4899);
    color: #fff;
}

.btn-simulate:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.4);
}

/* ==========================================================
   Alerts Banner Section (Dynamic)
   ========================================================== */
.alerts-container {
    margin-bottom: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.alert-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.25rem;
    border-radius: var(--radius-md);
    backdrop-filter: blur(10px);
    animation: slideDown 0.4s ease-out;
}

.alert-card.warning {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: #fbbf24;
}

.alert-card.danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #f87171;
}

.alert-content {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.alert-icon {
    font-size: 1.4rem;
}

.alert-title {
    font-weight: 700;
    font-size: 0.95rem;
}

.alert-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ==========================================================
   Section 1: Real-Time Sensor Grid
   ========================================================== */
.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.section-title .badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
}

.sensor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.sensor-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.35rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    box-shadow: var(--shadow-card);
}

.sensor-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-glow);
    box-shadow: var(--shadow-card), var(--shadow-glow);
}

.sensor-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
    opacity: 0.8;
}

.sensor-card.temp-card::before { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.sensor-card.humidity-card::before { background: linear-gradient(90deg, #06b6d4, #3b82f6); }
.sensor-card.air-card::before { background: linear-gradient(90deg, #10b981, #f59e0b); }
.sensor-card.rain-card::before { background: linear-gradient(90deg, #6366f1, #8b5cf6); }
.sensor-card.soil-card::before { background: linear-gradient(90deg, #10b981, #059669); }

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

.sensor-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sensor-icon-wrapper {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

.sensor-value-row {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    margin: 0.5rem 0;
}

.sensor-value {
    font-size: 2.1rem;
    font-weight: 800;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    transition: transform 0.3s ease;
}

.sensor-unit {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-muted);
}

.sensor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.85rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.78rem;
}

.sensor-badge {
    padding: 0.2rem 0.65rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.75rem;
}

.bg-green { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.bg-yellow { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.bg-orange { background: rgba(249, 115, 22, 0.15); color: #fb923c; border: 1px solid rgba(249, 115, 22, 0.3); }
.bg-red { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.bg-blue { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }

.sensor-timestamp {
    color: var(--text-muted);
}

/* Flash animation on real-time update */
.data-updated {
    animation: highlightPulse 0.8s ease-out;
}

@keyframes highlightPulse {
    0% { transform: scale(1.03); filter: brightness(1.3); }
    100% { transform: scale(1); filter: brightness(1); }
}

/* ==========================================================
   Dual Column Layout (Weather + AI Prediction)
   ========================================================== */
.two-col-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

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

/* Weather Card */
.weather-panel, .ai-panel {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
}

.weather-search-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.weather-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.6rem 1rem;
    color: #fff;
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.weather-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.weather-main-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, rgba(30, 58, 138, 0.35), rgba(17, 24, 39, 0.6));
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.weather-location-info h3 {
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.weather-condition-text {
    color: var(--accent-cyan);
    font-weight: 600;
    font-size: 0.95rem;
    margin-top: 0.2rem;
}

.weather-temp-hero {
    text-align: right;
}

.weather-temp-hero .big-temp {
    font-size: 2.6rem;
    font-weight: 800;
    line-height: 1;
    color: #fff;
}

.weather-temp-hero .feels-like {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.weather-details-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.weather-detail-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.85rem;
}

.weather-detail-item .label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    display: block;
}

.weather-detail-item .val {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 0.2rem;
}

/* AI Prediction Panel */
.ai-panel {
    border-color: rgba(139, 92, 246, 0.25);
    background: radial-gradient(circle at 100% 0%, rgba(139, 92, 246, 0.12) 0%, var(--bg-card) 65%);
}

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

.ai-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.8rem;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(236, 72, 153, 0.25));
    border: 1px solid rgba(139, 92, 246, 0.4);
    color: #c084fc;
}

.ai-prediction-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.ai-predicted-condition {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.ai-icon-large {
    font-size: 2.8rem;
}

.ai-condition-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
}

.ai-confidence-badge {
    margin-top: 0.25rem;
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.15rem 0.6rem;
    border-radius: var(--radius-full);
}

.ai-reason-box {
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid #8b5cf6;
    padding: 0.85rem 1rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-top: 1rem;
}

.ai-reason-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: #c084fc;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.3rem;
}

.ai-reason-text {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

/* ==========================================================
   Section 6: Visual Charts Grid
   ========================================================== */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

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

.chart-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
}

.chart-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.chart-card-header h3 {
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-wrapper {
    position: relative;
    height: 220px;
    width: 100%;
}

/* ==========================================================
   Section 5: Historical Data Table
   ========================================================== */
.history-panel {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    margin-bottom: 2rem;
}

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

.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.88rem;
}

.history-table th {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.history-table td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.history-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.25rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.pagination-controls {
    display: flex;
    gap: 0.5rem;
}

/* ==========================================================
   Landing Page (index.html) Specific Styles
   ========================================================== */
.hero-section {
    text-align: center;
    padding: 3.5rem 1rem;
    max-width: 900px;
    margin: 0 auto;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    border-radius: var(--radius-full);
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #60a5fa;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.hero-title {
    font-size: 2.8rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 1.25rem;
    background: linear-gradient(135deg, #ffffff 30%, #93c5fd 80%, #34d399 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-desc {
    font-size: 1.15rem;
    color: var(--text-secondary);
    max-width: 720px;
    margin: 0 auto 2rem auto;
    line-height: 1.6;
}

.hero-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 3rem 0;
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    transition: var(--transition);
}

.feature-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-glow);
}

.feature-icon {
    font-size: 2.2rem;
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.feature-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.arch-diagram-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin: 3rem 0;
}

.code-block {
    background: #000;
    color: #34d399;
    font-family: 'Consolas', 'Courier New', monospace;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-size: 0.88rem;
    line-height: 1.5;
    border: 1px solid var(--border-color);
}

/* ==========================================================
   Footer
   ========================================================== */
.footer {
    background: rgba(11, 15, 25, 0.9);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: auto;
}

/* ==========================================================
   Toast Notification & Modal
   ========================================================== */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 0.75rem 1.2rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideDown {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ==========================================================
   Comprehensive Mobile & Tablet Responsive Media Queries
   ========================================================== */

/* Medium Devices / Tablets (<= 900px) */
@media (max-width: 900px) {
    .navbar {
        padding: 0.75rem 1.25rem;
    }

    .container {
        padding: 1.25rem 1.25rem;
    }

    .two-col-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .sensor-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1rem;
    }
}

/* Mobile Screens (<= 640px) */
@media (max-width: 640px) {
    /* Navigation Bar */
    .navbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.6rem;
        padding: 0.65rem 0.85rem;
    }

    .nav-brand {
        font-size: 1.15rem;
        justify-content: space-between;
    }

    .nav-links {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        gap: 0.4rem;
        padding-bottom: 0.25rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Hide scrollbar for clean app feel */
    }

    .nav-links::-webkit-scrollbar {
        display: none;
    }

    .nav-links a {
        font-size: 0.85rem;
        padding: 0.35rem 0.65rem;
    }

    .nav-status {
        position: absolute;
        top: 0.65rem;
        right: 0.85rem;
    }

    .status-indicator {
        font-size: 0.7rem;
        padding: 0.25rem 0.6rem;
    }

    /* Container */
    .container {
        padding: 0.85rem 0.75rem;
    }

    /* Header */
    .dashboard-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.85rem;
        margin-bottom: 1.25rem;
        padding-bottom: 0.85rem;
    }

    .header-title h1 {
        font-size: 1.45rem;
        line-height: 1.25;
    }

    .header-title p {
        font-size: 0.82rem;
    }

    .header-controls {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        gap: 0.5rem;
    }

    .time-box {
        padding: 0.35rem 0.75rem;
        flex: 1;
        text-align: left;
    }

    .time-box .current-time {
        font-size: 0.92rem;
    }

    .time-box .current-date {
        font-size: 0.7rem;
    }

    .btn {
        padding: 0.45rem 0.85rem;
        font-size: 0.82rem;
    }

    /* Section Titles */
    .section-title {
        font-size: 1.05rem;
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    /* Sensor Grid (2-column layout on mobile) */
    .sensor-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.65rem;
        margin-bottom: 1.25rem;
    }

    .sensor-card {
        padding: 0.85rem;
        border-radius: var(--radius-md);
    }

    .sensor-name {
        font-size: 0.75rem;
    }

    .sensor-icon-wrapper {
        width: 32px;
        height: 32px;
        font-size: 1.1rem;
    }

    .sensor-value {
        font-size: 1.55rem;
    }

    .sensor-unit {
        font-size: 0.85rem;
    }

    .sensor-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.3rem;
        margin-top: 0.5rem;
        padding-top: 0.5rem;
    }

    .sensor-badge {
        font-size: 0.7rem;
        padding: 0.15rem 0.5rem;
    }

    .sensor-timestamp {
        font-size: 0.7rem;
    }

    /* Weather Panel */
    .weather-panel, .ai-panel {
        padding: 1rem;
        border-radius: var(--radius-md);
    }

    .weather-main-display {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 1rem;
        margin-bottom: 0.85rem;
    }

    .weather-location-info h3 {
        font-size: 1.15rem;
    }

    .weather-condition-text {
        font-size: 0.85rem;
    }

    .weather-temp-hero {
        text-align: left;
        display: flex;
        align-items: baseline;
        gap: 0.6rem;
    }

    .weather-temp-hero .big-temp {
        font-size: 2.1rem;
    }

    .weather-temp-hero .feels-like {
        font-size: 0.78rem;
    }

    .weather-details-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .weather-detail-item {
        padding: 0.5rem 0.65rem;
    }

    .weather-detail-item .label {
        font-size: 0.68rem;
    }

    .weather-detail-item .val {
        font-size: 0.85rem;
    }

    /* AI Panel */
    .ai-prediction-box {
        padding: 1rem;
    }

    .ai-icon-large {
        font-size: 2.2rem;
    }

    .ai-condition-title {
        font-size: 1.15rem;
    }

    .ai-chip {
        font-size: 0.7rem;
        padding: 0.2rem 0.6rem;
    }

    .ai-reason-box {
        padding: 0.65rem 0.85rem;
    }

    .ai-reason-text {
        font-size: 0.82rem;
    }

    /* Charts */
    .chart-card {
        padding: 0.85rem;
        border-radius: var(--radius-md);
    }

    .chart-card-header h3 {
        font-size: 0.88rem;
    }

    .chart-wrapper {
        height: 180px;
    }

    /* History Table */
    .history-panel {
        padding: 1rem;
        border-radius: var(--radius-md);
    }

    .history-table th {
        padding: 0.6rem 0.75rem;
        font-size: 0.7rem;
    }

    .history-table td {
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    .pagination {
        flex-direction: column;
        gap: 0.6rem;
        text-align: center;
    }

    /* Landing Page Mobile */
    .hero-section {
        padding: 2rem 0.5rem;
    }

    .hero-title {
        font-size: 1.75rem;
        line-height: 1.25;
    }

    .hero-desc {
        font-size: 0.92rem;
        line-height: 1.5;
    }

    .hero-actions {
        flex-direction: column;
    }

    .hero-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .features-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin: 2rem 0;
    }

    .feature-card {
        padding: 1.25rem;
    }

    .arch-diagram-card {
        padding: 1rem;
        margin: 1.5rem 0;
    }

    .code-block {
        font-size: 0.72rem;
        padding: 0.75rem;
    }

    /* Toast Notifications on Mobile */
    .toast-container {
        left: 12px;
        right: 12px;
        bottom: 12px;
    }

    .toast {
        font-size: 0.82rem;
        padding: 0.65rem 0.9rem;
    }
}

/* Extra-small screens (<= 380px) */
@media (max-width: 380px) {
    .sensor-grid {
        grid-template-columns: 1fr;
    }

    .weather-details-grid {
        grid-template-columns: 1fr;
    }

    .header-title h1 {
        font-size: 1.25rem;
    }
}
