@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Tajawal:wght@400;500;700&display=swap');

:root {
    /* Color Palette - HSL (Premium) */
    --primary-h: 210;
    --primary-s: 100%;
    --primary-l: 50%;
    --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
    --primary-hover: hsl(var(--primary-h), var(--primary-s), 40%);

    --accent-h: 34;
    --accent-s: 97%;
    --accent-l: 52%;
    --accent: hsl(var(--accent-h), var(--accent-s), var(--accent-l));

    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;

    /* Shadows & Radii */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.5);
}

/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    direction: rtl;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Tajawal', 'Inter', sans-serif;
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Utilities */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .glass {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Typography */
h1,
h2,
h3,
h4 {
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1rem;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--bg-main);
    border-color: var(--primary);
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

/* Grids */
.grid {
    display: grid;
    gap: 1.5rem;
}

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

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

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

@media (max-width: 768px) {

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

    .container {
        padding: 0 1rem;
    }
}

@media (max-width: 480px) {

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* --- Product Page Specifics (AliExpress Style) --- */

/* Tabs System */
.tabs-container {
    margin-top: 40px;
    background: #fff;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.tabs-header {
    display: flex;
    background: #fbfbfb;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    padding: 15px 30px;
    cursor: pointer;
    background: transparent;
    border: none;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    font-size: 1rem;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: #fff;
}

.tab-content {
    padding: 30px;
    display: none;
    line-height: 1.8;
}

.tab-content.active {
    display: block;
}

/* Product Info Visuals */
.price-tag {
    font-size: 2rem;
    font-weight: 800;
    color: #ff4747;
    /* AliExpress Red */
    display: flex;
    align-items: baseline;
    gap: 5px;
}

.price-tag small {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 400;
}

.vat-text {
    font-size: 0.8rem;
    color: #999;
    margin-bottom: 10px;
    display: block;
}

/* Trust Badges */
.trust-badges {
    margin-top: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 0.9rem;
}

.trust-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #333;
}

.trust-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

/* Sticky Layout */
.product-details {
    max-width: 1200px;
    margin: 40px auto;
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.details-grid {
    display: grid;
    grid-template-columns: 45% 55%;
    /* More space for info */
    gap: 40px;
    align-items: start;
}

.media-column {
    position: sticky;
    top: 20px;
}

/* Gallery Improvements */
.main-media-container {
    border: 1px solid #e2e2e2;
    border-radius: 8px;
    margin-bottom: 15px;
    background: #fff;
}

.thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 4px;
    border: 1px solid transparent;
}

.thumbnail.active {
    border-color: #000;
    box-shadow: 0 0 0 1px #000;
}

.thumbnail:hover {
    border-color: #666;
}

/* Quantity Selector */
.qty-selector {
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: fit-content;
    margin: 15px 0;
}

.qty-btn {
    width: 35px;
    height: 35px;
    background: #f5f5f5;
    border: none;
    cursor: pointer;
    font-weight: bold;
}

.qty-input {
    width: 50px;
    text-align: center;
    border: none;
    outline: none;
}

/* Action Buttons */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 25px;
}

.btn-buy {
    background: #ff4747;
    color: white;
    font-size: 1.1rem;
    padding: 12px;
}

.btn-cart {
    background: #ff9900;
    color: white;
    font-size: 1.1rem;
    padding: 12px;
}

.btn-buy:hover {
    background: #e03e3e;
}

.btn-cart:hover {
    background: #e68a00;
}

@media (max-width: 768px) {
    .details-grid {
        grid-template-columns: 1fr;
    }

    .media-column {
        position: static;
    }

    .action-buttons {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        padding: 10px;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 100;
        margin: 0;
    }

    /* Space for fixed buttons */
}

/* --- Store Page Product Cards (Refined & Compact) --- */
.product-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid transparent;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    height: 100%;
}

.product-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 24px -6px rgba(0, 0, 0, 0.08);
    border-color: var(--border-color);
}

.product-img-wrapper {
    width: 100%;
    aspect-ratio: 1/1;
    /* Square images */
    display: block;
    background: #f1f5f9;
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-lg);
    /* Match card radius roughly/inner */
    margin: 6px;
    /* Reduced outer margin */
    width: calc(100% - 12px);
    /* Compensate for margin */
}

.product-media {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.product-card:hover .product-media {
    transform: scale(1.08);
    /* Subtle zoom */
}

/* Hover video hidden by default */
.hover-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
    pointer-events: none;
}

.product-img-wrapper:hover .hover-video {
    opacity: 1;
}

.product-info {
    padding: 6px 8px 10px 8px;
    /* Further reduced padding for mobile */
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    /* Tighter gap */
    text-align: right;
    /* RTL alignment */
}

.product-title {
    font-size: 0.8rem;
    /* Smaller for mobile */
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
    line-height: 1.3;

    /* Truncate to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.4em;
    /* Smaller min-height */
}

.product-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
    display: none;
    /* Hide description for more compact look, or toggle via class if needed. Let's hide it by default for compactness as requested. */
}

.product-footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 6px;
    /* Further reduced top padding */
}

.product-price {
    color: var(--text-main);
    font-weight: 700;
    font-size: 0.9rem;
    /* Smaller for mobile */
    position: relative;
}

.product-price::after {
    content: '$';
    font-size: 0.65rem;
    margin-right: 2px;
    color: var(--text-muted);
}

.btn-action {
    padding: 4px 10px;
    /* Even smaller button */
    background: var(--bg-main);
    color: var(--text-main);
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 600;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.product-card:hover .btn-action {
    background: var(--text-main);
    color: white;
}

/* Responsive Grid Update */
@media (min-width: 1100px) {
    .grid-3 {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 600px) {
    .grid-3.mobile-grid-2 {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        /* Tighter gap on mobile */
    }

    .product-info {
        padding: 5px 6px 8px 6px;
    }

    .product-title {
        font-size: 0.75rem;
        min-height: 2.2em;
        line-height: 1.25;
    }

    .product-img-wrapper {
        margin: 3px;
        width: calc(100% - 6px);
    }

    .product-price {
        font-size: 0.85rem;
    }

    .btn-action {
        padding: 3px 8px;
        font-size: 0.65rem;
    }
}

/* --- Top Categories Bar (Premium Pill Design) --- */
.top-categories {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    white-space: nowrap;
    padding: 10px 0;
    margin-bottom: 25px;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */

    /* Fade mask for scrolling hint */
    mask-image: linear-gradient(to left, transparent, black 10px, black 90%, transparent);
    -webkit-mask-image: linear-gradient(to left, transparent, black 10px, black 90%, transparent);
}

.top-categories::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.top-categories a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 20px;
    background: transparent;
    /* No background by default for cleaner look, or very soft */
    border: 1px solid transparent;
    /* No border initially */
    border-radius: 50px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    user-select: none;
    white-space: nowrap;
    position: relative;
    background: rgba(0, 0, 0, 0.03);
    /* Very subtle background */
}

.top-categories a:hover {
    color: var(--text-main);
    background: rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

.top-categories a.active {
    background: var(--text-main);
    /* Dark pill for active */
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.top-categories a .cat-count {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-right: 6px;
    font-weight: 400;
    display: inline-block;
    vertical-align: middle;
}

.top-categories a.active .cat-count {
    color: rgba(255, 255, 255, 0.8);
}