/* ===== VARIABLES GLOBALES ===== */
:root {
    --cgt-red: #E3000F;
    --cgt-yellow: #FFD300;
    --dark-gray: #2c3e50;
    --light-gray: #ecf0f1;
    --white: #ffffff;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--dark-gray);
}

/* ===== PAGE DE CONNEXION ===== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: var(--white);
    padding: 40px;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    max-width: 450px;
    width: 100%;
    animation: slideIn 0.4s ease-out;
}

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

.logo-container {
    text-align: center;
    margin-bottom: 30px;
}

.logo-main {
    max-width: 200px;
    height: auto;
}

.login-box h1 {
    color: var(--cgt-red);
    font-size: 28px;
    margin-bottom: 10px;
    text-align: center;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 16px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark-gray);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--cgt-red);
    box-shadow: 0 0 0 3px rgba(227, 0, 15, 0.1);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 13px;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--cgt-red) 0%, #c4000d 100%);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(227, 0, 15, 0.3);
}

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

.error-message {
    margin-top: 15px;
    padding: 12px;
    background: #fee;
    color: #c00;
    border-radius: 8px;
    border-left: 4px solid #c00;
    font-size: 14px;
}

.back-link {
    display: block;
    text-align: center;
    margin-top: 20px;
    color: var(--cgt-red);
    text-decoration: none;
    font-weight: 500;
}

.back-link:hover {
    text-decoration: underline;
}

/* ===== HEADER APPLICATION ===== */
.app-header {
    background: linear-gradient(135deg, var(--cgt-red) 0%, #c4000d 100%);
    color: var(--white);
    padding: 20px 30px;
    box-shadow: var(--shadow);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.header-logos {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-castor {
    height: 60px;
    width: auto;
}

.logo-cgt {
    height: 50px;
    width: auto;
}

.header-title h1 {
    font-size: 24px;
    margin-bottom: 5px;
}

.header-title p {
    font-size: 14px;
    opacity: 0.9;
}

.btn-logout {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
    border: 2px solid var(--white);
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-logout:hover {
    background: var(--white);
    color: var(--cgt-red);
}

/* ===== CONTENEUR PRINCIPAL ===== */
.main-container {
    max-width: 1400px;
    margin: 30px auto;
    padding: 0 20px;
}

.chat-container {
    background: var(--white);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
}

/* ===== ZONE DE MESSAGES ===== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    scroll-behavior: smooth;
}

.welcome-message {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 30px;
    border-radius: 15px;
    border-left: 5px solid var(--cgt-red);
}

.welcome-message h2 {
    color: var(--cgt-red);
    margin-bottom: 15px;
}

.welcome-message p {
    margin-bottom: 15px;
    line-height: 1.6;
}

.welcome-message ul {
    list-style: none;
    padding-left: 0;
}

.welcome-message ul li {
    padding: 8px 0 8px 25px;
    position: relative;
}

.welcome-message ul li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--cgt-red);
    font-weight: bold;
}

/* ===== MESSAGES UTILISATEUR & IA ===== */
.message {
    margin-bottom: 25px;
    animation: fadeIn 0.4s ease-out;
}

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

.message-user {
    display: flex;
    justify-content: flex-end;
}

.message-user .message-content {
    background: linear-gradient(135deg, var(--cgt-red) 0%, #c4000d 100%);
    color: var(--white);
    padding: 15px 20px;
    border-radius: 18px 18px 5px 18px;
    max-width: 70%;
}

.message-ai {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--cgt-red);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
}

.message-label {
    font-weight: 600;
    color: var(--dark-gray);
}

/* Encadré détaillé */
.response-detailed {
    background: #f8f9fa;
    border: 2px solid var(--cgt-red);
    border-radius: 15px;
    padding: 25px;
    max-width: 90%;
}

.response-detailed h3 {
    color: var(--cgt-red);
    margin-bottom: 15px;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.response-detailed-content {
    line-height: 1.8;
    color: var(--dark-gray);
}

.response-detailed-content h4 {
    color: var(--cgt-red);
    margin: 20px 0 10px 0;
    font-size: 16px;
}

.response-detailed-content ul,
.response-detailed-content ol {
    margin: 10px 0;
    padding-left: 25px;
}

.response-detailed-content li {
    margin: 8px 0;
}

.response-detailed-content strong {
    color: var(--cgt-red);
}

/* Encadré résumé */
.response-summary {
    background: linear-gradient(135deg, var(--cgt-yellow) 0%, #ffc700 100%);
    border-radius: 15px;
    padding: 20px;
    max-width: 90%;
    border-left: 5px solid var(--cgt-red);
}

.response-summary h3 {
    color: var(--cgt-red);
    margin-bottom: 12px;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.response-summary-content {
    color: var(--dark-gray);
    font-weight: 500;
    line-height: 1.6;
}

/* ===== ZONE DE SAISIE ===== */
.chat-input-container {
    border-top: 2px solid #e0e0e0;
    padding: 20px;
    background: #f8f9fa;
}

#chatForm {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

#userInput {
    flex: 1;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 12px;
    font-size: 15px;
    resize: none;
    font-family: inherit;
    transition: all 0.3s ease;
}

#userInput:focus {
    outline: none;
    border-color: var(--cgt-red);
    box-shadow: 0 0 0 3px rgba(227, 0, 15, 0.1);
}

.btn-send {
    padding: 15px 30px;
    background: linear-gradient(135deg, var(--cgt-red) 0%, #c4000d 100%);
    color: var(--white);
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(227, 0, 15, 0.3);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ===== INTERFACE ADMIN ===== */
.admin-container {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
}

.admin-section {
    background: var(--white);
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.admin-section h2 {
    color: var(--cgt-red);
    margin-bottom: 25px;
    font-size: 22px;
}

.upload-form {
    max-width: 700px;
}

.btn-secondary {
    padding: 10px 20px;
    background: #6c757d;
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.documents-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 250px;
    padding: 10px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.documents-list {
    display: grid;
    gap: 15px;
}

.document-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    border-left: 4px solid var(--cgt-red);
    transition: all 0.3s ease;
}

.document-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

.document-info {
    flex: 1;
}

.document-name {
    font-weight: 600;
    color: var(--dark-gray);
    margin-bottom: 5px;
}

.document-meta {
    display: flex;
    gap: 15px;
    font-size: 13px;
    color: #666;
}

.document-actions {
    display: flex;
    gap: 10px;
}

.btn-icon {
    padding: 8px 12px;
    background: transparent;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-icon:hover {
    background: #f8f9fa;
}

.btn-danger {
    background: #dc3545;
    color: var(--white);
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

/* Statistiques */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    background: linear-gradient(135deg, var(--cgt-red) 0%, #c4000d 100%);
    color: var(--white);
    padding: 25px;
    border-radius: 12px;
    text-align: center;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 10px;
}

.stat-label {
    font-size: 14px;
    opacity: 0.9;
}

/* ===== MODAL ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--white);
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    color: var(--cgt-red);
    margin-bottom: 15px;
}

.modal-content p {
    margin-bottom: 25px;
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--cgt-yellow);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    color: var(--white);
    margin-top: 20px;
    font-size: 16px;
}

.loading-text {
    text-align: center;
    color: #666;
    padding: 40px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }

    .header-logos {
        justify-content: center;
    }

    .logo-castor,
    .logo-cgt {
        height: 40px;
    }

    .chat-container {
        height: calc(100vh - 250px);
    }

    .message-user .message-content,
    .response-detailed,
    .response-summary {
        max-width: 95%;
    }

    #chatForm {
        flex-direction: column;
    }

    .btn-send {
        width: 100%;
        justify-content: center;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .document-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .document-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 480px) {
    .login-box {
        padding: 25px;
    }

    .app-header {
        padding: 15px 20px;
    }

    .header-title h1 {
        font-size: 18px;
    }

    .chat-messages {
        padding: 15px;
    }

    .admin-section {
        padding: 20px;
    }
}
