:root {
    --primary: #3498db;
    --secondary: #2ecc71;
    --tertiary: #e74c3c;
    --quaternary: #f39c12;
    --bg: #f8f9fa;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --card-bg: #ffffff;
    --sleep-light: #95a5a6;
    --sleep-deep: #34495e;
    --sleep-rem: #8e44ad;
    --sleep-awake: #e74c3c;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--bg) 0%, #e8f4f8 100%);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    margin: 0;
    padding: 2rem 0;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    grid-auto-rows: minmax(180px, auto);
    gap: clamp(1rem, 2vw, 1.5rem);
    padding: 0 clamp(0.5rem, 3vw, 1.5rem) clamp(1rem, 3vw, 2rem);
    max-width: 1400px;
    margin: 0 auto;
}

/* Layout-specific grid configurations */
.dashboard-grid.layout-desktop {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.dashboard-grid.layout-tablet {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    grid-auto-rows: minmax(160px, auto);
}

.dashboard-grid.layout-mobile {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    grid-auto-rows: minmax(140px, auto);
    padding: 0 0.5rem 1rem;
}


.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 0.8rem;
    color: var(--text-light);
}

.error {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #e74c3c;
    text-align: center;
}

/* Card Size Classes */
.card-1x1 { grid-column: span 1; grid-row: span 1; }
.card-2x1 { grid-column: span 2; grid-row: span 1; }
.card-2x2 { grid-column: span 2; grid-row: span 2; }
.card-3x2 { grid-column: span 3; grid-row: span 2; }

/* Responsive Breakpoints */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        grid-auto-rows: minmax(160px, auto);
    }
}

@media (max-width: 768px) {
    body {
        padding: 1rem 0;
    }

    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        grid-auto-rows: minmax(140px, auto);
        justify-items: stretch;
    }

    .card-2x1,
    .card-2x2,
    .card-3x2 {
        grid-column: span 1;
        grid-row: span 1;
    }
}

@media (max-width: 480px) {
    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        grid-auto-rows: minmax(120px, auto);
    }

    .card {
        text-align: center;
    }
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: clamp(1rem, 2vw, 1.5rem);
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 0;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text);
    white-space: normal;
    overflow-wrap: anywhere;
}

.card-1x1 .card-title {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.card-3x2 .card-title {
    font-size: 1.1rem;
    margin-bottom: 1.2rem;
}

/* Line Chart Styles */
.line-chart {
    height: 280px;
    position: relative;
    width: 100%;
}

.line-chart-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Current State Card */
.current-state {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1rem;
}

.current-state .card-title {
    color: white;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.current-time {
    font-size: 2rem;
    font-weight: 300;
    margin-bottom: 0.3rem;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.current-date {
    font-size: 0.8rem;
    opacity: 0.9;
    margin-bottom: 0.8rem;
    line-height: 1.2;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.7rem;
    margin: 0 auto;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ecc71;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Notification Mood Card */
.mood-display {
    text-align: center;
    padding: 0.5rem 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
}

.mood-emoji {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    display: block;
    line-height: 1;
}

.mood-label {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    line-height: 1;
}

.mood-description {
    color: var(--text-light);
    font-size: 0.7rem;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

.card-2x1 .mood-display + div {
    font-size: 0.7rem;
    line-height: 1.2;
}

/* Legend */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 1rem;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-light);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin-right: 6px;
}

/* Loading */
.loader {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100px;
}

.loader::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid rgba(52, 152, 219, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 1.5rem 1rem;
    }
    
    .header-title {
        font-size: 2rem;
    }
    
    .current-time {
        font-size: 2.5rem;
    }
}
