/* ============================================
   RESET & BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-primary: #A8D8EA;
    --color-secondary: #FFB6B9;
    --color-success: #B5E7A0;
    --color-warning: #FFD97D;
    --color-danger: #FF9A9A;
    --color-bg: #F8F9FD;
    --color-card: #FFFFFF;
    --color-text: #333333;
    --color-text-light: #666666;
    --color-border: #E0E6ED;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
    --radius: 16px;
    --radius-sm: 12px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
}

.container {
    max-width: 480px;
    margin: 0 auto;
}

/* ============================================
   HEADER
   ============================================ */
header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 28px;
    color: var(--color-text);
    margin-bottom: 8px;
}

.subtitle {
    font-size: 16px;
    color: var(--color-text-light);
}

.header-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.back-btn, .home-btn {
    background: var(--color-card);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--color-text);
}

.back-btn:hover, .home-btn:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    transform: translateX(-2px);
}

.home-btn {
    background: var(--color-success);
    border-color: var(--color-success);
    color: white;
}

.home-btn:hover {
    background: #9dd68d;
    border-color: #9dd68d;
    transform: scale(1.05);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    border: none;
    border-radius: var(--radius);
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: var(--shadow-sm);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:not(:disabled):active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-secondary {
    background: var(--color-secondary);
    color: white;
}

.btn-success {
    background: var(--color-success);
    color: white;
}

.icon {
    font-size: 18px;
}

/* ============================================
   PAGE 1 - ENREGISTREMENT
   ============================================ */
.recording-section {
    background: var(--color-card);
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: var(--shadow-md);
}

.waveform-container {
    width: 100%;
    height: 120px;
    background: linear-gradient(135deg, #E8F4F8 0%, #D4E8F0 100%);
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#waveform {
    width: 100%;
    height: 100%;
}

.timer-display {
    text-align: center;
    margin-bottom: 24px;
}

#timer {
    font-size: 48px;
    font-weight: 700;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}

.controls {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    justify-content: center;
}

.controls .btn {
    flex: 1;
    flex-direction: column;
    padding: 20px 12px;
    font-size: 14px;
}

.controls .icon {
    font-size: 24px;
    margin-bottom: 4px;
}

#sendBtn {
    width: 100%;
    margin-top: 12px;
}

.status-message {
    text-align: center;
    margin-top: 16px;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.status-message.success {
    background: #E8F8E8;
    color: #2D7A2D;
}

.status-message.error {
    background: #FFE8E8;
    color: #C62828;
}

/* ============================================
   PAGE 2 - ANALYSE
   ============================================ */
.analysis-section {
    background: var(--color-card);
    border-radius: var(--radius);
    padding: 40px 30px;
    box-shadow: var(--shadow-md);
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner-container {
    text-align: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner-text {
    color: var(--color-text-light);
    font-size: 16px;
}

.result-container {
    width: 100%;
    text-align: center;
}

.result-card {
    background: linear-gradient(135deg, #F0F8FF 0%, #E6F3FF 100%);
    border-radius: var(--radius);
    padding: 30px;
    margin-bottom: 24px;
}

.result-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.result-card h2 {
    font-size: 24px;
    margin-bottom: 12px;
    color: var(--color-text);
}

.result-message {
    font-size: 18px;
    color: var(--color-text-light);
    margin-bottom: 20px;
}

.result-details {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    background: white;
    border-radius: var(--radius-sm);
}

.detail-label {
    color: var(--color-text-light);
}

.detail-value {
    font-weight: 700;
    color: var(--color-primary);
}

#nextBtn {
    width: 100%;
}

.error-container {
    text-align: center;
    width: 100%;
}

.error-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

#errorMessage {
    font-size: 16px;
    color: var(--color-danger);
    margin-bottom: 24px;
}

/* ============================================
   PAGE 3 - MODULES
   ============================================ */
.modules-section {
    min-height: 400px;
}

.class-indicator {
    text-align: center;
    margin-bottom: 24px;
}

.class-badge {
    display: inline-block;
    background: var(--color-primary);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
}

.modules-grid {
    display: grid;
    gap: 16px;
}

.module-card {
    background: var(--color-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

.module-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--color-primary);
}

.module-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.module-icon {
    font-size: 32px;
}

.module-info {
    flex: 1;
}

.module-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 4px;
}

.module-subtitle {
    font-size: 14px;
    color: var(--color-text-light);
}

.module-progress-bar {
    margin-top: 12px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--color-text-light);
    margin-bottom: 6px;
}

.progress-bar {
    height: 8px;
    background: var(--color-border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-success) 0%, var(--color-primary) 100%);
    transition: width 0.5s ease;
    border-radius: 4px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    color: var(--color-text-light);
    font-size: 16px;
}

/* ============================================
   PAGE 4 - AUDIOS
   ============================================ */
.audios-section {
    padding-bottom: 120px;
}

.module-progress {
    background: var(--color-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 600;
}

#progressPercent {
    color: var(--color-primary);
}

.audios-list {
    display: grid;
    gap: 12px;
}

.audio-item {
    background: var(--color-card);
    border-radius: var(--radius-sm);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
    box-shadow: var(--shadow-sm);
}

.audio-item:hover {
    transform: translateX(4px);
    border-color: var(--color-primary);
}

.audio-item.completed {
    background: linear-gradient(135deg, #E8F8E8 0%, #D4F0D4 100%);
    border-color: var(--color-success);
}

.audio-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.audio-info {
    flex: 1;
}

.audio-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 4px;
}

.audio-status {
    font-size: 12px;
    color: var(--color-text-light);
}

.audio-status.completed {
    color: var(--color-success);
    font-weight: 600;
}

.audio-check {
    font-size: 24px;
    color: var(--color-success);
}

.audio-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-card);
    padding: 16px 20px;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.15);
    z-index: 1000;
}

.player-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

#playerTitle {
    font-weight: 600;
    color: var(--color-text);
}

#playerTime {
    color: var(--color-text-light);
    font-variant-numeric: tabular-nums;
}

#audioElement {
    width: 100%;
}

.close-player-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--color-danger);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: var(--transition);
}

.close-player-btn:hover {
    transform: scale(1.1);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 380px) {
    body {
        padding: 12px;
    }
    
    header h1 {
        font-size: 24px;
    }
    
    .recording-section,
    .analysis-section {
        padding: 20px;
    }
    
    #timer {
        font-size: 40px;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .controls .btn {
        flex-direction: row;
        padding: 16px;
    }
}
