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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 8px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    min-height: calc(100vh - 16px);
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 12px;
    font-size: clamp(1.1em, 3vw, 1.6em);
    font-weight: 700;
}

.phrase-counter {
    text-align: center;
    font-size: clamp(0.85em, 2vw, 1em);
    color: #666;
    margin-bottom: 10px;
}

/* Phrase Box - Optimisé */
.phrase-box {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 12px;
    min-height: clamp(120px, 25vh, 180px);
    display: flex;
    align-items: center;
    justify-content: center;
}

#phrase-text {
    font-size: clamp(1.2em, 3.5vw, 2.8em);
    line-height: 1.4;
    text-align: center;
    color: #944903;
    font-weight: 700;
}

/* Translation Box - Optimisé */
.translation-box {
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    min-height: clamp(90px, 18vh, 120px);
    display: flex;
    align-items: center;
    justify-content: center;
}

#translation-text {
    font-size: clamp(1.1em, 3vw, 2.2em);
    line-height: 1.5;
    text-align: center;
    color: #856404;
    font-weight: 600;
    direction: rtl;
}

/* Formulaires */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: #555;
    font-weight: 600;
    font-size: clamp(0.85em, 2vw, 0.95em);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group select {
    width: 100%;
    padding: 10px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: clamp(0.9em, 2.5vw, 1em);
    transition: all 0.3s;
    background-color: white;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 16 16'%3E%3Cpath fill='%23667eea' d='M4 6l4 4 4-4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 35px;
}

.custom-group-input {
    display: none;
    margin-top: 8px;
}

.custom-group-input.show {
    display: block;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Structure bouton avec icon + text */
.btn-icon {
    display: inline-block;
}

.btn-text {
    display: inline-block;
}

/* Boutons - Version compacte */
.translation-toggle {
    text-align: center;
    margin-bottom: 10px;
}

.toggle-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: clamp(8px, 2vw, 10px) clamp(16px, 4vw, 20px);
    border-radius: 20px;
    font-size: clamp(0.85em, 2vw, 0.95em);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.2);
}

.toggle-btn:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.toggle-btn:active {
    transform: translateY(0);
}

/* Audio Controls - Compact */
.audio-controls {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
}

.progress-container {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 10px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    width: 0%;
    transition: width 0.1s;
    border-radius: 8px;
}

.time-display {
    text-align: center;
    color: #666;
    margin-bottom: 12px;
    font-size: clamp(0.85em, 2vw, 0.95em);
    font-weight: 500;
}

.control-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.nav-btn, .play-btn {
    padding: clamp(8px, 2vw, 10px) clamp(16px, 4vw, 20px);
    border: none;
    border-radius: 8px;
    font-size: clamp(0.85em, 2vw, 0.95em);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.nav-btn {
    background: #6c757d;
    color: white;
    min-width: clamp(70px, 20vw, 90px);
}

.nav-btn:hover:not(:disabled) {
    background: #5a6268;
    transform: translateY(-1px);
}

.nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.play-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    min-width: clamp(100px, 25vw, 130px);
    font-size: clamp(0.9em, 2.2vw, 1em);
}

.play-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.status-info {
    text-align: center;
    margin-top: 10px;
}

#status-message {
    color: #666;
    font-style: italic;
    font-size: clamp(0.8em, 2vw, 0.85em);
}

.hidden {
    display: none !important;
}

/* Page d'accueil - Compact */
.welcome-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.welcome-container {
    background: white;
    border-radius: 15px;
    padding: clamp(20px, 5vw, 30px);
    max-width: 480px;
    width: 100%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.welcome-container h1 {
    font-size: clamp(1.3em, 4vw, 1.7em);
    margin-bottom: 20px;
}

.welcome-form {
    margin-top: 20px;
}

.start-btn {
    width: 100%;
    padding: clamp(12px, 3vw, 14px);
    background: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: clamp(0.95em, 2.5vw, 1.05em);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 8px;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.2);
}

.start-btn:hover {
    background: #218838;
    transform: translateY(-1px);
}

.stats-btn {
    width: 100%;
    padding: clamp(10px, 2.5vw, 12px);
    background: #17a2b8;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: clamp(0.9em, 2.2vw, 1em);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(23, 162, 184, 0.2);
}

.stats-btn:hover {
    background: #138496;
    transform: translateY(-1px);
}

/* Stats - Compact */
.stats-screen {
    min-height: 100vh;
    padding: 10px;
}

.stats-container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    padding: clamp(15px, 4vw, 25px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.stats-list {
    display: grid;
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: clamp(12px, 3vw, 16px);
    transition: all 0.3s ease;
}

.stat-card:hover {
    border-color: #667eea;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.15);
    transform: translateY(-1px);
}

.stat-card h3 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: clamp(1em, 2.5vw, 1.1em);
}

.stat-card p {
    margin: 6px 0;
    color: #555;
    font-size: clamp(0.85em, 2vw, 0.9em);
    line-height: 1.4;
}

.no-stats {
    text-align: center;
    color: #999;
    padding: 30px;
    font-size: clamp(0.95em, 2.2vw, 1.05em);
}

.stats-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 15px;
}

.danger-btn {
    padding: clamp(9px, 2.2vw, 11px) clamp(18px, 4vw, 22px);
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: clamp(0.85em, 2vw, 0.9em);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(220, 53, 69, 0.2);
}

.danger-btn:hover {
    background: #c82333;
    transform: translateY(-1px);
}

/* User Info - Ultra compact */
.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    gap: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    min-height: 40px;
}

.user-info span {
    font-weight: 600;
    color: #333;
    font-size: clamp(0.8em, 2vw, 0.85em);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info span:not(:last-of-type)::after {
    content: " • ";
    color: #999;
    margin: 0 4px;
}

.small-btn {
    padding: 6px 12px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: clamp(0.75em, 1.8vw, 0.8em);
    font-weight: 600;
    transition: all 0.3s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.small-btn:hover {
    background: #c82333;
    transform: translateY(-1px);
}

/* Session Stats - Compact */
.session-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.stat-item {
    background: linear-gradient(135deg, #e8f5e8 0%, #d4edda 100%);
    border-left: 3px solid #28a745;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.stat-label {
    font-size: clamp(0.75em, 1.8vw, 0.8em);
    color: #555;
    font-weight: 600;
    margin-bottom: 4px;
}

.stat-value {
    font-size: clamp(1.1em, 2.8vw, 1.3em);
    color: #155724;
    font-weight: 700;
}

/* Speed Control - Compact */
.speed-control {
    margin: 10px 0;
    text-align: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
}

.speed-control label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #666;
    font-size: clamp(0.8em, 2vw, 0.85em);
}

#playback-speed {
    width: 100%;
    max-width: 250px;
    cursor: pointer;
    height: 6px;
}

#speed-value {
    display: inline-block;
    margin-left: 8px;
    font-weight: 700;
    color: #667eea;
    font-size: clamp(0.85em, 2vw, 0.9em);
}

/* RESPONSIVE - Mobile Optimization */
@media (max-width: 768px) {
    body {
        padding: 5px;
    }

    .container {
        padding: 10px;
        border-radius: 12px;
        min-height: calc(100vh - 10px);
    }

    h1 {
        margin-bottom: 8px;
    }

    .phrase-counter {
        margin-bottom: 8px;
    }

    .phrase-box {
        padding: 12px;
        margin-bottom: 10px;
        min-height: 110px;
    }

    .translation-box {
        padding: 10px;
        margin-bottom: 10px;
        min-height: 80px;
    }

    .audio-controls {
        padding: 10px;
        margin-bottom: 10px;
    }

    .control-buttons {
        gap: 6px;
    }

    .session-stats {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .stat-item {
        padding: 8px;
    }

    .user-info {
        padding: 6px 10px;
        margin-bottom: 8px;
        min-height: 38px;
    }

    /* ⭐ Mobile : Icônes seulement (sauf traduction) */
    .nav-btn .btn-text,
    .play-btn .btn-text,
    .small-btn .btn-text,
    .start-btn .btn-text,
    .stats-btn .btn-text,
    .danger-btn .btn-text {
        display: none;
    }
    
    .nav-btn .btn-icon,
    .play-btn .btn-icon,
    .small-btn .btn-icon {
        font-size: 1.3em;
    }
    
    .start-btn .btn-icon,
    .stats-btn .btn-icon,
    .danger-btn .btn-icon {
        font-size: 1.5em;
    }
    
    .nav-btn {
        min-width: 44px;
        padding: 10px;
    }
    
    .play-btn {
        min-width: 50px;
        padding: 10px 14px;
    }
    
    .small-btn {
        min-width: 40px;
        padding: 8px 10px;
    }
    
    .start-btn,
    .stats-btn,
    .danger-btn {
        padding: 12px;
    }
    
    /* Bouton traduction : GARDER le texte */
    .toggle-btn .btn-text {
        display: inline-block !important;
    }
}

@media (max-width: 480px) {
    body {
        padding: 3px;
    }

    .container {
        padding: 8px;
        border-radius: 10px;
    }

    .phrase-box {
        padding: 10px;
        min-height: 100px;
    }

    .translation-box {
        padding: 8px;
        min-height: 70px;
    }

    .control-buttons {
        gap: 5px;
    }

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

    .form-group input,
    .form-group select {
        font-size: 16px; /* Évite zoom iOS */
    }

    .welcome-container {
        padding: 18px;
    }

    .stats-container {
        padding: 12px;
    }

    .user-info {
        padding: 5px 8px;
        min-height: 36px;
    }

    /* ⭐ Icônes encore plus petites sur très petit écran */
    .nav-btn .btn-icon,
    .play-btn .btn-icon,
    .small-btn .btn-icon {
        font-size: 1.2em;
    }
    
    .nav-btn {
        min-width: 40px;
        padding: 8px;
    }
    
    .play-btn {
        min-width: 46px;
        padding: 8px 12px;
    }
}

/* Touch-friendly */
@media (hover: none) and (pointer: coarse) {
    .nav-btn, .play-btn, .toggle-btn, .start-btn, .stats-btn, .small-btn {
        min-height: 44px;
    }
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Loading */
.loading {
    text-align: center;
    padding: 30px;
    color: #999;
    font-size: clamp(0.9em, 2vw, 1em);
}

.loading::after {
    content: '...';
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}
