/* ============================================================
   NHÀ MÀNG THÔNG MINH - DASHBOARD STYLES
   ============================================================ */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #1e2130;
    --bg-card-hover: #252839;
    --border-color: rgba(255, 255, 255, 0.06);
    --text-primary: #f0f0f5;
    --text-secondary: #8b8fa3;
    --text-muted: #5a5e72;

    --accent-green: #22c55e;
    --accent-green-glow: rgba(34, 197, 94, 0.15);
    --accent-blue: #3b82f6;
    --accent-blue-glow: rgba(59, 130, 246, 0.15);
    --accent-orange: #f59e0b;
    --accent-orange-glow: rgba(245, 158, 11, 0.15);
    --accent-purple: #a855f7;
    --accent-purple-glow: rgba(168, 85, 247, 0.15);
    --accent-red: #ef4444;
    --accent-cyan: #06b6d4;

    --radius: 16px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Be Vietnam Pro', -apple-system, sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Ambient background glow */
body::before {
    content: '';
    position: fixed;
    top: -200px;
    right: -200px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(34, 197, 94, 0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    bottom: -200px;
    left: -200px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ======================== HEADER ======================== */

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    background: rgba(26, 29, 39, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 28px;
    animation: pulse-gentle 3s ease-in-out infinite;
}

@keyframes pulse-gentle {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.logo h1 {
    font-size: 20px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent-green), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-orange);
    border: 1px solid rgba(245, 158, 11, 0.2);
    transition: var(--transition);
}

.badge.connected {
    background: rgba(34, 197, 94, 0.15);
    color: var(--accent-green);
    border-color: rgba(34, 197, 94, 0.2);
}

.badge.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    border-color: rgba(239, 68, 68, 0.2);
}

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

.clock {
    font-size: 14px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.btn-settings {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-settings:hover {
    background: var(--bg-card-hover);
    transform: rotate(45deg);
}

/* ======================== MODAL ======================== */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    width: 90%;
    max-width: 440px;
    box-shadow: var(--shadow);
    animation: slideUp 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
}

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-group input,
.form-group select {
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-green);
    box-shadow: 0 0 0 3px var(--accent-green-glow);
}

.btn-primary {
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--accent-green), #16a34a);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.3);
}

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

.dashboard {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 32px;
    position: relative;
    z-index: 1;
}

/* ======================== CARDS ======================== */

.cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.card-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.card-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-value {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin: 8px 0;
}

.card-value span:first-child {
    font-size: 36px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.card-unit {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 500;
}

.card-trend {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

.trend-arrow {
    font-weight: 700;
}

.trend-up { color: var(--accent-red); }
.trend-down { color: var(--accent-blue); }
.trend-stable { color: var(--accent-green); }

/* Card accent borders */
.card-temp { border-top: 3px solid var(--accent-orange); }
.card-humid { border-top: 3px solid var(--accent-blue); }
.card-status { border-top: 3px solid var(--accent-green); }
.card-count { border-top: 3px solid var(--accent-purple); }

/* Progress bar */
.card-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.03);
}

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

.temp-bar {
    background: linear-gradient(90deg, var(--accent-green), var(--accent-orange), var(--accent-red));
}

.humid-bar {
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue));
}

/* Status text */
.status-text {
    font-size: 28px !important;
}

.status-online { color: var(--accent-green); }
.status-offline { color: var(--accent-red); }

/* ======================== CHARTS ======================== */

.charts-grid {
    margin-bottom: 24px;
}

.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.chart-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.chart-actions {
    display: flex;
    gap: 6px;
}

.btn-chart {
    padding: 6px 14px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-chart:hover {
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.btn-chart.active {
    background: var(--accent-green-glow);
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.chart-wrapper {
    height: 320px;
    position: relative;
}

/* ======================== TABLE ======================== */

.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
}

.btn-export {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-export:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background: var(--accent-blue-glow);
}

.table-wrapper {
    overflow-x: auto;
    max-height: 320px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--bg-card);
}

td {
    padding: 10px 16px;
    font-size: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-variant-numeric: tabular-nums;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.empty-row {
    text-align: center;
    color: var(--text-muted);
    padding: 40px !important;
}

/* ======================== FOOTER ======================== */

.footer {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border-color);
    margin-top: 24px;
}

/* ======================== RESPONSIVE ======================== */

@media (max-width: 1024px) {
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .header {
        padding: 12px 16px;
        flex-direction: column;
        gap: 12px;
    }

    .logo h1 {
        font-size: 16px;
    }

    .dashboard {
        padding: 16px;
    }

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

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

    .chart-wrapper {
        height: 240px;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
