/* ============================================
   Xovis Dashboard - Professional Medical Theme
   Font: Outfit (Headlines) + JetBrains Mono (Numbers)
   ============================================ */

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

:root {
    --accent: #0077B6;
    --accent-light: #90E0EF;
    --accent-soft: rgba(0, 119, 182, 0.08);
    --accent-glow: rgba(0, 119, 182, 0.15);
    --green: #2DC653;
    --green-soft: rgba(45, 198, 83, 0.1);
    --green-border: rgba(45, 198, 83, 0.25);
    --red: #E63946;
    --red-soft: rgba(230, 57, 70, 0.1);
    --red-border: rgba(230, 57, 70, 0.25);
    --bg: #F0F4F8;
    --surface: #FFFFFF;
    --surface-raised: #FFFFFF;
    --text: #1B2A4A;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --border: #E2E8F0;
    --ring-bg: #E2E8F0;
    --shadow-sm: 0 1px 2px rgba(27, 42, 74, 0.04);
    --shadow-md: 0 4px 16px rgba(27, 42, 74, 0.06);
    --shadow-lg: 0 8px 32px rgba(27, 42, 74, 0.08);
    --shadow-accent: 0 4px 24px rgba(0, 119, 182, 0.12);
    --radius: 14px;
    --radius-sm: 10px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Outfit', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

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

.dashboard {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 28px 40px;
}

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

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

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

.logo-img {
    height: 28px;
    width: auto;
}

.logo-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    border-left: 2px solid var(--accent);
    padding-left: 14px;
}

.logo-subtitle {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.03em;
}

h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

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

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: var(--transition);
}

.status-dot.connected {
    background: var(--green);
    box-shadow: 0 0 0 3px var(--green-soft);
    animation: pulse-green 2s ease infinite;
}

.status-dot.disconnected {
    background: var(--red);
    box-shadow: 0 0 0 3px var(--red-soft);
}

@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 0 3px var(--green-soft); }
    50% { box-shadow: 0 0 0 6px rgba(45, 198, 83, 0.05); }
}

.clock {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    min-width: 52px;
}

/* ============ HERO SECTION ============ */

.hero-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 16px;
}

.hero-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 36px 32px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

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

.hero-card:hover {
    box-shadow: var(--shadow-accent);
}

.hero-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.hero-label svg {
    color: var(--accent);
    flex-shrink: 0;
}

.hero-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 4.5rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
    letter-spacing: -0.03em;
    transition: color var(--transition);
}

.hero-subtext {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 6px;
    font-weight: 400;
}

.hero-ring {
    flex-shrink: 0;
    width: 100px;
    height: 100px;
}

.ring-svg {
    width: 100%;
    height: 100%;
}

.ring-svg circle:last-child {
    transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Metric Cards */
.metric-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.metric-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 22px 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.metric-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.metric-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.metric-in .metric-icon {
    background: var(--green-soft);
    border: 1px solid var(--green-border);
    color: var(--green);
}

.metric-out .metric-icon {
    background: var(--red-soft);
    border: 1px solid var(--red-border);
    color: var(--red);
}

.metric-data {
    display: flex;
    flex-direction: column;
}

.metric-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.metric-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 2px;
}

/* Value Animation */
.hero-value.updated,
.metric-value.updated {
    animation: value-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes value-pop {
    0% { transform: scale(1); }
    40% { transform: scale(1.08); color: var(--accent); }
    100% { transform: scale(1); }
}

/* ============ UPDATE BAR ============ */

.update-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 28px;
    padding: 8px 0;
}

.update-bar svg {
    opacity: 0.5;
}

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

.charts-section {
    margin-bottom: 32px;
}

.tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 8px 8px 0;
}

.tab {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 20px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: var(--transition);
    position: relative;
}

.tab:hover {
    color: var(--text-secondary);
    background: var(--accent-soft);
}

.tab.active {
    color: var(--accent);
    background: var(--accent-soft);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 12px;
    right: 12px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px 2px 0 0;
}

.tab svg {
    opacity: 0.6;
}

.tab.active svg {
    opacity: 1;
}

.chart-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 28px;
    box-shadow: var(--shadow-md);
}

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

.chart-header h2 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}

.month-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.month-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.month-nav-btn:hover {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
}

.month-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.chart-hint {
    font-size: 0.72rem;
    color: var(--text-muted, #94A3B8);
    margin-bottom: 8px;
    opacity: 0.7;
}

.chart-summary {
    display: flex;
    gap: 16px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.chart-summary .stat {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: var(--bg);
    border-radius: 6px;
    font-weight: 500;
}

.chart-summary .stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--text);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.chart-container {
    position: relative;
    height: 320px;
    width: 100%;
}

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

footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.78rem;
    padding: 16px 0;
}

.footer-sep {
    opacity: 0.3;
}

/* ============ LOAD ANIMATION ============ */

.dashboard {
    animation: dashboard-in 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes dashboard-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.hero-card, .metric-card {
    animation: card-in 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.hero-card { animation-delay: 0.1s; }
.metric-card:nth-child(1) { animation-delay: 0.2s; }
.metric-card:nth-child(2) { animation-delay: 0.3s; }

@keyframes card-in {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

@media (max-width: 768px) {
    .dashboard {
        padding: 16px 16px 32px;
    }

    .header {
        margin-bottom: 24px;
    }

    h1 {
        font-size: 1.15rem;
    }

    .hero-section {
        grid-template-columns: 1fr;
    }

    .hero-card {
        padding: 28px 24px;
    }

    .hero-value {
        font-size: 3.5rem;
    }

    .hero-ring {
        width: 80px;
        height: 80px;
    }

    .metric-cards {
        flex-direction: row;
    }

    .metric-card {
        flex: 1;
    }

    .metric-value {
        font-size: 1.4rem;
    }

    .tabs {
        padding: 6px 6px 0;
    }

    .tab {
        flex: 1;
        justify-content: center;
        padding: 9px 12px;
        font-size: 0.82rem;
    }

    .tab svg {
        display: none;
    }

    .chart-panel {
        padding: 20px 16px;
    }

    .chart-container {
        height: 250px;
    }

    .chart-summary {
        flex-wrap: wrap;
        gap: 8px;
    }

    .header-right {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 400px) {
    .metric-cards {
        flex-direction: column;
    }

    .hero-value {
        font-size: 3rem;
    }
}

/* ============ DARK MODE ============ */

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0C1222;
        --surface: #162032;
        --surface-raised: #1C2840;
        --text: #E8EDF5;
        --text-secondary: #8899B0;
        --text-muted: #5A6D87;
        --border: #243044;
        --ring-bg: #243044;
        --accent-soft: rgba(0, 119, 182, 0.12);
        --green-soft: rgba(45, 198, 83, 0.12);
        --green-border: rgba(45, 198, 83, 0.2);
        --red-soft: rgba(230, 57, 70, 0.12);
        --red-border: rgba(230, 57, 70, 0.2);
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.15);
        --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
        --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.25);
        --shadow-accent: 0 4px 24px rgba(0, 119, 182, 0.2);
    }
}
