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

:root {
    --bg-primary: #080b11;
    --bg-secondary: rgba(17, 24, 39, 0.7);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    
    --accent-temp: #f59e0b; /* Amber */
    --accent-humidity: #06b6d4; /* Cyan */
    --accent-energy: #10b981; /* Emerald */
    --accent-voltage: #ef4444; /* Red */
    --accent-current: #8b5cf6; /* Violet */
    --accent-power: #3b82f6; /* Blue */
    
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.05);
    --glow-strength: 15px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(at 10% 10%, rgba(59, 130, 246, 0.1) 0px, transparent 50%),
        radial-gradient(at 90% 10%, rgba(139, 92, 246, 0.08) 0px, transparent 50%),
        radial-gradient(at 50% 90%, rgba(16, 185, 129, 0.08) 0px, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 2rem 1.5rem;
    overflow-x: hidden;
}

h1, h2, h3, h4 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
}

/* Glassmorphism Card styling */
.glass-panel {
    background: var(--bg-secondary);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-panel:hover {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.45);
}

/* App Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.title-container h1 {
    font-size: 2.2rem;
    background: linear-gradient(135deg, #ffffff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

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

/* Control Row: Tab Buttons and Filter Settings */
.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Tabs UI */
.tabs-container {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 0.25rem;
    border-radius: 12px;
    display: flex;
    gap: 0.25rem;
}

.tab-btn {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-secondary);
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.tab-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Filters UI */
.filters-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-select, .date-input {
    background: rgba(17, 24, 39, 0.8);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.6rem 1rem;
    border-radius: 10px;
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.filter-select:focus, .date-input:focus {
    border-color: rgba(255, 255, 255, 0.3);
}

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

.metric-card {
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.metric-card.temp::before { background: var(--accent-temp); }
.metric-card.humidity::before { background: var(--accent-humidity); }
.metric-card.energy::before { background: var(--accent-energy); }
.metric-card.voltage::before { background: var(--accent-voltage); }
.metric-card.current::before { background: var(--accent-current); }
.metric-card.power::before { background: var(--accent-power); }

.metric-card.temp:hover { box-shadow: 0 0 20px rgba(245, 158, 11, 0.15); }
.metric-card.humidity:hover { box-shadow: 0 0 20px rgba(6, 182, 212, 0.15); }
.metric-card.energy:hover { box-shadow: 0 0 20px rgba(16, 185, 129, 0.15); }
.metric-card.voltage:hover { box-shadow: 0 0 20px rgba(239, 68, 68, 0.15); }
.metric-card.current:hover { box-shadow: 0 0 20px rgba(139, 92, 246, 0.15); }
.metric-card.power:hover { box-shadow: 0 0 20px rgba(59, 130, 246, 0.15); }

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

.metric-header svg {
    width: 20px;
    height: 20px;
}

.metric-value {
    font-family: 'Outfit', sans-serif;
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: baseline;
    gap: 0.2rem;
}

.metric-unit {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.metric-footer {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

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

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

.chart-card {
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

.chart-title {
    font-size: 1.1rem;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-container {
    position: relative;
    flex-grow: 1;
    width: 100%;
    height: 100%;
}

/* Data Table Panel */
.table-panel {
    margin-top: 2rem;
}

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

.table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

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

th {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

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

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(8, 11, 17, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(59, 130, 246, 0.1);
    border-radius: 50%;
    border-top-color: var(--accent-power);
    animation: spin 1s ease-in-out infinite;
}

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

.loading-text {
    margin-top: 1rem;
    font-size: 1.1rem;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.rotating {
    animation: spin 1s linear infinite;
}

@media (max-width: 600px) {
    body {
        padding: 1rem 0.75rem;
    }
    
    .app-header {
        margin-bottom: 1.5rem;
    }
    
    .title-container h1 {
        font-size: 1.8rem;
    }
    
    .glass-panel {
        padding: 1rem;
    }
    
    .metric-value {
        font-size: 1.8rem;
    }
    
    .controls-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .tabs-container {
        width: 100%;
    }
    
    .tab-btn {
        flex: 1;
        justify-content: center;
        padding: 0.6rem 0.5rem;
        font-size: 0.85rem;
    }
    
    .filters-container {
        width: 100%;
        justify-content: space-between;
    }
    
    .filter-select, .date-input {
        flex-grow: 1;
    }
}
