/* style.css */
/* Variables CSS */
:root {
    --primary-color: #1a237e;
    --info-color: #3b82f6;
    --success-color: #22c55e;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
}

/* Base Styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #333;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles */
.logo-container {
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-img {
    height: 80px;
    width: auto;
    margin-right: 20px;
}

/* Form Styles */
.input-field {
    padding: 8px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 35, 126, 0.2);
}

/* Ajustement spécifique pour input CNI */
#cin.input-field {
    width: 280px; /* Juste assez pour 14 caractères */
}

/* Button styles */
.search-btn {
    padding: 12px 25px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-btn:hover {
    background-color: #283593;
    transform: translateY(-2px);
}

/* Results Section */
.results-section {
    background-color: white;
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-top: 30px;
}

.result-card {
    background-color: #f9f9f9;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border-left: 4px solid var(--primary-color);
}

.result-card h3 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 15px;
}

/* Loading Spinner */
.loading-spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top: 4px solid var(--primary-color);
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Message Styles */
.message-container {
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
}

.success-message {
    background-color: #f0fdf4;
    color: #166534;
    border-left: 4px solid var(--success-color);
}

.error-message {
    background-color: #fef2f2;
    color: #b91c1c;
    border-left: 4px solid var(--error-color);
}

.info-message {
    background-color: #eff6ff;
    color: #1e40af;
    border-left: 4px solid var(--info-color);
}

.warning-message {
    background-color: #fffbeb;
    color: #b45309;
    border-left: 4px solid var(--warning-color);
}

/* Admin Panel */
.admin-panel {
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.admin-btn {
    padding: 10px 20px;
    background-color: #4b5563;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.admin-btn:hover {
    background-color: #374151;
}

/* File Upload */
.file-input-label {
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-input-label:hover {
    border-color: var(--primary-color);
    background-color: rgba(26, 35, 126, 0.05);
}

/* Visitor Counter */
.visitor-counter {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: rgba(26, 35, 126, 0.9);
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 14px;
    z-index: 1000;
}

/* Table Styles */
.overflow-x-auto {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 1.5rem;
}

th,
td {
    padding: 0.75rem 1rem;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid #e5e7eb;
}

th {
    background-color: var(--primary-color);
    color: white;
    position: sticky;
    top: 0;
    font-weight: 600;
}

tr:nth-child(even) {
    background-color: #f9f9f9;
}

tr:hover {
    background-color: #f1f1f1;
}

/* Info Note */
.info-note {
    background-color: #f0f9ff;
    border-left: 4px solid var(--info-color);
    padding: 1rem;
    margin: 1.5rem 0;
    border-radius: 0 0.5rem 0.5rem 0;
}

.info-note p {
    margin: 0;
    line-height: 1.6;
}

/* Blur Background */
.blur-bg {
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.85);
}

/* Communiqués et Publicités */
#communiquesContainer {
    display: grid;
    gap: 1rem;
}

.communique-img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 0.5rem;
    transition: transform 0.3s ease;
    cursor: pointer;
}

.communique-img:hover {
    transform: scale(1.02);
}

.communique-name {
    text-align: center;
    margin-top: 8px;
    font-weight: 600;
    color: var(--primary-color);
}

.delete-btn {
    background-color: #f44336;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    margin-top: 5px;
}

.delete-btn:hover {
    background-color: #d32f2f;
}

/* Publicités */
#publicitesContainer {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.publicite-video {
    width: 100%;
    height: 180px;
    border-radius: 0.5rem;
    background-color: #000;
}

/* Timeout Notification */
.timeout-notification {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background-color: #ff9800;
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    z-index: 1000;
    animation: fadeIn 0.5s;
}

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

/* Utility Classes */
.text-primary {
    color: var(--primary-color);
}

.bg-primary {
    background-color: var(--primary-color);
}

.text-info {
    color: var(--info-color);
}

.bg-info {
    background-color: var(--info-color);
}

.hidden {
    display: none;
}

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

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

/* Responsive Design */
@media (max-width: 768px) {
    .logo-container {
        flex-direction: column;
        text-align: center;
    }

    .logo-img {
        margin-right: 0;
        margin-bottom: 15px;
    }

    .search-btn {
        width: 100%;
    }

    th,
    td {
        padding: 0.5rem;
        font-size: 0.875rem;
    }

    #publicitesContainer {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }

    .visitor-counter {
        bottom: 10px;
        right: 10px;
        font-size: 12px;
        padding: 8px 12px;
    }
}

/* --- Styles pour l'Agent Carba --- */
.carba-widget-container {
    position: relative; /* Plus de 'fixed' */
    width: 100%;
    max-width: 800px; /* Prend toute la largeur du conteneur */
    margin: 0 auto;
    background-color: #ffffff;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1); /* Ombre plus douce */
    display: flex;
    flex-direction: column;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    border: 1px solid #e0e0e0;
    overflow: hidden;
}

.carba-header {
    background: linear-gradient(135deg, #1a237e, #283593);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 1.2rem;
}

/* ============================================ */
/* Bouton Fermer (X) — toujours visible         */
/* ============================================ */
.carba-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.carba-close-btn:hover {
    transform: scale(1.15);
    background-color: rgba(255, 255, 255, 0.15);
}

.carba-close-btn:focus {
    outline: 2px solid #ffc107;
    outline-offset: 2px;
}

/* ============================================ */
/* État "session fermée" (limite atteinte)      */
/* On ne désactive QUE le body, pas le header   */
/* → le bouton X reste toujours cliquable       */
/* ============================================ */
.session-closed .carba-body {
    opacity: 0.7;
    pointer-events: none;
    filter: grayscale(0.5);
}

.session-closed .carba-body .carba-input-group {
    display: none !important;
}

/* Sécurité : forcer le header interactif */
.session-closed .carba-header {
    pointer-events: auto;
    opacity: 1;
    filter: none;
}

.session-closed .carba-close-btn {
    pointer-events: auto;
    cursor: pointer;
}

.carba-body {
    padding: 30px; /* Plus d'espace */
    display: flex;
    flex-direction: column;
}

.carba-avatar-container {
    display: flex;
    align-items: flex-start;
    margin-bottom: 15px;
}

.carba-avatar {
    width: 80px; /* Avatar plus grand */
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #1a237e;
    margin-right: 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

/* Animations de l'avatar */
.carba-avatar.idle {
    animation: float 3s ease-in-out infinite;
}

.carba-avatar.talking {
    animation: talk 0.5s ease-in-out infinite alternate;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
    100% { transform: translateY(0px); }
}

@keyframes talk {
    0% { transform: scale(1); }
    100% { transform: scale(1.05); }
}

.carba-speech-bubble {
    background-color: white;
    padding: 15px 20px;
    border-radius: 0 15px 15px 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    color: #333;
    font-size: 1.1rem;
    flex-grow: 1;
    border: 1px solid #e0e0e0;
    line-height: 1.4;
}

.carba-input-group {
    display: flex;
    margin-top: 15px;
    gap: 10px;
}

.carba-input {
    flex-grow: 1;
    padding: 12px 15px;
    border: 2px solid #ccc;
    border-radius: 8px;
    font-size: 1.1rem;
    outline: none;
    transition: border-color 0.3s;
}

.carba-input:focus {
    border-color: #1a237e;
}

.carba-btn {
    background: linear-gradient(135deg, #1a237e, #283593);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1.1rem;
}

.carba-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(26, 35, 126, 0.3);
}

.carba-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Résultats de recherche dans le widget */
.carba-results {
    margin-top: 15px;
    background: white;
    border-radius: 8px;
    padding: 15px;
    border: 1px solid #e0e0e0;
    font-size: 1rem;
}

.carba-category-title {
    color: #1a237e;
    font-weight: bold;
    font-size: 1.05rem;
    margin-top: 10px;
    margin-bottom: 5px;
    border-bottom: 1px solid #eee;
    padding-bottom: 3px;
}

.carba-line {
    margin-bottom: 4px;
    color: #555;
}

.carba-total {
    font-weight: bold;
    color: #1a237e;
    font-size: 1.1rem;
    margin-top: 10px;
    text-align: right;
}

.carba-action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.carba-action-buttons .carba-btn {
    flex: 1;
}

.btn-satisfait {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.btn-satisfait:hover {
    box-shadow: 0 4px 10px rgba(34, 197, 94, 0.3);
}

.btn-non-satisfait {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.btn-non-satisfait:hover {
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
}

.carba-timer {
    text-align: center;
    color: #ef4444;
    font-weight: bold;
    margin-top: 10px;
    font-size: 0.9rem;
}

/* Animation d'apparition */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-up {
    animation: slideUp 0.3s ease-out forwards;
}

.carba-widget-container.session-closed {
    opacity: 0.7;
    pointer-events: none;
    filter: grayscale(0.5);
}
.carba-widget-container.session-closed .carba-input-group {
    display: none !important;
}

/* --- Fenêtres Carba (résultats + opérateur) avec bouton X --- */
.carba-window {
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    margin-top: 15px;
    overflow: hidden;
    animation: slideUp 0.3s ease-out forwards;
}

.carba-window-header {
    background: linear-gradient(135deg, #1a237e, #283593);
    color: #ffffff;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 1rem;
}

.carba-window-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #ffffff;
    font-size: 0.95rem;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}

.carba-window-close:hover {
    background: rgba(255, 255, 255, 0.45);
    transform: scale(1.05);
}

.carba-window-body {
    padding: 15px;
}

/* --- Sélecteur de langue Agent Carba --- */
.carba-lang-select {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    font-family: inherit;
    transition: background 0.2s ease;
}

.carba-lang-select:hover {
    background: rgba(255, 255, 255, 0.3);
}

.carba-lang-select option {
    background: #ffffff;
    color: #1a237e;
    font-weight: 600;
}