:root {
    --bg-main: #0d0f17;
    --bg-card: #161926;
    --bg-input: #202436;
    --accent-gold: #f5a623;
    --accent-gold-glow: rgba(245, 166, 35, 0.3);
    --accent-blue: #00d2ff;
    --text-primary: #f0f3f9;
    --text-muted: #8e96aa;
    --border-color: #2a2f45;
    --radius: 12px;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    padding-bottom: 40px;
}

/* Header */
header {
    background: linear-gradient(180deg, #181b2a 0%, var(--bg-main) 100%);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

header h1 {
    font-size: 1.8rem;
    color: var(--accent-gold);
    text-shadow: 0 0 12px var(--accent-gold-glow);
    letter-spacing: 1px;
}

.stats {
    font-size: 0.95rem;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.stats strong {
    color: var(--accent-gold);
}

.actions-bar {
    display: flex;
    gap: 10px;
}

/* Boutons communs */
button, .btn-import, .btn-lddb {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button:hover, .btn-import:hover, .btn-lddb:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
    box-shadow: 0 0 10px var(--accent-gold-glow);
}

/* Layout Main */
.container {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
}

.add-section, .collection-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 25px;
    margin-bottom: 35px;
}

h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: var(--text-primary);
    border-left: 4px solid var(--accent-gold);
    padding-left: 10px;
}

/* Recherche à la volée */
.search-box {
    position: relative;
    margin-bottom: 20px;
}

.search-box input {
    width: 100%;
    padding: 14px 18px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.search-box input:focus {
    border-color: var(--accent-gold);
    box-shadow: 0 0 12px var(--accent-gold-glow);
}

/* Liste des résultats de recherche */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 15px;
    margin-top: 15px;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 5px;
}

.results-grid::-webkit-scrollbar {
    width: 6px;
}
.results-grid::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.result-item {
    background: var(--bg-input);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    text-align: center;
}

.result-item:hover {
    border-color: var(--accent-gold);
    transform: translateY(-3px);
}

.result-item img {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
}

.result-item-info {
    padding: 8px;
}

.result-item-title {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-item-year {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Carte de Preview pour édition */
.preview-card {
    display: flex;
    gap: 20px;
    background: var(--bg-input);
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--accent-gold);
    margin-top: 20px;
}

.preview-card.hidden {
    display: none;
}

.preview-card img {
    width: 130px;
    border-radius: 8px;
    object-fit: cover;
}

.prev-info {
    flex: 1;
}

.prev-info h3 {
    font-size: 1.4rem;
    color: var(--accent-gold);
    margin-bottom: 5px;
}

.prev-info p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.ld-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin: 15px 0;
}

.ld-options label {
    display: flex;
    flex-direction: column;
    font-size: 0.8rem;
    color: var(--text-muted);
    gap: 4px;
}

.ld-options input, .ld-options select {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 10px;
    border-radius: 6px;
    outline: none;
}

.btn-add {
    background: var(--accent-gold);
    color: #000;
    font-weight: bold;
    padding: 10px 20px;
    border: none;
    margin-top: 10px;
}

.btn-add:hover {
    background: #ffb84d;
    box-shadow: 0 0 15px var(--accent-gold-glow);
}

/* Collection Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.disc-card {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.disc-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-gold);
}

.disc-card img {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
}

.card-info {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.badge {
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: bold;
    text-transform: uppercase;
}

.badge.pal { background: #1a4971; color: #72c1ff; }
.badge.ntsc { background: #5c1d24; color: #ff8e97; }
.badge.audio { background: #23422a; color: #7be08a; }
.badge.grade { background: #3b3519; color: var(--accent-gold); }

.card-info h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.card-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.card-info .price {
    color: var(--accent-gold);
    font-weight: bold;
    font-size: 1rem;
    margin-top: 8px;
}

.card-actions {
    display: flex;
    gap: 10px;
    margin-top: auto;
    padding-top: 12px;
}

.btn-delete {
    background: transparent;
    border-color: #612128;
    color: #ff6b6b;
}

.btn-delete:hover {
    background: #612128;
    color: #fff;
    box-shadow: none;
}

.preview-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 15px;
}

.btn-search {
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
}

.btn-search.lbc {
    background: #2a2218;
    color: #ff6e14;
    border-color: #ff6e14;
}

.btn-search.lbc:hover {
    background: #ff6e14;
    color: #fff;
    box-shadow: 0 0 12px rgba(255, 110, 20, 0.4);
}

.btn-search.ebay {
    background: #192736;
    color: #369be9;
    border-color: #369be9;
}

.btn-search.ebay:hover {
    background: #369be9;
    color: #fff;
    box-shadow: 0 0 12px rgba(54, 155, 233, 0.4);
}

.btn-edit {
    background: transparent;
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.btn-edit:hover {
    background: var(--accent-gold);
    color: #000;
    box-shadow: 0 0 10px var(--accent-gold-glow);
}

/* --- Barre de filtres LaserDisc Vault --- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    background: #1e1e24;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    margin-bottom: 24px;
    align-items: center;
}

.filter-bar input[type="text"] {
    flex: 1;
    min-width: 240px;
    padding: 10px 14px;
    background: #2a2a32;
    border: 1px solid #3f3f4e;
    border-radius: 8px;
    color: #ffffff;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.filter-bar input[type="text"]:focus,
.filter-bar select:focus {
    border-color: #6366f1; /* Un beau violet/bleu moderne, modifiable selon ton thème */
}

.filter-bar select {
    padding: 10px 14px;
    background: #2a2a32;
    border: 1px solid #3f3f4e;
    border-radius: 8px;
    color: #ffffff;
    font-size: 14px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.filter-bar select option {
    background: #1e1e24;
    color: #ffffff;
}

/* Responsive pour les petits écrans */
@media (max-width: 768px) {
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-bar input[type="text"], 
    .filter-bar select {
        width: 100%;
    }
}

/* Navigation par onglets */
.view-nav {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.tab-btn {
    background: #2a2a32;
    border: 1px solid #3f3f4e;
    color: #a0a0b0;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: #6366f1;
    border-color: #6366f1;
    color: #ffffff;
}

.hidden {
    display: none !important;
}

/* Cartouche de statistiques */
.stats-cartouche {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    background: #1e1e24;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    margin-bottom: 24px;
    border: 1px solid #2f2f3a;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 12px;
    color: #8e8e9e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-val {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
}

/* --- Badge de statut sur la carte --- */
.card-status-bar {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
}

.status-checkbox-wrapper input[type="checkbox"] {
    display: none; /* On cache la vraie checkbox moche */
}

.status-pill {
    display: inline-block;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 20px;
    cursor: pointer;
    background: rgba(30, 30, 36, 0.85);
    border: 1px solid #3f3f4e;
    color: #a0a0b0;
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
}

/* Style quand c'est coché (À vendre) */
.status-checkbox-wrapper input[type="checkbox"]:checked + .status-pill {
    background: rgba(99, 102, 241, 0.85); /* Un beau bleu/violet actif */
    border-color: #6366f1;
    color: #ffffff;
}

.status-pill:hover {
    transform: scale(1.05);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    background: #1e1e24;
    border-radius: 12px;
    border: 1px solid #2f2f3a;
}

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

.sale-table th, .sale-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #2f2f3a;
    color: #e0e0e6;
}

.sale-table th {
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.sale-table tr:last-child td {
    border-bottom: none;
}

/* --- AMÉLIORATIONS RESPONSIVE & MOBILE-FIRST --- */

/* Conteneurs de tableaux scrollables horizontalement avec effet "Snap" */
.table-responsive-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    padding-bottom: 8px;
    margin-bottom: 15px;
}

.table-responsive-wrapper table {
    width: 100%;
    min-width: 650px; /* Force l'alignement propre sans tout écraser */
}

.table-responsive-wrapper tr {
    scroll-snap-align: start;
}

/* Cartouches de statistiques côte à côte swipables sur mobile étroit */
@media (max-width: 768px) {
    .sale-strategy-container {
        display: flex !important;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        gap: 15px !important;
        padding-bottom: 10px;
        -webkit-overflow-scrolling: touch;
    }
    
    .sale-strategy-container > div {
        flex: 0 0 85%; /* Laisse dépasser le cartouche suivant pour inciter au swipe */
        scroll-snap-align: center;
    }

    /* Adaptation de la grille de collection sur mobile */
    #collectionGrid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
        gap: 10px !important;
    }

    .disc-card img {
        height: 180px !important;
    }

    .card-info h3 {
        font-size: 0.9rem !important;
    }

    /* Boutons d'action tactiles plus confortables */
    .btn-search, .card-actions button {
        padding: 8px 10px !important;
        font-size: 0.85rem !important;
    }
}

/* Style des barres de scroll tactiles (discrètes et élégantes) */
.sale-strategy-container::-webkit-scrollbar,
.table-responsive-wrapper::-webkit-scrollbar {
    height: 4px;
}

.sale-strategy-container::-webkit-scrollbar-thumb,
.table-responsive-wrapper::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}