/**
 * Styles pour la sidebar (arborescence véhicules)
 * Système collapsible pure CSS avec checkbox hack
 */

/* ========================================================================
   STRUCTURE SIDEBAR
   ======================================================================== */

.sidebar-container {
    padding: 15px 20px 20px 20px;
}

/* Header sidebar avec titre + sélecteur de vue - supprimé */
.sidebar-header {
    display: none;
}

.sidebar-title {
    display: none;
}

/* Sélecteur de vue (Liste/Carte) - intégré dans le cadre de filtres */
.view-switcher {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
    padding: 10px;
    background: var(--c-bg-subtle);
    color: var(--c-meta);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9rem;
    line-height: 1;
    transition: all 0.3s;
    cursor: pointer;
    font-weight: 500;
}

.view-btn svg {
    display: block;
}

.view-btn-text {
    font-size: 0.9rem;
    font-weight: 500;
}

.view-btn:hover {
    background: var(--c-faint);
    color: var(--c-dark);
    transform: translateY(-1px);
    text-decoration: none;
}

.view-btn.active {
    background: var(--c-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

/* Section filtres - style simplifié sans bordure */
.sidebar-filters {
    background: var(--c-bg-neutral);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

/* ========================================================================
   ARBORESCENCE À 3 NIVEAUX
   ======================================================================== */

.vehicle-tree {
    list-style: none;
}

.vehicle-tree ul {
    list-style: none;
    padding-left: 20px;
}

.vehicle-tree li {
    margin: 5px 0;
}

/* ========================================================================
   SYSTÈME COLLAPSIBLE PURE CSS (checkbox hack)
   ======================================================================== */

/* Cacher les checkboxes */
.tree-toggle {
    display: none;
}

/* Label qui sert de bouton expand/collapse */
.tree-label {
    display: block;
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
    border-radius: 4px;
    transition: background 0.2s;
    font-weight: 500;
    color: var(--c-mid-dark);
    position: relative;
    padding-left: 30px;
}

.tree-label:hover {
    background: var(--c-bg-subtle);
}

/* Icône pour expand/collapse */
.tree-label::before {
    content: "▶";
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.3s;
    font-size: 0.75rem;
    color: var(--c-meta);
}

/* Rotation de l'icône quand ouvert */
.tree-toggle:checked + .tree-label::before {
    transform: translateY(-50%) rotate(90deg);
}

/* Contenu collapsible (caché par défaut) */
.tree-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out;
}

/* Afficher le contenu quand la checkbox est cochée */
.tree-toggle:checked ~ .tree-content {
    max-height: 2000px;
    transition: max-height 0.6s ease-in;
}

/* ========================================================================
   NIVEAUX DE L'ARBORESCENCE
   ======================================================================== */

/* Niveau 1 : Marques */
.tree-brand > .tree-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--c-dark);
    background: var(--c-bg-neutral);
}

.tree-brand > .tree-label:hover {
    background: var(--c-bg-subtle);
}

/* Niveau 2 : Modèles */
.tree-model > .tree-label {
    font-size: 0.95rem;
    color: var(--c-mid-dark);
}

/* Niveau 3 : Séries (liens cliquables) */
.tree-series {
    padding-left: 30px;
}

.tree-series a {
    display: block;
    padding: 6px 12px;
    color: var(--c-primary);
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.tree-series a:hover {
    background: var(--c-hover-blue);
    color: var(--c-primary-d);
    text-decoration: none;
    padding-left: 16px;
}

.tree-series a.active {
    background: var(--c-primary);
    color: white;
    font-weight: 500;
}

/* ========================================================================
   COMPTEURS (nombre de modèles/séries)
   ======================================================================== */

.tree-count {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    background: var(--c-secondary);
    color: white;
    font-size: 0.75rem;
    border-radius: 10px;
    font-weight: 600;
}

/* ========================================================================
   INDICATEUR DE CHARGEMENT
   ======================================================================== */

.sidebar-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--c-secondary);
}

.sidebar-empty {
    padding: 20px;
    text-align: center;
    color: var(--c-meta);
    font-style: italic;
}

/* ========================================================================
   SCROLLBAR PERSONNALISÉE
   ======================================================================== */

.sidebar-container::-webkit-scrollbar {
    width: 8px;
}

.sidebar-container::-webkit-scrollbar-track {
    background: var(--c-bg-subtle);
}

.sidebar-container::-webkit-scrollbar-thumb {
    background: var(--c-faint);
    border-radius: 4px;
}

.sidebar-container::-webkit-scrollbar-thumb:hover {
    background: var(--c-secondary);
}

/* ========================================================================
   RESPONSIVE
   ======================================================================== */

@media (max-width: 768px) {
    .sidebar-container {
        padding: 15px;
    }

    .tree-label {
        font-size: 0.9rem;
        padding: 6px 10px;
        padding-left: 25px;
    }

    .tree-label::before {
        left: 5px;
    }

    .vehicle-tree ul {
        padding-left: 15px;
    }

    .tree-series {
        padding-left: 20px;
    }
}

/* ========================================================================
   OPTION "TOUS" et "MES VÉHICULES" (fond bleu foncé)
   ======================================================================== */

/* Styles communs pour les boutons "Tous les véhicules" et "Mes véhicules" */
.tree-all-vehicles > .tree-label.tree-all-link {
    background: var(--c-dark) !important;
    color: white !important;
    font-weight: 600;
    padding-left: 12px !important; /* Pas de flèche par défaut, padding normal */
    text-decoration: none;
    position: relative;
}

/* Masquer la flèche grise par défaut (héritée de .tree-label::before) */
.tree-all-vehicles > .tree-label.tree-all-link::before,
.tree-my-vehicles > .tree-label.tree-all-link::before {
    content: none !important; /* Pas de flèche par défaut */
}

.tree-all-vehicles:hover > .tree-label.tree-all-link {
    background: var(--c-dark-hover) !important;
    text-decoration: none;
}

/* Bouton "Mes véhicules" - même fond bleu foncé que "Tous les véhicules" */
.tree-my-vehicles > .tree-label.tree-all-link {
    background: var(--c-dark) !important;
    color: white !important;
    font-weight: 600;
    padding-left: 12px !important; /* Pas de flèche par défaut */
    position: relative;
}

.tree-my-vehicles:hover > .tree-label.tree-all-link {
    background: var(--c-dark-hover) !important;
    text-decoration: none;
}

/* État actif : même fond bleu + flèche */
.tree-all-vehicles.active > .tree-label.tree-all-link,
.tree-my-vehicles.active > .tree-label.tree-all-link {
    background: var(--c-dark) !important; /* Même fond bleu que par défaut */
    font-weight: 700;
    padding-left: 30px !important; /* Espace pour la flèche quand actif */
}

/* Flèche blanche uniquement quand actif */
.tree-all-vehicles.active > .tree-label.tree-all-link::before,
.tree-my-vehicles.active > .tree-label.tree-all-link::before {
    content: "▶" !important; /* Réafficher la flèche uniquement si actif */
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: white;
}

/* Compteur blanc pour ces boutons */
.tree-all-vehicles .tree-count,
.tree-my-vehicles .tree-count {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

/* Élément actif dans la sidebar (persistence de l'état) */
.tree-link.tree-active {
    background: var(--c-primary);
    color: white;
    font-weight: bold;
}

.tree-link.tree-active:hover {
    background: var(--c-primary-d);
}

/* ========================================================================
   BOUTON "CRÉER SÉRIE" (en bas de sidebar, pour Designers)
   ======================================================================== */

.sidebar-actions {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

.sidebar-btn-create {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.sidebar-btn-create:hover {
    box-shadow: 0 4px 8px rgba(39, 174, 96, 0.3);
}

.sidebar-btn-create .btn-icon {
    font-size: 1.2rem;
}

/* ========================================================================
   MENU ADMIN
   ======================================================================== */

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

.admin-menu li {
    margin-bottom: 10px;
}

.admin-menu-item {
    display: block;
    padding: 12px 15px;
    color: var(--c-mid-dark);
    text-decoration: none;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: all 0.3s;
    font-weight: 500;
}

.admin-menu-item:hover {
    background: var(--c-primary);
    color: white;
    border-color: var(--c-primary);
    text-decoration: none;
}

.admin-menu-item.active {
    background: var(--c-primary);
    color: white;
    border-color: var(--c-primary);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

/* ========================================================================
   SECTION FILTRES (en haut de la sidebar)
   ======================================================================== */

.sidebar-filters {
    background: var(--c-bg-neutral);
    border: 2px solid var(--c-bg-subtle);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.sidebar-section-title {
    font-size: 14px;
    font-weight: bold;
    color: var(--c-label);
    margin: 0 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filters-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.filter-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--c-label);
    margin: 0;
}

.filter-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 13px;
    color: var(--c-label);
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.filter-select:hover {
    border-color: var(--c-primary);
}

.filter-select:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.filter-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: background 0.2s;
}

.filter-checkbox-label:hover {
    background: rgba(52, 152, 219, 0.05);
}

.filter-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--c-primary);
}

.filter-checkbox-label span {
    font-size: 13px;
    color: var(--c-label);
    font-weight: 500;
}

.filter-reset {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid #dee2e6;
}

.filter-reset-btn {
    display: inline-block;
    width: 100%;
    padding: 8px 12px;
    background: var(--c-danger);
    color: white;
    text-align: center;
    text-decoration: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
}

.filter-reset-btn:hover {
    background: var(--c-danger-d);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(220, 53, 69, 0.3);
}

/* ========================================================================
   BOUTON "NOUVEAUX VÉHICULES" (style orange/amber)
   ======================================================================== */

.tree-new-vehicles > .tree-all-link {
    background: var(--c-new);
    color: white !important;
}

.tree-new-vehicles > .tree-all-link:hover {
    background: var(--c-new-d);
}

.tree-new-vehicles.active > .tree-all-link,
.tree-new-vehicles > .tree-all-link.active {
    background: var(--c-new-a);
    font-weight: bold;
}

}

/* ============================================================================
   Bouton vœux en bas de sidebar
   ============================================================================ */

.sidebar-wishes-btn {
    border-top: 1px solid rgba(255,255,255,0.15);
    margin-top: 8px;
    padding-top: 12px;
}

.sidebar-wishes-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 16px;
    border-radius: 6px;
    color: white;
    background: var(--c-success);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    box-sizing: border-box;
    transition: background 0.2s;
}

.sidebar-wishes-link:hover {
    background: var(--c-success-d);
    color: white;
    text-decoration: none;
}
