/* ================================================================
   NEXDIGI SMART FARMING - GLOBAL STYLES
   Modern, Glassmorphism, Responsive Dashboard
   ================================================================ */

:root {
    --primary: #10b981;
    --primary-light: #d1fae5;
    --primary-dark: #059669;
    --secondary: #3b82f6;
    --secondary-light: #dbeafe;
    --info: #06b6d4;
    --info-light: #cffafe;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --dark: #0f172a;
    --dark-light: #1e293b;
    --light: #f8fafc;
    --muted: #94a3b8;
    --white: #ffffff;
    --glass: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.3);
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --sidebar-width: 260px;
    --sidebar-collapsed: 80px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* DARK MODE VARIABLES */
body.dark-mode {
    --light: #0f172a;
    --dark: #f8fafc;
    --dark-light: #334155;
    --muted: #64748b;
    --glass: rgba(15, 23, 42, 0.9);
    --glass-border: rgba(255,255,255,0.08);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', 'Segoe UI', -apple-system, sans-serif;
    background: var(--light);
    color: var(--dark);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s, color 0.3s;
}

body.dark-mode { color: #e2e8f0; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* SIDEBAR */
.sidebar {
    position: fixed;
    left: 0; top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, #064e3b 0%, #022c22 100%);
    color: var(--white);
    padding: 24px 0;
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
}

.sidebar .brand {
    padding: 0 24px 32px;
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: space-between;
}

.sidebar .brand-icon {
    width: 42px; height: 42px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(16,185,129,0.3);
    flex-shrink: 0;
}

.sidebar-toggle-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.8);
    transform: translateX(-2px);
}

.sidebar-toggle-btn:active {
    transform: translateX(-4px);
}

.sidebar.collapsed .sidebar-toggle-btn i {
    transform: rotate(180deg);
}

.sidebar .brand-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.sidebar .brand-text small {
    display: block;
    font-size: 10px;
    font-weight: 500;
    opacity: 0.6;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 0 24px 16px;
}

.sidebar .nav-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.5;
    padding: 0 24px 10px;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 14px;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    padding: 12px 20px;
    margin: 4px 16px;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 14px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.sidebar a i {
    width: 22px; text-align: center;
    font-size: 16px;
    transition: 0.3s;
}

.sidebar a:hover {
    background: rgba(255,255,255,0.08);
    color: var(--white);
    transform: translateX(4px);
}

.sidebar a.active {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 4px 14px rgba(16,185,129,0.35);
}

.sidebar a.active::before {
    content: '';
    position: absolute;
    left: -16px; top: 50%;
    transform: translateY(-50%);
    width: 4px; height: 24px;
    background: var(--primary-light);
    border-radius: 0 4px 4px 0;
}

.sidebar .bottom-section {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 16px;
}

.sidebar .system-info {
    background: rgba(0,0,0,0.25);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 11px;
}

.sidebar-logout-link {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: var(--radius);
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
}
.sidebar-logout-link:hover {
    background: rgba(239,68,68,0.15);
    color: #fca5a5;
}
.sidebar-logout-link i { width: 18px; text-align: center; }

/* MAIN CONTENT */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 28px 32px;
    min-height: 100vh;
    transition: var(--transition);
}

/* SIDEBAR COLLAPSED STATE */
.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed a span,
.sidebar.collapsed .bottom-section {
    display: none;
}

.sidebar.collapsed .brand {
    justify-content: center;
    padding: 0 0 20px;
}

.sidebar.collapsed a {
    justify-content: center;
    padding: 14px;
    margin: 4px 10px;
}

.sidebar.collapsed a i {
    width: auto;
    font-size: 20px;
}

.main-content.collapsed {
    margin-left: var(--sidebar-collapsed);
}

/* TOP HEADER */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--glass-border);
}

.top-header h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.top-header .subtitle {
    color: var(--muted);
    font-size: 14px;
    margin-top: 2px;
}

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

/* THEME TOGGLE */
.theme-toggle {
    width: 44px; height: 44px;
    border-radius: var(--radius);
    border: 1px solid var(--glass-border);
    background: var(--glass);
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 16px;
}

.theme-toggle:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
    transform: rotate(20deg);
}

/* CONNECTION BADGE */
.connection-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    font-size: 13px;
    font-weight: 500;
    backdrop-filter: blur(10px);
}

.connection-badge .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0% { opacity: 1; box-shadow: 0 0 0 0 rgba(16,185,129,0.6); }
    70% { opacity: 0.8; box-shadow: 0 0 0 8px rgba(16,185,129,0); }
    100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

.connection-badge.disconnected .dot {
    background: var(--danger);
    box-shadow: 0 0 8px var(--danger);
    animation: none;
}

/* LIVE CLOCK */
.live-clock {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--muted);
    font-size: 13px;
}

/* CARDS */
.card-glass {
    background: var(--glass);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
    overflow: hidden;
}

.card-glass:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

body.dark-mode .card-glass {
    border-color: rgba(255,255,255,0.06);
}

/* SENSOR CARD */
.sensor-card {
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.sensor-card .card-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    margin-bottom: 16px;
}

.sensor-card .card-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    margin-bottom: 8px;
}

.sensor-card .card-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -1px;
    color: var(--dark);
}

body.dark-mode .sensor-card .card-value { color: #f1f5f9; }

.sensor-card .card-unit {
    font-size: 15px;
    font-weight: 500;
    color: var(--muted);
    margin-left: 4px;
}

.sensor-card .card-trend {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
}

.sensor-card .mini-chart {
    position: absolute;
    right: 16px; bottom: 16px;
    width: 80px; height: 40px;
    opacity: 0.3;
}

/* DEVICE CARD */
.device-card {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.device-card .device-icon {
    width: 52px; height: 52px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    transition: 0.3s;
}

.device-card .device-info { flex: 1; }
.device-card .device-info h6 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}
.device-card .device-info small {
    font-size: 12px;
    color: var(--muted);
}

.device-card .device-badge {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 6px 12px;
    border-radius: var(--radius-lg);
    letter-spacing: 0.5px;
}

/* STATUS COLORS */
.bg-soft-primary { background: var(--primary-light); color: var(--primary-dark); }
.bg-soft-secondary { background: var(--secondary-light); color: #1e40af; }
.bg-soft-info { background: var(--info-light); color: #0e7490; }
.bg-soft-warning { background: var(--warning-light); color: #92400e; }
.bg-soft-danger { background: var(--danger-light); color: #991b1b; }

body.dark-mode .bg-soft-primary { background: rgba(16,185,129,0.15); }
body.dark-mode .bg-soft-secondary { background: rgba(59,130,246,0.15); }
body.dark-mode .bg-soft-info { background: rgba(6,182,212,0.15); }
body.dark-mode .bg-soft-warning { background: rgba(245,158,11,0.15); }
body.dark-mode .bg-soft-danger { background: rgba(239,68,68,0.15); }

.text-success-soft { color: var(--primary); }
.text-danger-soft { color: var(--danger); }
.text-warning-soft { color: var(--warning); }

/* SECTION HEADING */
.section-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    font-size: 16px;
    font-weight: 700;
}

.section-heading i {
    font-size: 14px;
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
}

/* ANALYSIS CARD */
.analysis-card {
    padding: 24px;
}

.analysis-card .analysis-score {
    width: 100px; height: 100px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-direction: column;
    margin: 0 auto 16px;
    font-weight: 700;
    position: relative;
}

.analysis-card .analysis-score .score-value {
    font-size: 28px;
    line-height: 1;
}

.analysis-card .analysis-score .score-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
}

.analysis-card .analysis-title {
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 4px;
}

.analysis-card .analysis-desc {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}

/* PROGRESS BAR */
.progress-track {
    height: 6px;
    background: rgba(0,0,0,0.05);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 1s ease;
}

body.dark-mode .progress-track { background: rgba(255,255,255,0.06); }

/* TABLE STYLES */
.table-glass {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-glass thead th {
    background: rgba(0,0,0,0.02);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--glass-border);
}

body.dark-mode .table-glass thead th { background: rgba(255,255,255,0.03); }

.table-glass tbody td {
    padding: 14px 20px;
    font-size: 13px;
    border-bottom: 1px solid var(--glass-border);
    vertical-align: middle;
}

.table-glass tbody tr:hover {
    background: rgba(16,185,129,0.03);
}

/* BADGE */
.badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* PAGE HEADER */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 28px;
}

/* FILTER BAR */
.filter-bar {
    padding: 20px 24px;
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.filter-bar .filter-group { flex: 1; min-width: 180px; }
.filter-bar .filter-group label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    margin-bottom: 6px;
    display: block;
}

.filter-bar .form-control, .filter-bar .form-select {
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 14px;
    background: var(--glass);
    color: var(--dark);
    transition: var(--transition);
}

.filter-bar .form-control:focus, .filter-bar .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16,185,129,0.1);
    outline: none;
}

body.dark-mode .form-control, body.dark-mode .form-select {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.08);
    color: #e2e8f0;
}

/* BUTTONS */
.btn-glass {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-glass:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.btn-glass:active { transform: translateY(0); }

.btn-primary-glass { background: var(--primary); color: white; }
.btn-primary-glass:hover { background: var(--primary-dark); }

.btn-danger-glass { background: var(--danger); color: white; }
.btn-danger-glass:hover { background: #dc2626; }

/* PAGINATION */
.pagination-glass {
    display: flex;
    gap: 4px;
    justify-content: center;
    padding: 16px;
}

.pagination-glass a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    color: var(--dark);
    background: var(--glass);
    border: 1px solid var(--glass-border);
    transition: var(--transition);
}

.pagination-glass a:hover { background: var(--primary-light); color: var(--primary-dark); }
.pagination-glass a.active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination-glass a.disabled { opacity: 0.4; pointer-events: none; }

body.dark-mode .pagination-glass a { color: #e2e8f0; }

/* LOADING */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

body.dark-mode .loading-overlay { background: rgba(15,23,42,0.9); }

.loading-overlay.active { display: flex; }

.spinner-ring {
    width: 48px; height: 48px;
    border: 3px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ANIMATIONS */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-in {
    animation: fadeInUp 0.5s ease forwards;
}

/* HAMBURGER BUTTON */
.hamburger-btn {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1100;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #064e3b;
    color: white;
    border: none;
    font-size: 18px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    transition: left 0.3s ease, transform 0.3s ease, background 0.3s ease;
}
.hamburger-btn.open {
    left: min(240px, calc(100vw - 60px));
}

/* SIDEBAR OVERLAY */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* RESPONSIVE */
@media (max-width: 1024px) {
    .sidebar { width: var(--sidebar-collapsed); }
    .sidebar .brand-text, .sidebar .nav-label, .sidebar a span, .sidebar .bottom-section { display: none; }
    .sidebar .brand { justify-content: center; padding: 0 0 20px; }
    .sidebar a { justify-content: center; padding: 14px; margin: 4px 10px; }
    .sidebar a i { width: auto; font-size: 20px; }
    .main-content { margin-left: var(--sidebar-collapsed); }
}

@media (max-width: 768px) {
    /* Show hamburger, hide sidebar by default */
    .hamburger-btn { display: flex; }
    .sidebar {
        left: -280px;
        width: 260px !important;
        transition: left 0.3s ease;
        z-index: 1050;
    }
    .sidebar.open { left: 0; }
    /* Restore sidebar content visibility when open */
    .sidebar.open .brand-text,
    .sidebar.open .nav-label,
    .sidebar.open a span,
    .sidebar.open .bottom-section { display: block; }
    .sidebar.open .brand { justify-content: flex-start; padding: 0 24px 32px; }
    .sidebar.open a { justify-content: flex-start; padding: 12px 20px; margin: 4px 16px; }

    /* Main content takes full width */
    .main-content {
        margin-left: 0 !important;
        padding: 80px 16px 24px;
    }

    /* Top header stacking */
    .top-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .top-header h1 { font-size: 22px; }
    .header-actions { width: 100%; justify-content: flex-end; }

    /* Page header */
    .page-header { flex-direction: column; gap: 16px; }
    .page-header .header-actions { width: 100%; }

    /* Sensor card compact */
    .sensor-card { padding: 16px; }
    .sensor-card .card-value { font-size: 26px; }
    .sensor-card .card-icon { width: 40px; height: 40px; font-size: 16px; margin-bottom: 12px; }

    /* Chart height reduce */
    .chart-container { height: 220px !important; }

    /* Filter bar */
    .filter-bar { flex-direction: column; gap: 12px; padding: 16px; }
    .filter-bar .filter-group { width: 100%; min-width: unset; max-width: unset !important; }
    .filter-bar .ms-auto { margin-left: 0 !important; width: 100%; text-align: left !important; }

    /* Gauge chart container */
    .gauge-container { gap: 20px; }
    .gauge-item canvas { max-width: 120px !important; }

    /* Bottom nav hidden by default */
    .bottom-nav { display: none !important; }

    /* Device card compact */
    .device-card { padding: 14px; gap: 12px; }
    .device-card .device-icon { width: 44px; height: 44px; font-size: 18px; }

    /* Table scroll */
    .table-responsive-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Connection badge text hide on very small */
    .connection-badge { padding: 6px 10px; }
}

@media (max-width: 480px) {
    .main-content { padding: 76px 12px 24px; }
    .top-header h1 { font-size: 18px; }
    .sensor-card .card-value { font-size: 22px; }
    .chart-container { height: 180px !important; }
    .card-glass { border-radius: 14px; }
    /* Hide connection text, show only dot */
    #connText { display: none; }
}

@media (min-width: 769px) {
    .bottom-nav { display: none !important; }
    .hamburger-btn { display: none !important; }
    .sidebar-overlay { display: none !important; }
}

/* ================================================================
   UI IMPROVEMENTS — Tambahan Perbaikan Tampilan
   ================================================================ */

/* ── 1. Sensor Cards — Lebih proporsional & interaktif ── */
.sensor-card {
    padding: 20px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: default;
}

.sensor-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

body.dark-mode .sensor-card:hover {
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.card-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    margin-bottom: 8px;
}

.card-value {
    font-size: 36px;
    font-weight: 800;
    line-height: 1;
    color: var(--dark);
    letter-spacing: -1px;
}

body.dark-mode .card-value {
    color: #e2e8f0;
}

.card-unit {
    font-size: 16px;
    font-weight: 600;
    color: var(--muted);
    margin-left: 4px;
    align-self: flex-end;
    padding-bottom: 4px;
}

/* ── 2. Section Heading — Konsisten & rapi ── */
.section-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 700;
    color: var(--dark);
    letter-spacing: -0.2px;
}

body.dark-mode .section-heading { color: #e2e8f0; }

.section-heading i {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    font-size: 14px;
    flex-shrink: 0;
}

/* ── 3. Card Glass — Lebih polished ── */
.card-glass {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: all 0.25s ease;
    overflow: hidden;
}

body.dark-mode .card-glass {
    background: rgba(30, 41, 59, 0.85);
    border-color: rgba(255, 255, 255, 0.06);
}

/* ── 4. Device Cards — Status lebih jelas ── */
.device-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid var(--glass-border);
    transition: all 0.2s ease;
}

body.dark-mode .device-card {
    background: rgba(255, 255, 255, 0.02);
}

.device-card:hover {
    background: rgba(0, 0, 0, 0.04);
}

.device-info h6 {
    font-size: 13px;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
}

.device-info small {
    font-size: 11px;
    color: var(--muted);
}

.device-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-left: auto;
    flex-shrink: 0;
}

/* ── 5. Top Header — Lebih rapi ── */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 12px;
}

.top-header h1 {
    font-size: 22px;
    font-weight: 800;
    color: var(--dark);
    letter-spacing: -0.5px;
    margin: 0;
    line-height: 1.2;
}

body.dark-mode .top-header h1 { color: #f1f5f9; }

.top-header .subtitle {
    font-size: 12px;
    color: var(--muted);
    margin-top: 3px;
    display: flex;
    align-items: center;
}

/* ── 6. Badge Pill ── */
.badge-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* ── 7. Insight Items ── */
.insight-item {
    padding: 10px 0;
    gap: 12px;
    border-bottom: 1px solid var(--glass-border);
}

.insight-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.insight-text .title {
    font-size: 13px;
    font-weight: 600;
    color: var(--dark);
    line-height: 1.4;
}

body.dark-mode .insight-text .title { color: #e2e8f0; }

.insight-text .desc {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
    line-height: 1.4;
}

/* ── 8. Activity Items ── */
.activity-text {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
    color: var(--dark);
}

body.dark-mode .activity-text { color: #cbd5e1; }

.activity-time {
    font-size: 11px;
    color: var(--muted);
    font-weight: 500;
}

/* ── 9. Gauge Bar ── */
.gauge-bar {
    height: 5px;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.06);
    overflow: hidden;
    margin-top: 10px;
}

body.dark-mode .gauge-bar {
    background: rgba(255, 255, 255, 0.06);
}

.gauge-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 1.2s ease;
    min-width: 2px;
}

/* ── 10. Smooth Animations ── */
.animate-in {
    animation: fadeInUp 0.5s ease both;
}

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

/* ── 11. System Info di Sidebar ── */
.system-info {
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.65);
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(255,255,255,0.08);
}

/* ── 12. Theme Toggle Button ── */
.theme-toggle {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--muted);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: rgba(0, 0, 0, 0.08);
    color: var(--dark);
    transform: rotate(15deg);
}

body.dark-mode .theme-toggle {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
}

body.dark-mode .theme-toggle:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

/* ── 13. Loading Overlay ── */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--light);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 9999;
}

.loading-overlay.active {
    display: flex;
}

.spinner-ring {
    width: 44px; height: 44px;
    border: 3px solid rgba(16, 185, 129, 0.15);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ── 14. Mobile Header Fix ── */
@media (max-width: 768px) {
    .top-header {
        padding-top: 56px;
        margin-bottom: 20px;
    }

    .top-header h1 {
        font-size: 18px;
    }

    .top-header .header-actions {
        gap: 8px;
    }

    .connection-badge {
        font-size: 11px;
        padding: 5px 10px;
    }

    #connTime {
        display: none !important;
    }

    .card-value {
        font-size: 28px;
    }
}

@media (max-width: 480px) {
    .top-header h1 {
        font-size: 16px;
    }

    .card-value {
        font-size: 24px;
    }

    .section-heading {
        font-size: 13px;
    }
}

/* PRINT */
@media print {
    .sidebar, .btn, .pagination-glass, .theme-toggle, .connection-badge { display: none !important; }
    .main-content { margin-left: 0 !important; padding: 0 !important; }
    .card-glass { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ================================================================
   COLORFUL UPGRADE — gradient accents, mesh background, bell, dll
   ================================================================ */

/* ── Background mesh — subtle colorful depth di belakang konten ── */
.main-content { position: relative; }
.main-content::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(circle at 12% 18%, rgba(16,185,129,0.10), transparent 42%),
        radial-gradient(circle at 88% 12%, rgba(59,130,246,0.10), transparent 42%),
        radial-gradient(circle at 78% 88%, rgba(168,85,247,0.08), transparent 42%),
        radial-gradient(circle at 18% 92%, rgba(245,158,11,0.08), transparent 42%);
}
body.dark-mode .main-content::before {
    background:
        radial-gradient(circle at 12% 18%, rgba(16,185,129,0.16), transparent 42%),
        radial-gradient(circle at 88% 12%, rgba(59,130,246,0.16), transparent 42%),
        radial-gradient(circle at 78% 88%, rgba(168,85,247,0.14), transparent 42%),
        radial-gradient(circle at 18% 92%, rgba(245,158,11,0.12), transparent 42%);
}

/* ── Sensor card accent — top bar + gradient icon per kategori ── */
.sensor-card { position: relative; }
.sensor-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--primary);
    opacity: 0.9;
}
.sensor-card.accent-temp::after     { background: linear-gradient(90deg,#fb7185,#f59e0b); }
.sensor-card.accent-humidity::after { background: linear-gradient(90deg,#38bdf8,#3b82f6); }
.sensor-card.accent-ph::after       { background: linear-gradient(90deg,#34d399,#a78bfa); }
.sensor-card.accent-water::after    { background: linear-gradient(90deg,#22d3ee,#0ea5e9); }

.sensor-card.accent-temp .card-icon {
    background: linear-gradient(135deg,#fb7185,#f59e0b); color: #fff;
    box-shadow: 0 8px 20px rgba(244,63,94,0.35);
}
.sensor-card.accent-humidity .card-icon {
    background: linear-gradient(135deg,#38bdf8,#3b82f6); color: #fff;
    box-shadow: 0 8px 20px rgba(59,130,246,0.35);
}
.sensor-card.accent-ph .card-icon {
    background: linear-gradient(135deg,#34d399,#a78bfa); color: #fff;
    box-shadow: 0 8px 20px rgba(167,139,250,0.35);
}
.sensor-card.accent-water .card-icon {
    background: linear-gradient(135deg,#22d3ee,#0ea5e9); color: #fff;
    box-shadow: 0 8px 20px rgba(14,165,233,0.35);
}

/* ── Mini stat widget (Statistik Hari Ini) ── */
.mini-stat {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius);
    background: rgba(0,0,0,0.02);
    border: 1px solid var(--glass-border);
}
body.dark-mode .mini-stat { background: rgba(255,255,255,0.03); }
.mini-stat .mini-stat-icon {
    width: 38px; height: 38px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; color: #fff; flex-shrink: 0;
}
.mini-stat .mini-stat-label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.mini-stat .mini-stat-value { font-size: 16px; font-weight: 700; }

/* ── Notification bell ── */
.notif-wrap { position: relative; }
.notif-bell-btn { position: relative; }
.notif-badge {
    position: absolute; top: -4px; right: -4px;
    min-width: 18px; height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--danger);
    color: #fff;
    font-size: 10px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 0 2px var(--light);
}
body.dark-mode .notif-badge { box-shadow: 0 0 0 2px var(--dark-light); }

.notif-dropdown {
    /* position: fixed (bukan absolute) supaya tidak ke-clip oleh container
       manapun yang punya overflow:hidden (misal .hero-banner). Posisi
       top/left/right diisi via JS (notifications.js) saat dropdown dibuka. */
    position: fixed;
    top: 0;
    right: 0;
    width: 340px;
    max-width: 90vw;
    background: var(--glass);
    backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 1200;
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    overflow: hidden;
    visibility: hidden;
}
.notif-dropdown.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    visibility: visible;
}
body.dark-mode .notif-dropdown { background: rgba(20,28,46,0.97); }

.notif-dropdown-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px;
    font-size: 13px; font-weight: 700;
    border-bottom: 1px solid var(--glass-border);
}
.notif-clear-btn {
    background: none; border: none;
    font-size: 11px; font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: 0.2s;
}
.notif-clear-btn:hover { background: rgba(239,68,68,0.1); color: var(--danger); }

.notif-list { max-height: 320px; overflow-y: auto; }
.notif-empty { padding: 28px 16px; text-align: center; font-size: 12px; color: var(--muted); }

.notif-item {
    display: flex; gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--glass-border);
}
.notif-item:last-child { border-bottom: none; }
.notif-icon {
    width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
}
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: 12.5px; font-weight: 700; line-height: 1.3; }
.notif-desc { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.notif-time { font-size: 10.5px; color: var(--muted); margin-top: 4px; }

.notif-dropdown-footer {
    display: block;
    text-align: center;
    padding: 12px;
    font-size: 12px; font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    border-top: 1px solid var(--glass-border);
}
.notif-dropdown-footer:hover { background: rgba(16,185,129,0.06); }

/* ── Settings page ── */
.settings-card { padding: 24px; }
.settings-field-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}
.settings-field-group label {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--muted); margin-bottom: 6px; display: block;
}
.settings-section-title {
    font-size: 13px; font-weight: 700; margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px;
}
.settings-section-title .dot { width: 8px; height: 8px; border-radius: 50%; }
@media (max-width: 480px) {
    .settings-field-group { grid-template-columns: 1fr; }
}

/* ── Comparison cards (Analisis — Perbandingan Periode) ── */
.compare-card {
    padding: 18px;
    border-radius: var(--radius);
    background: rgba(0,0,0,0.02);
    border: 1px solid var(--glass-border);
}
body.dark-mode .compare-card { background: rgba(255,255,255,0.03); }
.compare-card .compare-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin-bottom: 8px; }
.compare-card .compare-values { display: flex; align-items: baseline; gap: 8px; }
.compare-card .compare-now { font-size: 22px; font-weight: 800; }
.compare-card .compare-prev { font-size: 12px; color: var(--muted); }
.delta-pill {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; font-weight: 700;
    padding: 3px 9px; border-radius: 20px;
    margin-top: 8px;
}
.delta-up { background: rgba(239,68,68,0.12); color: #ef4444; }
.delta-down { background: rgba(16,185,129,0.12); color: #10b981; }
.delta-flat { background: rgba(148,163,184,0.15); color: var(--muted); }

/* ── Toggle switch (filter mode: per bulan / custom range) ── */
.mode-switch {
    display: inline-flex;
    background: rgba(0,0,0,0.04);
    border-radius: var(--radius);
    padding: 4px;
    gap: 2px;
}
body.dark-mode .mode-switch { background: rgba(255,255,255,0.06); }
.mode-switch button {
    border: none; background: transparent;
    padding: 8px 14px; font-size: 12px; font-weight: 600;
    border-radius: 8px; cursor: pointer; color: var(--muted);
    transition: 0.2s;
}
.mode-switch button.active {
    background: var(--primary); color: #fff;
    box-shadow: 0 4px 10px rgba(16,185,129,0.3);
}

/* ================================================================
   HERO BANNER — Dashboard utama
   ================================================================ */
.hero-banner {
    background: linear-gradient(135deg, #0f766e 0%, #0ea5e9 55%, #6366f1 100%);
    border-radius: var(--radius-xl);
    padding: 28px 32px;
    margin-bottom: 28px;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
}
.hero-banner::before {
    content: '';
    position: absolute; inset: 0;
    background:
        radial-gradient(circle at 90% -10%, rgba(255,255,255,0.25), transparent 50%),
        radial-gradient(circle at 8% 120%, rgba(255,255,255,0.15), transparent 50%);
    pointer-events: none;
}
body.dark-mode .hero-banner { box-shadow: 0 20px 40px rgba(0,0,0,0.5); }

.hero-left { position: relative; z-index: 1; }
.hero-greeting { font-size: 13px; font-weight: 600; opacity: 0.85; margin-bottom: 4px; }
.hero-title { font-size: 26px; font-weight: 800; margin: 0; letter-spacing: -0.5px; color: #fff; }
.hero-date {
    font-size: 13px; opacity: 0.9; margin-top: 8px;
    display: flex; align-items: center; gap: 6px;
}

.hero-right { display: flex; align-items: center; gap: 18px; position: relative; z-index: 1; flex-wrap: wrap; }
.hero-actions { display: flex; align-items: center; gap: 10px; }

.hero-health-mini { position: relative; width: 64px; height: 64px; flex-shrink: 0; }
.hero-health-mini svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.hero-health-mini .ring-bg { fill: none; stroke: rgba(255,255,255,0.25); stroke-width: 6; }
.hero-health-mini .ring-progress {
    fill: none; stroke: #fff; stroke-width: 6; stroke-linecap: round;
    stroke-dasharray: 175.93; stroke-dashoffset: 175.93;
    transition: stroke-dashoffset 1.5s ease;
}
.hero-health-value {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 800; color: #fff;
}

/* Tombol & badge di dalam hero perlu kontras terang di atas background gradient */
.hero-actions .theme-toggle,
.hero-actions .notif-bell-btn {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.3);
    color: #fff;
}
.hero-actions .theme-toggle:hover,
.hero-actions .notif-bell-btn:hover {
    background: rgba(255,255,255,0.28);
    color: #fff;
}
.hero-actions .connection-badge {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.3);
    color: #fff;
}
.hero-actions .connection-badge.disconnected {
    background: rgba(239,68,68,0.3);
    border-color: rgba(239,68,68,0.45);
    color: #fff;
}
.hero-actions .conn-dot { background: #fff; box-shadow: 0 0 8px rgba(255,255,255,0.6); }
.hero-actions .connection-badge.disconnected .conn-dot { background: #fff; }

@media (max-width: 768px) {
    .hero-banner { padding: 60px 20px 20px; flex-direction: column; align-items: flex-start; }
    .hero-right { width: 100%; justify-content: space-between; }
    .hero-title { font-size: 21px; }
}

/* ================================================================
   SENSOR SPARKLINE — mini trend chart di tiap sensor card
   ================================================================ */
.sensor-sparkline {
    width: 100% !important;
    height: 34px !important;
    margin-top: 10px;
    display: block;
}
