@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    /* Rich dark theme colors */
    --bg-base: #0f172a;
    /* Deep slate */
    --bg-surface: #1e293b;
    /* Slightly lighter slate */
    --bg-surface-elevated: #334155;

    --primary: #3b82f6;
    /* Vibrant blue */
    --primary-glow: rgba(59, 130, 246, 0.4);
    --secondary: #8b5cf6;
    /* Purple */
    --accent: #f59e0b;
    /* Amber/Orange */
    --success: #10b981;
    /* Emerald Green */
    --error: #ef4444;
    /* Red */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.08);

    /* Glassmorphism */
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-blur: blur(12px);

    /* Shadows */
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.4);

    /* Layout */
    --sidebar-width: 280px;
    --transition-speed: 0.3s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    overflow-x: hidden;
    line-height: 1.5;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 var(--primary-glow);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(59, 130, 246, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

/* Base Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.logo {
    padding: 2rem;
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-main);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo i {
    -webkit-text-fill-color: var(--primary);
    font-size: 1.8rem;
}

.main-nav {
    flex: 1;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.main-nav a {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 2rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: all var(--transition-speed) ease;
    border-left: 3px solid transparent;
}

.main-nav a i {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.main-nav a:hover,
.main-nav a.active {
    color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
    /* very light primary */
    border-left-color: var(--primary);
}

.user-profile {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-profile .avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.user-profile .user-info h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.user-profile .user-info p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Main Content Surface */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem 3rem;
    max-width: 1600px;
    animation: fadeIn 0.5s ease;
}

/* Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.top-header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    margin-top: 0.2rem;
}

.period-selector {
    display: flex;
    background: var(--bg-surface);
    border-radius: 30px;
    padding: 0.3rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.period-selector button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 1.2rem;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    font-family: 'Outfit', sans-serif;
}

.period-selector button:hover {
    color: var(--text-main);
}

.period-selector button.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

/* Views Container */
#views-container {
    position: relative;
}

.view {
    display: none;
    animation: fadeIn 0.4s ease;
}

.view.active {
    display: block;
}

.card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: var(--shadow-sm);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.var-primary {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
}

.var-accent {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent);
}

.var-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.var-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.stat-details h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.3rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
}

.stat-value small {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Main Dashboard layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.chart-card,
.recent-sessions-card {
    background: var(--glass-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.card-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.view-all {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

.view-all:hover {
    color: var(--text-main);
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Recent Sessions List */
.sessions-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.session-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    transition: all 0.2s;
    cursor: pointer;
}

.session-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--glass-border);
    transform: translateX(5px);
}

.session-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    height: 60px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 12px;
    color: var(--primary);
}

.session-date .day {
    font-weight: 700;
    font-size: 1.2rem;
}

.session-date .month {
    font-size: 0.8rem;
    text-transform: uppercase;
}

.session-meta {
    flex: 1;
}

.session-meta h4 {
    margin-bottom: 0.2rem;
    font-weight: 600;
}

.session-meta p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.session-stat {
    text-align: right;
}

.session-stat .val {
    font-weight: 600;
}

.session-stat .unit {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.data-table tbody tr {
    transition: background 0.2s;
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.btn-icon {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--primary);
    color: white;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-surface);
    border-radius: 24px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--glass-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 2rem;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.btn-close:hover {
    color: var(--error);
}

/* Live Session */
.live-dashboard {
    background: var(--glass-bg);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.live-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 30px;
    margin-bottom: 2rem;
    color: var(--text-muted);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
}

.live-status.active .status-indicator {
    background: var(--primary);
    animation: pulse 2s infinite;
}

.live-metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

@media (min-width: 1024px) {
    .live-metrics-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.live-metric {
    background: rgba(255, 255, 255, 0.03);
    padding: 2rem;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.metric-label {
    display: block;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.live-metric .metric-value {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

.live-metric .metric-value small {
    font-size: 1.2rem;
}

.btn {
    padding: 1rem 2rem;
    border-radius: 12px;
    border: none;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-error {
    background: var(--error);
    color: white;
}

.btn-error:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Toasts */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-surface-elevated);
    color: var(--text-main);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    display: flex;
    align-items: center;
    gap: 1rem;
    animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
    min-width: 250px;
}

.toast.error {
    border-left-color: var(--error);
}

.toast.success {
    border-left-color: var(--success);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-bottom: 85px;
    }

    /* Space for bottom nav */
    .top-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    /* Bottom Mobile Navigation */
    .sidebar {
        width: 100%;
        height: auto;
        position: fixed;
        bottom: 0;
        left: 0;
        border-right: none;
        border-top: 1px solid var(--border);
        flex-direction: row;
        padding: 0;
        background: rgba(15, 23, 42, 0.9);
        backdrop-filter: blur(20px);
        z-index: 1000;
    }

    .logo,
    .user-profile {
        display: none;
    }

    .main-nav {
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        width: 100%;
        padding: 0.5rem;
    }

    .main-nav a {
        flex-direction: column;
        padding: 0.5rem;
        gap: 0.3rem;
        font-size: 0.75rem;
        border-left: none;
        border-bottom: 3px solid transparent;
        border-radius: 12px;
        flex: 1;
        text-align: center;
    }

    .main-nav a i {
        font-size: 1.4rem;
        margin: 0 auto;
    }

    .main-nav a:hover,
    .main-nav a.active {
        background: rgba(59, 130, 246, 0.1);
        border-left-color: transparent;
        border-bottom-color: var(--primary);
        color: var(--primary);
    }

    /* Optimize view padding for mobile */
    .card {
        padding: 1rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .live-dashboard {
        padding: 1rem;
    }

    .live-metrics-grid {
        gap: 0.5rem;
    }

    .live-metric {
        padding: 1rem;
    }
}

/* Auth Page Styles */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-base);
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 3rem 2.5rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    animation: fadeIn 0.4s ease;
}

.auth-container h1 {
    margin-bottom: 2rem;
    font-size: 1.8rem;
    font-weight: 700;
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 0.9rem 1.2rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.4);
    color: white;
    font-family: inherit;
    transition: all 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(15, 23, 42, 0.6);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.alert {
    padding: 1rem;
    border-radius: 12px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    margin-bottom: 1.5rem;
    border: 1px solid rgba(239, 68, 68, 0.2);
    text-align: left;
    font-size: 0.9rem;
}

.toggle-mode {
    margin-top: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
    transition: color 0.2s;
}

.toggle-mode:hover {
    color: var(--primary);
    text-decoration: underline;
}