/**
 * Stylesheet Club de Tir La Loupe
 * Responsive : Sidebar WordPress sur Desktop + Burger sur Mobile
 * Impression Fiches A4 & Mode PWA
 */

:root {
    --primary: #b3261e;
    --primary-dark: #8c1d17;
    --primary-light: #fbebe9;
    --bg-main: #f0f2f5;
    --bg-card: #ffffff;
    --sidebar-bg: #1d2327;
    --sidebar-hover: #2c3338;
    --sidebar-text: #f0f0f1;
    --sidebar-active: #b3261e;
    --text-dark: #1e1e1e;
    --text-muted: #646970;
    --border-color: #dcdcde;
    --success: #008a20;
    --warning: #dba617;
    --danger: #d63638;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    background-color: var(--bg-main);
    color: var(--text-dark);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==========================================================================
   SIDEBAR (Style Admin WordPress)
   ========================================================================== */
.sidebar {
    width: 250px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: transform 0.25s ease;
}

.sidebar-header {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: #13171a;
    border-bottom: 1px solid #2c3338;
}

.sidebar-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 6px;
    background: #fff;
    padding: 2px;
}

.sidebar-title h1 {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.sidebar-title small {
    font-size: 11px;
    color: #9da5ae;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    color: #c3c4c7;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border-left: 4px solid transparent;
}

.nav-item:hover {
    background-color: var(--sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background-color: var(--sidebar-hover);
    color: #fff;
    border-left-color: var(--primary);
}

.nav-item .icon {
    font-size: 18px;
    width: 22px;
    text-align: center;
}

.nav-item .badge {
    margin-left: auto;
    padding: 2px 7px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    background-color: var(--primary);
    color: #fff;
}

.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid #2c3338;
    background-color: #13171a;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
}

.sidebar-footer button {
    background: none;
    border: none;
    color: #a7aaad;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.sidebar-footer button:hover {
    color: #fff;
}

/* ==========================================================================
   ZONE PRINCIPALE & HEADER MOBILE
   ========================================================================== */
.main-wrapper {
    margin-left: 250px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100% - 250px);
}

.topbar {
    height: 56px;
    background-color: #fff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.burger-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-dark);
    cursor: pointer;
    padding: 4px;
}

.topbar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 480px;
}

.topbar-search input {
    width: 100%;
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 13px;
    background-color: var(--bg-main);
    outline: none;
}

.topbar-search input:focus {
    border-color: var(--primary);
    background-color: #fff;
}

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

.content-container {
    padding: 24px;
    flex: 1;
}

/* ==========================================================================
   BOUTONS & COMPOSANTS
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background-color: #fff;
    color: var(--text-dark);
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn:hover {
    background-color: #f6f7f7;
    border-color: #8c8f94;
}

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

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

.btn-danger {
    color: var(--danger);
    border-color: #f0b8b8;
}

.btn-danger:hover {
    background-color: #fcf0f0;
    border-color: var(--danger);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* ==========================================================================
   CARTES & STATISTIQUES DASHBOARD
   ========================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background-color: var(--primary-light);
    color: var(--primary);
}

.stat-info h3 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-dark);
}

.stat-info p {
    font-size: 13px;
    color: var(--text-muted);
}

/* ==========================================================================
   TABLEAUX & LISTES
   ========================================================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.card-header h2 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-dark);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

table.data-table th {
    background-color: #f6f7f7;
    color: var(--text-muted);
    font-weight: 600;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

table.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #f0f0f1;
    color: var(--text-dark);
}

table.data-table tr:hover {
    background-color: #fafafa;
}

.badge-status {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-status.libre { background-color: #e6f4ea; color: var(--success); }
.badge-status.occupe { background-color: #fce8e6; color: var(--danger); }
.badge-status.disponible { background-color: #e6f4ea; color: var(--success); }
.badge-status.pretee { background-color: #fef7e0; color: #b06000; }
.badge-status.alerte { background-color: #fce8e6; color: var(--danger); font-weight: 700; }

/* ==========================================================================
   GRILLE VISUELLE DES CASIERS (32 CASIERS)
   ========================================================================== */
.lockers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
    padding: 16px;
}

.locker-box {
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
    cursor: pointer;
    background: #fff;
    transition: all 0.15s ease;
}

.locker-box:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.locker-box.occupe {
    border-color: #d63638;
    background: #fdf5f5;
}

.locker-box.libre {
    border-color: #008a20;
    background: #f3faf5;
}

.locker-num {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.locker-user {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.locker-meta {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ==========================================================================
   MODALES & DIALOGUES
   ========================================================================== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

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

.modal-box {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    font-size: 17px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 20px;
    flex: 1;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background-color: #fafafa;
}

/* Formulaires dans les modales */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background-color: #fff;
    color: var(--text-dark);
}

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

.form-row {
    display: flex;
    gap: 12px;
}

.form-row > * {
    flex: 1;
}

/* ==========================================================================
   VISEUR SCANNER CAMÉRA
   ========================================================================== */
.camera-container {
    position: relative;
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    aspect-ratio: 4/3;
}

.camera-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scan-viewfinder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 220px;
    height: 160px;
    border: 2px dashed #b3261e;
    border-radius: 8px;
    box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.45);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scan-laser {
    width: 100%;
    height: 2px;
    background-color: #b3261e;
    box-shadow: 0 0 8px #b3261e;
    animation: laserScan 2s infinite ease-in-out;
}

@keyframes laserScan {
    0% { transform: translateY(-70px); }
    50% { transform: translateY(70px); }
    100% { transform: translateY(-70px); }
}

/* ==========================================================================
   FICHE A4 INVENTAIRE & IMPRESSION
   ========================================================================== */
.a4-sheet {
    background: #fff;
    color: #111;
    width: 210mm;
    min-height: 297mm;
    padding: 14mm;
    margin: 20px auto;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 6mm;
    box-sizing: border-box;
}

.sh-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 6mm;
}

.sh-logo {
    height: 26mm;
    width: auto;
}

.sh-club {
    font-size: 11pt;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sh-title {
    font-size: 22pt;
    font-weight: 700;
    line-height: 1.1;
    margin: 2mm 0;
}

.sh-cat {
    font-size: 11pt;
    color: #555;
}

.sh-bc svg {
    height: 20mm;
    max-width: 80mm;
}

.sh-info-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3mm;
}

.sh-info-card {
    border: 1px solid #ccc;
    border-radius: 3mm;
    padding: 3mm 4mm;
    font-size: 10pt;
}

.sh-info-card span {
    display: block;
    font-size: 7pt;
    color: #777;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 2px;
}

.sh-notes {
    font-size: 10pt;
    padding: 3mm;
    border: 1px solid #e0e0e0;
    border-radius: 3mm;
    background: #fafafa;
    white-space: pre-wrap;
    min-height: 20mm;
}

.sh-photos-grid {
    flex: 1;
    display: grid;
    gap: 4mm;
    grid-template-columns: repeat(2, 1fr);
    min-height: 80mm;
}

.sh-photo-item {
    border: 1px solid #ddd;
    border-radius: 3mm;
    overflow: hidden;
    background: #fafafa;
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: 70mm;
}

.sh-photo-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

@page {
    size: A4 portrait;
    margin: 0;
}

@media print {
    body {
        background: #fff !important;
    }
    .sidebar, .topbar, .no-print, .btn, .toast-container {
        display: none !important;
    }
    .modal-overlay:not(.active) {
        display: none !important;
    }
    .modal-overlay.active {
        display: block !important;
        position: static !important;
        background: transparent !important;
        padding: 0 !important;
    }
    .modal-overlay.active .modal-box {
        max-width: 100% !important;
        width: 100% !important;
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
    }
    .modal-overlay.active .modal-header,
    .modal-overlay.active .modal-footer,
    .modal-overlay.active .modal-close {
        display: none !important;
    }
    .main-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }
    .content-container {
        padding: 0 !important;
    }
    .a4-sheet {
        margin: 0 !important;
        box-shadow: none !important;
        width: 100% !important;
        page-break-after: always;
        break-after: page;
    }
    #modalFicheIdentiteArme .modal-body {
        background: transparent !important;
        padding: 0 !important;
        max-height: none !important;
        overflow: visible !important;
    }
}

/* ==========================================================================
   RESPONSIVE DESIGN (Mobile & Tablette)
   ========================================================================== */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,0.5);
    }
    .main-wrapper {
        margin-left: 0;
        width: 100%;
    }
    .burger-btn {
        display: block;
    }
    .content-container {
        padding: 16px;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .a4-sheet {
        width: 100%;
        min-height: auto;
        padding: 16px;
        transform: none;
    }
}

@media (max-width: 500px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .sh-info-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ==========================================================================
   TOAST NOTIFICATIONS (Système d'alertes flottantes professionnelles)
   ========================================================================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: 380px;
    width: calc(100% - 40px);
}

.toast-item {
    pointer-events: auto;
    background: #ffffff;
    color: #1e293b;
    border-radius: 10px;
    padding: 12px 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    border-left: 4px solid var(--primary-color);
    animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: opacity 0.25s, transform 0.25s;
}

.toast-item.toast-success {
    border-left-color: #10b981;
}
.toast-item.toast-error {
    border-left-color: #ef4444;
}
.toast-item.toast-warning {
    border-left-color: #f59e0b;
}
.toast-item.toast-info {
    border-left-color: #3b82f6;
}

.toast-item .toast-icon {
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
}

.toast-item .toast-content {
    flex: 1;
    line-height: 1.4;
}

.toast-item .toast-close {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.15s;
}
.toast-item .toast-close:hover {
    color: #1e293b;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast-item.toast-hiding {
    opacity: 0;
    transform: translateY(-10px);
}

@media (max-width: 600px) {
    .toast-container {
        top: auto;
        bottom: 20px;
        right: 20px;
        left: 20px;
        width: auto;
    }
    @keyframes toastSlideIn {
        from {
            opacity: 0;
            transform: translateY(30px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* ==========================================================================
   CONFIRM & ALERT POPUP MODALES SUR-MESURE
   ========================================================================== */
.dialog-box {
    max-width: 440px !important;
    text-align: center;
    padding: 24px !important;
}

.dialog-icon-circle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    margin: 0 auto 16px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    background: #f1f5f9;
}
.dialog-icon-circle.danger {
    background: #fee2e2;
    color: #dc2626;
}
.dialog-icon-circle.warning {
    background: #fef3c7;
    color: #d97706;
}
.dialog-icon-circle.success {
    background: #d1fae5;
    color: #059669;
}
.dialog-icon-circle.info {
    background: #e0f2fe;
    color: #0284c7;
}

.dialog-title {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 8px 0;
}

.dialog-message {
    font-size: 14px;
    color: #475569;
    line-height: 1.5;
    margin: 0 0 24px 0;
    white-space: pre-line;
}

.dialog-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.dialog-actions button {
    flex: 1;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
}

/* ==========================================================================
   BOUTONS DE FILTRES RAPIDES
   ========================================================================== */
.btn-filter {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    padding: 4px 12px;
    font-weight: 600;
    transition: all 0.2s ease;
    cursor: pointer;
}
.btn-filter:hover {
    background: #e2e8f0;
    color: #1e293b;
}
.btn-filter.active {
    background: var(--primary, #003366);
    color: #fff;
    border-color: var(--primary, #003366);
    box-shadow: 0 2px 4px rgba(0,51,102,0.25);
}
