/* ==========================================================================
   Store Theme System (v1) CSS Engine
   ========================================================================== */

/* Product Image Rule: NEVER CROP PRODUCT IMAGES, CONTAIN ASPECT RATIO */
.theme-product-card .product-card-image img,
.product-card-image img,
.product-card img.prod-img,
.product-detail-image img {
    object-fit: contain !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    display: block !important;
}

/* Image Container */
.theme-img-wrap,
.product-card-image {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: var(--theme-img-bg, rgba(0, 0, 0, 0.03));
    border-radius: var(--theme-card-radius, 12px);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/* Theme Grid Columns */
.store-grid-container {
    display: grid;
    gap: 24px;
    width: 100%;
    margin-top: 24px;
}

.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
    .grid-cols-4 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .grid-cols-4, .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-cols-2 { grid-template-columns: 1fr; }
    .store-grid-container { gap: 14px; }
}

@media (max-width: 480px) {
    .grid-cols-4, .grid-cols-3, .grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
}

/* Theme Product Card Variants */

/* 1. Editorial (Fashion / Luxury) */
.card-style-editorial {
    background: var(--theme-card-bg, #ffffff);
    border: none;
    padding: 0;
    border-radius: 0;
    transition: all 0.3s ease;
}
.card-style-editorial .theme-img-wrap {
    aspect-ratio: 4 / 5;
    background: #f7f6f2;
    border-radius: 4px;
    padding: 16px;
}
.card-style-editorial .card-info {
    padding: 14px 4px 6px;
    text-align: left;
}
.card-style-editorial .card-title {
    font-family: Georgia, serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--theme-text, #1a1a1a);
}

/* 2. Compact (Modern Catalog / Supermarket) */
.card-style-compact {
    background: var(--theme-card-bg, #ffffff);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.card-style-compact .theme-img-wrap {
    aspect-ratio: 1 / 1;
    padding: 8px;
    background: #f8fafc;
}
.card-style-compact .card-title {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
}

/* 3. Tech Card (Electronics / SaaS / Gaming) */
.card-style-tech_card {
    background: var(--theme-card-bg, #0f172a);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 16px;
    color: #f8fafc;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.card-style-tech_card:hover {
    transform: translateY(-4px);
    border-color: var(--theme-accent, #06b6d4);
}
.card-style-tech_card .theme-img-wrap {
    background: rgba(255,255,255,0.04);
    border-radius: 8px;
    padding: 14px;
}

/* 4. Food Card (Restaurant / Local Store) */
.card-style-food_card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    background: var(--theme-card-bg, #ffffff);
    border: 1px solid rgba(0,0,0,0.07);
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.card-style-food_card .theme-img-wrap {
    width: 110px;
    height: 110px;
    min-width: 110px;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    padding: 6px;
}
.card-style-food_card .card-info {
    flex: 1;
}

/* 5. Soft Rounded (Home / Wellness / Cafe) */
.card-style-soft_rounded {
    background: var(--theme-card-bg, #ffffff);
    border-radius: 20px;
    padding: 16px;
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 4px 14px rgba(0,0,0,0.03);
}
.card-style-soft_rounded .theme-img-wrap {
    border-radius: 16px;
}

/* 6. Glossy (Beauty / Cosmetic) */
.card-style-glossy {
    background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(253,242,248,0.6));
    backdrop-filter: blur(8px);
    border: 1px solid rgba(244,114,182,0.25);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 6px 20px rgba(244,114,182,0.08);
}

/* 7. Service & SaaS Card */
.card-style-service_card, .card-style-saas_card {
    background: var(--theme-card-bg, #ffffff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 14px;
    padding: 20px;
    transition: all 0.25s ease;
}

/* Theme Navigation Bar Styles */
.theme-cat-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow-x: auto;
    padding: 12px 0;
    margin-bottom: 24px;
    scrollbar-width: thin;
}

.theme-cat-nav.nav-pills .cat-btn {
    padding: 8px 18px;
    border-radius: 50px;
    background: var(--theme-secondary, #f3f4f6);
    color: var(--theme-text, #1f2937);
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}
.theme-cat-nav.nav-pills .cat-btn.active,
.theme-cat-nav.nav-pills .cat-btn:hover {
    background: var(--theme-primary, #111827);
    color: #ffffff;
}

.theme-cat-nav.nav-circular_icons {
    justify-content: flex-start;
    gap: 20px;
}
.theme-cat-nav.nav-circular_icons .cat-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--theme-text, #374151);
}
.theme-cat-nav.nav-circular_icons .cat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--theme-secondary, #fdf2f8);
    border: 2px solid var(--theme-accent, #f472b6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.theme-cat-nav.nav-tab_bar {
    border-bottom: 2px solid rgba(0,0,0,0.08);
    gap: 24px;
}
.theme-cat-nav.nav-tab_bar .cat-btn {
    background: transparent;
    border: none;
    padding: 10px 4px;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--theme-text, #4b5563);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
}
.theme-cat-nav.nav-tab_bar .cat-btn.active {
    color: var(--theme-accent, #2563eb);
    border-bottom-color: var(--theme-accent, #2563eb);
}

/* ============================================================
   THEME SELECTION PAGE — Responsive UI System
   ============================================================ */

/* Outer wrapper for the entire theme selection section */
.theme-selection-wrapper {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius, 14px);
    padding: 24px;
    margin-bottom: 36px;
    overflow: hidden;
}

/* Info bar at top of theme selection section */
.theme-selection-infobar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

/* Category Filter Tab Wrapper — horizontally scrollable on mobile */
.theme-cat-nav-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    padding-bottom: 12px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.theme-cat-nav-wrap::-webkit-scrollbar {
    height: 4px;
}
.theme-cat-nav-wrap::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.theme-cat-nav-scroll {
    display: flex;
    align-items: center;
    gap: 8px;
    width: max-content;
    min-width: 100%;
    padding: 2px 0;
}

/* Override original .theme-cat-nav for the settings page context */
.theme-selection-wrapper .theme-cat-nav {
    display: contents; /* handled by theme-cat-nav-wrap */
}

/* Category pill buttons in settings page */
.theme-cat-nav-scroll .cat-btn {
    padding: 8px 16px;
    border-radius: 50px;
    background: var(--bg, #f3f4f6);
    color: var(--text-light);
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.theme-cat-nav-scroll .cat-btn:hover,
.theme-cat-nav-scroll .cat-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.theme-cat-nav-scroll .cat-btn.matched-cat {
    border-color: var(--accent, #f59e0b);
}

/* ── Theme Cards Grid ──────────────────────────────────────── */
.theme-cards-grid {
    display: grid;
    /* Desktop: 3 cards per row minimum, auto-fill wider */
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* ── Individual Theme Card ─────────────────────────────────── */
.theme-card-box {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: all 0.25s ease;
    /* Equal height for all cards in a row */
    height: 100%;
    box-sizing: border-box;
}
.theme-card-box:hover {
    border-color: var(--primary);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}
.theme-card-box.active-theme {
    border-color: var(--primary);
}

/* Active badge */
.theme-card-active-badge {
    position: absolute;
    top: -12px;
    right: 16px;
    background: var(--primary);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    z-index: 2;
}

/* ── Theme Thumbnail Preview ───────────────────────────────── */
.theme-thumbnail {
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 16px;
    overflow: hidden;
    position: relative;
    height: 130px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

/* ── Card Meta & Info ──────────────────────────────────────── */
.theme-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    flex-wrap: wrap;
    gap: 4px;
}
.theme-card-meta .category-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.theme-card-meta .grid-badge {
    font-size: 0.72rem;
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 600;
    white-space: nowrap;
}

.theme-card-name {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text);
    line-height: 1.3;
}
.theme-card-tagline {
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.4;
    margin-bottom: 12px;
    min-height: 36px;
}

/* Color swatches */
.theme-swatches {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.theme-swatch {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}
.theme-swatches .swatch-label {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-left: 4px;
}

/* Feature tags */
.theme-features {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 18px;
}
.theme-feature-tag {
    font-size: 0.72rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 2px 7px;
    border-radius: 6px;
    color: var(--text-light);
    white-space: nowrap;
}

/* Card content grows to fill height */
.theme-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ── Action Buttons Row ────────────────────────────────────── */
.theme-card-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}
.theme-card-btn-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.theme-card-btn-row .btn {
    padding: 7px 4px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-decoration: none;
    white-space: nowrap;
    width: 100%;
}
.theme-card-btn-row form {
    margin: 0;
    display: contents;
}

/* ============================================================
   RESPONSIVE BREAKPOINTS — Theme Selection
   ============================================================ */

/* Large Desktop: 1440px+ → 4 cols */
@media (min-width: 1440px) {
    .theme-cards-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Desktop: 1024px – 1439px → 3 cols */
@media (min-width: 1024px) and (max-width: 1439px) {
    .theme-cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Tablet: 600px – 1023px → 2 cols */
@media (min-width: 600px) and (max-width: 1023px) {
    .theme-cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    .theme-selection-wrapper {
        padding: 20px;
    }
}

/* Mobile: < 600px → 1 col */
@media (max-width: 599px) {
    .theme-cards-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    .theme-selection-wrapper {
        padding: 16px;
    }
    .theme-card-box {
        padding: 16px;
    }
    .theme-thumbnail {
        height: 110px;
    }
    .theme-card-tagline {
        min-height: unset;
    }
    /* Buttons stay 2-column grid on narrow mobile */
    .theme-card-btn-row .btn {
        font-size: 0.75rem;
        padding: 6px 2px;
    }
}

/* Tiny Mobile: < 375px → slightly smaller */
@media (max-width: 375px) {
    .theme-card-btn-row {
        grid-template-columns: 1fr 1fr;
        gap: 4px;
    }
    .theme-card-btn-row .btn {
        font-size: 0.7rem;
        padding: 5px 2px;
    }
    .theme-card-name {
        font-size: 1rem;
    }
}

/* ============================================================
   PREVIEW MODAL — Responsive
   ============================================================ */
@media (max-width: 768px) {
    .theme-preview-modal-header {
        height: auto;
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 16px;
    }
    .theme-preview-modal-header > div {
        flex-wrap: wrap;
        gap: 8px;
    }
    /* Hide view switcher tabs on mobile (just use homepage) */
    .theme-preview-modal-header .preview-view-tabs {
        display: none;
    }
    .theme-preview-modal-body {
        padding: 12px;
    }
    .theme-preview-device-frame.mobile {
        width: 320px;
        height: 568px;
        border-radius: 28px;
        border-width: 10px;
    }
}

/* Modal Live Preview Frame */
.theme-preview-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.25s ease;
}

.theme-preview-modal-header {
    height: 60px;
    background: #0f172a;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    color: #ffffff;
}

.theme-preview-modal-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 20px;
    background: #1e293b;
}

.theme-preview-device-frame {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #ffffff;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.theme-preview-device-frame.desktop {
    width: 100%;
    height: 100%;
    border-radius: 12px;
}

.theme-preview-device-frame.mobile {
    width: 375px;
    height: 667px;
    max-height: 100%;
    border-radius: 36px;
    border: 12px solid #090d16;
}

.theme-preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #ffffff;
}
