/* ===== Base ===== */
* { box-sizing: border-box; }

body {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-weight: 400;
    background: #F4F9FD;
    margin: 0;
    color: #14263D;
}

h1, h2, h3 {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* ===== Page de connexion ===== */
body:not(.app) {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(160deg, #EAF4FC 0%, #F4F9FD 45%, #FFFFFF 100%);
}

.card {
    background: #FFFFFF;
    padding: 2.75rem;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(11, 31, 51, 0.10);
    width: 100%;
    max-width: 380px;
    border: 1px solid #E3EEF7;
}

.card h1 {
    font-size: 1.3rem;
    margin: 0 0 1.75rem;
    color: #0B1F33;
}

label {
    display: block;
    font-size: .8rem;
    font-weight: 700;
    margin-bottom: .3rem;
    color: #3A5169;
    text-transform: uppercase;
    letter-spacing: .03em;
}

input[type=email], input[type=password], input[type=text] {
    width: 100%;
    padding: .65rem .75rem;
    border: 1px solid #D3E2EE;
    border-radius: 8px;
    margin-bottom: 1.1rem;
    box-sizing: border-box;
    font-size: .95rem;
    background: #FBFDFE;
    transition: border-color .15s ease, box-shadow .15s ease;
}

input[type=email]:focus, input[type=password]:focus, input[type=text]:focus {
    outline: none;
    border-color: #2C6FBB;
    box-shadow: 0 0 0 3px rgba(44, 111, 187, 0.15);
    background: #FFFFFF;
}

button {
    width: 100%;
    padding: .75rem;
    background: linear-gradient(135deg, #14345E 0%, #1D4E89 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: .95rem;
    font-weight: 700;
    transition: filter .15s ease;
}

button:hover { filter: brightness(1.12); }

.error {
    color: #B3261E;
    background: #FCEBEA;
    border: 1px solid #F3C6C3;
    padding: .6rem .8rem;
    border-radius: 8px;
    font-size: .85rem;
    margin-bottom: 1.1rem;
}

/* ===== Application (dashboard) ===== */
body.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: #F4F9FD;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(120deg, #0B1F33 0%, #14345E 55%, #1D4E89 100%);
    color: #fff;
    padding: 1.1rem 1.75rem;
    box-shadow: 0 2px 12px rgba(11, 31, 51, 0.18);
    flex-shrink: 0;
}

.topbar h1 {
    font-size: 1.15rem;
    margin: 0;
    color: #fff;
    letter-spacing: -0.01em;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: .85rem;
    color: #CFE1F3;
}

.topbar-user button {
    width: auto;
    background: rgba(255,255,255,0.12);
    padding: .45rem .9rem;
    border-radius: 6px;
    font-size: .8rem;
    font-weight: 700;
    border: 1px solid rgba(255,255,255,0.25);
}

.topbar-user button:hover {
    background: rgba(255,255,255,0.22);
    filter: none;
}

/* ===== Mise en page : colonne de filtres + contenu ===== */
.app-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    gap: 1rem;
    padding: 1.25rem 1.75rem;
}

.filter-sidebar {
    width: 280px;
    flex-shrink: 0;
    max-height: 100%;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #E3EEF7;
    box-shadow: 0 2px 16px rgba(11, 31, 51, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width .2s ease, opacity .2s ease;
}

.filter-sidebar.collapsed {
    width: 0;
    border: none;
    box-shadow: none;
    opacity: 0;
    pointer-events: none;
}

.expand-tab {
    display: none;
    width: 32px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #1D4E89 0%, #14345E 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    align-self: flex-start;
    height: 44px;
    font-size: 1rem;
}

.expand-tab:hover { filter: brightness(1.12); }

.filter-sidebar.collapsed ~ .expand-tab {
    display: block;
}

.content-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ===== Contenu de la colonne de filtres ===== */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid #EAF1F8;
    flex-shrink: 0;
}

.sidebar-title {
    font-weight: 700;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #14345E;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #6A87A3;
    font-size: 1rem;
    width: auto;
    padding: .25rem .5rem;
}

.icon-btn:hover { color: #14345E; filter: none; background: none; }

.sidebar-search {
    padding: .9rem 1.1rem;
    border-bottom: 1px solid #EAF1F8;
    flex-shrink: 0;
}

.sidebar-search input {
    width: 100%;
    padding: .55rem .65rem;
    border: 1px solid #D3E2EE;
    border-radius: 8px;
    font-size: .85rem;
    background: #FBFDFE;
    margin: 0;
}

.sidebar-groups {
    overflow-y: auto;
    padding: .5rem 0;
}

.filter-group { border-bottom: 1px solid #EAF1F8; }

.filter-group-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    padding: .75rem 1.1rem;
    font-size: .8rem;
    font-weight: 700;
    color: #14345E;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.filter-group-header:hover { background: #F6FAFE; filter: none; }

.filter-group-header .chevron {
    transition: transform .15s ease;
    color: #6A87A3;
    font-size: .7rem;
}

.filter-group.open .chevron { transform: rotate(180deg); }

.filter-group-body {
    display: none;
    padding: 0 1.1rem;
}

.filter-group.open .filter-group-body {
    display: block;
    padding: .25rem 1.1rem .75rem;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .35rem 0;
    font-size: .83rem;
    color: #1E3350;
    cursor: pointer;
    text-transform: none;
    font-weight: 400;
}

.checkbox-row input[type=checkbox] {
    width: 15px;
    height: 15px;
    accent-color: #1D4E89;
    cursor: pointer;
    flex-shrink: 0;
}

/* ===== Barre d'outils et étiquettes de filtres actifs ===== */
.toolbar {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: #EAF4FC;
    color: #14345E;
    border: 1px solid #C7DCEE;
    padding: .35rem .7rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s ease;
}

.chip:hover { background: #D6E9F8; }

.chip-x { color: #6A87A3; font-size: .7rem; }

.chip-reset {
    background: transparent;
    border-style: dashed;
    color: #6A87A3;
}

/* ===== Tableau ===== */
.table-wrap {
    overflow-x: auto;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(11, 31, 51, 0.08);
    border: 1px solid #E3EEF7;
}

table {
    border-collapse: collapse;
    width: 100%;
    font-size: .84rem;
}

td {
    white-space: nowrap;
}

th {
    white-space: normal;
    min-width: 90px;
    max-width: 160px;
    line-height: 1.25;
}

th {
    background: linear-gradient(180deg, #1D4E89 0%, #14345E 100%);
    color: #fff;
    font-weight: 700;
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .04em;
    padding: .85rem 1rem;
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 1;
}

th .count-badge {
    color: #FF7900 !important;
    font-size: 1.20em;
}

td {
    padding: .7rem 1rem;
    text-align: left;
    border-bottom: 1px solid #EAF1F8;
    color: #1E3350;
}

tbody tr:nth-child(even) td { background: #F6FAFE; }
tbody tr:hover td { background: #E3F0FB; }

tbody tr td[colspan] {
    text-align: center;
    color: #7891A8;
    font-style: italic;
    padding: 2rem;
}

/* ===== Scrollbar personnalisée du tableau ===== */
.table-wrap::-webkit-scrollbar { height: 14px; width: 14px; }

.table-wrap::-webkit-scrollbar-track {
    background: #EAF4FC;
    border-radius: 999px;
}

.table-wrap::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #3D74B3 0%, #14345E 100%);
    border-radius: 999px;
    border: 2px solid #EAF4FC;
    box-shadow: inset 0 1px 2px rgba(255,255,255,0.4), inset 0 -1px 2px rgba(0,0,0,0.25);
}

.table-wrap::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #4A85C9 0%, #1D4E89 100%);
}

.table-wrap {
    scrollbar-width: auto;
    scrollbar-color: #1D4E89 #EAF4FC;
}

/* ===== Administration ===== */
.topbar-title-link {
    text-decoration: none;
    cursor: pointer;
}

.admin-layout {
    flex: 1;
    overflow-y: auto;
    padding: 1.75rem;
}

.admin-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: .75rem;
}

.back-link {
    color: #14345E;
    text-decoration: none;
    font-size: .85rem;
    font-weight: 700;
}
.back-link:hover { text-decoration: underline; }

.admin-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.admin-card {
    background: #fff;
    border: 1px solid #E3EEF7;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 16px rgba(11, 31, 51, 0.08);
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform .15s ease, box-shadow .15s ease;
}
.admin-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(11, 31, 51, 0.14);
}
.admin-card h3 { color: #14345E; font-size: 1rem; margin: 0 0 .5rem; }
.admin-card p { color: #5C7690; font-size: .85rem; margin: 0; line-height: 1.4; }

.admin-form {
    background: #fff;
    border: 1px solid #E3EEF7;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 16px rgba(11, 31, 51, 0.08);
    margin-bottom: 1.5rem;
}
.admin-form h2, .admin-form h3 { margin-top: 0; color: #14345E; font-size: 1rem; }

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

.form-field label { font-size: .72rem; }

.form-field input[type=text],
.form-field input[type=number],
.form-field select,
.form-field textarea {
    width: 100%;
    padding: .55rem .65rem;
    border: 1px solid #D3E2EE;
    border-radius: 8px;
    font-size: .85rem;
    background: #FBFDFE;
    font-family: inherit;
    margin: 0;
}

.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
    outline: none;
    border-color: #2C6FBB;
    box-shadow: 0 0 0 3px rgba(44, 111, 187, 0.15);
}

.checkbox-inline {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .85rem;
    font-weight: 400;
    text-transform: none;
    color: #1E3350;
}
.checkbox-inline input { width: 15px; height: 15px; accent-color: #1D4E89; }

.btn-primary { width: auto; padding: .6rem 1.3rem; font-size: .85rem; }

.btn-secondary {
    width: auto;
    padding: .6rem 1.3rem;
    font-size: .85rem;
    background: #fff;
    color: #14345E;
    border: 1px solid #D3E2EE;
}
.btn-secondary:hover { background: #EAF4FC; filter: none; }

.status-badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
}
.status-badge.actif { background: #E3F5E9; color: #1E7B42; }
.status-badge.inactif { background: #F3E9E9; color: #9A3B3B; }

.action-links { display: flex; gap: .75rem; align-items: center; }
.action-links a, .action-links .link-btn {
    font-size: .78rem;
    color: #2C6FBB;
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
    width: auto;
    cursor: pointer;
    font-weight: 600;
}
.action-links a:hover, .action-links .link-btn:hover { text-decoration: underline; filter: none; }

.success-banner {
    background: #E3F5E9;
    color: #1E7B42;
    border: 1px solid #B9E3C6;
    padding: .7rem 1rem;
    border-radius: 8px;
    font-size: .85rem;
    margin-bottom: 1rem;
}

.boutique-picker {
    background: #fff;
    border: 1px solid #E3EEF7;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 16px rgba(11, 31, 51, 0.08);
    margin-bottom: 1.5rem;
}

.search-results { margin-top: 1rem; }
.search-result-row {
    display: flex;
    justify-content: space-between;
    padding: .6rem .5rem;
    border-bottom: 1px solid #EAF1F8;
    text-decoration: none;
    color: #1E3350;
    font-size: .85rem;
}
.search-result-row:hover { background: #F6FAFE; }
.search-result-row .muted { color: #7891A8; }

.carac-group-title {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6A87A3;
    font-weight: 700;
    margin: 1.5rem 0 .75rem;
    padding-top: 1rem;
    border-top: 1px solid #EAF1F8;
}
.carac-group-title:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }

.carac-field {
    background: #FBFDFE;
    border: 1px solid #E3EEF7;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: .85rem;
}

.carac-field-label {
    font-size: .85rem;
    font-weight: 700;
    color: #14345E;
    margin-bottom: .5rem;
    display: block;
}

.sub-fields {
    margin-top: .75rem;
    padding-top: .75rem;
    border-top: 1px dashed #D3E2EE;
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    align-items: center;
}
.sub-fields.hidden { display: none; }
.sub-fields .pos-field { display: flex; align-items: center; gap: .5rem; }
.sub-fields .pos-field input { width: 80px; margin: 0; }
.sub-fields .positions-max-hint { color: #7891A8; font-size: .78rem; }

thead tr:nth-child(2) th {
    position: sticky;
    top: 2.6rem;
}

th, td {
    border-right: 1px solid #C7DCEE;
}
th:last-child, td:last-child {
    border-right: none;
}

thead tr:first-child th {
    border-bottom: 1px solid rgba(255, 255, 255, 0.25);
}

thead tr:nth-child(2) th {
    background: #EAF4FC;
    color: #14345E;
}

th {
    text-align: center;
}

.cat-boundary {
    border-right: 2px solid #14345E !important;
}

.sidebar-groups::-webkit-scrollbar { width: 14px; }

.sidebar-groups::-webkit-scrollbar-track {
    background: #EAF4FC;
    border-radius: 999px;
}

.sidebar-groups::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #3D74B3 0%, #14345E 100%);
    border-radius: 999px;
    border: 2px solid #EAF4FC;
    box-shadow: inset 0 1px 2px rgba(255,255,255,0.4), inset 0 -1px 2px rgba(0,0,0,0.25);
}

.sidebar-groups::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #4A85C9 0%, #1D4E89 100%);
}

.sidebar-groups {
    scrollbar-width: auto;
    scrollbar-color: #1D4E89 #EAF4FC;
}

.reset-all-link {
    font-size: .72rem;
    color: #2C6FBB;
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
}
.reset-all-link:hover {
    text-decoration: underline;
}


/* ===== Masquage / démasquage de colonnes ===== */
.column-toggle-actions {
    margin-bottom: .5rem;
}

.column-toggle-actions .link-btn {
    width: auto;
    padding: .35rem .7rem;
    font-size: .75rem;
    color: #2C6FBB;
    background: #fff;
    border: 1px solid #C7DCEE;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.column-toggle-actions .link-btn:hover {
    background: #EAF4FC;
    filter: none;
}

td.has-comment {
    position: relative;
}
td.has-comment::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    border-top: 10px solid #FF7900;
    border-left: 10px solid transparent;
}

th[data-col="nom_boutique"],
td[data-col="nom_boutique"] {
    position: sticky;
    left: 0;
    z-index: 1;
}

th[data-col="nom_boutique"] {
    z-index: 2;
}

td[data-col="nom_boutique"] {
    background: #fff;
    box-shadow: 2px 0 5px rgba(11, 31, 51, 0.1);
}

tbody tr:nth-child(even) td[data-col="nom_boutique"] {
    background: #F6FAFE;
}

tbody tr:hover td[data-col="nom_boutique"] {
    background: #E3F0FB;
}

/* ===== Réorganisation des colonnes ===== */
.reorder-block {
    border: 1px solid #E3EEF7;
    border-radius: 8px;
    margin-bottom: .5rem;
    overflow: hidden;
}

.reorder-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .5rem .65rem;
    background: #F6FAFE;
    font-size: .82rem;
    font-weight: 700;
    color: #14345E;
}

.reorder-sublist {
    padding: .3rem .65rem .5rem;
}

.reorder-subitem {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .3rem 0;
    font-size: .8rem;
    color: #1E3350;
    border-top: 1px dashed #EAF1F8;
}
.reorder-subitem:first-child {
    border-top: none;
}

.reorder-arrows {
    display: flex;
    gap: .25rem;
}

.reorder-btn {
    width: 22px;
    height: 22px;
    padding: 0;
    font-size: .65rem;
    line-height: 1;
    background: #fff;
    color: #2C6FBB;
    border: 1px solid #C7DCEE;
    border-radius: 4px;
    cursor: pointer;
}
.reorder-btn:hover {
    background: #EAF4FC;
    filter: none;
}

/* ===== Fenêtre de réorganisation des colonnes ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11, 31, 51, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}
.modal-overlay.hidden {
    display: none;
}

.modal-panel {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 420px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(11, 31, 51, 0.25);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #EAF1F8;
    flex-shrink: 0;
}

.modal-title {
    font-weight: 700;
    color: #14345E;
    font-size: .95rem;
}

.modal-body {
    padding: 1rem 1.25rem;
    overflow-y: auto;
}

.modal-hint {
    font-size: .78rem;
    color: #7891A8;
    margin: 0 0 .75rem;
    line-height: 1.4;
}