/* ========================================
   FICHIER CSS - MOTOREX TURBO VOICE
   VERSION AVEC NAVBAR MODERNE (STYLE WHATSAPP)
   ======================================== */

/* ========== STYLES GÉNÉRAUX ========== */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #f0f4f8;
    overflow: hidden;
    position: fixed;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

/* ========== EN-TÊTE FIXE EN HAUT (STYLE iOS MODERNE) ========== */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(1, 144, 132, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    font-weight: 600;
    font-size: 1.1rem;
    z-index: 10;
    border-bottom: 0.5px solid rgba(255, 255, 255, 0.15);
}

/* Logo avec espacement */
header img[alt="Logo Motorex"] {
    height: 32px;
    transition: opacity 0.2s ease;
}

header img[alt="Logo Motorex"]:active {
    opacity: 0.7;
}

/* Container des boutons à droite */
.header-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

/* Boutons d'action style iOS minimaliste */
.header-button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease, transform 0.1s ease;
    min-width: 32px;
    min-height: 32px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    opacity: 0.9;
}

.header-button:hover {
    opacity: 1;
}

.header-button:active {
    opacity: 0.5;
    transform: scale(0.92);
}

.header-button svg {
    width: 24px;
    height: 24px;
    stroke: white;
    transition: none;
}

.header-button:active svg {
    transform: none;
}

/* ========== FENÊTRE DE CHAT (MESSAGES) ========== */
#chat-window {
    margin-top: 70px;
    height: calc(100vh - 120px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
}

#chat-window::after {
    content: '';
    display: block;
    height: 60px;
    flex-shrink: 0;
}

/* ========== STYLES DES MESSAGES ========== */
.message {
    padding: 10px 14px;
    border-radius: 16px;
    max-width: 75%;
    word-break: break-word;
    animation: fadeIn 0.3s ease;
}

.user {
    background: #26a89b;
    color: white;
    align-self: flex-end;
}

.assistant {
    background: white;
    color: #333;
    align-self: flex-start;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ========== ZONE DE SAISIE EN BAS (FIXE) ========== */
#input-container {
    position: fixed;
    bottom: 0px;
    left: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 1000;
}

.input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 24px;
    padding: 6px 10px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-wrapper:has(#user-input:focus) {
    border-color: #26a89b;
    box-shadow: 0 0 0 3px rgba(38, 168, 155, 0.15);
}

.icon-button {
    border: none;
    background: transparent;
    font-size: 1.2rem;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    flex-shrink: 0;
}

#user-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    padding: 8px 0;
    caret-color: #26a89b;
    background: transparent;
}

#user-input::placeholder {
    color: #999;
}

#mic-button {
    position: relative;
    font-size: 26px;
    background: rgb(255, 204, 0);
    border: none;
    padding: 12px;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    z-index: 1001;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 44px;
    min-height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: transform 0.2s ease;
}

#mic-button:hover {
    transform: scale(1.05);
}

#mic-button:active {
    transform: scale(0.95);
}

#mic-button img {
    pointer-events: none;
    display: block;
}

#send-button {
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    background: #26a89b;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    flex-shrink: 0;
    touch-action: manipulation;
    transition: transform 0.2s ease;
}

#send-button:hover {
    background: #1e8a7f;
    transform: scale(1.05);
}

#send-button:active {
    transform: scale(0.95);
}

#mic-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgb(255, 204, 0);
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

#mic-indicator.recording {
    opacity: 0.85;
    transform: translate(-50%, -50%) scale(1.1);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.3); }
    100% { transform: translate(-50%, -50%) scale(1); }
}

.tool-indicator {
    color: #666;
    font-style: italic;
    padding: 5px 0;
    animation: tool-pulse 1.5s infinite;
    font-size: 14px;
    opacity: 0.8;
}

@keyframes tool-pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 0.4; }
}

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

/* ========== TABLEAUX DESKTOP (PAR DÉFAUT) ========== */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    font-size: 0.9rem;
    border-radius: 8px;
    margin: 8px 0;
}

th, td {
    padding: 12px 16px;
    text-align: left;
}

th {
    background: #26a89b;
    color: white;
    font-weight: 600;
}

th:first-child {
    border-top-left-radius: 8px;
}

th:last-child {
    border-top-right-radius: 8px;
}

tbody tr:not(:last-child) td {
    border-bottom: 1px solid #e0e0e0;
}

tbody tr {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

tbody tr:hover {
    background: #f0f8f7;
}

tbody tr:last-child td:first-child {
    border-bottom-left-radius: 8px;
}

tbody tr:last-child td:last-child {
    border-bottom-right-radius: 8px;
}

/* ========== MOBILE ========== */
@media (max-width: 768px) {
    header {
        font-size: 1rem;
        height: 54px;
        padding: 0 16px;
    }
    
    header img[alt="Logo Motorex"] {
        height: 28px;
    }
    
    .header-actions {
        gap: 20px;
    }
    
    .header-button {
        min-width: 28px;
        min-height: 28px;
    }
    
    .header-button svg {
        width: 22px;
        height: 22px;
    }
    
    #chat-window {
        margin-top: 60px;
        margin-bottom: 100px;
        height: calc(100vh - 160px);
    }
    
    .message {
        max-width: 85%;
    }
    
    #input-container {
        bottom: 10px;
        left: 5px;
        right: 5px;
    }
    
    #user-input {
        font-size: 16px;
    }
    
    /* TABLEAUX → CARTES STYLE MODERNE iOS */
    table {
        border: none;
        background: transparent;
        box-shadow: none;
    }

    thead { 
        display: none; 
    }

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

    tbody tr {
        display: block;
        background: linear-gradient(135deg, #ffffff 0%, #f8fffe 100%);
        border: none;
        border-left: 4px solid #26a89b;
        border-radius: 12px;
        padding: 12px 14px;
        box-shadow: 
            0 2px 8px rgba(38, 168, 155, 0.08),
            0 1px 3px rgba(0, 0, 0, 0.06);
        margin: 0;
        transition: all 0.2s ease;
    }

    tbody tr:active {
        background: linear-gradient(135deg, #e8f5f4 0%, #f0faf9 100%);
        transform: scale(0.98);
        box-shadow: 
            0 1px 4px rgba(38, 168, 155, 0.12),
            0 0px 2px rgba(0, 0, 0, 0.08);
    }

    tbody td {
        display: block;
        padding: 0;
        margin: 3px 0;
        font-size: 14px;
        border: none !important;
        color: #2d3748;
        line-height: 1.4;
        font-weight: 400;
    }

    tbody td:first-child {
        font-size: 15px;
        color: #1a202c;
        margin-bottom: 6px;
        padding-bottom: 6px;
        border-bottom: 1px solid rgba(38, 168, 155, 0.15) !important;
    }

    tbody td:first-child strong {
        font-weight: 600;
        color: #26a89b;
    }

    tbody td:nth-child(2) {
        font-size: 14px;
        color: #4a5568;
    }

    tbody td:last-child {
        font-style: italic;
        color: #718096;
        font-size: 13px;
        margin-top: 6px;
        padding-top: 6px;
        border-top: 1px solid rgba(38, 168, 155, 0.1) !important;
    }

    tbody td::before {
        content: none;
    }
}

/* ========== ACCESSIBILITÉ ========== */
*:focus-visible {
    outline: 2px solid #26a89b;
    outline-offset: 2px;
}

*:focus:not(:focus-visible) {
    outline: none;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

* {
    touch-action: manipulation;
}

#chat-window {
    -webkit-overflow-scrolling: touch;
}

#mic-button, #send-button, .icon-button, .header-button {
    -webkit-user-select: none;
    user-select: none;
}