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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1000px; /* Increased for better desktop spacing */
    margin: 0 auto;
    padding: 0 20px;
}

.mobile-list-view {
    display: none;
}

/* CSS Grid Dashboard Layout (Command Center) */
.dashboard-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 0; /* Clean split */
    height: 600px; /* Fixed height for the widget feel */
    overflow: hidden;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid #eaeaea;
}

/* Left Column: Controls */
.dashboard-sidebar {
    background: #f8f9fa;
    border-right: 1px solid #eaeaea;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Right Column: Content */
.dashboard-content {
    background: white;
    padding: 0;
    min-height: 0; /* Allow shrinking for scroll */
    overflow-y: auto; /* Scrollable agenda */
    padding-bottom: 100px; /* Extra generous padding to prevent cutoff */
    position: relative; /* For sticky header context */
}

/* Mini Calendar Styling */
.mini-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-top: 10px;
}

.mini-calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 11px;
    color: #666;
    margin-bottom: 5px;
}

.mini-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    font-size: 13px;
    position: relative;
    transition: background 0.2s;
}

.mini-day:hover {
    background: #e2e8f0;
}

.mini-day.selected {
    background: #3b82f6;
    color: white;
}

.mini-day.other-month {
    color: #ccc;
}

.mini-day.today {
    color: #fc4c02;
    font-weight: bold;
}

/* Dots for Mini Calendar */
.mini-dots {
    display: flex;
    gap: 2px;
    margin-top: 2px;
    height: 4px;
}

.mini-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
}

.mini-dot.AM { background: #3b82f6; }
.mini-dot.PM { background: #f97316; }
.mini-dot.EVE { background: #a855f7; }
.mini-dot.ALL_DAY { background: #10b981; }

/* Sidebar Action Area */
.sidebar-actions {
    margin-top: auto; /* Push to bottom */
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-status {
    font-size: 12px;
    color: #666;
    text-align: center;
    margin-top: 10px;
}

/* Agenda View Styling */
.agenda-section-header {
    position: sticky;
    top: 0;
    background: #f8f9fa; /* Opaque background is crucial */
    padding: 10px 20px;
    font-weight: 600;
    color: #444;
    border-bottom: 1px solid #eaeaea;
    z-index: 10; /* Ensure it stays on top of items */
    box-shadow: 0 1px 2px rgba(0,0,0,0.05); /* Subtle shadow for separation */
}

.agenda-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.1s;
}

.agenda-item:hover {
    background: #fcfcfc;
}

.agenda-item.selected-day {
    background: #eff6ff; /* Light blue highlight for clicked date */
}

.agenda-date {
    width: 60px;
    text-align: center;
    margin-right: 15px;
    display: flex;
    flex-direction: column;
}

.agenda-day-num {
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

.agenda-day-name {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
}

.agenda-pill {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    margin-right: 15px;
    min-width: 45px;
    text-align: center;
}

.agenda-pill.AM { background: #3b82f6; }
.agenda-pill.PM { background: #f97316; }
.agenda-pill.EVE { background: #a855f7; }
.agenda-pill.ALL_DAY { background: #10b981; }
.agenda-pill.hidden { background: #e5e7eb; color: #9ca3af; }

.agenda-details {
    flex: 1;
}

.agenda-title {
    font-weight: 500;
    color: #333;
    margin-bottom: 2px;
}

.agenda-title.hidden {
    color: #9ca3af;
    text-decoration: line-through;
}

.agenda-gear {
    font-size: 12px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* --- Existing Header/Nav Styles below --- */

header {
    background: #ffffff;
    color: #333;
    padding: 0;
    margin-bottom: 30px;
    position: relative;
    z-index: 1001;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    height: 70px;
    display: flex;
    align-items: center;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 100%;
}

header h1 {
    font-size: 0;
    margin: 0;
    line-height: 1;
    display: flex;
    align-items: center;
}

header h1 a {
    display: block;
    text-decoration: none;
}

header h1 a:hover {
    opacity: 0.9;
}

.hamburger {
    display: none;
    background: transparent;
    border: none;
    color: #333;
    padding: 10px;
    cursor: pointer;
    z-index: 1002;
}

.hamburger-icon {
    display: inline-block;
    width: 24px;
    height: 18px;
    position: relative;
}

.hamburger-icon span {
    display: block;
    position: absolute;
    height: 2px;
    width: 100%;
    background: #333;
    border-radius: 2px;
    opacity: 1;
    left: 0;
    transform: rotate(0deg);
    transition: .25s ease-in-out;
}

.hamburger-icon span:nth-child(1) { top: 0px; }
.hamburger-icon span:nth-child(2) { top: 8px; }
.hamburger-icon span:nth-child(3) { top: 16px; }

.hamburger.active .hamburger-icon span:nth-child(1) { top: 8px; transform: rotate(135deg); }
.hamburger.active .hamburger-icon span:nth-child(2) { opacity: 0; left: -60px; }
.hamburger.active .hamburger-icon span:nth-child(3) { top: 8px; transform: rotate(-135deg); }

.nav-menu {
    display: flex;
    gap: 8px;
    align-items: center;
    background: transparent;
    padding: 0;
}

.nav-menu a {
    color: #555;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-menu a:hover {
    background: #f0f2f5;
    color: #fc4c02;
}

.nav-menu button {
    background: transparent;
    border: 1px solid #dc3545;
    color: #dc3545;
    padding: 6px 16px;
    font-size: 14px;
    border-radius: 20px;
    font-weight: 600;
    margin-left: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-menu button:hover {
    background: #dc3545;
    color: white;
}

.nav-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    opacity: 0.8;
}

.nav-menu a:hover .nav-icon {
    opacity: 1;
}

.nav-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.nav-backdrop.active {
    display: block;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000; /* High z-index to sit on top */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px); /* Optional blur */
}

.modal-content {
    background-color: white;
    margin: 5% auto; /* Center vertically */
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    position: relative; /* Ensure close button is relative to this */
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #333;
}

.detail-row {
    margin: 15px 0;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #eee;
}

.detail-label {
    font-weight: 600;
    color: #666;
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.detail-value {
    font-size: 16px;
    font-weight: 500;
    color: #333;
}

/* --- Mobile Responsive Styles --- */
@media (max-width: 768px) {
    header {
        height: 60px;
    }

    header .container {
        padding: 0 15px;
    }

    .hamburger {
        display: block;
    }

    /* Mobile Menu Drawer */
    .nav-menu {
        display: none;
        position: absolute;
        top: 60px;
        right: 15px;
        width: 260px;
        height: auto;
        max-height: calc(100vh - 75px);
        overflow-y: auto;
        flex-direction: column;
        background: white;
        padding: 15px;
        border-radius: 12px;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
        z-index: 1000;
        gap: 0;
        align-items: stretch;
        border: 1px solid #eee;
    }

    .nav-menu.active {
        display: flex;
        animation: slideLeft 0.2s ease-out;
    }

    .nav-menu a {
        color: #333;
        width: 100%;
        padding: 12px 15px;
        font-size: 16px;
        font-weight: 500;
        border-radius: 8px;
        justify-content: flex-start;
    }

    .nav-menu a:hover {
        background: #f8f9fa;
    }

    .nav-icon {
        width: 24px;
        height: 24px;
        opacity: 1;
    }

    .nav-menu button {
        margin-left: 0;
        margin-top: 15px;
        width: 100%;
        text-align: center;
        background: #fff1f0;
        border: 1px solid #ffccc7;
        color: #d93025;
        padding: 12px;
    }

    .nav-menu button:hover {
        background: #d93025;
        color: white;
    }

    /* --- Dashboard Specific Mobile Overrides --- */
    .dashboard-container {
        display: none; /* Hide desktop dashboard on mobile */
    }

    .mobile-list-view {
        display: block; /* Ensure mobile list is shown */
    }

    /* Restore Mobile Styles */
    .mobile-date-group {
        margin-bottom: 20px;
    }

    .mobile-date-header {
        font-size: 16px;
        font-weight: 600;
        padding: 10px;
        background: #f5f5f5;
        border-radius: 4px;
        margin-bottom: 8px;
    }

    .mobile-date-header.today {
        background: #fffbeb;
        border: 2px solid #fbbf24;
    }

    .mobile-workouts {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding-left: 10px;
    }

    .mobile-workout {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 10px;
        background: white;
        border: 1px solid #ddd;
        border-radius: 8px;
        cursor: pointer;
    }

    .mobile-workout:hover {
        background: #f9f9f9;
    }

    .workout-indicator {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 3px 8px;
        border-radius: 12px;
        font-size: 11px;
        font-weight: 600;
        color: white;
    }

    .workout-indicator.AM { background: #3b82f6; }
    .workout-indicator.PM { background: #f97316; }
    .workout-indicator.EVE { background: #a855f7; }
    .workout-indicator.ALL_DAY { background: #10b981; }
    .workout-indicator.hidden { background: #e5e7eb; color: #9ca3af; border: 1px dashed #d1d5db; }
    .mobile-workout.hidden { background: #f9fafb; opacity: 0.6; border: 1px dashed #e5e7eb; }
}

@keyframes slideLeft {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* --- General UI Components --- */

.card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid #eaeaea;
}

.card h2 {
    margin-bottom: 20px;
    color: #1a1a1a;
    font-size: 22px;
    font-weight: 700;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #444;
    font-size: 14px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
    transition: border-color 0.2s;
}

input:focus, select:focus {
    border-color: #fc4c02;
    outline: none;
}

input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
    transform: scale(1.2);
}

button {
    background: #fc4c02;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: transform 0.1s, background 0.2s;
}

button:hover {
    background: #e03c00;
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

button.secondary {
    background: #4a5568;
}

button.secondary:hover {
    background: #2d3748;
}

button.btn-small {
    padding: 6px 14px;
    font-size: 13px;
    margin-left: 10px;
}

button.btn-danger {
    background: #dc3545;
}

button.btn-danger:hover {
    background: #c82333;
}

button.btn-success {
    background: #28a745;
}

button.btn-success:hover {
    background: #218838;
}

button.btn-warning {
    background: #f59e0b;
    color: white;
}

button.btn-warning:hover {
    background: #d97706;
}

input:disabled,
select:disabled {
    background: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
}

.success {
    color: #155724;
    padding: 15px;
    background: #d4edda;
    border-radius: 6px;
    margin-bottom: 20px;
    border: 1px solid #c3e6cb;
}

.error {
    color: #721c24;
    padding: 15px;
    background: #f8d7da;
    border-radius: 6px;
    margin-bottom: 20px;
    border: 1px solid #f5c6cb;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-connected {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-disconnected {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.hidden {
    display: none;
}

.logout-btn {
    float: right;
    padding: 8px 16px;
    font-size: 12px;
}

.code-block {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 15px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 13px;
    overflow-x: auto;
    margin: 15px 0;
    color: #d63384; /* Distinct code color */
}

.flex-buttons {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.info-text {
    font-size: 15px;
    color: #666;
    margin-bottom: 20px;
    line-height: 1.6;
}