:root {
    --color-primary: #019cdb;
    --color-primary-dark: #0278a9;
    --color-background: #f4f7fb;
    --color-surface: #ffffff;
    --color-border: #d4dde7;
    --color-text: #173042;
    --color-muted: #577184;
    --color-danger: #b33434;
    --color-warning: #9b6a05;
    --color-success: #1f7a45;
    --shadow-soft: 0 10px 30px rgba(20, 55, 85, 0.08);
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background:
        radial-gradient(circle at top right, rgba(1, 156, 219, 0.12), transparent 28%),
        linear-gradient(180deg, #eef5fa 0%, #f7fafc 100%);
    color: var(--color-text);
}

a {
    color: var(--color-primary-dark);
    text-decoration: none;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.brand-logo {
    width: 54px;
    height: 54px;
}

.brand-subtitle {
    color: var(--color-muted);
    font-size: 0.9rem;
}

.nav {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 1.5rem;
}

.panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    padding: 1.5rem;
}

.subpanel {
    margin-top: 1.25rem;
    background: #fbfdff;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1.25rem;
}

.auth-panel {
    max-width: 520px;
    margin: 2rem auto;
}

.form-grid {
    display: grid;
    gap: 1rem;
}

.form-grid label {
    display: grid;
    gap: 0.35rem;
}

select {
    width: 100%;
    padding: 0.8rem 0.9rem;
    border-radius: 10px;
    border: 1px solid var(--color-border);
    background: #fff;
}

input,
button,
select {
    font: inherit;
}

input {
    width: 100%;
    padding: 0.8rem 0.9rem;
    border-radius: 10px;
    border: 1px solid var(--color-border);
}

.button-primary {
    background: var(--color-primary);
    color: #fff;
    border: 0;
    border-radius: 10px;
    padding: 0.9rem 1.1rem;
    cursor: pointer;
}

.button-secondary,
.button-danger {
    display: inline-block;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--color-border);
    background: #fff;
    color: var(--color-text);
    text-align: center;
}

.button-danger {
    border-color: #e6b6b6;
    color: var(--color-danger);
    background: #fff6f6;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.card {
    background: #f9fcff;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1rem;
}

.toast {
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 12px;
    border: 1px solid transparent;
}

.toast-error {
    background: #fff1f1;
    border-color: #f3caca;
    color: var(--color-danger);
}

.toast-warning {
    background: #fff8e7;
    border-color: #f2dfaa;
    color: var(--color-warning);
}

.toast-success {
    background: #edf9f1;
    border-color: #c7e8d1;
    color: var(--color-success);
}

.muted {
    color: var(--color-muted);
}

.small {
    font-size: 0.92rem;
}

.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(320px, 420px) 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.agent-grid {
    grid-template-columns: minmax(360px, 460px) 1fr;
}

.absence-grid {
    grid-template-columns: minmax(320px, 420px) 1fr;
}

.checkbox-row {
    display: flex !important;
    align-items: flex-start;
    gap: 0.75rem;
}

.inline-filter {
    display: flex;
    gap: 0.75rem;
    align-items: end;
    flex-wrap: wrap;
}

.inline-filter label {
    min-width: 240px;
}

.info-strip {
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 12px;
    background: #eef6fc;
    border: 1px solid #cfe2f0;
}

textarea {
    width: 100%;
    padding: 0.8rem 0.9rem;
    border-radius: 10px;
    border: 1px solid var(--color-border);
    font: inherit;
    resize: vertical;
}

.color-chip {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    vertical-align: middle;
    margin-right: 0.4rem;
}

.absence-table-shell {
    --absence-sticky-top: 86px;
    --absence-sticky-left-week: 0px;
    --absence-sticky-left-day: 64px;
    position: relative;
}

.absence-table-sticky-head {
    position: sticky;
    top: var(--absence-sticky-top);
    z-index: 20;
    background: #fbfdff;
}

.absence-table-head-wrap {
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
    background: #fbfdff;
}

.absence-table-scrollbar {
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid var(--color-border);
    border-top: 0;
    background: #f5f9fc;
}

.absence-table-scrollbar-inner {
    height: 16px;
}

.absence-table-wrap {
    overflow-x: auto;
    overflow-y: visible;
    border: 1px solid var(--color-border);
    border-top: 0;
    border-radius: 0 0 12px 12px;
    background: #fff;
}

.absence-table {
    width: max-content;
    min-width: 980px;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 0.92rem;
}

.absence-table-head,
.absence-table-body {
    margin: 0;
}

.absence-col-week {
    width: 64px;
}

.absence-col-day {
    width: 92px;
}

.absence-col-slot {
    width: 78px;
}

.absence-table th,
.absence-table td {
    border: 1px solid var(--color-border);
    padding: 0.5rem;
    text-align: center;
    vertical-align: top;
}

.absence-table th {
    background: #f5f9fc;
}

.absence-table-head th {
    border-top: 0;
}

.absence-table-head tr:first-child th:first-child {
    border-left: 0;
}

.absence-table-head tr:first-child th:last-child {
    border-right: 0;
}

.absence-table-head tr:not(:first-child) th:first-child {
    border-left: 0;
}

.absence-table-head tr th:last-child {
    border-right: 0;
}

.absence-table-body td:first-child {
    border-left: 0;
}

.absence-table-body td:last-child {
    border-right: 0;
}

.absence-table-body tr:last-child td {
    border-bottom: 0;
}

.absence-table-body tr.week-separator td {
    border-bottom: 3px solid #8ea3b5;
}

.absence-week-col {
    width: 64px;
    min-width: 64px;
}

.absence-day-col {
    width: 92px;
    min-width: 92px;
}

.absence-table-head .absence-week-col,
.absence-table-body .absence-week-col {
    position: sticky;
    left: var(--absence-sticky-left-week);
    z-index: 4;
    background: #fbfdff;
}

.absence-table-head .absence-day-col,
.absence-table-body .absence-day-col {
    position: sticky;
    left: var(--absence-sticky-left-day);
    z-index: 4;
    background: #fbfdff;
}

.absence-table-head th.absence-week-col,
.absence-table-head th.absence-day-col {
    z-index: 5;
    background: #f5f9fc;
}

.absence-table-body .holiday-row .absence-week-col,
.absence-table-body .holiday-row .absence-day-col {
    background: #fff7e7;
}

.absence-cell a {
    color: inherit;
    text-decoration: underline;
}

.absence-cell-action {
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.absence-cell-action:hover {
    transform: translateY(-1px);
    box-shadow: inset 0 0 0 2px rgba(1, 156, 219, 0.18);
}

.holiday-row td:first-child {
    background: #fff7e7;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(14, 33, 49, 0.46);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
}

.modal-panel {
    width: min(680px, 100%);
    max-height: 90vh;
    overflow: auto;
    background: #fff;
    border-radius: 16px;
    border: 1px solid var(--color-border);
    box-shadow: 0 24px 60px rgba(17, 40, 64, 0.24);
    padding: 1.25rem;
}

.modal-panel-compact {
    width: min(520px, 100%);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.modal-close {
    border: 0;
    background: transparent;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-muted);
    padding: 0;
}

.top-gap-form {
    margin-top: 1rem;
}

.checkbox-row input[type="checkbox"] {
    width: auto;
    margin-top: 0.25rem;
}

.button-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.action-stack {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.action-stack form {
    margin: 0;
}

.diagnostic-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.diagnostic-table th,
.diagnostic-table td {
    padding: 0.8rem;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    vertical-align: top;
}

.settings-tabs .tabs {
    margin: 1rem 0 0;
    gap: 0.45rem;
}

.settings-tabs .tabs .tab {
    margin: 0;
    padding: 0.85rem 1.1rem;
    border-radius: 12px 12px 0 0;
    background: #dceaf2;
    color: #305164;
    font-weight: 600;
}

.settings-tabs .tabs .tab.sel {
    background: #fbfdff;
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-bottom-color: transparent;
}

.settings-tabs .tab-section {
    background: #fbfdff;
    border: 1px solid var(--color-border);
    border-radius: 0 12px 12px 12px;
    padding: 1.25rem;
}

.settings-tabs .tab-section > .subpanel:first-child,
.settings-tabs .tab-section > .admin-grid:first-child,
.settings-tabs .tab-section > .agent-grid:first-child {
    margin-top: 0;
}

.planning-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

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

.planning-table {
    width: 100%;
    min-width: 1200px;
    border-collapse: collapse;
}

.planning-table th,
.planning-table td {
    border: 1px solid var(--color-border);
    padding: 0.55rem;
    vertical-align: top;
}

.planning-table th {
    background: #f5f9fc;
    text-align: center;
}

.planning-line-label {
    min-width: 240px;
    background: #fbfdff;
}

.planning-group-row td {
    background: #e9f4fb;
    font-weight: 700;
}

.planning-holiday-head {
    background: #fff5df !important;
}

.planning-cell {
    min-width: 148px;
}

.planning-cell-editable {
    padding: 0;
}

.planning-cell-button {
    display: block;
    width: 100%;
    min-height: 62px;
    padding: 0.55rem;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.planning-confirm-box {
    margin-top: 1rem;
    padding: 1rem 1.1rem;
    border: 1px solid #f0d2d2;
    border-radius: 14px;
    background: #fff8f8;
}

.planning-confirm-box p {
    margin: 0 0 0.5rem;
}

.planning-cell-button:hover {
    background: rgba(1, 156, 219, 0.08);
}

.planning-cell-drop-hover {
    background: rgba(1, 156, 219, 0.12) !important;
    box-shadow: inset 0 0 0 2px rgba(1, 156, 219, 0.35);
}

.planning-assignment {
    display: inline-block;
    width: 100%;
    padding: 0.45rem 0.55rem;
    border-radius: 10px;
    color: #173042;
    font-weight: 600;
}

.planning-holiday-default {
    display: inline-block;
    width: 100%;
    padding: 0.45rem 0.55rem;
    border: 1px dashed #d7b35a;
    border-radius: 10px;
    background: #fff7e6;
    color: #8a6113;
    font-weight: 700;
    text-align: center;
}

.planning-assignment-draggable {
    cursor: grab;
}

.planning-assignment-dragging {
    opacity: 0.55;
    cursor: grabbing;
}

.planning-auto-stack {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.planning-auto-chip {
    display: inline-block;
    padding: 0.35rem 0.5rem;
    background: #eef5fa;
    border: 1px solid #d6e3ec;
    border-radius: 999px;
    font-size: 0.88rem;
}

.planning-table-print .planning-cell,
.planning-table-print .planning-line-label {
    min-width: auto;
}

.settings-tab-panel {
    display: grid;
    gap: 1rem;
}

.settings-link-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.1rem;
    border: 1px solid #d7e4ed;
    border-radius: 14px;
    background: #f8fbfd;
}

.settings-link-card p {
    margin: 0.35rem 0 0;
}

.plain-list {
    margin: 0.75rem 0 0;
    padding-left: 1rem;
}

.horaires-admin-grid {
    display: grid;
    grid-template-columns: minmax(280px, 340px) 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.horaires-site-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.horaires-site-card {
    margin-top: 0;
}

.horaires-admin-main {
    display: grid;
    gap: 1rem;
}

.horaires-tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.horaires-tool-card {
    align-content: start;
    min-height: 100%;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: #f9fcff;
}

.horaires-tool-card h2 {
    margin: 0;
}

.horaires-tool-card .small.muted {
    margin: -0.35rem 0 0;
}

.horaires-tool-submit {
    width: 100%;
    margin-top: auto;
}

.horaires-calendar-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

#horaires-admin-calendar {
    min-height: 760px;
}

#horaires-admin-calendar .fc {
    --fc-border-color: var(--color-border);
    --fc-button-bg-color: var(--color-primary);
    --fc-button-border-color: var(--color-primary);
    --fc-button-hover-bg-color: var(--color-primary-dark);
    --fc-button-hover-border-color: var(--color-primary-dark);
    --fc-button-active-bg-color: var(--color-primary-dark);
    --fc-button-active-border-color: var(--color-primary-dark);
    --fc-event-border-color: transparent;
    --fc-neutral-bg-color: #f6fafc;
    --fc-page-bg-color: #ffffff;
    --fc-today-bg-color: rgba(1, 156, 219, 0.08);
}

#horaires-admin-calendar .fc .fc-toolbar-title {
    font-size: 1.2rem;
}

#horaires-admin-calendar .fc .fc-button {
    border-radius: 10px;
    box-shadow: none;
}

#horaires-admin-calendar .fc .fc-timegrid-slot {
    height: 1.8rem;
}

#horaires-admin-calendar .fc-bg-event {
    opacity: 0.45;
}

.public-horaires-body {
    margin: 0;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top, rgba(93, 146, 97, 0.14), transparent 38%),
        linear-gradient(180deg, #f6fbf7 0%, #edf4ef 100%);
    color: #17311d;
}

.public-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.public-stack {
    width: min(100%, 560px);
}

.public-logo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.public-logo {
    display: block;
    width: min(100%, 150px);
    height: auto;
}

.public-card {
    width: 100%;
    background: #ffffff;
    border: 1px solid #d4e1d6;
    border-radius: 28px;
    box-shadow: 0 20px 45px rgba(20, 48, 31, 0.12);
    padding: 1.5rem;
}

.status-card {
    text-align: center;
}

.public-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.public-header h1 {
    margin: 0 0 0.5rem;
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    line-height: 1.05;
}

.public-kicker {
    margin: 0 0 0.5rem;
    color: #0f6a3d;
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.public-lead {
    margin: 0;
    color: #587260;
    font-size: 1rem;
}

.button-stack {
    display: grid;
    gap: 1rem;
}

.choice-button,
.site-button {
    display: block;
    width: 100%;
    text-decoration: none;
    border-radius: 22px;
    padding: 1.25rem;
    color: #fff;
    font-size: 1.35rem;
    font-weight: 700;
    text-align: center;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    box-shadow: 0 16px 26px rgba(16, 45, 31, 0.16);
}

.choice-button {
    border: 0;
    cursor: pointer;
}

.choice-button:hover,
.site-button:hover,
.choice-button:focus-visible,
.site-button:focus-visible {
    transform: translateY(-2px);
}

.choice-button-primary,
.site-button {
    background: linear-gradient(135deg, #0d8b4c 0%, #11723f 100%);
}

.site-button-open {
    background: linear-gradient(135deg, #138b4a 0%, #0f6e3b 100%);
}

.site-button-closed {
    background: linear-gradient(135deg, #c53a3a 0%, #932727 100%);
}

.choice-button-secondary {
    background: linear-gradient(135deg, #2e79b0 0%, #205882 100%);
}

.choice-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    transform: none;
    box-shadow: none;
}

.site-button {
    text-align: left;
}

.choice-button-title,
.site-button-title {
    display: block;
}

.choice-button-meta,
.site-button-meta {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.92rem;
    font-weight: 500;
    opacity: 0.92;
}

.public-type-sites[hidden] {
    display: none !important;
}

.status-light {
    width: 130px;
    height: 130px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    border: none;
    box-shadow:
        0 0 0 0 rgba(21, 153, 71, 0.72),
        inset 0 -18px 30px rgba(0, 0, 0, 0.16);
    animation: statusPulse 1.25s infinite cubic-bezier(0.66, 0, 0, 1);
}

.status-light.open {
    background: #159947;
}

.status-light.closed {
    background: #c62828;
    box-shadow:
        0 0 0 0 rgba(198, 40, 40, 0.72),
        inset 0 -18px 30px rgba(0, 0, 0, 0.16);
    animation-name: statusPulseClosed;
}

.status-light:hover {
    animation: none;
}

@keyframes statusPulse {
    to {
        box-shadow:
            0 0 0 45px rgba(21, 153, 71, 0),
            inset 0 -18px 30px rgba(0, 0, 0, 0.16);
    }
}

@keyframes statusPulseClosed {
    to {
        box-shadow:
            0 0 0 45px rgba(198, 40, 40, 0),
            inset 0 -18px 30px rgba(0, 0, 0, 0.16);
    }
}

.status-text {
    font-size: clamp(2.2rem, 8vw, 3.4rem);
    font-weight: 800;
    letter-spacing: 0.04em;
    margin-bottom: 1rem;
}

.status-text-open {
    color: #0f6a3d;
}

.status-text-closed {
    color: #c62828;
}

.status-panel {
    background: #f5faf6;
    border-radius: 20px;
    padding: 1rem;
    font-size: 1.05rem;
}

.status-panel p {
    margin: 0.45rem 0;
}

.status-panel-link a {
    color: #0f6a3d;
    font-weight: 700;
}

.absence-summary-table td {
    vertical-align: top;
}

.absence-summary-details {
    min-width: 320px;
}

.absence-summary-details summary {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    font-weight: 700;
}

.absence-summary-details-body {
    margin-top: 0.75rem;
}

.absence-summary-chip {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    flex: 0 0 auto;
}

.absence-summary-periods {
    margin: 0;
    padding-left: 1.1rem;
}

.absence-summary-periods li + li {
    margin-top: 0.35rem;
}

.public-actions {
    margin-top: 1.5rem;
    text-align: center;
}

.back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 140px;
    padding: 0.85rem 1.25rem;
    border-radius: 999px;
    background: #eef3ef;
    color: #17311d;
    text-decoration: none;
    font-weight: 700;
    border: 0;
    cursor: pointer;
}

.empty-state {
    padding: 1rem;
    text-align: center;
    border-radius: 16px;
    background: #f5faf6;
}

@media (max-width: 768px) {
    .topbar {
        position: static;
        flex-direction: column;
        align-items: flex-start;
    }

    .container {
        padding: 1rem;
    }

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

    .planning-toolbar {
        align-items: stretch;
    }

    .horaires-admin-grid {
        grid-template-columns: 1fr;
    }

    .horaires-calendar-toolbar {
        align-items: stretch;
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    .status-light {
        animation: none;
    }
}

@media (max-width: 640px) {
    .public-card {
        padding: 1.25rem;
        border-radius: 22px;
    }

    .choice-button,
    .site-button {
        font-size: 1.15rem;
        padding: 1rem;
    }
}
