* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Roboto', sans-serif;
}

body {
    background-color: #f5f5f5;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    color: #3a3a3a;
    margin-bottom: 10px;
}

header p {
    font-size: 1.2rem;
    color: #666;
}

/* Navigation Links */
.nav-links {
    margin-top: 15px;
    display: flex;
    gap: 15px;
    justify-content: center;
}

.nav-link {
    color: #3498db;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 20px;
    background-color: #e8f4fc;
    transition: all 0.3s;
    font-weight: 500;
}

.nav-link:hover {
    background-color: #3498db;
    color: white;
}

.main-content {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.camera-panels {
    display: flex;
    flex: 1 1 100%;
    gap: 16px;
    flex-wrap: wrap;
    min-width: 0;
}

.camera-panels .video-container {
    flex: 1 1 320px;
    min-width: 280px;
}

.camera-panels .body-panel {
    min-height: 650px;
}

.panel-toggle-bar {
    flex: 1 1 100%;
    display: flex;
    justify-content: flex-end;
}

.panel-toggle-bar .toggle-btn {
    width: auto;
    margin-top: 0;
}

.face-panel.hidden,
.facial-status.hidden,
.input-group.hidden {
    display: none;
}

.panel-title {
    position: absolute;
    top: 10px;
    left: 12px;
    z-index: 2;
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.45);
    padding: 4px 10px;
    border-radius: 12px;
}

.face-panel {
    border: 2px solid rgba(155, 89, 182, 0.35);
}

.face-panel .video-placeholder {
    background: linear-gradient(145deg, #2d1b4e, #1a1a2e);
}

.placeholder-hint {
    font-size: 0.8rem;
    color: #aaa;
    margin-top: 6px;
}

.facial-status {
    border-top: 3px solid #9b59b6;
}

.facial-fatigue-score.level-fresh,
.facial-fatigue-level.level-fresh { color: #27ae60; }
.facial-fatigue-score.level-moderate,
.facial-fatigue-level.level-moderate { color: #f39c12; }
.facial-fatigue-score.level-high,
.facial-fatigue-level.level-high { color: #e67e22; }
.facial-fatigue-score.level-critical,
.facial-fatigue-level.level-critical { color: #e74c3c; }

.video-container {
    flex: 1 1 600px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    background: linear-gradient(145deg, #1a1a2e, #16213e);
    min-height: 400px;
    position: relative;
}

.video-container img {
    width: 100%;
    height: auto;
    display: block;
}

/* AI encouragement banner - shown on the final rep of a set */
.encouragement-banner {
    position: absolute;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%) translateY(0);
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 90%;
    padding: 14px 22px;
    border-radius: 999px;
    background: linear-gradient(135deg, #e74c3c, #f39c12);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.5);
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    z-index: 5;
    animation: encouragement-pulse 1.4s ease-in-out infinite;
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 1;
}

.encouragement-banner.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(12px);
    pointer-events: none;
}

.encouragement-icon {
    font-size: 1.3rem;
}

.encouragement-text {
    white-space: normal;
    line-height: 1.3;
}

@keyframes encouragement-pulse {
    0%, 100% { box-shadow: 0 6px 20px rgba(231, 76, 60, 0.5); }
    50% { box-shadow: 0 6px 28px rgba(231, 76, 60, 0.85); }
}

/* Video Placeholder for lazy camera loading */
.video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #1a1a2e, #16213e);
}

.placeholder-content {
    text-align: center;
    color: white;
}

.placeholder-icon {
    font-size: 4rem;
    margin-bottom: 15px;
    opacity: 0.8;
}

.placeholder-content p {
    font-size: 1.1rem;
    color: #888;
    margin-bottom: 20px;
}

.placeholder-content .btn {
    padding: 12px 30px;
    font-size: 1rem;
}

.controls {
    flex: 1 1 300px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.controls h2 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: #3a3a3a;
    border-bottom: 2px solid #3498db;
    padding-bottom: 5px;
}

.exercise-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.exercise-option {
    flex: 1 1 calc(33% - 10px);
    min-width: 80px;
    background-color: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
    text-align: center;
}

.exercise-option:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.exercise-option.selected {
    border: 2px solid #3498db;
    transform: translateY(-5px);
}

.exercise-option img {
    width: 100%;
    height: 100px;
    object-fit: cover;
}

.exercise-option h3 {
    padding: 10px;
    font-size: 1rem;
}

.config-inputs {
    display: flex;
    gap: 15px;
}

.input-group {
    flex: 1;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.input-group input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

.btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s;
}

.primary-btn {
    background-color: #3498db;
    color: white;
}

.primary-btn:hover {
    background-color: #2980b9;
}

.secondary-btn {
    background-color: #e74c3c;
    color: white;
}

.secondary-btn:hover {
    background-color: #c0392b;
}

.btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.toggle-btn {
    width: 100%;
    margin-top: 12px;
    background-color: #7f8c8d;
    color: white;
}

.toggle-btn:hover {
    background-color: #6c7a7b;
}

.toggle-btn.is-on {
    background-color: #27ae60;
}

.toggle-btn.is-on:hover {
    background-color: #219150;
}

#csv-dir-group {
    margin-top: 10px;
}

#csv-dir-group.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.csv-path-hint {
    font-size: 0.8rem;
    color: #888;
    margin-top: 6px;
    word-break: break-all;
}

.csv-path-hint.active {
    color: #27ae60;
}

.voice-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.voice-picker label {
    margin: 0;
    white-space: nowrap;
}

.voice-picker select {
    flex: 1;
    padding: 8px 10px;
    border-radius: 5px;
    border: 1px solid #ccc;
    font-size: 0.9rem;
}

.voice-preview-btn {
    flex: 0 0 auto;
    padding: 8px 14px;
    font-size: 0.9rem;
}

.workout-status {
    background-color: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.status-display {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid #eee;
}

.status-label {
    font-weight: 500;
    color: #555;
}

.status-value {
    font-weight: 700;
    color: #3498db;
}

.fatigue-score.level-fresh,
.fatigue-level.level-fresh { color: #27ae60; }
.fatigue-score.level-warming_up,
.fatigue-level.level-warming_up { color: #7f8c8d; }
.fatigue-score.level-moderate,
.fatigue-level.level-moderate { color: #f39c12; }
.fatigue-score.level-high,
.fatigue-level.level-high { color: #e67e22; }
.fatigue-score.level-critical,
.fatigue-level.level-critical { color: #e74c3c; }

.fatigue-signals {
    margin-top: 12px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
}

.fatigue-signal {
    display: flex;
    justify-content: space-between;
    color: #555;
}

.fatigue-signal span:last-child {
    font-weight: 600;
    color: #2c3e50;
}

.fatigue-messages {
    margin-top: 10px;
}

.fatigue-msg {
    font-size: 0.85rem;
    color: #c0392b;
    background: #fdecea;
    padding: 8px 10px;
    border-radius: 5px;
    margin-bottom: 6px;
    border-left: 3px solid #e74c3c;
}

.fatigue-msg.facial-msg {
    color: #6c3483;
    background: #f4ecf7;
    border-left-color: #9b59b6;
}

.face-panel img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

/* Category Tabs */
.category-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.category-tab {
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    background-color: #e0e0e0;
    color: #555;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s;
}

.category-tab:hover {
    background-color: #3498db;
    color: white;
}

.category-tab.active {
    background-color: #3498db;
    color: white;
}

/* Exercise Grid - Compact */
.exercise-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    max-height: 280px;
    overflow-y: auto;
    padding: 5px;
}

.exercise-option {
    background-color: white;
    border-radius: 8px;
    padding: 10px 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    text-align: center;
    position: relative;
}

.exercise-option:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.exercise-option.selected {
    border: 2px solid #3498db;
    background-color: #e8f4fc;
}

.exercise-icon {
    font-size: 1.8rem;
    margin-bottom: 5px;
}

.exercise-option h3 {
    font-size: 0.75rem;
    margin-bottom: 5px;
    color: #333;
}

.exercise-type-badge {
    display: inline-block;
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 10px;
    color: white;
}

/* Exercise Info Panel */
.exercise-info {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    padding: 15px;
    margin-top: 10px;
    color: white;
}

.exercise-info.hidden {
    display: none;
}

.info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.info-name {
    font-size: 1.1rem;
    font-weight: 700;
}

.info-type {
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 15px;
    background-color: rgba(255,255,255,0.2);
}

.info-description {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 10px;
}

.info-note {
    background-color: rgba(255,255,255,0.15);
    border-radius: 5px;
    padding: 8px 10px;
    font-size: 0.8rem;
    line-height: 1.4;
}

/* Exercise Count */
.exercise-count {
    font-size: 0.9rem;
    color: #888;
    font-weight: normal;
}

/* Form Score Styles */
.form-score {
    font-size: 1.1rem;
}

.form-grade {
    font-size: 1.2rem;
    padding: 2px 10px;
    border-radius: 5px;
}

.grade-a { background-color: #27ae60; color: white; }
.grade-b { background-color: #3498db; color: white; }
.grade-c { background-color: #f1c40f; color: #333; }
.grade-d { background-color: #e67e22; color: white; }
.grade-f { background-color: #e74c3c; color: white; }

/* Loading and Error */
.loading, .error {
    text-align: center;
    padding: 20px;
    color: #888;
}

.error {
    color: #e74c3c;
}

/* Scrollbar styling */
.exercise-options::-webkit-scrollbar {
    width: 6px;
}

.exercise-options::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.exercise-options::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.exercise-options::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .config-inputs {
        flex-direction: column;
    }
    
    .exercise-options {
        grid-template-columns: repeat(3, 1fr);
    }
}
