/* css/components/ai-chat.css */
/* Réutilise .ai-panel pour la coquille (position, taille, animation open/fullscreen, RTL) */

.ai-chat {
    background: linear-gradient(180deg, #FCFBE0 0%, #EDEE9E 55%, #E3E166 100%);
}

.ai-chat__header {
    justify-content: space-between;
    align-items: center;
}

.ai-chat__title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #111;
}

.ai-chat__header-actions {
    display: flex;
    gap: var(--sp-2);
}

.ai-chat__messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--sp-2) var(--sp-3) var(--sp-3);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.ai-chat__row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.ai-chat__row--user {
    justify-content: flex-end;
}

.ai-chat__row--bot {
    justify-content: flex-start;
}

.ai-chat__avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.ai-chat__avatar--bot {
    object-fit: contain;
    background: rgba(255, 255, 255, 0.6);
    padding: 2px;
}

.ai-chat__bubble-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 78%;
}

.ai-chat__bubble {
    padding: 12px 14px;
    font-size: 0.82rem;
    line-height: 1.45;
    border-radius: 18px;
}

.ai-chat__bubble--user {
    max-width: 78%;
    background: linear-gradient(135deg, #8C8F1E 0%, #C7CA3A 100%);
    color: #111;
    border-bottom-right-radius: 4px;
}

.ai-chat__bubble--bot {
    background: #fff;
    color: #222;
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.ai-chat__reactions {
    display: flex;
    gap: 6px;
    padding-left: 4px;
}

.ai-chat__reaction {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background var(--transition-fast);
}

.ai-chat__reaction:hover {
    background: rgba(255, 255, 255, 0.6);
    color: #111;
}

.ai-chat__typing {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #fff;
    padding: 12px 16px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.ai-chat__typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #999;
    animation: ai-chat-typing 1.2s infinite ease-in-out;
}

.ai-chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.ai-chat__typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ai-chat-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.ai-chat__composer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: var(--sp-2) var(--sp-3);
    background: rgba(255, 255, 255, 0.5);
}

.ai-chat__tool {
    width: 30px;
    height: 30px;
    border: none;
    background: none;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 50%;
    transition: background var(--transition-fast);
}

.ai-chat__tool:hover {
    background: rgba(255, 255, 255, 0.7);
}

.ai-chat__input {
    flex: 1;
    min-width: 0;
    height: 40px;
    border: none;
    border-radius: 20px;
    padding: 0 16px;
    background: #fff;
    font-size: 0.82rem;
    color: #111;
}

.ai-chat__input:focus {
    outline: 2px solid var(--clr-saffron);
    outline-offset: -2px;
}

.ai-chat__mic {
    width: 30px;
    height: 30px;
    border: none;
    background: none;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-chat__send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--clr-saffron);
    color: #111;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform var(--transition-fast);
}

.ai-chat__send:hover {
    transform: scale(1.05);
}

[dir="rtl"] .ai-chat__bubble--user {
    border-bottom-right-radius: 18px;
    border-bottom-left-radius: 4px;
}

[dir="rtl"] .ai-chat__bubble--bot,
[dir="rtl"] .ai-chat__typing {
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 4px;
}

@media (max-width: 480px) {
    .ai-chat__bubble-group,
    .ai-chat__bubble--user {
        max-width: 85%;
    }
}

.ai-audio-player {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 999px;
    padding: 8px 14px;
    min-width: 180px;
}

.ai-chat__bubble--user .ai-audio-player {
    background: rgba(255, 255, 255, 0.18);
}

.ai-audio-player__toggle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: #111;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 0.7rem;
    padding: 0;
}

.ai-chat__bubble--user .ai-audio-player__toggle {
    background: var(--clr-saffron);
    color: #111;
}

.ai-audio-player__track {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.ai-chat__bubble--user .ai-audio-player__track {
    background: rgba(255, 255, 255, 0.3);
}

.ai-audio-player__progress {
    height: 100%;
    width: 0%;
    background: var(--clr-saffron);
    border-radius: 2px;
}

.ai-chat__bubble--user .ai-audio-player__progress {
    background: #111;
}

.ai-audio-player__time {
    font-size: 0.72rem;
    color: #333;
    min-width: 32px;
    text-align: right;
}

.ai-chat__bubble--user .ai-audio-player__time {
    color: #fff;
}

.ai-chat__timestamp {
    display: block;
    font-size: 0.68rem;
    color: #888;
    margin-top: 4px;
    unicode-bidi: isolate;
}


.ai-chat__bubble-file {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: inherit;
    text-decoration: underline;
    font-size: 0.85rem;
}

.ai-chat__mic.is-recording {
    background-color: #e74c3c;
    color: #fff;
    animation: mic-pulse 1s ease-in-out infinite;
}

@keyframes mic-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}

.ai-chat__camera-overlay {
    position: absolute;
    inset: 0;
    background: #000;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat__camera-overlay[hidden] {
    display: none;
}

.ai-chat__camera-overlay video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.ai-chat__camera-controls {
    position: absolute;
    bottom: 24px;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ai-chat__camera-capture {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #fff;
    border: 4px solid rgba(255, 255, 255, 0.5);
    cursor: pointer;
}
.ai-chat__camera-cancel {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    border: none;
    font-size: 1rem;
    cursor: pointer;
}

.ai-chat__bubble-group {
    align-items: flex-start;
}

.ai-chat__row--user .ai-chat__bubble-group {
    align-items: flex-end;
}

.ai-chat__bubble--media {
    width: 220px !important;
    max-width: 220px !important;
    padding: 10px !important;
    box-sizing: border-box;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.ai-chat__bubble-image {
    display: block;
    width: 200px;
    height: auto;
    max-height: 240px;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.ai-chat__bubble--media .ai-audio-player {
    width: 200px;
    max-width: 200px;
}

.ai-chat__bubble-group:has(.ai-chat__bubble--media) {
    max-width: 240px;
}



.ai-file-card {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 10px;
    padding: 8px 10px;
    width: 100%;
    box-sizing: border-box;
}


.ai-chat__bubble--user .ai-file-card {
    background: rgba(255, 255, 255, 0.18);
}

.ai-file-card__icon {
    position: relative;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: #111;
    flex-shrink: 0;
}

.ai-chat__bubble--user .ai-file-card__icon {
    background: var(--clr-saffron);
}

.ai-file-card__icon::before {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 16px;
    height: 16px;
    background-color: #fff;
    -webkit-mask-image: url('../../images/icons/eng_fils.png');
    mask-image: url('../../images/icons/eng_fils.png');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}

.ai-chat__bubble--user .ai-file-card__icon::before {
    background-color: #111;
}

.ai-file-card__info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ai-file-card__name {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}

.ai-file-card__meta {
    font-size: 0.68rem;
    color: #666;
}

.ai-chat__bubble--user .ai-file-card__meta {
    color: rgba(0, 0, 0, 0.55);
}

.ai-file-card__download {
    margin-left: auto;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.ai-chat__waveform {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 16px;
}

.ai-chat__send.is-recording .ai-chat__send-icon {
    display: none;
}

.ai-chat__send.is-recording .ai-chat__waveform {
    display: flex;
}

.ai-chat__waveform span {
    display: block;
    width: 3px;
    border-radius: 2px;
    background-color: #111;
    animation: ai-chat-wave 1s ease-in-out infinite;
}

.ai-chat__waveform span:nth-child(1) { height: 30%; animation-delay: 0s; }
.ai-chat__waveform span:nth-child(2) { height: 60%; animation-delay: 0.12s; }
.ai-chat__waveform span:nth-child(3) { height: 100%; animation-delay: 0.24s; }
.ai-chat__waveform span:nth-child(4) { height: 55%; animation-delay: 0.36s; }
.ai-chat__waveform span:nth-child(5) { height: 25%; animation-delay: 0.48s; }

@keyframes ai-chat-wave {
    0%, 100% { transform: scaleY(0.4); }
    50% { transform: scaleY(1); }
}

.ai-chat__meta-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-chat__edit-btn {
    background: none;
    border: none;
    padding: 0;
    color: #666;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition-fast);
    display: flex;
    align-items: center;
}

.ai-chat__row--user:hover .ai-chat__edit-btn {
    opacity: 1;
}

.ai-chat__edit-btn:hover {
    color: #111;
}