:root {
    --bg-color: #0f172a;
    --sidebar-bg: #1e293b;
    --text-color: #e2e8f0;
    --text-muted: #94a3b8;
    --primary-color: #38bdf8;
    --hover-bg: #334155;
    --border-color: #334155;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100%;
}

/* Sidebar Styles */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.sidebar-header {
    margin-bottom: 2rem;
}

.sidebar-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.user-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
}

.user-item {
    margin-bottom: 0.5rem;
}

.user-link {
    display: block;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.user-link:hover {
    background-color: var(--hover-bg);
    transform: translateX(4px);
}

.user-link.active {
    background-color: rgba(56, 189, 248, 0.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.user-zwift-id {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Main Content Styles */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background: radial-gradient(circle at top right, #1e293b 0%, transparent 40%);
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 1.125rem;
}

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

.header-meta {
    display: flex;
    flex-direction: column;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-filter {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-muted);
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.btn-filter:hover {
    color: var(--text-color);
    border-color: var(--text-muted);
    background-color: var(--hover-bg);
}

.btn-filter.active {
    background-color: var(--primary-color);
    color: #0f172a;
    border-color: var(--primary-color);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.stat-card {
    background-color: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    text-align: center;
}

.stat-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.text-green {
    color: #4ade80;
}

.text-red {
    color: #f87171;
}

.text-neutral {
    color: var(--text-color);
}


.user-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
}

/* Table Styles (Placeholder for now) */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th,
td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

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

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 100;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(56, 189, 248, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 1rem;
}

.loading-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
}

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

/* Sidebar Button */
.btn-add {
    width: 100%;
    padding: 0.75rem;
    background-color: transparent;
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
    margin-bottom: 1rem;
}

.btn-add:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background-color: rgba(56, 189, 248, 0.05);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal {
    background-color: var(--sidebar-bg);
    padding: 2rem;
    border-radius: 0.75rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.5rem;
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-color);
    font-size: 1rem;
    box-sizing: border-box;
    /* Fix sizing */
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-size: 0.875rem;
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-muted);
}

.btn-secondary:hover {
    color: var(--text-color);
}

.btn-primary {
    background-color: var(--primary-color);
    color: #0f172a;
    /* Dark text for contrast */
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-delete {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-delete:hover {
    color: #ef4444;
    /* Red-500 */
    background: rgba(239, 68, 68, 0.1);
}

/* Mobile Responsive Layout */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        padding: 1rem;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        box-sizing: border-box;
    }

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

    .sidebar-title {
        font-size: 1rem;
        margin: 0;
    }

    .btn-add {
        width: auto;
        margin-bottom: 0;
        padding: 0.4rem 0.8rem;
    }

    .user-list {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        gap: 0.5rem;
        padding-bottom: 0.25rem;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        margin-top: 1rem;
    }

    .user-item {
        margin-bottom: 0;
        flex: 0 0 auto;
    }

    .user-link {
        padding: 0.5rem 0.75rem;
        background-color: rgba(255, 255, 255, 0.03);
        border: 1px solid var(--border-color);
    }

    .user-link:hover {
        transform: none;
    }

    .user-zwift-id {
        display: none;
        /* Hide ID to save space on mobile */
    }

    .main-content {
        padding: 1rem;
    }

    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .header-meta {
        width: 100%;
    }

    .filter-actions {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }

    /* Make charts scrollable if needed or resize */
    #power_chart {
        min-height: 300px;
    }
}