@font-face {
    font-family: 'Campton Book';
    src: url('fonts/CamptonBold.otf') format('opentype');
    /* Format OpenType (.otf) */
    font-weight: normal;
    font-style: normal;
}

/* --- STYLES GÉNÉRAUX --- */
body {
    font-family: 'Inter', sans-serif;
    background-color: #f3f4f6;
}

.custom-font {
    font-family: 'Campton Book', sans-serif;
}

.btn {
    background-color: #212551;
    color: white;
    font-weight: 500;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:hover {
    background-color: #2E346E;
}

.btn:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

#user-email {
    font-size: 1rem;
    /* 16px */
    font-weight: 600;
    /* semibold */
    color: #374151;
    /* gray-700 */
    padding: 0 0.25rem;
}

#logout-button {
    background-color: #fee2e2;
    /* red-100 */
    color: #ef4444;
    /* red-500 */
    font-weight: 600;
    /* semibold */
    padding: 0.5rem 1rem;
    /* Equivalent btn-sm */
    border-radius: 0.5rem;
    /* rounded-lg */
    transition: all 0.2s ease-in-out;
    border: 1px solid #fecaca;
    /* red-200 */
    font-size: 0.875rem;
    /* text-sm */
    line-height: 1.25rem;
    cursor: pointer;
}

#logout-button:hover {
    background-color: #ef4444;
    /* red-500 */
    color: white;
    text-decoration: none;
    /* Enlève le soulignement au survol */
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}

.input-error-message {
    font-size: 0.75rem;
    /* text-xs */
    color: #ef4444;
    /* red-500 */
    margin-top: 0.25rem;
    /* mt-1 */
}

.form-subheading {
    font-size: 1.125rem;
    /* text-lg */
    font-weight: 600;
    /* semibold */
    color: #4b5563;
    /* gray-600 */
    border-bottom: 1px solid #e5e7eb;
    /* border-gray-200 */
    padding-bottom: 0.25rem;
    /* pb-1 */
    margin-bottom: 1rem;
    /* mb-4 */
}

.form-subheading:not(:first-child) {
    margin-top: 2rem;
    /* mt-8, pour remplacer l'ancien pt-6 + border-t */
}

.dish-section {
    background-color: #f9fafb;
    /* gray-50 */
    padding: 1rem;
    border-radius: 0.5rem;
    /* rounded-lg */
    border: 1px solid #f3f4f6;
    /* gray-100 */
}

.dish-option {
    display: flex;
    align-items: center;
}

.spinner1 {
    width: 44px;
    height: 44px;
    animation: spinner1-y0fdc1 2s infinite ease;
    transform-style: preserve-3d;
}

.spinner1>div {
    background-color: rgba(255, 242, 0, 0.2);
    height: 100%;
    position: absolute;
    width: 100%;
    border: 2px solid #ecae24;
}

.spinner1 div:nth-of-type(1) {
    transform: translateZ(-22px) rotateY(180deg);
}

.spinner1 div:nth-of-type(2) {
    transform: rotateY(-270deg) translateX(50%);
    transform-origin: top right;
}

.spinner1 div:nth-of-type(3) {
    transform: rotateY(270deg) translateX(-50%);
    transform-origin: center left;
}

.spinner1 div:nth-of-type(4) {
    transform: rotateX(90deg) translateY(-50%);
    transform-origin: top center;
}

.spinner1 div:nth-of-type(5) {
    transform: rotateX(-90deg) translateY(50%);
    transform-origin: bottom center;
}

.spinner1 div:nth-of-type(6) {
    transform: translateZ(22px);
}

@keyframes spinner1-y0fdc1 {
    0% {
        transform: rotate(45deg) rotateX(-25deg) rotateY(25deg);
    }

    50% {
        transform: rotate(45deg) rotateX(-385deg) rotateY(25deg);
    }

    100% {
        transform: rotate(45deg) rotateX(-385deg) rotateY(385deg);
    }
}

/* --- PAGE DE CONNEXION --- */
#login-page {
    background-color: #f3f4f6;
}

/* --- APPLICATION PRINCIPALE --- */
.card {
    background-color: white;
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.standing-btn {
    background-color: #212551;
    color: white;
    font-weight: 500;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    border: 1px solid transparent;
}

.standing-btn:hover {
    background-color: #2E346E;
}

.standing-btn.selected {
    background-color: #ecae22;
}

.alert-warning {
    color: #856404;
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
}

/* --- TABLEAUX (ZONES & DISPOSITIF) --- */
.zone-cell {
    padding: 0.75rem 1rem;
    vertical-align: middle;
}

.period {
    min-width: 8.5rem;
}

.zone-name-static {
    font-size: 1.1rem;
    font-weight: 600;
    color: #111827;
}

.zone-name-input {
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    background: transparent;
    padding: 0.25rem;
    width: 100%;
}

.zone-name-input:focus {
    outline: none;
    background-color: #fef9c3;
    border-radius: 4px;
}

.zone-hours-cell {
    font-size: 1.25rem;
    font-weight: 700;
    color: #212551;
    text-align: center;
    min-width: 120px;
}

.remove-btn {
    background-color: #fee2e2;
    color: #ef4444;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.remove-btn:hover {
    background-color: #ef4444;
    color: white;
    transform: scale(1.1);
}

.day-checkbox-label {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    line-height: 2rem;
    text-align: center;
    border: 1px solid #d1d5db;
    border-radius: 50%;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
}

.day-checkbox:checked+.day-checkbox-label {
    background-color: #212551;
    color: white;
    border-color: #212551;
}

/* --- NOUVEAUX STYLES POUR LE CAHIER DES CHARGES --- */
.cdc-table {
    border-collapse: collapse;
    width: 100%;
    border: 1px solid #00000023;
}

.cdc-header {
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 1rem;
    color: #4b5563;
    border-bottom: 2px solid #e5e7eb;
}

.cdc-row {
    border-bottom: 1px solid #f3f4f6;
}

.cdc-row:last-child {
    border-bottom: none;
}

.cdc-cell {
    padding: 0.3rem 0.75rem;
    vertical-align: middle;
}

.cdc-cell[contenteditable="true"] {
    background-color: #f9fafb;
    transition: background-color 0.3s;
}

.cdc-cell[contenteditable="true"]:focus {
    background-color: #fef9c3;
    outline: 1px solid #fbbf24;
}

.cdc-select {
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    padding: 0.25rem 0.5rem;
    background-color: #f9fafb;
    font-size: 0.875rem;
    transition: background-color 0.2s;
    /* Ajout d'une transition douce */
    color: #1f2937;
    font-weight: 500;
}

.remove-task-btn {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 1.25rem;
}

/* Couleurs pour les fréquences */
.freq-daily {
    background-color: #fee2e2;
    border-color: #ef4444;
}

/* Rouge plus vif */
.freq-weekly {
    background-color: #fef3c7;
    border-color: #f59e0b;
}

/* Jaune plus vif */
.freq-monthly {
    background-color: #dbeafe;
    border-color: #3b82f6;
}

/* Bleu plus vif */
.freq-quarterly {
    background-color: #d1fae5;
    border-color: #10b981;
}

/* Vert plus vif */
.freq-bi-annually {
    background-color: #ede9fe;
    border-color: #8b5cf6;
}

/* Violet plus vif */
.freq-default {
    background-color: #f3f4f6;
    border-color: #9ca3af;
}

/* Gris plus contrasté */

/* --- NOUVEAUX STYLES POUR LE PLANNING AGENT --- */
.planning-agent-card {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.planning-agent-header {
    background-color: #f3f4f6;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.planning-agent-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #212551;
}

.planning-agent-header p {
    font-size: 0.875rem;
    color: #4b5563;
}

.planning-day-card {
    background-color: white;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
}

.planning-day-header {
    font-weight: 600;
    padding: 0.75rem 1rem;
    background-color: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    color: #374151;
}

.planning-tasks-list {
    padding: 1rem;
    list-style-type: none;
    margin: 0;
}

.planning-tasks-list li {
    font-size: 0.875rem;
    padding: 0.5rem;
    border-bottom: 1px solid #f3f4f6;
    color: #1f2937;
}

.planning-tasks-list li:last-child {
    border-bottom: none;
}

.planning-tasks-list li strong {
    font-weight: 600;
    color: #4b5563;
    display: block;
    /* Mettre la zone en gras sur sa propre ligne */
    margin-bottom: 0.25rem;
}

/* --- FIN DES NOUVEAUX STYLES --- */


.margin-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.margin-card {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.margin-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.75rem 1rem;
    background-color: #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
}

.margin-card-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.margin-card-footer {
    padding: 1rem;
    background-color: #fff;
    margin-top: auto;
    /* Pousse le footer en bas */
}

.data-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}


/* --- ASSISTANT IA (CHAT) --- */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, .1);
    border-radius: 50%;
    border-top-color: #212551;
    animation: spin 1s ease-in-out infinite;
}

#chat-fab {
    position: fixed;
    bottom: 7rem;
    right: 2rem;
    width: 4rem;
    height: 4rem;
    background-color: #212551;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    cursor: pointer;
    transition: all 0.3s;
    z-index: 999;
}

#chat-fab:hover {
    transform: scale(1.1);
    background-color: #2E346E;
}

#chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease-in-out;
}

#chat-overlay.visible {
    opacity: 1;
    visibility: visible;
}

#chat-modal {
    background: white;
    border-radius: 0.75rem;
    width: 90%;
    max-width: 1400px;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    transform: scale(0.95);
    transition: all 0.3s ease-in-out;
}

#chat-overlay.visible #chat-modal {
    transform: scale(1);
}

#chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#chat-window {
    height: 700px;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex-grow: 1;
}

#chat-window .chat-message.ai-message {
    padding: 0;
    /* Le padding sera géré par les éléments internes */
    background-color: transparent;
}

.chat-message {
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    max-width: 80%;
    line-height: 1.5;
}

.user-message {
    background-color: #dbeafe;
    color: #000000;
    align-self: flex-end;
}

.ai-message {
    background-color: #ffecc1;
    padding: 1rem;
    border-radius: 0.75rem;
    color: #000000;
    align-self: flex-start;
}

.ai-message.loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* --- STYLES POUR LE CONTENU MARKDOWN DU CHAT IA --- */

/* Cible tous les éléments à l'intérieur d'un message de l'IA */
#chat-window .ai-message>* {
    margin: 0;
    /* Réinitialise les marges par défaut */
}

/* Paragraphes */
#chat-window .ai-message p {
    margin-bottom: 0.75rem;
    /* 12px */
    line-height: 1.6;
}

/* Titres */
#chat-window .ai-message h3 {
    font-size: 1.125rem;
    /* text-lg */
    font-weight: 700;
    color: #212551;
    /* Couleur principale */
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
}

#chat-window .ai-message h3:first-child {
    margin-top: 0;
    /* Pas de marge en haut si c'est le premier élément */
}

/* Listes */
#chat-window .ai-message ul {
    list-style-type: disc;
    padding-left: 1.5rem;
    /* Espace pour les puces */
    margin-bottom: 0.75rem;
}

#chat-window .ai-message li {
    margin-bottom: 0.25rem;
}

/* Listes imbriquées */
#chat-window .ai-message ul ul {
    list-style-type: circle;
    margin-top: 0.25rem;
    margin-bottom: 0.5rem;
}

/* Éléments en gras (Marked les transforme en <strong>) */
#chat-window .ai-message strong {
    font-weight: 700;
    color: #111827;
    /* Un peu plus sombre pour le contraste */
}

/* --- BARRE DE PRIX FIXE --- */
#final-price-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background: #212551;
    color: white;
    z-index: 990;
    display: flex;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
}

/* Ajout d'un espace en bas de la page pour éviter que le contenu ne soit caché par la barre */
#app-page {
    padding-bottom: 100px;
}