/* --- CONFIGURATION DES VARIABLES (DARK THEME) --- */
:root {
    --bg-deep: #0f111a;          /* Fond le plus sombre */
    --bg-card: #1a1d29;          /* Fond des cartes et tableaux */
    --bg-input: #24283b;         /* Fond des champs */
    --accent: #3d5afe;           /* Bleu électrique Premium */
    --accent-hover: #536dfe;     /* Bleu plus clair */
    --ajouterobjet:#ff4d4d;
    --ajouterobjet-hover:#ff6666;
    --text-head: #ffffff;        /* Titres blancs */
    --text-main: #c0caf5;        /* Texte bleuté lisible */
    --text-muted: #787c99;       /* Texte secondaire gris */
    --border: #2f334d;           /* Bordures fines */
    --success: #10b981;          /* Vert moderne */
    --warning: #f59e0b;          /* Orange chaud */
    --danger: #ef4444;           /* Rouge vif */
    --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

/* --- RÉGLAGES GÉNÉRAUX --- */
* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--bg-deep);
    color: var(--text-main);
    margin: 0;
    line-height: 1.6;
}

.container {
    padding: 30px;
    max-width: 1400px;
    margin: auto;
}

/* --- NAVIGATION --- */
.navbar {
    background-color: var(--bg-card);
    padding: 12px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-logo { height: 100px; border-radius: 8px; cursor: pointer; transition: transform 0.2s; }
.nav-logo:hover { transform: translateY(-2px); }

/* --- BLOC TITRE ET SOUS-TITRE --- */
.nav-title-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-left: 15px; /* L'espacement se fait sur le groupe entier */
    flex-grow: 1;      /* C'est le groupe qui pousse les liens vers la droite */
}

.nav-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-head);
    margin: 0;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.nav-subtitle {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin: 2px 0 0 0;
}

.nav-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-weight: 700;
    font-size: 2rem;
    color: var(--text-head);
    letter-spacing: 1px;
    white-space: nowrap;
    pointer-events: none; /* Évite d'interférer avec les clics */
}

/* --- LIENS DE NAVIGATION --- */
.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    margin-left: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.nav-links a:hover { 
    color: var(--accent); 
}

/* --- RECHERCHE ET FILTRES --- */
.search-bar-container {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    background-color: var(--bg-card);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    align-items: center;
}

.search-wrapper { position: relative; flex: 3; }

.search-wrapper input {
    width: 100%;
    padding: 14px 45px 14px 15px;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-head);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.search-wrapper input:focus { border-color: var(--accent); outline: none; }

.clear-search {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--danger);
    font-size: 24px;
    cursor: pointer;
    font-weight: bold;
}

.search-bar-container select {
    flex: 1;
    padding: 13px;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-head);
    cursor: pointer;
}

.btn-search {
    background-color: var(--success);
    color: #000;
    border: none;
    padding: 14px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    transition: 0.3s;
}

.btn-search:hover { filter: brightness(1.2); transform: scale(1.02); }

/* --- BOUTONS --- */
.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.btn {
    padding: 15px;
    text-align: center;
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    transition: 0.3s;
    border: none;
    cursor: pointer;
}

.btn-primary {
    background-color: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    box-shadow: 0 0 20px rgba(61, 90, 254, 0.4);
}

.btn-ajouterobjet {
    background-color: var(--ajouterobjet);
    color: #fff;
}

.btn-ajouterobjet:hover {
    background-color: var(--ajouterobjet-hover);
    box-shadow: 0 0 20px rgba(255, 77, 77, 0.4);
}



/* --- TABLEAU --- */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background-color: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

th {
    background-color: #24283b;
    padding: 18px;
    text-align: left;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 1px;
}

td { padding: 16px; border-bottom: 1px solid var(--border); font-size: 0.95rem; }

tr:hover { background-color: rgba(255,255,255,0.03); }

/* --- BADGES ET STATUTS --- */
.status-badge {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
}

.status-Disponible { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.status-Réclamé { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
[class*="status-Courrier envoyé en attente de réponse"] { background: rgba(245, 158, 11, 0.15); color: var(--warning); }

[class*="status-Restitué le"], .status-Donation { 
    background: rgba(61, 90, 254, 0.25); 
    color: #8da2ff;
    font-weight: 700;
}

.status-Préfecture { 
    background: rgba(255, 255, 255, 0.1); 
    color: #e0e0e0; 
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.status-Destruction { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

.row-expired { background-color: rgba(239, 68, 68, 0.05) !important; box-shadow: inset 4px 0 0 var(--danger); }

/* --- CARTES ET FORMULAIRES --- */
.form-card {
    background-color: var(--bg-card);
    padding: 30px;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin: 20px auto;
}

label { display: block; margin-top: 15px; font-weight: 600; font-size: 0.85rem; color: var(--text-muted); }

input, select, textarea {
    width: 100%;
    padding: 12px;
    margin-top: 6px;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-head);
    font-size: 0.95rem;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }

/* --- MODAL (POPUP) --- */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
}

.modal-content {
    background-color: var(--bg-card);
    margin: 5% auto;
    padding: 35px;
    border-radius: 20px;
    width: 90%;
    max-width: 900px;
    border: 1px solid var(--border);
    color: var(--text-head);
    position: relative;
}

.modal-body { display: flex; gap: 30px; margin-top: 25px; }
.modal-image { flex: 1; }
.modal-fields { flex: 1.5; }

.img-preview { width: 55px; height: 55px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }

.locked-field { background-color: #1a1a1a !important; color: #555 !important; cursor: not-allowed; opacity: 0.6; }

.btn-update { background-color: var(--success); color: #000; font-weight: 800; padding: 15px 35px; border-radius: 10px; border: none; cursor: pointer; }

/* --- ÉLÉMENTS SPÉCIFIQUES --- */
.close { position: absolute; right: 25px; top: 20px; font-size: 30px; color: var(--text-muted); cursor: pointer; }
.close:hover { color: #fff; }

.no-print { /* Utilisé pour stats.php export */ }

@media (max-width: 850px) {
    .modal-body { flex-direction: column; }
    .search-bar-container { flex-direction: column; }
    th:nth-child(1), td:nth-child(1), th:nth-child(5), td:nth-child(5) { display: none; }
}

/* --- STYLES EXCLUSIFS À L'EXPORT PDF / IMPRESSION --- */
@media print {
    /* Réduction de la taille des cartes de statistiques */
    .form-card {
        padding: 10px !important;    /* Moins d'espace interne */
        margin: 5px !important;     /* Moins d'espace entre les cases */
        border: 1px solid #ccc !important; /* Bordure plus fine pour le PDF */
    }

    /* Réduction de la taille du texte à l'intérieur des cases */
    .form-card h3 {
        font-size: 0.7rem !important; /* Titres plus petits */
        margin-bottom: 5px !important;
    }

    .form-card p {
        font-size: 1.2rem !important; /* Chiffres plus petits */
        margin: 0 !important;
    }

    /* Ajustement de la grille pour que tout tienne sur une ligne */
    div[style*="display: flex"] {
        gap: 5px !important;
    }
}

/* --- POPUP CHANGEMENT STATUT RAPIDE --- */
.status-modal {
    display: none;
    position: fixed;
    z-index: 3000; /* Au-dessus de tout */
    left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
}

.status-modal-content {
    background-color: var(--bg-card);
    margin: 15% auto;
    padding: 25px;
    border-radius: 12px;
    width: 320px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    text-align: center;
}