:root {
    --brand-950: #022238;
    --brand-900: #043653;
    --brand-800: #06456d;
    --brand-700: #085789;
    --brand-600: #0b6eae;
    --brand-500: #188bd5;
    --accent: #f5c800;
    --surface: #fff;
    --line: #dbe5ec
}

html {
    scroll-behavior: smooth
}

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif
}

.app-sidebar,
.app-mobile-header,
.app-public-nav {
    background: linear-gradient(180deg, var(--brand-900), var(--brand-950))
}

.landing-hero {
    background: radial-gradient(circle at 20% 15%, rgba(24, 139, 213, .55), transparent 35%), linear-gradient(135deg, var(--brand-700), var(--brand-950))
}

.landing-hero>.absolute {
    background-image: linear-gradient(45deg, rgba(255, 255, 255, .12) 1px, transparent 1px);
    background-size: 24px 24px
}

.app-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 1rem;
    box-shadow: 0 8px 26px rgba(2, 34, 56, .06)
}

.sidebar-group {
    margin-bottom: .35rem
}

.sidebar-summary {
    display: flex;
    cursor: pointer;
    list-style: none;
    align-items: center;
    justify-content: space-between;
    border-radius: .65rem;
    padding: .7rem .8rem;
    color: #d9effd;
    font-weight: 600
}

.sidebar-summary:hover {
    background: rgba(255, 255, 255, .08)
}

.sidebar-summary::-webkit-details-marker {
    display: none
}

.sidebar-group[open] .sidebar-summary>span:last-child {
    transform: rotate(90deg)
}

.sidebar-submenu {
    margin: .25rem 0 .45rem .75rem;
    border-left: 1px solid rgba(255, 255, 255, .16);
    padding-left: .65rem
}

.sidebar-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: .6rem;
    padding: .58rem .7rem;
    color: #c8e7f9;
    font-size: .875rem
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff
}

.sidebar-link.is-active {
    background: var(--brand-500);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--accent)
}

.sidebar-count {
    min-width: 1.35rem;
    border-radius: 999px;
    background: var(--accent);
    padding: .1rem .4rem;
    text-align: center;
    color: var(--brand-950);
    font-size: .7rem;
    font-weight: 800
}

.app-alert {
    border-width: 1px;
    border-radius: .75rem;
    padding: .75rem 1rem;
    font-size: .875rem
}

.app-alert--error {
    border-color: #fecaca;
    background: #fef2f2;
    color: #991b1b
}

.app-alert--success {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534
}

.app-alert--warning {
    border-color: #fde68a;
    background: #fffbeb;
    color: #92400e
}

.app-alert--info {
    border-color: #bae6fd;
    background: #f0f9ff;
    color: #075985
}

.app-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center
}

.app-loader[hidden] {
    display: none
}

.app-loader__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 34, 56, .36);
    backdrop-filter: blur(2px)
}

.app-loader__panel {
    position: relative;
    display: flex;
    align-items: center;
    gap: .8rem;
    border: 1px solid rgba(255, 255, 255, .7);
    border-radius: 1rem;
    background: #fff;
    padding: 1rem 1.25rem;
    color: var(--brand-900);
    box-shadow: 0 20px 60px rgba(2, 34, 56, .24);
    font-weight: 600
}

.app-loader__spinner {
    width: 1.5rem;
    height: 1.5rem;
    border: 3px solid #d9effd;
    border-top-color: var(--brand-600);
    border-radius: 999px;
    animation: app-spin .75s linear infinite
}

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

.is-loading {
    pointer-events: none;
    opacity: .75
}

.button-spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-right: .45rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 999px;
    vertical-align: -.15em;
    animation: app-spin .7s linear infinite
}

/* Harmonisation non destructive des tableaux existants */
table {
    border-collapse: separate;
    border-spacing: 0
}

thead.bg-slate-800 {
    background: var(--brand-800) !important
}

tbody tr:hover {
    background: #f4faff !important
}

th {
    letter-spacing: .01em
}

a.text-brand-600 {
    color: var(--brand-600)
}

.bg-brand-600 {
    background-color: var(--brand-600) !important
}

.hover\:bg-brand-700:hover {
    background-color: var(--brand-700) !important
}

.border-brand-600 {
    border-color: var(--brand-600) !important
}

.text-brand-700 {
    color: var(--brand-700) !important
}

.focus\:ring-brand-500:focus {
    --tw-ring-color: var(--brand-500) !important
}

.hp-wrapper {
    position: absolute !important;
    left: -10000px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important
}

.is-invalid {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .12)
}

@media(prefers-reduced-motion:reduce) {

    *,
    *:before,
    *:after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important
    }
}

.stepper-item {
    position: relative;
}

.stepper-item:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 16px;
    left: 55%;
    width: 90%;
    height: 2px;
    background-color: #e2e8f0;
    /* slate-200 */
    z-index: 0;
}

.stepper-item.done:not(:last-child)::after {
    background-color: #16a34a;
    /* green-600 */
}

.stepper-item.active .stepper-circle {
    background-color: #0984D3;
    /* brand-500 (bleu du logo) */
    color: #fff;
}

.stepper-item.active .stepper-label {
    color: #0984D3;
    font-weight: 600;
}

.stepper-item.done .stepper-circle {
    background-color: #16a34a;
    /* green-600 */
    color: #fff;
}

.stepper-item.done .stepper-label {
    color: #16a34a;
}

@media (max-width: 420px) {
    .stepper-label {
        display: none;
    }
}

/* Bordure rouge sur les champs invalides, ajoutée dynamiquement par wizard.js */
.is-invalid {
    border-color: #dc2626 !important;
    /* red-600 */
}

/* Piège anti-robot : masqué visuellement (hors écran), mais toujours
   présent dans le DOM. On évite display:none, que certains robots
   ignorent lors du remplissage automatique des formulaires. */
.hp-wrapper {
    position: absolute;
    left: -9999px;
    top: -9999px;
    height: 0;
    width: 0;
    overflow: hidden;
}

/* Prévisualisation des photos */
.photo-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.75rem;
}

.photo-preview-card {
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    overflow: hidden;
    background: #ffffff;
}

.photo-preview-card img {
    display: block;
    width: 100%;
    height: 110px;
    object-fit: cover;
}

.photo-preview-caption {
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* États visibles de la géolocalisation */
.gps-status-card {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    border-radius: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
}

.gps-found {
    border-color: #86efac;
    background: #f0fdf4;
    color: #166534;
}

.gps-insufficient,
.gps-retry,
.gps-cancelled {
    border-color: #fcd34d;
    background: #fffbeb;
    color: #92400e;
}

.gps-error {
    border-color: #fecaca;
    background: #fef2f2;
    color: #991b1b;
}

.gps-spinner {
    flex: 0 0 auto;
    width: 1rem;
    height: 1rem;
    margin-top: 0.1rem;
    border-radius: 9999px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    animation: gps-spin 0.8s linear infinite;
}

.photo-preview-item {
    position: relative;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    background: #fff;
    padding: 0.5rem;
}

.photo-preview-item img {
    display: block;
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 0.5rem;
    background: #f1f5f9;
}

.photo-preview-number {
    display: block;
    margin-top: 0.5rem;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 600;
}

.photo-remove-button {
    width: 100%;
    min-height: 40px;
    margin-top: 0.5rem;
    border: 1px solid #dc2626;
    border-radius: 0.5rem;
    color: #b91c1c;
    background: #fff;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
}

.photo-remove-button:hover {
    background: #fef2f2;
}

.photo-remove-button:focus-visible {
    outline: 3px solid rgba(220, 38, 38, 0.25);
    outline-offset: 2px;
}

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

/* Bouton inactif : modifications manager/superviseur sans motif */
.btn-disabled,
button:disabled,
input[type="submit"]:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    filter: grayscale(20%);
}

/* Carte : couleurs stables par district et statut par contour */
.map-legend-card {
    display: grid;
    gap: .75rem;
    border: 1px solid var(--line);
    border-radius: .9rem;
    background: var(--surface);
    padding: .8rem 1rem;
    box-shadow: 0 6px 20px rgba(2, 34, 56, .05);
}

.map-legend-section {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem .8rem;
}

.map-legend-title {
    color: #334155;
    font-size: .75rem;
    font-weight: 700;
}

.district-legend {
    display: flex;
    max-height: 7.5rem;
    flex: 1 1 100%;
    flex-wrap: wrap;
    gap: .4rem .75rem;
    overflow-y: auto;
    padding-right: .25rem;
}

.district-legend-item,
.map-status-item {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    color: #475569;
    font-size: .75rem;
}

.district-legend-swatch {
    width: .8rem;
    height: .8rem;
    flex: 0 0 auto;
    border: 1px solid rgba(15, 23, 42, .15);
    border-radius: 999px;
}

.map-status-legend {
    border-top: 1px solid #e2e8f0;
    padding-top: .65rem;
}

.map-status-dot {
    width: .9rem;
    height: .9rem;
    border: 3px solid;
    border-radius: 999px;
    background: #fff;
}

.map-status-dot--validated {
    border-color: #16a34a;
}

.map-status-dot--province {
    border-color: #f59e0b;
}

.map-status-dot--district {
    border-color: #64748b;
}

@media (min-width: 768px) {
    .map-legend-card {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: start;
    }

    .map-status-legend {
        border-top: 0;
        border-left: 1px solid #e2e8f0;
        padding-top: 0;
        padding-left: 1rem;
    }
}

/*
   * Champ géographique actuellement attendu.
   */
.geo-field-current {
    background-color: #ffffff !important;
    border-color: #2563eb !important;
    color: #0f172a !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16) !important;
    opacity: 1 !important;
    cursor: pointer !important;
}

/*
   * Champ géographique déjà renseigné.
   */
.geo-field-completed {
    background-color: #eff6ff !important;
    border-color: #93c5fd !important;
    color: #1e3a8a !important;
    opacity: 1 !important;
}

/*
   * Champ géographique pas encore accessible.
   */
.geo-field-locked {
    background-color: #e2e8f0 !important;
    border-color: #cbd5e1 !important;
    color: #94a3b8 !important;
    opacity: 0.72 !important;
    cursor: not-allowed !important;
}

/*
   * Différenciation du libellé associé au champ actif.
   */
.geo-label-current {
    color: #1d4ed8 !important;
    font-weight: 700 !important;
}

.geo-label-locked {
    color: #94a3b8 !important;
}

.geo-label-completed {
    color: #334155 !important;
    font-weight: 600 !important;
}

.geo-field-transition {
    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        opacity 0.2s ease;
}
/* ========================================================================== */
/* Prévisualisation / galerie des images existantes                           */
/* ========================================================================== */

.image-gallery-trigger {
    border: 0;
    background: transparent;
    padding: 0;
    cursor: zoom-in;
}

.image-gallery-trigger:focus-visible {
    outline: 3px solid rgba(24, 139, 213, .3);
    outline-offset: 3px;
    border-radius: .65rem;
}

.image-gallery-preview[hidden] {
    display: none !important;
}

.image-gallery-preview {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(2, 18, 31, .92);
    backdrop-filter: blur(5px);
}

.image-gallery-preview__dialog {
    position: relative;
    display: grid;
    width: min(96vw, 1200px);
    height: min(92vh, 900px);
    place-items: center;
}

.image-gallery-preview__figure {
    display: flex;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    margin: 0;
}

.image-gallery-preview__stage {
    display: grid;
    width: 100%;
    min-height: 0;
    flex: 1 1 auto;
    place-items: center;
}

.image-gallery-preview__image {
    display: block;
    max-width: 100%;
    max-height: calc(92vh - 4.5rem);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: .8rem;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
    user-select: none;
    -webkit-user-drag: none;
}

.image-gallery-preview__caption {
    display: flex;
    min-height: 1.75rem;
    max-width: min(90vw, 900px);
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: .5rem 1rem;
    color: #e2e8f0;
    font-size: .875rem;
    text-align: center;
}

.image-gallery-preview__title {
    font-weight: 600;
}

.image-gallery-preview__counter {
    color: #cbd5e1;
    font-variant-numeric: tabular-nums;
}

.image-gallery-preview__close,
.image-gallery-preview__nav {
    position: absolute;
    z-index: 2;
    display: inline-grid;
    width: 3rem;
    height: 3rem;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 999px;
    background: rgba(15, 23, 42, .7);
    color: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
    cursor: pointer;
    transition: background-color .15s ease, transform .15s ease;
}

.image-gallery-preview__close:hover,
.image-gallery-preview__nav:hover {
    background: rgba(30, 41, 59, .95);
}

.image-gallery-preview__close:focus-visible,
.image-gallery-preview__nav:focus-visible {
    outline: 3px solid rgba(255, 255, 255, .75);
    outline-offset: 2px;
}

.image-gallery-preview__close {
    top: 0;
    right: 0;
    font-size: 2rem;
    line-height: 1;
}

.image-gallery-preview__nav {
    top: 50%;
    transform: translateY(-50%);
    font-size: 2.25rem;
    line-height: 1;
}

.image-gallery-preview__nav--prev {
    left: 0;
}

.image-gallery-preview__nav--next {
    right: 0;
}

.image-gallery-preview__nav[hidden] {
    display: none;
}

@media (max-width: 640px) {
    .image-gallery-preview {
        padding: .5rem;
    }

    .image-gallery-preview__dialog {
        width: 100%;
        height: 96vh;
    }

    .image-gallery-preview__image {
        max-height: calc(96vh - 5rem);
        border-radius: .55rem;
    }

    .image-gallery-preview__close,
    .image-gallery-preview__nav {
        width: 2.75rem;
        height: 2.75rem;
        background: rgba(15, 23, 42, .78);
    }

    .image-gallery-preview__close {
        top: .25rem;
        right: .25rem;
    }

    .image-gallery-preview__nav--prev {
        left: .25rem;
    }

    .image-gallery-preview__nav--next {
        right: .25rem;
    }
}
