:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #18212f;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #3157d5;
    --primary-hover: #2648b5;
    --danger-bg: #fef2f2;
    --danger-text: #b42318;
    --success-bg: #ecfdf3;
    --success-text: #027a48;
    --shadow: 0 16px 50px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: inherit;
}

.topbar {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

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

.container {
    width: min(1800px, calc(100% - 32px));
    margin: 0 auto;
    padding: 34px 0 60px;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 28px;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 8px;
    font-size: clamp(1.8rem, 3vw, 2.5rem);
    letter-spacing: -0.04em;
}

.eyebrow {
    margin-bottom: 6px;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.muted {
    color: var(--muted);
    line-height: 1.6;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--muted);
    border: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 800;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 12px;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: 0.18s ease;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-full {
    width: 100%;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.dashboard-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 150px;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
    text-decoration: none;
}

.dashboard-card-title {
    font-size: 1.1rem;
    font-weight: 800;
}

.dashboard-card-text {
    color: var(--muted);
    line-height: 1.6;
}

.login-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
}

.login-card {
    width: min(100%, 430px);
    padding: 32px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
}

.login-brand h1 {
    margin: 0;
    font-size: 1.6rem;
}

.login-icon {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: var(--primary);
    color: #fff;
    font-size: 1.4rem;
    font-weight: 900;
}

.field {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
}

.field label {
    font-size: 0.9rem;
    font-weight: 700;
}

.field input {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font: inherit;
    outline: none;
}

.field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(49, 87, 213, 0.1);
}

.alert {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
}

.empty-state {
    padding: 40px;
    border: 1px dashed var(--border);
    border-radius: 20px;
    background: var(--surface);
    text-align: center;
}

@media (max-width: 720px) {
    .topbar {
        align-items: flex-start;
        padding: 16px;
    }

    .topbar-user {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .container {
        width: min(100% - 24px, 1180px);
        padding-top: 24px;
    }

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

    .login-card {
        padding: 24px;
        border-radius: 20px;
    }
}


/* =========================================================
   PLANNING
   ========================================================= */

.planning-head {
    align-items: center;
}

.planning-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
}

.planning-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    font-size: 0.82rem;
    font-weight: 700;
}

.planning-legend-item i {
    width: 11px;
    height: 11px;
    border-radius: 50%;
}

.calendar-shell {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

#calendar {
    min-height: 620px;
}

.fc .fc-toolbar-title {
    font-size: clamp(1.1rem, 2vw, 1.45rem);
}

.fc .fc-button {
    border-radius: 10px !important;
}

.fc .fc-event {
    padding: 3px 5px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
}

.fc .fc-daygrid-day {
    cursor: pointer;
}

.fc .fc-day-today {
    background: rgba(49, 87, 213, 0.045) !important;
}

.modal[hidden] {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 20px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(5px);
}

.modal-dialog {
    position: relative;
    z-index: 1;
    width: min(760px, 100%);
    max-height: min(88vh, 920px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: 0 30px 90px rgba(15, 23, 42, 0.28);
}

.modal-header,
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 22px;
}

.modal-header {
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    margin-bottom: 0;
    text-transform: capitalize;
}

.modal-footer {
    justify-content: flex-end;
    border-top: 1px solid var(--border);
}

.modal-body {
    overflow-y: auto;
    padding: 22px;
}

.modal-close {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 1.65rem;
    line-height: 1;
    cursor: pointer;
}

.modal-open {
    overflow: hidden;
}

.exam-assignment + .exam-assignment {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.exam-assignment-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}

.exam-assignment-head h3 {
    margin: 0 0 3px;
}

.exam-assignment-head p {
    margin: 0;
    color: var(--muted);
    font-size: 0.84rem;
}

.exam-dot {
    flex: 0 0 auto;
    width: 14px;
    height: 14px;
    margin-top: 5px;
    border-radius: 50%;
}

.doctor-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.doctor-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    padding: 12px 13px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-soft);
    cursor: pointer;
}

.doctor-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.doctor-checkbox {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    border: 2px solid #cbd5e1;
    border-radius: 7px;
    background: #fff;
}

.doctor-option input:checked + .doctor-checkbox {
    border-color: var(--primary);
    background:
        linear-gradient(var(--primary), var(--primary));
    box-shadow: inset 0 0 0 4px #fff;
}

.doctor-option input:disabled ~ * {
    opacity: 0.75;
}

.doctor-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.doctor-meta,
.doctor-status {
    color: var(--muted);
    font-size: 0.76rem;
}

.doctor-option--unavailable {
    border-color: #f1c7c7;
    background: #fff8f8;
}

.doctor-status {
    color: var(--danger-text);
}

.planning-warning {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 14px;
    background: #fffbeb;
    color: #92400e;
    font-size: 0.9rem;
    line-height: 1.5;
}

.planning-warning ul {
    margin: 8px 0 0;
    padding-left: 20px;
}

.planning-loading {
    padding: 40px;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 760px) {
    .calendar-shell {
        padding: 10px;
        border-radius: 16px;
    }

    #calendar {
        min-height: 540px;
    }

    .fc .fc-toolbar {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .fc .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
    }

    .modal {
        padding: 0;
        align-items: end;
    }

    .modal-dialog {
        width: 100%;
        max-height: 92vh;
        border-radius: 22px 22px 0 0;
    }

    .doctor-list {
        grid-template-columns: 1fr;
    }

    .modal-header,
    .modal-footer,
    .modal-body {
        padding-left: 16px;
        padding-right: 16px;
    }
}


/* =========================================================
   V3 - ADMINISTRATION / TABLEAUX / NOTIFICATIONS
   ========================================================= */

.panel {
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.admin-layout {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.field select,
.field textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

.field textarea {
    resize: vertical;
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.text-right {
    text-align: right !important;
}

.btn-danger {
    background: #fff1f1;
    color: #b42318;
    border: 1px solid #f3caca;
}

.checkbox-line {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 10px 0 20px;
}

.actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.notification-list {
    display: grid;
    gap: 12px;
}

.notification-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
}

.notification-card p {
    margin: 5px 0;
}

.notification-card small {
    color: var(--muted);
}

.notification-count {
    display: inline-grid;
    place-items: center;
    min-width: 25px;
    height: 25px;
    margin-left: 6px;
    padding: 0 7px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 0.75rem;
}

.status {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 800;
}

.status--active {
    background: #ecfdf3;
    color: #027a48;
}

.status--inactive {
    background: #f2f4f7;
    color: #667085;
}

.inline-filter {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.inline-filter input {
    min-height: 44px;
    width: 120px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
}

@media (max-width: 900px) {
    .admin-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .notification-card {
        align-items: flex-start;
        flex-direction: column;
    }

    .actions {
        align-items: stretch;
        flex-direction: column;
    }

    .page-head {
        flex-direction: column;
    }
}


/* =========================================================
   CORRECTIF PLANNING - COULEURS / DOUBLE VACATION
   ========================================================= */

.fc .fc-event,
.fc .fc-daygrid-event,
.fc .fc-timegrid-event {
    overflow: hidden;
}

.fc .fc-event-main {
    color: inherit !important;
}

.fc .fc-daygrid-event {
    white-space: normal;
}

.fc .fc-event-title,
.fc .fc-event-title-container {
    font-weight: 700;
}



/* Dimanche non interactif */
.fc .day-disabled {
    background: #f3f4f6 !important;
    cursor: not-allowed !important;
}

.fc .day-disabled .fc-daygrid-day-number {
    color: #b8bec8 !important;
}

.fc .day-disabled:hover {
    background: #f3f4f6 !important;
}


.token-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 260px;
}

.token-input {
    width: 100%;
    min-height: 40px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-soft);
    font: inherit;
    font-size: 0.78rem;
}


/* =========================================================
   V4 - AFFECTATION EN MASSE / LIVE
   ========================================================= */

.mass-toolbar,
.mass-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 14px;
}

.mass-toolbar .field,
.mass-actions .field {
    margin-bottom: 0;
}

.mass-day {
    padding: 22px 0;
    border-top: 1px solid var(--border);
}

.mass-day:first-child {
    border-top: 0;
}

.mass-day-title h2 {
    margin-bottom: 14px;
}

.mass-exams {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.mass-exam {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface-soft);
}

.mass-exam-head {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 12px;
}

.mass-doctors {
    display: grid;
    gap: 8px;
}

.mass-doctor {
    display: flex;
    align-items: center;
    gap: 9px;
}

.mass-actions {
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.model-name-field {
    margin-right: auto;
}

.duplicate-panel {
    margin-top: 20px;
}

.fc-event-modified {
    position: relative;
}

.fc-event-modified::after {
    content: "";
    position: absolute;
    top: 3px;
    right: 3px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #dc2626;
    box-shadow: 0 0 0 2px rgba(255,255,255,.8);
}

.planning-toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 2000;
    width: min(380px, calc(100vw - 40px));
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 20px 60px rgba(15,23,42,.18);
    opacity: 0;
    transform: translateY(10px);
    transition: .22s ease;
}

.planning-toast--visible {
    opacity: 1;
    transform: translateY(0);
}

.planning-toast span {
    color: var(--muted);
    font-size: .88rem;
}

@media (max-width: 780px) {
    .mass-exams {
        grid-template-columns: 1fr;
    }

    .mass-toolbar,
    .mass-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .model-name-field {
        margin-right: 0;
    }
}


/* =========================================================
   V5 - UTILISATEURS / EXAMENS
   ========================================================= */

.actions--right {
    justify-content: flex-end;
    flex-wrap: wrap;
}

.color-field {
    display: flex;
    align-items: center;
    gap: 12px;
}

.color-field input[type="color"] {
    width: 54px;
    height: 42px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}

.color-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.color-chip i {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,.08);
}
/* Sélecteur de mois */
.month-select-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-width: 175px;
}

.month-select {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    height: 44px;
    padding: 0 42px 0 16px;

    background: #ffffff;
    color: #25324a;
    border: 1px solid #dce3ee;
    border-radius: 12px;

    font-family: inherit;
    font-size: 14px;
    font-weight: 600;

    cursor: pointer;
    outline: none;

    box-shadow: 0 2px 6px rgba(20, 35, 60, 0.04);
    transition: border-color .2s ease, box-shadow .2s ease;
}

.month-select:hover {
    border-color: #a9b8cf;
}

.month-select:focus {
    border-color: #6479a7;
    box-shadow: 0 0 0 4px rgba(100, 121, 167, 0.12);
}

.month-select-arrow {
    position: absolute;
    right: 14px;
    width: 17px;
    height: 17px;
    color: #64748b;
    pointer-events: none;
    transition: transform .2s ease;
}

.month-select-wrapper:focus-within .month-select-arrow {
    transform: rotate(180deg);
}