/* --- Global Variables --- */
:root {
    --ds-app-bg: #f4f5f8;
    --ds-brand-accent: #6D28D9;
    --ds-brand-accent-old: #04C366;
    --ds-brand-accent2: #000000;
    --ds-brand-text: #000000;
    --ds-primary-white: #ffffff;
    --ds-text-dark: #1f2937;
    --ds-text-muted: #6b7280;
    --ds-border: #d7d7d7;
    
    /* Functional Colors */
    --ds-alert-red: #ff3b30;
}

/* --- App Container --- */
.ds-app-container {
    max-width: 600px; 
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--ds-app-bg);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(0,0,0,0.08);
}

/* --- Header & Search Bar --- */
.ds-app-header {
    background: white;
    padding: 5px 20px 0 20px;
}

.ds-search-pill {
    display: flex;
    align-items: center;
    background: var(--ds-primary-white);
    border-radius: 50px;
    border: 2px solid var(--ds-brand-accent2);
    padding: 2px 16px;
    gap: 12px;
    margin-top: 10px;
    margin-bottom: 10px;
}

.ds-search-icon {
    width: 20px;
    height: 20px;
    color: var(--ds-text-muted);
}

.ds-search-pill input {
    flex-grow: 1;
    border: none;
    background: transparent;
    font-size: 15px;
    color: var(--ds-text-dark);
    outline: none;
    box-shadow: none;
}

.ds-search-pill input::placeholder {
    color: #9ca3af;
}

/* --- Underlined Tabs --- */
.ds-tabs-container {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    scrollbar-width: none; 
    background: var(--ds-primary-white);
    margin: 0 -20px; 
    padding: 0 20px;
    border-bottom: 1px solid var(--ds-border);
}

.ds-tabs-container::-webkit-scrollbar {
    display: none; 
}

.ds-tab {
    padding: 16px 4px;
    font-size: 15px;
    font-family: almarai, sans-serif;
    font-weight: 600;
    color: var(--ds-text-muted);
    cursor: pointer;
    white-space: nowrap;
    position: relative;
    user-select: none;
    transition: color 0.2s;
    text-decoration: none !important;
}

.ds-tab:hover {
    color: var(--ds-brand-accent);
}

.ds-tab.active {
    color: var(--ds-brand-accent);
    font-weight: 700;
    font-size: 17px;
}

.ds-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--ds-brand-accent);
    border-radius: 3px 3px 0 0;
}

/* --- Content Wrapper & Loader --- */
.ds-content-wrapper {
    position: relative;
    min-height: 200px;
}

.ds-loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(244, 245, 248, 0.7); 
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ds-loader-overlay.active {
    opacity: 1;
    visibility: visible;
    transition: none; 
}

.ds-spinner-wrapper {
    position: sticky;
    top: 150px; 
    display: flex;
    justify-content: center;
    width: 100%;
    padding-top: 40px; 
}

.ds-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--ds-border);
    border-top: 4px solid var(--ds-brand-accent);
    border-radius: 50%;
    animation: ds-spin 1s linear infinite;
}

@keyframes ds-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Product List & Card Design --- */
.ds-product-list {
    margin: 15px;
    margin-bottom: 30px;
    padding: 5px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Fix applied: strict flexbox rules to prevent squash/cut-off */
.ds-card {
    background: var(--ds-primary-white);
    border-radius: 20px;
    overflow: hidden !important; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border: 1px solid var(--ds-border);
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    min-height: min-content !important; 
    position: relative;
    width: 100%;
}

.ds-card-img-wrap {
    position: relative;
    padding: 12px 12px 0 12px;
    display: block;
    flex-shrink: 0 !important; /* Forces the image block to never squish */
}

/* Fix applied: modern aspect-ratio overrides */
.ds-slider {
    width: 100%;
    display: block !important;
}

.ds-slider-main {
    position: relative !important;
    display: block !important;
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 4 / 5 !important; /* Perfect native 4:5 scaling */
    border-radius: 10px;
    overflow: hidden !important;
    background: var(--ds-app-bg);
}

.ds-slider-main img.ds-slide {
    position: absolute !important;
    inset: 0 !important; /* Shorthand for top 0 left 0 right 0 bottom 0 */
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;
    object-fit: cover !important;
    object-position: center center;
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
    display: block !important;
    margin: 0 !important;
}

.ds-slider-main img.ds-slide.active {
    opacity: 1;
    z-index: 2;
}

/* Thumbnails */
.ds-slider-thumbs {
    display: flex;
    flex-wrap: nowrap !important;
    gap: 8px;
    margin-top: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.ds-slider-thumbs::-webkit-scrollbar {
    display: none;
}

.ds-slider-thumbs img.ds-thumb {
    width: 45px;
    height: 45px;
    object-fit: cover;
    object-position: center center; 
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: 0.5;
    transition: all 0.2s;
    flex-shrink: 0;
    display: block;
}

.ds-slider-thumbs img.ds-thumb.active,
.ds-slider-thumbs img.ds-thumb:hover {
    border-color: var(--ds-brand-accent);
    opacity: 1;
}

/* No image fallback */
.ds-no-image {
    position: relative !important;
    display: block !important;
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 4 / 5 !important;
    border-radius: 10px;
    background: var(--ds-app-bg);
    color: var(--ds-text-muted);
    font-weight: 500;
}

.ds-no-image::after {
    content: 'No Image';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Top Left Availability Badge */
.ds-avail-badge {
    position: absolute;
    top: 22px;
    right: 22px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 3;
}

.ds-avail-badge svg {
    width: 14px;
    height: 14px;
}

.ds-bg-brand { 
    background: var(--ds-primary-white); 
    color: var(--ds-brand-accent); 
    border: 1px solid var(--ds-border);
}

.ds-bg-red { 
    background: var(--ds-alert-red); 
    color: var(--ds-primary-white); 
    border: 1px solid var(--ds-alert-red);
}

/* Card Content Details */
.ds-card-body {
    padding: 16px;
    position: relative;
    z-index: 2;
    flex-grow: 1 !important; /* Ensure content expands naturally */
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

/* Wrapper for the title */
.ds-title-row {
    margin-bottom: 12px;
}

.ds-title {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    color: var(--ds-text-dark);
    line-height: 1.3;
}

/* Call to Action Button */
.ds-action-btn {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 8px; 
    background: var(--ds-brand-accent);
    color: var(--ds-primary-white);
    padding: 10px 14px; /* Increased padding slightly to ensure it doesn't squish */
    border-radius: 8px; 
    font-size: 15px; 
    font-weight: 800;
    text-decoration: none !important;
    transition: opacity 0.2s;
    margin-top: 14px; 
    flex-shrink: 0 !important; /* Forces the button to never squish */
}

.ds-action-btn:hover {
    opacity: 0.85;
}

.ds-btn-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* --- Consolidated Info Row --- */
.ds-info-row {
    display: flex;
    flex-wrap: wrap; 
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
    font-size: 14px;
    color: var(--ds-text-dark);
}

.ds-info-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ds-info-item .ds-icon {
    width: 18px;
    height: 18px;
    color: var(--ds-brand-accent);
    flex-shrink: 0;
}

.ds-info-val {
    color: var(--ds-text-dark);
    white-space: nowrap;
}

.ds-info-val.ds-bold {
    font-weight: 800;
    font-size: 15px; 
}

.ds-location-item .ds-info-val {
    color: var(--ds-text-dark);
    font-weight: 800;
}

.ds-info-divider {
    color: #d1d5db;
    font-size: 14px;
    line-height: 1;
}

/* --- Pagination Elements --- */
.ds-pagination-wrapper {
    display: block !important;
    width: 100%;
    padding: 10px 20px 40px 20px;
    clear: both !important; /* Forces it below the product list */
}

.ds-pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    position: relative;
    z-index: 10;
}

.ds-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    background: var(--ds-primary-white);
    border: 1px solid var(--ds-border);
    border-radius: 8px;
    color: var(--ds-text-dark);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.ds-pagination .page-numbers.current {
    background: var(--ds-brand-accent);
    color: var(--ds-brand-text);
    border-color: var(--ds-brand-accent);
}

.ds-pagination .prev, .ds-pagination .next {
    text-decoration: none !important;
}

.ds-no-results {
    text-align: center;
    padding: 40px 20px;
    background: var(--ds-primary-white);
    border-radius: 12px;
    color: var(--ds-text-muted);
}