:root {
    --primary: #913b8e;
    --primary-dark: #722d70;
    --primary-light: #f4e8f3;
    --success: #99c339;
    --success-dark: #7a9c2d;
    --danger: #dc2626;
    --gray: #6b7280;
    --bg: #f3f4f6;
    --border: #e5e7eb;
    --text: #000000;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.topbar {
    background: white;
    border-bottom: 3px solid var(--primary);
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar h1 { font-size: 18px; margin: 0; color: var(--text); display: flex; align-items: center; gap: 10px; }
.topbar span { color: var(--gray); }
.logo-ticks { height: 32px; vertical-align: middle; }
.topbar h1 a { display: inline-flex; align-items: center; text-decoration: none; }
.login-box .logo-ticks { height: 40px; display: block; margin: 0 auto 16px; }

.topbar-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.container { max-width: 1200px; margin: 24px auto; padding: 0 16px; }

.btn {
    padding: 8px 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    display: inline-block;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--primary-light); color: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--gray); border: 1px solid var(--border); }
.btn-valider { background: var(--success); color: white; margin-right: 6px; }
.btn-valider:hover { background: var(--success-dark); }
.btn-refuser { background: var(--danger); color: white; }

#calendar { background: white; padding: 16px; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

.legend { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 13px; color: var(--gray); flex-wrap: wrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.hint { margin-left: 8px; font-style: italic; }

/* Modale */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal.hidden { display: none; }
.modal-content { background: white; padding: 24px; border-radius: 10px; width: 460px; max-width: 90vw; }
.modal-content h2 { margin-top: 0; font-size: 18px; color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

form label { display: block; margin-bottom: 12px; font-size: 14px; color: #374151; }
form input, form select, form textarea {
    width: 100%; padding: 8px; margin-top: 4px;
    border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
}
form input:focus, form select:focus, form textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light);
}
.row { display: flex; gap: 12px; }
.row label { flex: 1; }

.alert { padding: 10px; border-radius: 6px; font-size: 14px; margin-bottom: 12px; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-info { background: var(--primary-light); color: var(--primary-dark); }
.hidden { display: none; }

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; height: 100vh; background: var(--text); }
.login-box { background: white; padding: 32px; border-radius: 10px; width: 360px; max-width: 90vw; box-shadow: 0 4px 24px rgba(124,58,237,0.25); border-top: 4px solid var(--primary); }
.login-box h1 { font-size: 18px; margin-bottom: 20px; text-align: center; color: var(--text); }
.login-box button { width: 100%; padding: 10px; background: var(--primary); color: white; border: none; border-radius: 6px; cursor: pointer; font-size: 15px; }
.login-box button:hover { background: var(--primary-dark); }

/* Table admin */
.table { width: 100%; border-collapse: collapse; background: white; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; text-align: left; }
.table th { background: var(--text); color: white; font-weight: 600; }

.badge { padding: 3px 8px; border-radius: 12px; font-size: 12px; text-transform: capitalize; }
.badge-en_attente { background: var(--primary-light); color: var(--primary-dark); }
.badge-validee { background: #dcfce7; color: var(--success-dark); }
.badge-refusee { background: #fee2e2; color: #991b1b; }

.ligne-filtres th { padding: 6px 8px; background: #fafafa; }
.table th { vertical-align: top; }
.table th .filtre-colonne { display: block; margin-top: 6px; font-weight: 400; text-transform: none; }
.filtre-colonne {
    width: 100%; padding: 5px 6px; font-size: 12px;
    border: 1px solid var(--border); border-radius: 5px; box-sizing: border-box;
}
.filtre-colonne:focus { outline: none; border-color: var(--primary); }

.fc-event.statut-en_attente { opacity: 0.6; background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.25) 0 6px, transparent 6px 12px); }
.fc-event.statut-refusee { opacity: 0.5; text-decoration: line-through; }

/* Sélecteur de projet */
.grille-projets { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.carte-projet { background: white; padding: 20px; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); display: flex; flex-direction: column; gap: 10px; border-left: 4px solid var(--primary); }
.carte-projet h3 { margin: 0; color: var(--text); }
.carte-projet p { margin: 0; color: var(--gray); font-size: 14px; flex-grow: 1; }
.projet-actuel { background: var(--primary-light); color: var(--primary-dark); padding: 4px 10px; border-radius: 6px; font-size: 13px; font-weight: 600; }

/* Conteneur défilant pour les tableaux (évite le débordement sur mobile) */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; }
.table-wrapper .table { box-shadow: none; }

/* ============================================
   RESPONSIVE — écrans étroits (mobile / petite tablette)
   ============================================ */
@media (max-width: 720px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 12px 16px;
    }
    .topbar h1 { font-size: 15px; }
    .logo-ticks { height: 22px; }
    .topbar-actions { width: 100%; justify-content: space-between; }

    .container { padding: 0 12px; margin: 16px auto; }

    /* Les champs côte à côte passent en colonne */
    .row { flex-direction: column; gap: 0; }

    .modal-content { width: 94vw; padding: 18px; }
    .modal-actions { flex-wrap: wrap; }
    .modal-actions .btn { flex: 1; min-width: 100px; }

    .grille-projets { grid-template-columns: 1fr; }

    .table th, .table td { padding: 8px; font-size: 13px; }

    .menu-dropdown { right: 0; max-width: calc(100vw - 24px); }

    /* Les cartes projet avec bouton supprimer en haut passent en colonne */
    .carte-projet > div[style*="justify-content:space-between"] {
        flex-direction: column;
        align-items: stretch !important;
    }

    #calendar .fc-toolbar { flex-direction: column; gap: 8px; }
    #calendar .fc-toolbar-title { font-size: 16px; }
}

@media (max-width: 480px) {
    .btn { padding: 7px 10px; font-size: 13px; }
    .login-box { width: 92vw; padding: 24px; }
}

.resume-projet::-webkit-details-marker { display: none; }
.resume-projet::marker { content: ''; }
.resume-projet:hover { background: var(--primary-light); border-radius: 10px; }

/* Menu déroulant */
.menu-wrapper { position: relative; display: inline-block; }
.menu-dropdown {
    position: absolute; right: 0; top: calc(100% + 6px);
    background: white; border: 1px solid var(--border); border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15); min-width: 210px; z-index: 100;
    overflow: hidden; display: flex; flex-direction: column;
}
.menu-dropdown.hidden { display: none; }
.menu-dropdown a {
    padding: 10px 16px; color: var(--text); text-decoration: none; font-size: 14px;
    border-bottom: 1px solid var(--border);
}
.menu-dropdown a:last-child { border-bottom: none; }
.menu-dropdown a:hover { background: var(--primary-light); color: var(--primary-dark); }
