/* ==========================================
   JCBDB - Design System Unifié
   Flat design, mobile-first
   Version: 2025-01-29 - overlay-nav-buttons + btn-nav
   ========================================== */

/* CSS Variables - Flat Design System */
:root {
    /* Main Color Palette */
    --red-dark: #991010;
    /* Terracotta - Primary accent, buttons */
    --red-light: #d97f3e;
    /* Orange - Secondary color for charts */
    --beige-dark: #f0eee7;
    /* Dark beige - Headers, sections */
    --beige-light: #faf9f5;
    /* Light beige - Main backgrounds */

    /* Text */
    --color-text: #141413;
    --color-text-light: #73726d;
    --color-text-muted: #9e9d98;

    /* Borders */
    --color-border: #e5e3da;

    /* Status Colors (for badges) */
    --color-sold-text: #141413;
    --color-available: #ffffff;
    --color-available-border: #141413;

    /* Accent Variations */
    --color-accent-light: #c97d5f;
    --color-accent-hover: var(--red-dark);

    /* Functional */
    --color-success: #4a9b6f;
    --color-warning: #d97f3e;
    --color-danger: #c84a3d;
    --color-info: #555555;

    /* Layout */
    --radius: 4px;
    --transition: 0.2s ease;
}

/* ==========================================
   RESET & BASE
   ========================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--beige-light);
    color: var(--color-text);
    line-height: 1.5;
    min-height: 100vh;
}

/* ==========================================
   HEADER - CATALOGUE
   ========================================== */

.header {
    position: sticky;
    top: 0;
    z-index: 400;
    background: var(--beige-dark);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid white;
}


/* Header wrappers (used to keep logo centered on mobile) */
.header-mobile-left {
    display: none;
}

.header-mobile-right {
    display: flex;
    align-items: center;
    margin-left: auto;
    gap: 10px;
    flex-wrap: nowrap;
}

/* Mobile navigation buttons */
.mobile-nav-btn,
.mobile-filters-toggle {
    display: none;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--red-dark);
    border-radius: 0;
    transition: none;
    text-decoration: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mobile-nav-btn svg,
.mobile-nav-btn img,
.mobile-filters-toggle svg,
.mobile-filters-toggle img {
    height: 24px;
    width: auto;
}

.mobile-nav-btn:hover,
.mobile-filters-toggle:hover {
    background: transparent;
}

/* Mobile menu drawer */
.mobile-menu-drawer {
    position: fixed;
    top: 0;
    left: -100%;
    width: 280px;
    max-width: 80vw;
    height: 100vh;
    background: var(--beige-dark);
    z-index: 250;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
}

.mobile-menu-drawer.active {
    left: 0;
}

.mobile-menu-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid white;
}

.mobile-menu-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text);
}

.mobile-menu-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: background var(--transition);
}

.mobile-menu-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

.mobile-menu-nav {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
}

.mobile-menu-item {
    padding: 16px 20px;
    color: var(--color-text);
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    transition: background var(--transition);
    border-bottom: 1px solid rgba(255, 255, 255, 0.5);
}

.mobile-menu-item:hover {
    text-decoration: underline;
}

.mobile-menu-item.active {
    color: var(--red-dark);
    background: rgba(153, 16, 16, 0.1);
}

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    display: none;
}

.mobile-menu-overlay.active {
    display: block;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.logo-svg {
    height: 46px;
    width: auto;
}

.reset-filters-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--color-text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: all var(--transition);
}

.reset-filters-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--color-text);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-left: auto;
}

.nav-item {
    color: var(--color-text);
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    padding: 4px 0;
    margin: 0 12px;
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
}

.nav-item:hover {
    color: var(--color-text);
    border-bottom: 2px solid var(--color-text);
}

.nav-item.active {
    color: var(--red-dark);
    border-bottom: 2px solid var(--red-dark);
}

.nav-btn {
    text-decoration: none;
    color: var(--color-text);
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color var(--transition);
}

.nav-btn:hover {
    color: var(--red-dark);
}

.nav-btn.logout {
    color: var(--red-dark);
}

.nav-btn.logout:hover {
    color: var(--color-accent-hover);
}

.user-info {
    font-size: 0.85rem;
    color: var(--color-text-light);
    padding: 0.5rem 1rem;
    background: #ffffff;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}

/* User Avatar */
.user-menu {
    position: relative;
    margin-left: 20px;
    display: inline-flex;
    align-items: center;
}

.user-icon {
    width: 20px;
    height: 20px;
    display: block;
    cursor: pointer;
    user-select: none;
    transition: opacity var(--transition);
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    padding: 8px 0;
    display: none;
    min-width: 150px;
    z-index: 1000;
    margin-top: -2px;
}

.user-menu.active .user-dropdown {
    display: block;
}

/* Hover and active state: icon changes to -on version */
.user-menu:hover .user-icon,
.user-menu.active .user-icon {
    content: url('../img/menu-logout-on.svg');
}

.dropdown-item {
    display: block;
    padding: 8px 16px;
    text-decoration: none;
    font-size: 0.9rem;
    text-align: center;
    transition: all var(--transition);
    background: var(--red-dark);
    color: white;
    border: 1px solid var(--red-dark);
    border-radius: var(--radius);
}

.dropdown-item:hover {
    background: var(--color-text);
    border: 1px solid var(--color-text);
    color: white;
}

/* Simulation de rôle (admin) */
.simulation-buttons {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: 20px;
}

.btn-simulate {
    display: block;
    padding: 8px 16px;
    text-decoration: none;
    font-size: 0.9rem;
    text-align: center;
    transition: all var(--transition);
    background: white;
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: 0;
    cursor: pointer;
    margin-top: -1px;
}

.btn-simulate:first-child {
    border-radius: var(--radius) var(--radius) 0 0;
    margin-top: 0;
}

.btn-simulate:last-child {
    border-radius: 0 0 var(--radius) var(--radius);
}

.btn-simulate:hover {
    background: var(--color-text);
    color: white;
    border-color: var(--color-text);
}

.btn-simulate.active {
    background: var(--color-text);
    color: white;
    border-color: var(--color-text);
}


/* ==========================================
   HEADER - ADMIN & STATS
   ========================================== */

.wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* (header base styles defined above) */

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-left h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text);
}

.user-badge {
    background: #ffffff;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    color: var(--color-text-light);
    border: 1px solid var(--color-border);
}

.header-nav {
    display: flex;
    gap: 0.5rem;
}

/* ==========================================
   FILTERS
   ========================================== */

.sticky-filters {
    position: sticky;
    top: var(--header-height, 64px);
    z-index: 90;
    background: var(--beige-light);
    transition: transform 0.3s ease;
}

.sticky-filters.hidden {
    transform: translateY(-100%);
}

.filters {
    padding: 16px 20px;
    background: var(--beige-light);
    border-bottom: 1px solid var(--beige-dark);
}

.mobile-filters-tab {
    /* Desktop: no tab UI */
    display: none;
    border-radius: 0 0 var(--radius) var(--radius);


    color: var(--color-text);
    -webkit-appearance: none;
    appearance: none;
}

.mobile-filters-tab * {
    color: inherit;
    -webkit-text-fill-color: currentColor;
}


.filters-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
}

.filter-group:has(.filter-checkbox) {
    justify-content: flex-end;
    padding-bottom: 2px;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: #ffffff;
    color: var(--color-text);
    cursor: pointer;
    transition: border-color var(--transition);
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--color-border);
}

/* ==========================================
   CUSTOM SELECT (multi-checkbox dropdown)
   ========================================== */

.custom-select-wrapper {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: #ffffff;
    color: var(--color-text);
    cursor: pointer;
    transition: border-color var(--transition);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-sizing: border-box;
    -webkit-user-select: none;
    user-select: none;
}

.custom-select-trigger:hover {
    border-color: #999;
}

.custom-select-wrapper.open .custom-select-trigger {
    border-color: #999;
}

.custom-select-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 100%;
    width: max-content;
    margin-top: 2px;
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 1000;
    max-height: 60vh;
    overflow-y: auto;
    padding: 11px 5px;
}

.custom-select-wrapper.open .custom-select-dropdown {
    display: block;
}

.custom-select-item {
    display: flex;
    align-items: center;
    padding: 5px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--color-text);
    transition: background-color 0.1s;
}

/* Espacement checkbox/label via marge (flex gap pas supporté iOS 12) */
.custom-select-item > * + * {
    margin-left: 8px;
}

.custom-select-item:hover {
    background-color: #f5f5f5;
}

.custom-select-item input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    accent-color: var(--color-text);
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.custom-select-item label {
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--color-text);
    text-transform: none;
    letter-spacing: 0;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.custom-select-reset {
    padding: 4px 12px 6px;
    font-size: 0.7rem;
    color: var(--color-text-light);
    cursor: pointer;
    text-decoration: underline;
}

.custom-select-reset:hover {
    color: var(--color-text);
}

.custom-select-separator {
    height: 1px;
    background: var(--color-border);
    margin: 4px 12px;
}

.custom-select-section-label {
    padding: 4px 12px 2px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Single-select items (no checkbox) */
.custom-select-item .custom-select-label {
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--color-text);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.custom-select-item.selected {
    background-color: #f0f0f0;
    font-weight: 500;
}

.custom-select-item.selected .custom-select-label {
    font-weight: 500;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--color-text);
}

.filter-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--red-dark);
    cursor: pointer;
}

.search-row {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 10px;
}

.search-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

#search-titre {
    width: 100%;
    padding: 10px 36px 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: border-color var(--transition);
    scroll-margin-top: 120px;
    background: #ffffff;
    box-sizing: border-box;
    /* hauteur dérivée du padding pour matcher les .custom-select-trigger */
}

#search-titre:focus {
    outline: none;
    border-color: var(--color-border);
}

#search-titre::placeholder {
    color: var(--color-text-light);
}

.search-clear {
    position: absolute;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    background: var(--color-border);
    border-radius: 50%;
    font-size: 1rem;
    line-height: 1;
    color: var(--color-text-light);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.filters-reset {
    height: 40px;
    padding: 0 14px;
    font-size: 0.85rem;
    white-space: nowrap;
}



.btn-secondary.filters-reset,
#filters-reset.filters-reset {
    background: var(--red-dark);
    border: 1px solid var(--red-dark);
    color: white;
    height: 38px;
    /* mets la même hauteur que tes autres boutons */
    line-height: 38px;
    /* centre verticalement le texte */
    padding: 0 14px;
    /* pas de padding vertical */
    display: inline-flex;
    /* encore plus stable */
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.btn-secondary.filters-reset:hover,
#filters-reset.filters-reset:hover {
    color: white;
    border: 1px solid var(--color-text);
    background: var(--color-text);
    height: 38px;
    /* mets la même hauteur que tes autres boutons */
    line-height: 38px;
    /* centre verticalement le texte */
    padding: 0 14px;
    /* pas de padding vertical */
    display: inline-flex;
    /* encore plus stable */
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

/* Optionnel : cohérence clavier */
.btn-secondary.filters-reset:focus-visible,
#filters-reset:focus-visible {
    outline: 2px solid var(--red-dark);
    outline-offset: 2px;
}

.search-clear:hover {
    background: var(--color-text);
    color: white;
}

.search-clear.visible {
    display: flex;
}

.sort-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sort-btn {
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--color-text);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.sort-btn:hover {
    background: var(--color-text);
    color: white;
}

.sort-btn.active {
    background: var(--red-dark);
    color: white;
}

.sort-icon {
    font-size: 1rem;
    transition: transform var(--transition);
}

.sort-btn[data-order="desc"] .sort-icon {
    transform: rotate(180deg);
}

/* ==========================================
   RESULTS ROW (Bottom Sticky Bar)
   ========================================== */

.results-row {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--beige-light);
    border-top: 1px solid var(--beige-dark);
    z-index: 100;
    justify-content: space-between;
}

.results-left-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.results-center-group {
    display: flex;
    align-items: center;
    gap: 0;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    height: 100%;
}

.results-separator {
    display: none !important;
}

.filters-toggle {
    width: 32px;
    height: 32px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--color-text-light);
    transition: all var(--transition);
    flex-shrink: 0;
}

.filters-toggle:hover {
    background: var(--color-text);
    color: white;
    border-color: var(--color-text);
}

.filters-toggle .icon {
    transition: transform 0.3s ease;
}

.filters-toggle.collapsed .icon {
    transform: rotate(180deg);
}

.results-count {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;

    font-size: 0.85rem;
    color: var(--color-text-light);
    text-align: left;
    padding-left: 32px;
    padding-right: 32px;
    height: 100%;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

/* Bar buttons group (bottom bar action buttons) */
.bar-buttons-group {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}

.bar-btn {
    position: relative;
    width: 40px;
    height: 40px;
    background: var(--red-dark);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0;
    flex-shrink: 0;
    transition: background 0.2s ease;
    overflow: visible;
    white-space: nowrap;
    padding: 0;
    z-index: 1;
}

.bar-btn .bar-btn-icon {
    width: 18px;
    height: 18px;
    filter: brightness(0) invert(1);
    flex-shrink: 0;
    transition: opacity 0.2s ease;
}

.bar-btn .icon-hover {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
}

.bar-btn .bar-btn-label {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    background: var(--color-text);
    padding: 6px 12px;
    border-radius: var(--radius);
    transition: opacity 0.2s ease;
}

/* Prevent tooltips from overflowing viewport right edge */
.bar-buttons-group .bar-btn:last-child .bar-btn-label {
    left: auto;
    right: 0;
    transform: none;
}

.bar-btn:not(:disabled):hover {
    background: var(--color-text);
    z-index: 10;
}

.bar-btn:not(:disabled):hover .icon-default {
    opacity: 0;
}

.bar-btn:not(:disabled):hover .icon-hover {
    opacity: 1;
}

.bar-btn:not(:disabled):hover > .bar-btn-label:not(.bar-btn-label-alt):not(.bar-btn-label-default) {
    opacity: 1;
    pointer-events: auto;
}

.bar-btn:disabled {
    background: var(--beige-dark);
    cursor: not-allowed;
}

/* Page publique button: two labels, special inactive state */
.bar-btn-web .bar-btn-label-alt,
.bar-btn-web .bar-btn-label-default {
    opacity: 0;
    pointer-events: none;
}

.bar-btn-web:not(.bar-btn-inactive):not(:disabled):hover .bar-btn-label-default {
    opacity: 1;
    pointer-events: auto;
}

.bar-btn-web.bar-btn-inactive {
    cursor: pointer;
}

.bar-btn-web.bar-btn-inactive:hover .bar-btn-label-alt {
    opacity: 1;
    pointer-events: auto;
}

.bar-btn-web.bar-btn-inactive:hover .icon-default {
    opacity: 0;
}

.bar-btn-web.bar-btn-inactive:hover .icon-hover {
    opacity: 1;
}

/* Dark variant (page publique) */
.bar-btn-dark {
    background: var(--color-text);
}

.bar-btn-dark:not(:disabled):hover {
    background: var(--red-dark);
}

.bar-btn-dark .bar-btn-label {
    background: var(--red-dark);
}

.bar-btn-dark.bar-btn-inactive {
    background: var(--beige-dark);
}

.bar-btn-dark.bar-btn-inactive:hover {
    background: var(--red-dark);
}

.bar-btn-dark.bar-btn-inactive .bar-btn-label {
    background: var(--red-dark);
}


.select-all-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    height: 40px;
    margin-right: 10px;
}

.select-all-wrapper input[type="checkbox"] {
    width: 24px;
    height: 24px;
    cursor: pointer;
    accent-color: var(--red-dark);
    flex-shrink: 0;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}

.selection-count {
    color: var(--red-dark);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
}

/* ==========================================
   ARTWORKS LIST
   ========================================== */

.artworks-list {
    padding: 8px 20px 80px;
    background: white;
}

.artwork-item {
    padding: 12px;
    margin: 0 -12px;
    border-bottom: 1px solid var(--beige-dark);
    transition: background var(--transition);
    display: flex;
    align-items: center;
}

/* Espacement via marges plutôt que flex gap (pas supporté Safari < 14.1 / iOS 12) */
.artwork-item > * + * {
    margin-left: 12px;
}

.artwork-item:last-child {
    border-bottom: none;
}

.artwork-item:hover {
    background: var(--beige-light);
}

.artwork-thumb {
    width: 60px;
    height: 60px;
    background-color: #ffffff;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--color-border);
    cursor: pointer;
}

.artwork-content {
    flex: 1;
    min-width: 0;
    cursor: default;
    pointer-events: none;
}

.artwork-id,
.artwork-title,
.artwork-meta {
    pointer-events: auto;
    cursor: pointer;
    width: fit-content;
}

.artwork-id {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--red-dark);
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.photo-icon {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

.artwork-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 4px;
}

.artwork-checkbox-wrapper {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 0;
}

.artwork-checkbox {
    width: 24px;
    height: 24px;
    cursor: pointer;
    accent-color: var(--red-dark);
    flex-shrink: 0;
    display: block !important;
    margin: 0;
}

.artwork-meta {
    font-size: 0.8rem;
    color: var(--color-text-light);
}

.meta-year {
    font-weight: 500;
}

.meta-year.bold {
    font-weight: 700;
}

.artwork-status {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 8px;
}

.artwork-status.sold {
    background: var(--beige-dark);
    color: var(--color-sold-text);
}

.artwork-status.available {
    background: var(--color-available);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

/* Favorite button */
.artwork-favorite-btn {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
}

.artwork-favorite-btn img {
    display: block;
    position: absolute;
    top: 8px;
    left: 8px;
}

.artwork-favorite-btn .star-hover {
    opacity: 0;
}

.artwork-favorite-btn:hover .star-default {
    opacity: 0;
}

.artwork-favorite-btn:hover .star-hover {
    opacity: 1;
}

/* After click, keep showing default state until mouse leaves */
.artwork-favorite-btn.just-clicked .star-default {
    opacity: 1;
}

.artwork-favorite-btn.just-clicked .star-hover {
    opacity: 0;
}

.artwork-item {
    position: relative;
}

/* ==========================================
   OVERLAY & MODAL
   ========================================== */

.overlay,
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
}

.overlay.active,
.modal.active {
    display: flex;
}

.overlay-content {
    background: #ffffff;
    width: 900px;
    max-width: 95vw;
    max-height: 90vh;
    margin: 0;
    border-radius: var(--radius);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1;
}

.modal-content {
    background: #ffffff;
    border-radius: var(--radius);
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.modal-wide {
    max-width: 900px;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    background-image: url('../img/icon-close.svg');
    background-size: 20px 20px;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 50%;
    font-size: 0;
    cursor: pointer;
    transition: all var(--transition);
    padding: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.modal-close:hover {
    background-color: rgba(255, 255, 255, 1);
    transform: scale(1.05);
}

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

.modal-body .form-group {
    margin-bottom: 1rem;
}

.modal-body label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.95rem;
}

.modal-body input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--red-dark);
}

.modal-actions {
    padding: 20px 24px;
    border-top: none !important;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--beige-light);
    border-radius: 0 0 var(--radius) var(--radius);
    margin-left: 0;
    margin-right: 0;
    margin-top: 0;
    width: 100%;
}

/* Universal close button - always on top */
.universal-close-btn {
    position: fixed;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    background-image: url('../img/icon-close.svg');
    background-size: 20px 20px;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 50%;
    font-size: 0;
    cursor: pointer;
    z-index: 99999;
    transition: all var(--transition);
    padding: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.universal-close-btn:hover {
    background-color: rgba(255, 255, 255, 1);
    transform: scale(1.05);
}

.overlay-close {
    display: none !important;
}

.overlay-close:hover {
    display: none !important;
}

.overlay-body {
    padding: 24px 24px 0 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    flex: 1;
    overflow-y: auto;
    background: #ffffff;
    border-radius: var(--radius);
    max-height: calc(100vh - 200px); /* Contrainte globale pour laisser place aux actions */
}

.overlay-photo {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 0;
    flex-shrink: 0;
}

.overlay-photo-wrapper {
    position: relative;
    display: inline-block;
}

.overlay-photo img {
    max-width: 100%;
    max-height: 60vh; /* Hauteur max réduite pour images verticales */
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform var(--transition);
    display: block;
}


.overlay-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-row {
    display: flex;
    align-items: flex-start;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 8px;
}

.info-row:last-child {
    border-bottom: none;
    margin-bottom: 20px;
}

.info-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: 100px;
    flex-shrink: 0;
    line-height: 1.4;
}

.info-value {
    font-size: 0.8rem;
    color: var(--color-text);
    flex: 1;
    line-height: 1.4;
}

/* Price column in overlay (Identifiant row) */
.info-row-with-price {
    display: flex;
    flex-wrap: nowrap;
}

.info-label-price {
    margin-left: auto;
    width: auto;
    flex-shrink: 0;
    text-align: right;
}

.info-value-price {
    flex: 0 0 auto;
    text-align: right;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text);
    min-width: 120px;
}

/* Prix dans l'ODO (marchand+) :
   - Desktop souris : visible au hover de la row Identifiant
   - Mobile tactile : visible 3s après tap, puis masqué */
.info-value-price.price-hover-only {
    opacity: 0;
    transition: opacity 0.4s ease;
}

/* Desktop avec souris : hover révèle le prix */
@media (hover: hover) and (pointer: fine) {
    .info-row-with-price:hover .info-value-price.price-hover-only {
        opacity: 1;
    }
}

/* Tactile : on masque via visibility (que le hover sticky iOS ne peut
   pas écraser, contrairement à opacity). Le JS retire visibility au tap
   pour révéler, puis la remet au timeout 3s. */
@media (pointer: coarse) {
    .info-row-with-price {
        cursor: pointer;
    }
    .info-value-price.price-hover-only {
        visibility: hidden;
    }
}

/* Price in artwork list (when sorted by price) */
.artwork-price {
    color: var(--color-text-light);
    font-weight: 400;
}

/* Certificate link in overlay */
.certificate-link {
    color: var(--color-text);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color var(--transition);
}

.certificate-link:hover {
    color: var(--red-dark);
}

/* Contact link in overlay (for visitors) */
.contact-link-wrapper {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--color-text);
}

.contact-link {
    color: var(--color-text);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color var(--transition);
}

.contact-link:hover {
    color: var(--red-dark);
}

/* Public site link (mode public, en bas à droite) */
.public-site-link {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color var(--transition);
}

.public-site-link .btn-arrow.icon-hover { display: none; }
.public-site-link:hover .btn-arrow.icon-default { display: none; }
.public-site-link:hover .btn-arrow.icon-hover { display: inline-block; }
.public-site-link:hover { color: var(--red-dark); }

/* Mobile: texte court */
.public-site-link-short { display: none; }
@media (max-width: 768px) {
    .public-site-link-full { display: none; }
    .public-site-link-short { display: inline; }
}

/* Public page title (centré sur toute la largeur du header) */
.public-page-title {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    font-size: 1.4rem;
    font-weight: 500;
    color: var(--color-text);
    pointer-events: none;
    white-space: nowrap;
}
@media (max-width: 768px) {
    .public-page-title { display: none; }
}

/* Public mode desktop : search + reset sur la même ligne que les filtres */
@media (min-width: 768px) {
    body.public-mode .filters {
        display: flex;
        flex-wrap: wrap;
        align-items: end;
        gap: 12px;
    }
    body.public-mode .filters-row,
    body.public-mode .search-row {
        display: contents;
    }
    body.public-mode .search-wrapper {
        flex: 1 1 240px;
        min-width: 200px;
    }
}

/* Public mode mobile : ordre voulu = filtres 2x2 → bouton Réinitialiser
   (pleine largeur) → champ de recherche en bas. Le mode connecté met
   par défaut Réinitialiser en haut (order:0) ; on l'override ici. */
@media (max-width: 767px) {
    body.public-mode .filters .filters-row { order: 1; }
    body.public-mode .filters .filters-reset {
        order: 2;
        margin-top: 12px;
        margin-bottom: 0;
        width: 100%;
    }
    body.public-mode .filters .search-wrapper {
        order: 3;
        margin-top: 12px;
        width: 100%;
    }
}

/* Admin: lien email dans la liste des users */
.email-link {
    color: inherit;
    text-decoration: none;
    transition: text-decoration 0.15s ease;
}
.email-link:hover {
    text-decoration: underline;
    text-decoration-color: var(--color-text);
    text-underline-offset: 3px;
}

/* Login icon in public header */
.user-menu-public {
    position: relative;
    margin-left: 20px;
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
    line-height: 0;
}
.user-menu-public .icon-hover { display: none; }
.user-menu-public:hover .icon-default { display: none; }
.user-menu-public:hover .icon-hover { display: inline-block; }

/* Login overlay (mode public) */
.login-overlay-hidden { display: none; }
.login-overlay-visible { display: block; }

.login-overlay-veil {
    position: fixed;
    inset: 0;
    background: rgba(250, 249, 245, 0.85); /* --beige-light avec opacité */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9998;
}

.login-overlay-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    background: #ffffff;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    width: calc(100% - 32px);
    max-width: 400px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
}

.login-overlay-box .login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-overlay-box .login-header .logo-svg {
    width: 200px;
    height: auto;
    margin-bottom: 0;
}

.login-overlay-box .login-header p {
    font-size: 0.9rem;
    color: var(--color-text-light);
}

.login-overlay-box .form-group {
    margin-bottom: 20px;
}

.login-overlay-box .form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}

.login-overlay-box .form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: #ffffff;
    color: var(--color-text);
}

.login-overlay-box .form-group input:focus {
    outline: none;
    border-color: var(--color-text-light);
}

.login-overlay-box .btn-login {
    width: 100%;
    padding: 12px;
    background: var(--red-dark);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.2s;
}

.login-overlay-box .btn-login:hover {
    filter: brightness(0.95);
}

.login-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: transparent;
    border: 0;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--color-text-light);
    cursor: pointer;
    padding: 4px 8px;
}

.login-close:hover { color: var(--red-dark); }

/* Certificate warning message in modal */
.certificate-warning {
    color: var(--color-text);
    font-size: 0.9rem;
    line-height: 1.5;
}

.overlay-actions {
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    background: var(--beige-dark);
}

.btn-email {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: var(--red-dark);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition);
    margin-left: auto;
}

.btn-email:hover {
    background: var(--color-text);
}

/* Boutons de navigation prev/next simplifiés dans l'overlay */
.btn-nav-simple {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 26px;
    margin-right: 4px;
}

.btn-nav-simple img {
    height: 100%;
    width: auto;
}

.btn-nav-simple .icon-hover {
    display: none;
}

.btn-nav-simple:hover .icon-default {
    display: none;
}

.btn-nav-simple:hover .icon-hover {
    display: block;
}

/* ==========================================
   BUTTONS
   ========================================== */

.btn-primary,
.btn-secondary,
.btn-danger {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: var(--red-dark);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-text);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--beige-light);
    color: var(--color-text);
    border: none;
}

.btn-secondary:hover {
    background: var(--beige-dark);
}

.btn-danger {
    background: var(--color-danger);
    color: white;
}

.btn-danger:hover {
    background: #a83d32;
}

.btn-link {
    color: var(--red-dark);
    text-decoration: none;
    font-size: 0.9rem;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--color-text-light);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all var(--transition);
}

.btn-icon:hover {
    background: var(--beige-dark);
    color: var(--color-text);
}

.btn-icon.danger:hover {
    background: var(--color-danger);
    color: white;
}

/* ==========================================
   LIGHTBOX
   ========================================== */

.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9500;
    display: none;
    align-items: center;
    justify-content: center;
}

.lightbox.active {
    display: flex;
}

.lightbox-close {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 50%;
    font-size: 2rem;
    cursor: pointer;
    z-index: 9999;
    transition: background var(--transition);
    display: none !important;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-container {
    width: 100%;
    height: 100%;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.lightbox-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: zoom-in;
    transition: transform 0.1s ease-out;
    user-select: none;
    -webkit-user-drag: none;
}

/* Medium image upscaled to fill container while HD loads */
.lightbox-container img.lightbox-upscaled {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.lightbox-container img.zoomed {
    max-width: none;
    max-height: none;
    cursor: move;
}

.lightbox-title {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    text-align: center;
    pointer-events: none;
    z-index: 1;
    max-width: 80%;
    transition: opacity 0.2s;
}

.lightbox-title.hidden {
    opacity: 0;
}

/* ==========================================
   ADMIN CONTENT
   ========================================== */

.admin-content {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    background: var(--beige-light);
}

.admin-section {
    background: #ffffff;
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.admin-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--color-text);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    margin-bottom: 0;
}

/* ==========================================
   CERTIFICATE VERIFICATION
   ========================================== */

.verify-certificate-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    min-height: 180px;
}

.verify-form-column {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.verify-form-column .form-group {
    margin-bottom: 0;
}

.verify-form-column input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
}

.verify-form-column input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.verify-result-column {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--beige-light);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.verify-placeholder {
    text-align: center;
    color: var(--color-text-light);
}

.verify-placeholder p {
    margin: 0;
    font-size: 0.9rem;
}

.verify-loading {
    color: var(--color-text-light);
    font-style: italic;
}

.verify-error {
    color: var(--color-danger);
    text-align: center;
}

.verify-valid,
.verify-invalid {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.verify-signature {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    width: 145px;
    height: auto;
    opacity: 0.85;
    pointer-events: none;
}

.verify-status {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.verify-status.valid {
    /* Couleur définie dynamiquement en inline style */
}

.verify-status.invalid {
    background: #f8d7da;
    color: #721c24;
}

.verify-artwork {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1rem;
    flex: 1;
    min-height: 0;
}

.verify-image-column {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
}

.verify-image {
    max-width: 100%;
    max-height: 120px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
}

.verify-info-column {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.verify-titre {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.verify-detail {
    font-size: 0.85rem;
    color: var(--color-text-light);
    margin-bottom: 0.25rem;
}

.verify-cert-date {
    font-size: 0.85rem;
    color: var(--color-text-light);
    font-style: italic;
    margin-top: 0.5rem;
}

@media (max-width: 768px) {
    .verify-certificate-container {
        grid-template-columns: 1fr;
    }

    .verify-result-column {
        min-height: 150px;
    }
}

/* ==========================================
   TABLES
   ========================================== */

.users-table-wrapper {
    overflow-x: auto;
}

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

.users-table th {
    background: var(--beige-dark);
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--color-text-light);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
}

.users-table td {
    padding: 1rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.users-table tbody tr:hover {
    background: var(--beige-light) !important;
}

.role-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1000px;
    font-size: 0.8rem;
    font-weight: 500;
}

.role-visiteur {
    background: var(--beige-dark);
    color: var(--color-text-light);
    border: 1px solid var(--color-border);
}

.role-marchand {
    background: var(--color-info);
    color: white;
}

.role-artiste {
    background: var(--color-warning);
    color: white;
}

.role-admin {
    background: var(--red-dark);
    color: white;
}

.table-actions {
    display: flex;
    gap: 0.5rem;
}

/* ==========================================
   TOOLS & CARDS
   ========================================== */

.tools-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

/* Tablet: 2 columns (2x2 layout) */
@media (min-width: 640px) {
    .tools-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop: 4 columns (1x4 layout) */
@media (min-width: 1200px) {
    .tools-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

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

/* Ajout de bordures aux boutons dans les tool-cards */
.tool-card .btn-primary,
.tool-card .btn-secondary,
.tool-card button:not(.btn-icon-refresh),
.tool-card a.btn-secondary {
    border: 1px solid var(--color-border);
}

/* Boutons secondaires sur fond beige-light (modals et tool-cards) */
.modal .btn-secondary,
.tool-card .btn-secondary:not(.btn-icon-refresh) {
    background: var(--beige-dark);
    color: var(--color-text);
}

.modal .btn-secondary:hover,
.tool-card .btn-secondary:not(.btn-icon-refresh):hover {
    background: #ffffff;
    color: var(--color-text);
}

.tool-card {
    display: flex;
    flex-direction: column;
}

.tool-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--color-text);
}

.tool-card p {
    color: var(--color-text-light);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.tool-card .clickable-subtitle {
    transition: color 0.2s ease;
}

.tool-card .clickable-subtitle:hover {
    color: var(--red-dark);
}

/* Tool card stats list */
.tool-card-stats {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem 0;
    color: var(--color-text-light);
    font-size: 0.9rem;
}

.tool-card-stats li {
    padding: 0.25rem 0;
    padding-left: 1.2rem;
    position: relative;
}

.tool-card-stats li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--color-text-light);
}

/* Orphan photos list */
.orphans-list-container {
    max-height: 400px;
    overflow-y: auto;
    background: #ffffff;
}

.orphans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.5rem;
}

.orphan-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--beige-light);
    border-radius: 6px;
    font-size: 0.85rem;
}

.orphan-thumb {
    width: 40px;
    height: 40px;
    background-color: #ffffff;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--color-border);
}

.orphan-item code {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    word-break: break-all;
}

/* Tool cards: keep space between primary content (button) and the footer separator */
.tool-card>button,
.tool-card>a.btn-secondary {
    margin-bottom: 1.5rem;
}



.tool-card>div:not(.tool-card-footer) {
    margin-bottom: 1.5rem;
}

.tool-card>div button:not(:last-child),
.tool-card>div .btn-primary:not(:last-child),
.tool-card>div .btn-secondary:not(:last-child) {
    margin-right: 0.5rem;
}

.tool-card-footer {
    margin-top: auto;
    padding-top: 0.4rem;
    margin-left: -1.5rem;
    margin-right: -1.5rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.tool-card-info {
    font-size: 0.75rem;
    color: var(--color-text-light);
}

.btn-icon-refresh {
    background: var(--red-dark);
    color: white;
    border: 1px solid var(--red-dark);
    border-radius: var(--radius);
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.btn-icon-refresh:disabled {
    background: var(--beige-light) !important;
    color: var(--color-text-muted) !important;
    border-color: var(--color-border) !important;
    cursor: not-allowed !important;
    opacity: 0.5 !important;
    pointer-events: none !important;
}

.btn-icon-refresh:disabled svg {
    stroke: var(--color-text-muted) !important;
    color: var(--color-text-muted) !important;
}

.btn-icon-refresh:not(:disabled):hover {
    background: var(--color-text);
    border-color: var(--color-text);
}

/* Boutons icône avec image SVG */
.btn-icon-img {
    background: transparent;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--transition);
}

.btn-icon-img:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-icon-img:not(:disabled):hover {
    opacity: 0.8;
}

.btn-icon-img img {
    display: block;
}

/* All viewports: même hauteur pour les blocs */
.tools-grid {
    align-items: stretch;
}

/* ==========================================
   STATS
   ========================================== */

.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: #ffffff;
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    font-size: 2rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--beige-dark);
    border-radius: var(--radius);
}

.stat-content {
    flex: 1;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--color-text-light);
    margin-bottom: -7px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--color-text);
    display: inline;
}

.stat-detail {
    font-size: 0.75rem;
    color: var(--color-text-light);
    display: inline;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.stat-card-secondary {
    background: #ffffff;
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}

.stat-value-lg {
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0.5rem 0;
}

/* Health Score */
.health-score {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 2rem;
    align-items: center;
}

.health-gauge {
    text-align: center;
}

.gauge-value {
    font-size: 4rem;
    font-weight: 700;
    color: var(--color-success);
}

.gauge-label {
    font-size: 0.9rem;
    color: var(--color-text-light);
    margin-top: 0.5rem;
}

.health-details {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.health-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.95rem;
}

.health-icon {
    font-size: 1.5rem;
}

/* Charts */
.chart-container {
    position: relative;
    height: 300px;
}

/* Themes header: title + tabs side by side */
.themes-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.themes-header h2 {
    margin: 0 !important;
}

.themes-tabs {
    display: inline-flex;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.themes-tab {
    background: #fff;
    border: none;
    padding: 6px 14px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--color-text-light);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    border-right: 1px solid var(--color-border);
}

.themes-tab:last-child {
    border-right: none;
}

.themes-tab:hover {
    background: var(--beige-dark);
    color: var(--color-text);
}

.themes-tab.active {
    background: var(--color-text);
    color: #fff;
}

/* Themes section: 3 colonnes (camembert | liste gauche | liste droite) */
.themes-section .themes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    column-gap: 3rem; /* espace X uniforme entre les colonnes */
    row-gap: 1rem;
    align-items: start; /* valign top */
    padding: 0 3rem; /* espace X uniforme à gauche/droite du bloc */
    box-sizing: border-box;
}

.themes-chart-col {
    position: relative;
    height: 300px;
}

.themes-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.theme-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.2rem 0; /* interligage réduit */
    font-size: 0.9rem;
}

.theme-dot {
    flex: 0 0 auto;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.theme-name {
    flex: 1 1 auto;
    color: var(--color-text);
}

.theme-count {
    flex: 0 0 auto;
    color: var(--color-text-light);
    font-variant-numeric: tabular-nums;
}

@media (max-width: 768px) {
    .themes-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .themes-chart-col {
        height: 240px;
    }
}

/* ==========================================
   LOGS
   ========================================== */

.logs-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.log-entry {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    padding-right: 56px; /* Reserve space for thumbnail */
    margin-bottom: 10px;
    background: var(--beige-dark);
    border-radius: var(--radius);
    min-height: 50px;
}

.log-time {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
    flex-shrink: 0;
    text-align: left;
}

.log-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
}

.log-message {
    font-weight: 500;
    color: var(--color-text);
}

.log-details {
    font-size: 0.85rem;
    color: var(--color-text-light);
}

.log-strikethrough .log-message,
.log-strikethrough .log-details {
    text-decoration: line-through;
    opacity: 0.5;
}

.log-link {
    color: var(--color-text);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color var(--transition);
}

.log-link:hover {
    color: var(--red-dark);
}

.log-thumbnail {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 4px;
    overflow: hidden;
    transition: opacity 0.2s ease;
}

.log-thumbnail.clickable {
    cursor: pointer;
}

.log-thumbnail.clickable:hover {
    opacity: 0.8;
}

.log-thumbnail:not(.clickable) {
    opacity: 0.5;
    cursor: default;
}

.log-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Multiple thumbnails row (for CropMachine with 2+ photos) */
.log-thumbnails-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 2px;
    width: 100%;
}

.log-entry.has-thumbnails-row {
    flex-wrap: wrap;
}

.log-entry.has-thumbnails-row .log-thumbnails-row {
    flex-basis: 100%;
    margin-left: 0;
    padding-left: 0;
}

/* Non-clickable thumbnail badge */
.log-thumbnail .no-csv-badge {
    position: absolute;
    top: 0;
    right: 0;
    width: 14px;
    height: 14px;
    border-radius: 0 4px 0 2px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1px;
}

.log-thumbnail .no-csv-badge img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Clickable CSV log link */
.log-csv-link {
    cursor: pointer;
    transition: color 0.2s ease;
}

.log-csv-link:hover {
    color: var(--red-dark);
}

/* Logs filters */
.logs-filters {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    margin-right: 1rem;
}

.logs-filter {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--color-text);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
    transition: color 0.15s ease;
}

.logs-filter:hover {
    color: var(--red-dark);
}

.logs-filter.active {
    color: var(--red-dark);
}

.logs-filter-sep {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    user-select: none;
}

.logs-container {
    padding: 1.5rem;
    height: 600px;
    overflow-y: auto;
}

.logs-loading-more {
    text-align: center;
    padding: 1rem;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.logs-end {
    text-align: center;
    padding: 1rem;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    font-style: italic;
}

/* ==========================================
   SUGGESTIONS
   ========================================== */

.suggestions-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--beige-dark);
    border-radius: var(--radius);
}

.suggestion-icon {
    font-size: 1.5rem;
}

.suggestion-content {
    flex: 1;
}

.suggestion-action {
    flex-shrink: 0;
}

/* ==========================================
   FORMS
   ========================================== */

form {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--color-text);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.625rem;
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--red-dark);
}

.form-group select:focus {
    outline: none;
    border-color: var(--color-border);
}

/* Suppression du filet focus dans les modals (comme login et filtres) */
.modal .form-group input:focus,
.modal .form-group select:focus {
    border-color: var(--color-border);
}

.form-group input::placeholder {
    color: var(--color-text-muted);
}

#password-optional {
    color: var(--color-text-muted);
    font-weight: normal;
    font-size: 0.85rem;
}

.role-descriptions {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--beige-light) !important;
    border: none !important;
    border-radius: var(--radius);
}

.role-desc {
    display: none;
    font-size: 0.9rem;
    color: var(--color-text-light);
    line-height: 1.5;
}

.role-desc.active {
    display: block;
}

/* ==========================================
   UTILITIES
   ========================================== */

.no-results {
    text-align: center;
    padding: 48px 16px;
    color: var(--color-text-light);
    grid-column: 1 / -1;
}

.no-results p {
    margin-bottom: 16px;
    font-size: 1.1rem;
}

.no-results-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

#reset-all-favorites {
    padding-top: 56px;
    padding-bottom: 32px;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: var(--color-text-light);
}

.time-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.time-stat {
    text-align: center;
}

.time-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text);
    display: block;
    margin-top: 0.25rem;
}

/* ==========================================
   RESPONSIVE - MOBILE
   ========================================== */

@media (max-width: 768px) {
    .modal {
        align-items: flex-start;
        /* au lieu de centrer verticalement */
        padding-top: calc(var(--header-height, 64px) + 12px);
    }

    .modal-content {
        max-height: calc(100vh - var(--header-height, 64px) - 24px);
        overflow: auto;
    }
}

@media (max-width: 768px) {
    .stats-overview {
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .stat-card {
        padding: 1rem;
    }
}

@media (max-width: 768px) {
    .admin-content>.tools-grid {
        gap: 1rem;
        margin: 0 auto 1.5rem;
    }
}

@media (max-width: 768px) {

    /* Un user = plein largeur + filet en bas */
    .user-mobile-card {
        width: 100%;
        box-sizing: border-box;

        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        column-gap: 12px;
        row-gap: 10px;
        /* <-- tes 10px entre ligne identifiant/nom et rôle */

        padding: 12px 0;
        margin: 0;
        background: transparent;

        border: 0;
        border-bottom: 1px solid var(--color-border);
        /* <-- filet comme séparateur */
        border-radius: 0;
    }

    /* Colonne actions collée à droite, sur toute la hauteur (2 lignes) */
    .user-mobile-actions {
        grid-column: 2;
        grid-row: 1 / span 2;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        /* <-- edit en face de ligne1, delete en face de ligne2 */
        align-items: flex-end;
        height: 100%;
    }
}



@media (max-width: 768px) {

    /* Mobile: remove transition so filters can follow the scroll precisely */
    .sticky-filters {
        transition: none;
        will-change: transform;
        background: transparent;
    }

    .users-table thead {
        display: none !important;
    }

    /* Mobile: ensure results bar aligns with list padding */
    .results-row {
        padding-left: 20px;
        padding-right: 20px;
    }

    /* Mobile: add space above artworks list */
    .artworks-list {
        padding-top: 20px;
    }

    /* Mobile: select-all checkbox moved into the left group */
    .select-all-wrapper.mobile-select-all {
        padding-left: 0;
        padding-right: 0;
        height: auto;
        margin-right: 10px;
    }

    .select-all-wrapper.mobile-select-all input[type="checkbox"] {
        width: 24px;
        height: 24px;
    }

    /* Mobile: hide separators in the bottom bar */
    .results-separator {
        display: none;
    }

    .header {
        flex-wrap: nowrap;
        padding: 12px;
        gap: 12px;
        position: sticky;
        top: 0;
    }

    /* Show mobile navigation buttons */
    .mobile-nav-btn,
    .mobile-filters-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    /* Mobile: put Stats button first in the header-right group */
    .header-mobile-right {
        display: flex;
        flex-wrap: nowrap;
        gap: 10px;
    }

    /* Mobile header: stats stays near the logo (left edge of the right zone),
       and avatar/admin are swapped (avatar before admin) */
    .header-mobile-right .mobile-nav-btn[href*="stats.php"] {
        order: 0;
        margin-right: auto;
    }

    .header-mobile-right .header-nav {
        order: 1;
        margin-left: 0;
    }

    .header-mobile-right .mobile-nav-btn[href*="admin.php"] {
        order: 2;
    }

    /* Mobile: legacy floating filters button removed (replaced by the centered tab) */
    #mobile-filters-toggle {
        display: none !important;
    }

    /* Mobile header layout - 3 zones: left / centered logo / right */
    .header {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        padding: 12px;
        gap: 8px;
        position: relative;
    }

    .header-mobile-left {
        grid-column: 1;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 8px;
        min-width: 0;
        padding-left: 5px;
    }

    .logo-link {
        grid-column: 2;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .logo-link .logo-svg {
        height: 40px;
    }

    .header-mobile-right {
        grid-column: 3;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 8px;
        min-width: 0;
        flex-wrap: nowrap;
        padding-right: 5px;
    }

    .header-mobile-right .header-nav {
        width: auto;
        display: flex;
        align-items: center;
        gap: 10px;
        margin-left: 0;
        flex-wrap: nowrap;
    }

    /* Hide desktop navigation items but keep user menu */
    .header-nav .nav-item {
        display: none;
    }

    .header-nav .user-menu {
        display: flex;
        margin-left: 0;
        flex-shrink: 0;
    }

    .header-nav .user-avatar {
        width: 36px;
        height: 36px;
        font-size: 13px;
    }

    /* Mobile header buttons sizing + spacing */
    .header-mobile-left,
    .header-mobile-right,
    .header-mobile-right .header-nav {
        gap: 15px;
    }

    .mobile-nav-btn,
    .mobile-filters-toggle {
        width: 24px;
        height: 24px;
        padding: 0;
        color: inherit;
    }

    .mobile-nav-btn svg,
    .mobile-filters-toggle svg {
        height: 24px;
        width: auto;
        display: block;
    }

    /* User icon on mobile: same size as other header icons */
    .header-nav .user-icon {
        width: 24px;
        height: 24px;
    }

    .header-right {
        width: 100%;
        justify-content: space-between;
        margin-top: 0.5rem;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .nav-btn {
        font-size: 0.8rem;
    }

    .user-info {
        order: -1;
        width: 100%;
        text-align: center;
    }

    /* Mobile: filters panel pushes content when OPEN, but TAB can float over the list when CLOSED */
    .sticky-filters {
        --tab-y: 0px;
        position: sticky;
        top: var(--header-height, 64px);
        z-index: 350;
        /* below header (400), above content */

        background: transparent;
        transform: none;
        pointer-events: auto;

        /* When closed, do not reserve height (so the list can scroll under the TAB) */
        height: 0;
        overflow: visible;

        transition: none;
        /* mobile: no translate animations */
    }

    .sticky-filters.hidden {
        transform: none;
        /* mobile: never translate away */
        pointer-events: auto;
    }

    /* White strip behind the TAB (only when CLOSED) */
    .sticky-filters:not(.mobile-visible)::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 52px;
        /* covers the TAB row */
        background: transparent;
        z-index: 0;
    }

    /* Collapsible panel that pushes the list down (OPEN only) */
    .mobile-filters-panel {
        max-height: 0;
        overflow: hidden;
        transition: max-height 240ms ease;

        background: transparent;
    }

    .sticky-filters.mobile-visible {
        height: auto;
        /* allow the panel to take space and push content */
    }

    .sticky-filters.mobile-visible .mobile-filters-panel {
        max-height: 80vh;
        padding-bottom: 0;
        /* Laisser les dropdowns custom-select sortir du panneau (sinon clippés) */
        overflow: visible;
    }

    /* The centered TAB "handle" */
    .mobile-filters-tab {
        display: flex;
        width: fit-content;
        align-items: center;
        justify-content: center;

        margin: 0;
        margin-top: -12px;
        padding: 10px;

        background: var(--beige-dark);
        border: none;

        border-radius: 0 0 var(--radius) var(--radius);

        font-weight: 700;
        font-size: 0.75rem;
        /* same as filter headings */
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--red-dark);

        cursor: pointer;
        user-select: none;

        position: absolute;
        top: 0;
        left: 50%;
        /* X centered, Y driven by JS via --tab-y */
        transform: translate(-50%, var(--tab-y, 0px));
        z-index: 1;

        transition: transform 240ms ease, margin-top 240ms ease, background 240ms ease, border-color 240ms ease;
        will-change: transform, margin-top;
    }

    /* When OPEN, the TAB is placed directly after the panel,
       glued to the last horizontal rule (no extra beige band) */
    .sticky-filters.mobile-visible .mobile-filters-tab {
        /* Keep the TAB absolutely positioned (no extra band),
           but let --tab-y drive the vertical animation */
        position: absolute;
        left: 50%;
        top: 0;
        margin-top: -12px;
        padding-bottom: 7px;
        transform: translate(-50%, var(--tab-y, 0px));
        z-index: -20;
        border-radius: 0 0 var(--radius) var(--radius);
    }

    .mobile-filters-tab[aria-expanded="true"] {
        background: var(--beige-light);

        /* Le bouton "cache" le filet horizontal derrière lui */
        z-index: 5;

        /* Bordure autour du bouton, sauf en haut */
        border: 1px solid var(--beige-dark);
        border-top: 0;

        /* Pour qu’il colle au filet et le masque bien */
        margin-top: -2px;
        /* -1 si tu préfères plus léger */

        border-radius: 0 0 var(--radius) var(--radius);
    }


    /* Optimize bottom sticky bar for mobile */
    .results-row {
        padding: 8px 20px;
        gap: 8px;
        flex-wrap: wrap;
        justify-content: center;
    }



    .results-center-group {
        position: static;
        left: auto;
        transform: none;
        width: 100%;
        height: auto;
        justify-content: center;
    }

    .results-count {
        width: 100%;
        justify-content: center;
    }

    /* Hide "Tout sélectionner" label text on mobile */
    .select-all-wrapper .select-all-label {
        display: none;
    }

    /* Hide selection separator on mobile */
    .selection-separator {
        display: none;
    }

    /* Make selected count smaller */
    #selected-count-number {
        font-size: 0.95rem;
        font-weight: 700;
    }

    #selected-count-label {
        display: none;
    }

    #count-text {
        display: inline !important;
    }

    /* Bar buttons: smaller on mobile, no tooltip labels */
    .bar-buttons-group {
        gap: 4px;
    }

    .bar-btn {
        width: 28px;
        height: 28px;
    }

    .bar-btn .bar-btn-icon {
        width: 14px;
        height: 14px;
    }

    .bar-btn .bar-btn-label {
        display: none !important;
    }

    .btn-kiosque-header {
        display: none !important;
    }

    /* Make results center group more compact */
    .results-center-group {
        position: static;
        transform: none;
        gap: 8px;
        font-size: 0.8rem;
    }

    /* Mobile: keep sort buttons + select-all + selected count on one flow line (not centered absolute) */
    .results-row {
        justify-content: flex-start;
        flex-wrap: nowrap;
    }

    .select-all-wrapper {
        padding-left: 0;
        padding-right: 0;
    }

    #select-all {
        width: 24px;
        height: 24px;
        margin: 0;
        accent-color: var(--red-dark);
    }

    .select-all-label {
        display: none;
    }


    .results-count {
        padding-left: 0;
        padding-right: 0;
        font-size: 0.8rem;
    }

    .admin-content {
        padding: 1rem;
    }

    .admin-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-nav {
        width: 100%;
        flex-wrap: wrap;
    }

    .stats-overview {
        grid-template-columns: 1fr 1fr;
    }

    .health-score {
        grid-template-columns: 1fr;
        text-align: center;
    }


    /* Admin and stats headers responsive */
    .admin-header {
        flex-wrap: wrap;
    }

    .modal-content {
        max-width: 100%;
    }

    /* Overlay: remove top margin on mobile (overlay is above everything) */
    .overlay-content {
        margin-top: 0;
        max-height: 95vh;
    }
}

/* ==========================================
   RESPONSIVE - TABLET & DESKTOP
   ========================================== */

@media (min-width: 768px) {
    .filters-row {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1200px) {
    .filters-row {
        grid-template-columns: repeat(7, 1fr);
    }

    .overlay-body {
        flex-direction: row;
        align-items: flex-start;
    }

    .overlay-photo {
        flex: 0 0 auto;
        max-width: 50%;
        padding-right: 24px;
        padding-bottom: 24px;
    }

    .overlay-photo img {
        max-height: 70vh; /* Hauteur max pour desktop */
        height: auto;
    }

    .overlay-info {
        flex: 1;
        min-width: 0;
    }
}

@media (min-width: 1024px) {
    .filters {
        padding: 20px 32px;
    }

    .results-row {
        padding: 12px 32px;
    }


    .results-count {
        padding: 12px 32px;
    }

    .artworks-list {
        padding: 8px 32px 100px;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0 52px;
    }

    /* En grille 2 colonnes, tous les items ont un filet (pas de :last-child sans filet) */
    .artworks-list .artwork-item:last-child {
        border-bottom: 1px solid var(--beige-dark);
    }

    /* Sauf si c'est aussi l'avant-dernier (= seul sur sa ligne, dernière ligne impaire) */
    .artworks-list .artwork-item:nth-last-child(1):nth-child(odd) {
        border-bottom: none;
    }

    .artwork-item:hover {
        background: var(--beige-light);
    }

    .overlay-body {
        flex-direction: row;
        align-items: flex-start;
        overflow-y: visible;
    }

    .overlay-photo {
        flex: 0 0 45%;
        max-height: calc(90vh - 140px);
        display: flex;
        align-items: center;
    }

    .overlay-info {
        flex: 1;
        padding-top: 0;
    }
}

/* =========================
   ROUND 5 OVERRIDES
   ========================= */

/* Mobile layout: bottom sticky bar stays on one line (left controls / centered selected count / right inventory button) */
@media (max-width: 768px) {
    .results-row {
        display: grid !important;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        justify-content: initial !important;
        flex-wrap: initial !important;
        gap: 10px !important;
    }

    .results-left-group {
        grid-column: 1;
        display: inline-flex;
        align-items: center;
        gap: 5px;
        flex-wrap: nowrap;
        white-space: nowrap;
        min-width: 0;
    }

    .results-center-group {
        grid-column: 2;
        width: auto !important;
        justify-content: center;
        min-width: 0;
    }

    .results-count {
        justify-content: center;
        width: 100%;
    }

    /* Mobile: hide the separate selection elements (we merge them into count-text in JS) */
    #selected-count-label {
        display: none !important;
    }

    .selection-separator {
        display: none !important;
    }

    /* Sort buttons: single cartouche on mobile */
    .sort-group {
        gap: 0;
        background: #fff;
        border-radius: var(--radius);
        overflow: hidden;
    }

    .sort-btn {
        padding: 4px 6px;
        font-size: 0.75rem;
        height: 24px;
        line-height: 1;
        border-radius: 0;
        gap: 1px;
    }

    .sort-group .sort-btn + .sort-btn {
        border-left: 1px solid var(--beige-dark);
    }

    .sort-group .sort-btn.active + .sort-btn,
    .sort-group .sort-btn + .sort-btn.active {
        border-left-color: transparent;
    }
}

/* Mobile header icons: <img> instead of inline SVG */
@media (max-width: 768px) {

    .mobile-nav-btn,
    .mobile-filters-toggle {
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
    }

    .mobile-nav-btn .mobile-nav-icon,
    .mobile-filters-toggle .mobile-nav-icon {
        width: 24px;
        height: 24px;
        display: block;
    }

    /* Mobile nav buttons hover state */
    .mobile-nav-btn .icon-hover {
        display: none;
    }

    .mobile-nav-btn:hover .icon-default,
    .mobile-nav-btn:active .icon-default {
        display: none;
    }

    .mobile-nav-btn:hover .icon-hover,
    .mobile-nav-btn:active .icon-hover {
        display: block;
    }
}

/* Responsive text: show/hide based on viewport */
.text-mobile {
    display: none;
}

.text-desktop {
    display: inline;
}

@media (max-width: 768px) {
    .text-mobile {
        display: inline;
    }

    .text-desktop {
        display: none;
    }
}

/* Legacy .btn-inventory / .btn-download-hd rules removed — now uses .bar-btn */


/* Selection count typography */
.selection-count {
    justify-content: center;
    align-items: center;
    white-space: nowrap;
}

#selected-count-number,
#selected-count-label {
    white-space: nowrap;
}

#selected-count-number.admin-downloadable {
    cursor: pointer;
}

#selected-count-number.admin-downloadable:hover {
    text-decoration: underline;
}

/* Mobile: header must stay visible (no hide on scroll) */
@media (max-width: 768px) {
    .header {
        transition: none;
        will-change: auto;
    }

    .header.is-hidden {
        transform: none !important;
    }
}

/* ==========================================
   MOBILE STICKY HEADER + FILTER PANEL (override)
   ========================================== */
@media (max-width: 768px) {

    /* Header: fixed (iOS Safari sticky-in-flex workaround) */
    .header {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
    }

    /* Push the page content below the fixed header */
    .wrapper {
        padding-top: var(--header-height, 64px);
    }

    /* Filters panel: push-down under the header (tab always visible) */
    .sticky-filters {
        position: sticky !important;
        top: var(--header-height, 64px) !important;
        z-index: 950;
        transform: none !important;
        pointer-events: auto !important;
        overflow: visible !important;
        max-height: none !important;
        background: transparent !important;
    }

    /* Mobile: never translate the whole sticky block away */
    .sticky-filters.hidden {
        transform: none !important;
        pointer-events: auto !important;
    }

    /* Collapsible panel that pushes the list down */
    .mobile-filters-panel {
        max-height: 0;
        overflow: hidden;
        transition: max-height 240ms ease;

        background: transparent !important;
        padding: 0 !important;
        border: 0 !important;
    }

    .filters {
        padding: 16px 20px 20px !important;
        /* bottom = 16 + 10 */
    }

    .sticky-filters.mobile-visible .mobile-filters-panel {
        max-height: 80vh;
    }

    /* Mobile: reset button full width at very top of filters */
    .filters {
        display: flex;
        flex-direction: column;
    }

    .filters .filters-row {
        order: 1;
    }

    .filters .search-row {
        display: contents;
    }

    .filters .search-wrapper {
        order: 2;
        width: 100%;
        margin-top: 12px;
    }

    .filters .filters-reset {
        order: 0;
        width: 100%;
        margin-bottom: 12px;
    }
}

/* =========================
   MOBILE – USERS LIST FIXES
   ========================= */
@media (max-width: 768px) {

    /* Le "petit filet" vient souvent du border-bottom des <td> */
    .users-table tbody td {
        border-bottom: none !important;
        padding: 0 !important;
        /* le padding est géré par .user-mobile-card */
    }

    /* On garde UN seul séparateur : celui du card (full width) */
    .user-mobile-card {
        border-bottom: 1px solid var(--color-border) !important;
    }

    /* Filet full width au-dessus du 1er user */
    .users-table tbody tr:first-child .user-mobile-card {
        border-top: 1px solid var(--color-border) !important;
    }
}

/* =========================
   MOBILE – SPACING TIGHTER
   ========================= */
@media (max-width: 768px) {

    /* Entre les gros blocs (admin-section) */
    .admin-section {
        margin-bottom: 1rem !important;
        /* au lieu de 2rem */
        padding: 1rem !important;
        /* au lieu de 1.5rem */
    }

    /* Grilles stats */
    .stats-overview {
        gap: 0.75rem !important;
        margin-bottom: 0.75rem !important;
    }

    .stats-grid {
        gap: 0.75rem !important;
    }

    /* Grille des tool cards (admin) */
    .tools-grid {
        gap: 0.75rem !important;
    }
}

/* ==========================================
   IMAGE EDITOR (Super Admin Only)
   ========================================== */

.editor-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 100000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.editor-overlay.active {
    display: flex;
}

.editor-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    max-width: 95vw;
    max-height: 95vh;
}

.editor-image-wrapper {
    position: relative;
    width: 90vw;
    height: calc(90vh - 100px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.editor-image-wrapper img {
    position: absolute;
    max-width: 90vw;
    max-height: calc(90vh - 100px);
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

/* Crop Box - Marching ants effect */
.editor-crop-box {
    position: absolute;
    box-sizing: border-box;
    cursor: grab;
    background: transparent;
    border: none;
    /* Gradient-based marching ants */
    background-image:
        linear-gradient(90deg, #fff 50%, transparent 50%),
        linear-gradient(90deg, #fff 50%, transparent 50%),
        linear-gradient(0deg, #fff 50%, transparent 50%),
        linear-gradient(0deg, #fff 50%, transparent 50%);
    background-size:
        8px 2px,
        8px 2px,
        2px 8px,
        2px 8px;
    background-position:
        0 0,
        0 100%,
        0 0,
        100% 0;
    background-repeat:
        repeat-x,
        repeat-x,
        repeat-y,
        repeat-y;
    animation: marching-ants 0.3s linear infinite;
}

@keyframes marching-ants {
    0% {
        background-position:
            0 0,
            8px 100%,
            0 8px,
            100% 0;
    }
    100% {
        background-position:
            8px 0,
            0 100%,
            0 0,
            100% 8px;
    }
}

/* Crop Handles */
.crop-handle {
    position: absolute;
    width: 16px;
    height: 16px;
    background: #ffffff;
    border: 2px solid var(--red-dark);
    border-radius: 2px;
    z-index: 10;
}

.crop-handle:hover {
    background: var(--red-dark);
}

/* Corner handles */
.handle-nw {
    top: -8px;
    left: -8px;
    cursor: nw-resize;
}

.handle-ne {
    top: -8px;
    right: -8px;
    cursor: ne-resize;
}

.handle-sw {
    bottom: -8px;
    left: -8px;
    cursor: sw-resize;
}

.handle-se {
    bottom: -8px;
    right: -8px;
    cursor: se-resize;
}

/* Middle edge handles */
.handle-n {
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    cursor: n-resize;
}

.handle-e {
    top: 50%;
    right: -8px;
    transform: translateY(-50%);
    cursor: e-resize;
}

.handle-s {
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    cursor: s-resize;
}

.handle-w {
    top: 50%;
    left: -8px;
    transform: translateY(-50%);
    cursor: w-resize;
}

/* Editor Action Buttons */
.editor-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.editor-btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 140px;
    position: relative;
    overflow: hidden;
}

/* Primary button (SAUVEGARDER) - Red style */
.editor-btn-primary {
    background: var(--red-dark);
    color: white;
    border: 1px solid var(--red-dark);
}

.editor-btn-primary:hover {
    background: var(--beige-light);
    color: var(--color-text);
    border-color: var(--color-text);
}

/* Secondary buttons (all white, hover beige-light) */
.editor-btn-secondary {
    background: #ffffff;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.editor-btn-secondary:hover {
    background: var(--beige-light);
    border-color: var(--color-text);
}

/* Active state for Correction Auto button */
.editor-btn-secondary.active {
    background: var(--color-success);
    color: white;
    border-color: var(--color-success);
}

.editor-btn-secondary.active:hover {
    background: var(--beige-light);
    color: var(--color-text);
    border-color: var(--color-text);
}

/* Loading state with progress bar effect */
.editor-btn.loading {
    pointer-events: none;
    position: relative;
}

.editor-btn.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--progress, 0%);
    background: rgba(255, 255, 255, 0.3);
    transition: width 0.2s ease;
}

.editor-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Icon buttons - same height as primary button */
.editor-btn-icon {
    background: #ffffff;
    border: 1px solid var(--color-border);
    padding: 12px;
    min-width: auto;
    width: auto;
    height: auto;
}

.editor-btn-icon img {
    width: 18px;
    height: 18px;
    display: block;
}

.editor-btn-icon .icon-active {
    display: none;
}

.editor-btn-icon .icon-default {
    display: block;
}

.editor-btn-icon:hover {
    background: var(--beige-light);
    border-color: var(--color-text);
}

/* Active state for icon buttons */
.editor-btn-icon.active .icon-default {
    display: none;
}

.editor-btn-icon.active .icon-active {
    display: block;
}

/* Close button for editor - uses universal-close-btn style */
.editor-close-btn {
    /* Inherits from universal-close-btn, just needs higher z-index */
    z-index: 100001;
}

/* Confirmation modal */
.editor-confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100002;
}

.editor-confirm-modal.active {
    display: flex;
}

.editor-confirm-content {
    background: #ffffff;
    padding: 24px 32px;
    border-radius: var(--radius);
    text-align: center;
    max-width: 400px;
}

.editor-confirm-content p {
    font-size: 1rem;
    color: var(--color-text);
    margin-bottom: 20px;
}

.editor-confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.editor-confirm-actions .editor-btn {
    min-width: 120px;
}

.editor-btn-secondary {
    background: var(--beige-light);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.editor-btn-secondary:hover {
    background: var(--beige-dark);
    border-color: var(--color-text);
}

/* Favorite button on overlay photo - positioned in top right of image (same distance as edit button) */
.btn-overlay-favorite {
    position: absolute;
    right: 10px;
    top: 10px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-overlay-favorite img {
    width: 24px;
    height: 24px;
}

.btn-overlay-favorite .star-hover {
    display: none;
}

.btn-overlay-favorite:hover .star-default {
    display: none;
}

.btn-overlay-favorite:hover .star-hover {
    display: block;
}

/* Note: is-favorite state is handled via JavaScript by changing img src */

/* Edit button on overlay photo - positioned in bottom left of image */
.btn-edit-photo {
    position: absolute;
    left: 10px;
    bottom: 10px;
    height: 31px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer !important;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-edit-photo img {
    height: 100%;
    width: auto;
    cursor: pointer !important;
}

.btn-edit-photo .icon-hover {
    display: none;
}

.btn-edit-photo:hover .icon-default {
    display: none;
}

.btn-edit-photo:hover .icon-hover {
    display: block;
}

/* Restore backup button on overlay photo - positioned in top left of image */
.btn-restore-backup {
    position: absolute;
    left: 10px;
    top: 10px;
    height: 31px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer !important;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-restore-backup img {
    height: 100%;
    width: auto;
    cursor: pointer !important;
}

.btn-restore-backup .icon-hover {
    display: none;
}

.btn-restore-backup:hover .icon-default {
    display: none;
}

.btn-restore-backup:hover .icon-hover {
    display: block;
}

/* Only show on desktop */
@media (max-width: 1023px) {
    .btn-edit-photo,
    .btn-restore-backup {
        display: none !important;
    }

    .editor-overlay {
        display: none !important;
    }
}

/* ==========================================
   FORMATS & SURFACES SECTION (stats.php)
   ========================================== */

.formats-section {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr;
    gap: 1.5rem;
    margin-top: 2rem;
    align-items: stretch;
}

.format-card {
    background: var(--beige-light);
    border-radius: var(--radius);
    padding: 1.5rem 1.5rem 0 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.format-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 1rem 0;
}

/* Surface totale card */
.format-card-surface {
    text-align: left;
    justify-content: space-between;
}

.format-value {
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
}

.format-detail {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-top: 0.5rem;
}

.format-subdetail {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: auto;
    padding-top: 1rem;
}

/* Plus grande œuvre card */
.format-card-largest {
    text-align: left;
    background: #fff;
    padding-bottom: 1.5rem;
}

.largest-artwork-image {
    width: 100%;
    min-height: 150px;
    background: var(--beige-light);
    border-radius: calc(var(--radius) - 4px);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.largest-artwork-image img {
    max-width: 100%;
    max-height: 206px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: calc(var(--radius) - 4px);
    display: block;
}

.largest-artwork-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 0.25rem;
}

/* Clickable artwork links in stats (no underline, no hover effects) */
a.artwork-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

a.artwork-link:hover {
    text-decoration: none;
    color: inherit;
}

a.largest-artwork-title.artwork-link {
    display: block;
}

.largest-artwork-dimensions {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* Top 10 formats card */
.format-card-top10 {
    width: 100%;
    background: #fff;
    padding: 1.5rem;
}

.top10-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    width: 100%;
    height: 100%;
}

.top10-list {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    height: 100%;
}

.top10-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.8rem;
    background: var(--beige-light);
    border-radius: calc(var(--radius) - 4px);
}

.top10-format {
    font-weight: 500;
    color: var(--color-text);
}

.top10-count {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 1023px) {
    .formats-section {
        grid-template-columns: 1fr 1fr;
    }

    .format-card-top10 {
        grid-column: span 2;
    }
}

@media (max-width: 640px) {
    .formats-section {
        grid-template-columns: 1fr;
    }

    .format-card-top10 {
        grid-column: span 1;
        order: 2;
    }

    .format-card-largest {
        order: 3;
    }

    .format-card-surface {
        order: 1;
    }
}

/* ==========================================
   FUN STATS SECTION (stats.php)
   Random fun facts - reuses .formats-section styles
   ========================================== */

/* Add spacing below the last section */
#last-section {
    margin-bottom: 100px;
}

/* Fun stats section: align with 4-column grid above */
#fun-stats-section {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr;
    gap: 1.5rem;
    margin-top: 0;
    margin-bottom: 2rem;
}

/* Use same grid as stats-overview (4 equal columns) */
@supports (display: grid) {
    #fun-stats-section {
        grid-template-columns: repeat(4, 1fr);
    }

    #fun-stats-section #fun-stat-col1 {
        grid-column: span 1;
    }

    #fun-stats-section #fun-stat-col2 {
        grid-column: span 1;
    }

    #fun-stats-section #fun-stat-col3 {
        grid-column: span 2;
    }
}

/* Col1: white background like col2 */
#fun-stats-section .format-card-surface {
    background: #fff;
    padding-bottom: 1.5rem;
}

/* Loading and error states */
.fun-stat-loading,
.fun-stat-error {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 250px;
    text-align: center;
    width: 100%;
}

/* Fun stats: artwork image with padding for visible beige border */
#fun-stats-section .largest-artwork-image {
    padding: 5px;
    box-sizing: border-box;
}

/* Artwork reference ID */
.artwork-ref {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-weight: 400;
}

/* Fun stats responsive - tablet */
@media (max-width: 1023px) {
    #fun-stats-section {
        grid-template-columns: 1fr 1fr;
    }

    #fun-stats-section #fun-stat-col1 {
        grid-column: span 1;
    }

    #fun-stats-section #fun-stat-col2 {
        grid-column: span 1;
    }

    #fun-stats-section #fun-stat-col3 {
        grid-column: span 2;
    }
}

/* Fun stats responsive - mobile */
@media (max-width: 640px) {
    /* 1/ Marge à droite pour les 4 premiers blocs et fun-stats */
    .stats-overview,
    #fun-stats-section {
        margin-left: 0;
        margin-right: 0;
        padding-left: 0;
        padding-right: 0;
    }

    /* 2/ Même gap pour fun-stats que stats-overview */
    #fun-stats-section {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    #fun-stats-section #fun-stat-col1 {
        grid-column: span 1;
        order: 1;
    }

    #fun-stats-section #fun-stat-col2 {
        grid-column: span 1;
        order: 2;
    }

    #fun-stats-section #fun-stat-col3 {
        grid-column: span 2;
        order: 3;
    }

    /* 3/ Chiffre de col1 : taille responsive */
    #fun-stats-section .format-value {
        font-size: clamp(1.8rem, 12vw, 3.5rem);
        word-break: break-word;
    }

    /* 4/ Image col2 : pas de conteneur beige, juste l'image pleine largeur */
    #fun-stats-section .largest-artwork-image {
        background: transparent;
        min-height: auto;
        padding: 0;
        margin-bottom: 0.75rem;
    }

    #fun-stats-section .largest-artwork-image img {
        max-height: none;
        width: 100%;
        height: auto;
    }

    /* 5/ Réduire la taille des icônes dans les 4 premiers blocs */
    .stat-icon {
        width: 32px;
        height: 32px;
        font-size: 1rem;
        flex-shrink: 0;
    }

    .stat-icon svg,
    .stat-icon img {
        width: 18px;
        height: 18px;
    }

    .stat-card {
        padding: 0.6rem;
        gap: 0.4rem;
    }

    .stat-value {
        font-size: 1.3rem;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    .stat-detail {
        font-size: 0.6rem;
    }

    /* Réduire aussi les paddings des cards fun-stats */
    #fun-stats-section .format-card {
        padding: 0.75rem;
    }

    #fun-stats-section h3 {
        font-size: 0.85rem;
        margin-bottom: 0.5rem;
    }

    #fun-stats-section .format-detail,
    #fun-stats-section .format-subdetail {
        font-size: 0.75rem;
    }

    #fun-stats-section .largest-artwork-title {
        font-size: 0.8rem;
    }

    #fun-stats-section .largest-artwork-dimensions {
        font-size: 0.7rem;
    }
}

/* ==========================================
   MODE KIOSQUE
   ========================================== */

/* Legacy .btn-kiosque-bar removed — now uses .bar-btn #btn-kiosque */

/* Diaporama button in header left (btnimg: plain icon, no background) */
.btn-diapo-header {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    align-items: center;
}

.btn-diapo-header img {
    width: 25px;
    height: 25px;
}

.btn-diapo-header .icon-hover {
    display: none;
}

.btn-diapo-header:hover .icon-default {
    display: none;
}

.btn-diapo-header:hover .icon-hover {
    display: inline;
}

/* In kiosque mode, show header-mobile-left pinned to left */
.kiosque-mode .header-mobile-left {
    display: flex !important;
    position: absolute;
    left: 20px;
}

/* Diaporama button only visible in kiosque mode */
.kiosque-mode .btn-diapo-header {
    display: inline-flex !important;
}

/* Kiosque entry button in header (next to logout, hidden in kiosque mode) */
.btn-kiosque-header {
    position: relative;
    display: inline-flex;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-left: 16px;
    align-items: center;
}

.btn-kiosque-header img {
    width: 20px;
    height: 20px;
}

.btn-kiosque-header .icon-hover {
    display: none;
}

.btn-kiosque-header::after {
    content: 'Kiosque';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    background: var(--color-text);
    padding: 6px 12px;
    border-radius: var(--radius);
    transition: opacity 0.2s ease;
}

.btn-kiosque-header:hover::after {
    opacity: 1;
}

.btn-kiosque-header:hover .icon-default {
    display: none;
}

.btn-kiosque-header:hover .icon-hover {
    display: inline;
}

.kiosque-mode .btn-kiosque-header {
    display: none !important;
}

/* Kiosque exit button in header (only visible in kiosque mode) */
.btn-kiosque-exit-header {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-left: 16px;
    align-items: center;
}

.btn-kiosque-exit-header img {
    width: 20px;
    height: 20px;
}

.btn-kiosque-exit-header .icon-hover {
    display: none;
}

.btn-kiosque-exit-header:hover .icon-default {
    display: none;
}

.btn-kiosque-exit-header:hover .icon-hover {
    display: inline;
}

.kiosque-mode .btn-kiosque-exit-header {
    display: inline-flex !important;
}

/* Hide elements in kiosque mode */
.kiosque-mode .header-nav .nav-item:not(#nav-favorites):not(#nav-catalogue),
.kiosque-mode .header-nav .user-menu,
.kiosque-mode .header-mobile-left > *:not(.btn-diapo-header),
.kiosque-mode .sticky-filters,
.kiosque-mode .results-row,
.kiosque-mode .btn-edit-photo,
.kiosque-mode .btn-restore-backup,
.kiosque-mode .overlay-actions .btn-email,
.kiosque-mode .select-all-wrapper,
.kiosque-mode .artwork-item .artwork-checkbox {
    display: none !important;
}

/* Hide prices everywhere in kiosque mode */
.kiosque-mode .info-value-price,
.kiosque-mode .artwork-price {
    display: none !important;
}

/* Hide year (Création/Année) in ODO */
.kiosque-mode .info-row[data-field="annee"] {
    display: none !important;
}

/* In kiosque mode, center the header logo and position exit button top-right */
.kiosque-mode .header {
    justify-content: center;
}

.kiosque-mode .header-mobile-right {
    position: absolute;
    right: 16px;
}

.kiosque-mode .header-mobile-right .header-nav {
    display: flex;
    align-items: center;
}

/* ==========================================
   DIAPORAMA (kiosque mode)
   ========================================== */

.diaporama {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.diaporama.active {
    display: flex;
}

/* Hide scrollbar and prevent scroll during diaporama */
body.diaporama-active {
    overflow: hidden !important;
}

/* Fullscreen styles */
.diaporama:-webkit-full-screen {
    background: #000;
}

.diaporama:fullscreen {
    background: #000;
}

.diaporama-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: opacity 0.5s ease;
}

.diaporama-img.diapo-upscaled {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.diaporama-img.fade-out {
    opacity: 0;
}

.diaporama-title {
    position: fixed;
    bottom: 24px;
    right: 24px;
    text-align: right;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    font-weight: 400;
    letter-spacing: 0.5px;
    pointer-events: none;
}

.diaporama-pause {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.6);
    font-size: 3rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.diaporama-pause.visible {
    opacity: 1;
}

.diaporama-pause.visible.fade-out {
    opacity: 0;
    transition: opacity 1.5s ease;
}

/* Progress bar — hidden for now, may be re-enabled later */
.diaporama-progress-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 0;
    height: 4px;
    background: white;
    opacity: 0.5;
    z-index: 100002;
    pointer-events: none;
    transition: none;
    display: none;
}

.diaporama-progress-bar.animating {
    transition: width linear;
}

/* Kiosque exit overlays */
.kiosque-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.kiosque-overlay.active {
    display: flex;
}

.kiosque-overlay-content {
    background: white;
    border-radius: 12px;
    padding: 32px 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.kiosque-overlay-content h3 {
    font-size: 1.1rem;
    margin: 0 0 20px;
    color: var(--color-text);
}

.kiosque-overlay-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.kiosque-code-hint {
    font-size: 1.2rem;
    color: var(--color-text-light);
    margin-top: 12px;
    letter-spacing: 4px;
    min-height: 1.5em;
}

/* Shake animation (macOS-style "wrong password") */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 50%, 90% { transform: translateX(-8px); }
    30%, 70% { transform: translateX(8px); }
}

.kiosque-overlay-content.shake {
    animation: shake 0.5s ease-in-out;
}