/* 
   Startech Catalogue Styles
   Extracted from catalogue.php for performance and caching.
*/

/* Lightbox Styles */
#image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#image-lightbox.active {
    display: flex;
    opacity: 1;
}

#image-lightbox .lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#image-lightbox.active .lightbox-content {
    transform: scale(1);
}

#lightbox-img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

#lightbox-title {
    color: white;
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-align: center;
    max-width: 800px;
    line-height: 1.5;
    padding: 10px 20px;
    background: rgba(0,0,0,0.5);
    border-radius: 4px;
}

#close-lightbox {
    position: absolute;
    top: 30px;
    right: 30px;
    color: white;
    cursor: pointer;
    font-size: 32px;
    transition: all 0.3s ease;
    z-index: 10000;
}

#close-lightbox:hover {
    color: var(--primary, #ffac52);
    transform: rotate(90deg);
}

/* Brand popup */
.brand-popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 8999;
    display: none;
}

.brand-popup-overlay.active {
    display: block;
}

.brand-popup {
    position: fixed;
    z-index: 9000;
    background: #111;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 20px;
    min-width: 220px;
    max-width: 320px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.6);
    transform: translateY(-50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.brand-popup.visible {
    opacity: 1;
    pointer-events: all;
}

.brand-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 6px;
    border: 1px solid #222;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    color: #888;
    font-family: monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.brand-filter-chip:hover,
.brand-filter-chip.active {
    border-color: var(--primary, #ffac52);
    color: white;
    background: rgba(255,172,82,0.08);
}

.brand-filter-chip img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    border-radius: 3px;
    background: white;
    padding: 1px;
}

.brand-filter-chip .brand-initial {
    width: 20px;
    height: 20px;
    background: #222;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: bold;
    color: #888;
    flex-shrink: 0;
}

.brand-logo-inline {
    display: inline-block;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 3px;
    padding: 2px;
    vertical-align: middle;
    cursor: pointer;
    flex-shrink: 0;
}

.brand-logo-inline img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-table-display {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    background: white;
    border-radius: 4px;
    padding: 5px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.brand-table-display:hover {
    transform: scale(1.15) rotate(-2deg);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    border-color: var(--primary);
}

.brand-table-display img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Floating Image Preview Tooltip */
#hover-preview {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    display: none;
    width: 240px;
    height: 180px;
    background: #111;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
#hover-preview.visible {
    opacity: 1;
    transform: scale(1);
}
#hover-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #050505;
    border-radius: 4px;
}

/* PREMIUM FILTER PANEL */
.filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    animation: filterRowIn 0.22s ease both;
}
.filter-row.hidden {
    display: none !important;
}
@keyframes filterRowIn {
    from { opacity: 0; transform: translateY(-5px); }
    to   { opacity: 1; transform: translateY(0); }
}
.filter-row-label {
    font-family: 'Space Mono', monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #777;
    white-space: nowrap;
    min-width: 80px;
    flex-shrink: 0;
}
/* Level 1: Category chips */
.chip-cat {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 12px; border-radius: 3px; border: 1px solid #333;
    background: transparent; color: #eee;
    font-family: 'Space Mono', monospace; font-size: 11px;
    text-transform: uppercase; letter-spacing: 0.1em;
    cursor: pointer; transition: all 0.18s ease; white-space: nowrap;
}
.chip-cat:hover { border-color: #666; color: #fff; background: rgba(255,255,255,0.08); }
.chip-cat.active { background: #ea580c; border-color: #ea580c; color: #000; font-weight: 700; box-shadow: 0 0 12px rgba(234,88,12,0.25); }
.chip-cat .chip-count { font-size: 9px; padding: 2px 6px; border-radius: 20px; background: rgba(0,0,0,0.25); font-weight: 700; opacity: 0.7; }
.chip-cat.active .chip-count { opacity: 1; }
/* Level 2: Subcategory parent chips */
.chip-sub-parent {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; border-radius: 20px; border: 1px solid #333;
    background: transparent; color: #ccc;
    font-family: 'Space Mono', monospace; font-size: 10px;
    text-transform: uppercase; letter-spacing: 0.1em;
    cursor: pointer; transition: all 0.18s ease; white-space: nowrap;
}
.chip-sub-parent:hover { border-color: #ea580c; color: #ea580c; background: rgba(234,88,12,0.06); }
.chip-sub-parent.active { background: rgba(234,88,12,0.15); border-color: #ea580c; color: #ea580c; font-weight: 700; }
.chip-sub-parent .chip-count { font-size: 8px; padding: 1px 5px; border-radius: 20px; background: rgba(234,88,12,0.12); color: #ea580c; font-weight: 700; }
/* Level 3: Subcategory child chips */
.chip-sub-child {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px; border-radius: 20px; border: 1px dashed #444;
    background: transparent; color: #bbb;
    font-family: 'Space Mono', monospace; font-size: 9px;
    text-transform: uppercase; letter-spacing: 0.08em;
    cursor: pointer; transition: all 0.18s ease; white-space: nowrap;
}
.chip-sub-child:hover { border-color: #ea580c; border-style: solid; color: #ea580c; background: rgba(234,88,12,0.06); }
.chip-sub-child.active { background: rgba(234,88,12,0.15); border-color: #ea580c; border-style: solid; color: #ea580c; font-weight: 700; }
.chip-sub-child .chip-count { font-size: 8px; padding: 1px 4px; border-radius: 20px; background: rgba(234,88,12,0.12); color: #ea580c; font-weight: 700; }
/* Active filter badge (summary pill) */
.active-filter-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 20px;
    background: rgba(234,88,12,0.12); border: 1px solid rgba(234,88,12,0.3);
    color: #ea580c; font-family: 'Space Mono', monospace; font-size: 9px;
    text-transform: uppercase; cursor: pointer;
    transition: all 0.15s ease;
}
.active-filter-badge:hover { background: rgba(234,88,12,0.22); }
.active-filter-badge .badge-x { font-size: 12px; line-height: 1; opacity: 0.7; }

/* MOBILE CARD LAYOUT */

/* Sur mobile : grille de cartes, la table est masquée */
@media (max-width: 767px) {
    /* Cache la table desktop */
    .desktop-table { display: none !important; }
    /* Affiche la grille de cartes mobile */
    .mobile-cards { display: grid !important; }

    /* Filtre panel : scroll horizontal pour les chips */
    .filter-row {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }
    .filter-row::-webkit-scrollbar { display: none; }
    .filter-row-label { min-width: 70px; font-size: 9px; }

    /* Header plus compact */
    #catalogue-container h2.text-2xl { font-size: 18px; }
}

/* Sur desktop : affiche la table, cache les cartes */
@media (min-width: 768px) {
    .desktop-table { display: block !important; }
    .mobile-cards { display: none !important; }
}

/* Carte article mobile */
.item-card {
    background: #0e0e0e;
    border: 1px solid #1f1f1f;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s ease, transform 0.2s ease;
    position: relative;
}
.item-card:active {
    transform: scale(0.98);
    border-color: #333;
}
.item-card .card-image {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: contain;
    background: #050505;
    border-bottom: 1px solid #1a1a1a;
    padding: 12px;
}
.item-card .card-image-placeholder {
    width: 100%;
    aspect-ratio: 16/9;
    background: #080808;
    border-bottom: 1px solid #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
}
.item-card .card-body {
    padding: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.item-card .card-ref {
    display: inline-block;
    background: #181818;
    border: 1px solid #2a2a2a;
    color: #888;
    font-family: 'Space Mono', monospace;
    font-size: 9px;
    padding: 2px 7px;
    border-radius: 4px;
    letter-spacing: 0.05em;
    align-self: flex-start;
}
.item-card .card-title {
    color: #f0f0f0;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: 0.02em;
}
.item-card .card-desc {
    color: #555;
    font-size: 10px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.item-card .card-footer {
    display: grid;
    grid-template-columns: 100px 1fr 100px;
    align-items: center;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid #1a1a1a;
}
.item-card .card-price {
    color: #ffac52;
    font-family: 'Space Mono', monospace;
    font-size: 14px;
    font-weight: 700;
}
.item-card .card-brand-logo {
    width: 36px;
    height: 36px;
    background: white;
    border-radius: 6px;
    padding: 3px;
    object-fit: contain;
}
.item-card .card-brand-text {
    font-size: 9px;
    color: #444;
    font-family: monospace;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Bouton PWA d'installation */
/* Bouton PWA d'installation */
#pwa-install-wrapper {
    display: none;
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9000;
    background: #ffac52;
    color: #000;
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 6px 6px 6px 20px;
    border-radius: 100px;
    box-shadow: 0 8px 30px rgba(255,172,82,0.35);
    align-items: center;
    gap: 12px;
    white-space: nowrap;
    animation: pwaSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
#pwa-install-wrapper.show { display: flex; }
@media (min-width: 1024px) {
    #pwa-install-wrapper { display: none !important; }
}

#pwa-install-btn {
    background: none;
    border: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
}

#pwa-dismiss-btn {
    background: rgba(0,0,0,0.1);
    border: none;
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    transition: background 0.2s;
}
#pwa-dismiss-btn:hover {
    background: rgba(0,0,0,0.2);
}
@keyframes pwaSlideUp {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Fix scroll horizontal */
.overflow-x-auto { overflow-x: hidden !important; }
@media (min-width: 768px) { .overflow-x-auto { overflow-x: auto !important; } }

/* RELATIONS ROW (Accessoires + Alternatives) */
tr.item-row {
    cursor: pointer;
}
tr.item-row:hover td { background: rgba(255,255,255,0.025); }
tr.item-row.expanded td { background: rgba(255,172,82,0.04); border-bottom: none; }

tr.relations-row td {
    padding: 0 !important;
    background: rgba(255,172,82,0.03);
    border-bottom: 1px solid #222;
}
tr.relations-row { display: none; }
tr.relations-row.open { display: table-row; }

.relations-panel {
    padding: 16px 20px 20px 52px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: relPanelIn 0.25s ease both;
}
@media (min-width: 1024px) {
    .relations-panel.has-both {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 32px;
    }
}
@keyframes relPanelIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}


.relations-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Space Mono', monospace;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #b5b5b5;
    margin-bottom: 8px;
}
.relations-section-title .rel-icon {
    font-size: 14px;
    line-height: 1;
}

.relation-chips {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
}

/* Individual relation chip */
.rel-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px 8px 10px;
    border-radius: 4px;
    border: 1px solid #252525;
    background: #0d0d0d;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    width: 100%;
    min-height: 48px;
}
.rel-chip:hover {
    border-color: rgba(255,172,82,0.5);
    background: rgba(255,172,82,0.06);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.rel-chip.rel-chip--alt {
    border-color: #1e2a1e;
    background: #0a0f0a;
}
.rel-chip.rel-chip--alt:hover {
    border-color: rgba(74,222,128,0.4);
    background: rgba(74,222,128,0.05);
}
.rel-chip .chip-thumb {
    width: 32px;
    height: 32px;
    border-radius: 3px;
    object-fit: contain;
    background: #fff;
    flex-shrink: 0;
    padding: 2px;
}
.rel-chip .chip-thumb-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 3px;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}
.rel-chip .chip-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rel-chip .chip-name {
    font-size: 11px;
    color: #e0e0e0;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
    line-height: 1.3;
}
.rel-chip .chip-meta {
    font-family: 'Space Mono', monospace;
    font-size: 8px;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.rel-chip.rel-chip--alt .chip-name { color: #cce8cc; }
.rel-chip.rel-chip--alt .chip-meta { color: #2a4a2a; }
.rel-chip .chip-arrow {
    margin-left: auto;
    color: #333;
    font-size: 14px;
    flex-shrink: 0;
    transition: color 0.2s;
}
.rel-chip:hover .chip-arrow { color: #ffac52; }
.rel-chip.rel-chip--alt:hover .chip-arrow { color: #4ade80; }

/* Loading spinner inside panel */
.relations-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Space Mono', monospace;
    font-size: 9px;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 8px 0;
}
.relations-loading .spin {
    width: 14px; height: 14px;
    border: 2px solid #222;
    border-top-color: #ffac52;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toggle chevron on row */
.item-row-toggle {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #333;
    font-size: 14px;
    transition: all 0.25s ease;
    border-radius: 3px;
    flex-shrink: 0;
}
tr.item-row.expanded .item-row-toggle {
    color: #ffac52;
    transform: rotate(180deg);
}

/* Mobile card: relations section */
.card-relations {
    display: none;
    flex-direction: column;
    gap: 10px;
    border-top: 1px solid #1a1a1a;
    padding-top: 10px;
    margin-top: 4px;
    animation: relPanelIn 0.25s ease both;
}
.card-relations.open { display: flex; }
.card-relations .relations-section-title { margin-bottom: 4px; }
.card-relations .relation-chips { gap: 6px; }
.card-relations .rel-chip { max-width: 100%; }
.card-relations .rel-chip .chip-name { max-width: 200px; }

/* Qty badge */
.rel-qty-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(255,172,82,0.15);
    border: 1px solid rgba(255,172,82,0.3);
    color: #ffac52;
    font-family: 'Space Mono', monospace;
    font-size: 8px;
    font-weight: 700;
    flex-shrink: 0;
}
