/* ============================================
   STYLE CSS - JASONTUTOR
   Version avec boutons optimisés pour TDAH
   ============================================ */

:root {
    --profile-color: #4F46E5;
    --profile-name: 'Standard';
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    min-height: 100dvh;
    padding: 20px;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: stretch;
}

@supports (padding: max(0px)) {
    body {
        padding: max(20px, env(safe-area-inset-left))
                 max(20px, env(safe-area-inset-right))
                 max(20px, env(safe-area-inset-bottom))
                 max(20px, env(safe-area-inset-top));
    }
}

.container {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

.header {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
    border-top: 4px solid var(--profile-color);
    position: relative;
}

.header::after {
    content: attr(data-profile);
    position: absolute;
    top: -2px;
    right: 20px;
    background: var(--profile-color);
    color: white;
    padding: 4px 12px;
    border-radius: 0 0 8px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: #4F46E5;
}

#connectionStatus {
    font-size: 12px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 6px;
    background: #F0F0F0;
}

.user-info {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.user-name {
    font-size: 14px;
    color: #666;
}

/* ============================================
   BOUTONS - TAILLE OPTIMISÉE POUR TDAH
   ============================================ */

.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.btn-primary {
    background: #4F46E5;
    color: white;
}

.btn-primary:hover {
    background: #3730A3;
}

.btn-danger {
    background: #EF4444;
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
}

/* ============================================
   CHAT BOX
   ============================================ */

.chat-box {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    height: 600px;
    margin-bottom: 20px;
    border-left: 6px solid var(--profile-color);
}

.messages {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    padding: 12px 15px;
    border-radius: 8px;
    max-width: 80%;
    word-wrap: break-word;
}

.message-user {
    background: #4F46E5;
    color: white;
    align-self: flex-end;
}

.message-tutor {
    background: #F0F0F0;
    color: #333;
    align-self: flex-start;
}

/* ============================================
   TTS CONTROLS
   ============================================ */

.tts-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    padding: 8px;
    background: #f0f0f0;
    border-radius: 8px;
    align-items: center;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.tts-controls button {
    padding: 8px 14px;
    font-size: 12px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    background: #0EA5E9;
    color: white;
    transition: all 0.2s;
}

.tts-controls button:hover {
    background: #0284C7;
}

.tts-controls button.active {
    background: #0C4A6E;
}

.tts-label {
    font-size: 11px;
    font-weight: 600;
    color: #333;
}

/* ============================================
   INPUT AREA
   ============================================ */

.input-area {
    display: flex;
    gap: 10px;
}

.input-field {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.input-field:focus {
    outline: none;
    border-color: #4F46E5;
}

/* ============================================
   BOUTONS D'ACTION PRINCIPAUX
   ============================================ */

.btn-send {
    padding: 14px 28px;
    background: #4F46E5;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s;
    touch-action: manipulation;
}

.btn-send:hover {
    background: #3730A3;
}

.btn-mic {
    padding: 14px 28px;
    background: #10B981;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s;
    touch-action: manipulation;
}

.btn-mic:hover {
    background: #059669;
}

.btn-mic.listening {
    background: #EF4444;
    animation: pulse-mic 1s infinite;
}

@keyframes pulse-mic {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ============================================
   ERROR MESSAGES
   ============================================ */

.error {
    color: #EF4444;
    font-size: 12px;
    padding: 10px;
    background: #FEE2E2;
    border-radius: 8px;
    margin-top: 10px;
}

/* ============================================
   DEBUG PANEL
   ============================================ */

#debugPanel {
    position: fixed;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.9);
    color: #0f0;
    font-family: monospace;
    font-size: 10px;
    padding: 10px;
    border-radius: 6px;
    max-width: 300px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 9999;
    display: none;
    border: 2px solid #0f0;
}

#debugPanel button {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #0f0;
    color: black;
    border: none;
    padding: 2px 5px;
    cursor: pointer;
    font-size: 9px;
    font-weight: bold;
}

/* ============================================
   SETTINGS MODAL
   ============================================ */

#settingsModal {
    padding: 20px;
}

#settingsModal > div {
    animation: slideUp 0.3s ease;
}

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

/* ============================================
   MINI-GAMES STYLES
   ============================================ */

.minigame-btn {
    padding: 16px 20px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
    min-height: 44px;
}

.minigame-btn-primary {
    background: #667eea;
    color: white;
}

.minigame-btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.4);
}

.minigame-btn-secondary {
    background: #F0F4FF;
    color: #667eea;
    border: 2px solid #667eea;
}

.minigame-btn-secondary:hover {
    background: #E5E7FF;
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */

@media (max-width: 600px) {
    #settingsModal {
        padding: 10px;
    }

    #settingsModal > div {
        max-width: 100% !important;
        width: calc(100% - 20px) !important;
        padding: 20px !important;
        border-radius: 12px;
    }

    #settingsModal h2 {
        font-size: 18px;
        margin-bottom: 15px;
    }

    #settingsModal button {
        font-size: 14px;
        padding: 12px;
    }

    body {
        padding: 0 !important;
        margin: 0;
    }

    .container {
        max-width: 100%;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        padding: 0;
        margin: 0;
    }

    .header {
        padding: 10px 12px !important;
        margin: 0 !important;
        border-radius: 0;
        gap: 8px;
        margin-bottom: 0 !important;
        display: grid;
        grid-template-columns: auto 1fr auto auto auto;
        align-items: center;
        row-gap: 5px;
    }

    .logo {
        font-size: 16px;
        grid-column: 1;
        grid-row: 1;
        min-width: fit-content;
    }

    #connectionStatus {
        font-size: 9px;
        padding: 3px 6px;
        grid-column: 2;
        grid-row: 1;
    }

    .user-info {
        gap: 6px;
        grid-column: 3 / 6;
        grid-row: 1;
        margin-left: auto;
        display: flex;
    }

    .user-name {
        font-size: 10px;
        display: none;
    }

    .btn {
        padding: 10px 14px;
        font-size: 12px;
        border-radius: 6px;
        white-space: nowrap;
        min-width: fit-content;
        min-height: 40px;
    }

    .chat-box {
        height: auto;
        flex: 1;
        margin: 0;
        padding: 8px;
        border-radius: 0;
        box-shadow: none;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    .messages {
        flex: 1;
        margin-bottom: 6px;
        gap: 6px;
        min-height: 50px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .message {
        padding: 8px 10px;
        font-size: 13px;
        max-width: 92%;
        border-radius: 6px;
    }

    .tts-controls {
        padding: 6px;
        margin-bottom: 8px;
        gap: 6px;
        flex-shrink: 0;
        display: none;
    }

    .tts-controls button {
        padding: 6px 10px;
        font-size: 10px;
    }

    .input-area {
        display: flex;
        gap: 6px;
        flex-shrink: 0;
    }

    .input-field {
        flex: 1;
        min-width: 0;
        padding: 10px;
        font-size: 16px;
        border: 1px solid #ddd;
        border-radius: 6px;
    }

    .btn-send,
    .btn-mic {
        padding: 10px 14px;
        font-size: 12px;
        flex-shrink: 0;
        min-width: fit-content;
        min-height: 40px;
    }

    .error {
        font-size: 11px;
        padding: 6px;
        margin-top: 4px;
        border-radius: 6px;
    }

    /* Mini-games responsive */
    .minigame-btn {
        padding: 12px 16px;
        font-size: 12px;
        min-height: 40px;
    }
}

/* ============================================
   ANIMATIONS GÉNÉRALES
   ============================================ */

@keyframes slideDown {
    from { transform: translateX(-50%) translateY(0); opacity: 1; }
    to { transform: translateX(-50%) translateY(100%); opacity: 0; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

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