/* ===== DW Store — Professional UI System ===== */

:root {
    --brand: #F97316;
    --brand-light: #FED7AA;
    --brand-lighter: #FFF7ED;
    --brand-dark: #EA580C;
    --brand-darker: #C2410C;
    --surface: #F8FAFC;
    --surface-card: #FFFFFF;
    --surface-dark: #0F172A;
    --surface-dark-2: #1E293B;
    --surface-dark-3: #334155;
    --ink: #0F172A;
    --ink-secondary: #475569;
    --ink-muted: #64748B;
    --ink-light: #94A3B8;
    --ink-lighter: #CBD5E1;
    --border: #E2E8F0;
    --border-light: #F1F5F9;
    --success: #059669;
    --success-light: #D1FAE5;
    --error: #DC2626;
    --error-light: #FEE2E2;
    --warning: #D97706;
    --warning-light: #FEF3C7;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
    --sidebar-w: 260px;
}

/* ===== Reset & Global ===== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }
body { min-height: 100dvh; overflow-x: hidden; background: var(--surface); }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; }

/* ===== Loading Screen ===== */
.loading-progress { display: block; width: 5rem; height: 5rem; }
.loading-progress circle { fill: none; stroke: #334155; stroke-width: 0.5rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child { stroke: var(--brand); stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%; transition: stroke-dasharray 0.05s ease-in-out; }
.loading-progress-text::after { content: var(--blazor-load-percentage-text, "جاري التحميل"); }

/* ===== Error UI ===== */
#blazor-error-ui { background: var(--error-light); color: var(--error); bottom: 0; box-shadow: 0 -4px 16px rgba(0,0,0,0.08); display: none; left: 0; padding: 0.75rem 1.25rem; position: fixed; width: 100%; z-index: 9999; font-size: 0.875rem; border-radius: var(--radius) var(--radius) 0 0; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; left: 0.75rem; top: 0.5rem; }
#blazor-error-ui .reload { text-decoration: underline; margin-inline-start: 0.5rem; }

/* ===== Card ===== */
.dw-card {
    background: var(--surface-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.dw-card:hover { box-shadow: var(--shadow-md); border-color: var(--border); }
.dw-card:active { transform: scale(0.98); }

/* ===== Button System ===== */
.dw-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    font-family: 'Tajawal', sans-serif; font-weight: 700; font-size: 0.9375rem;
    border-radius: var(--radius); padding: 0.75rem 1.5rem;
    transition: all 0.15s ease; cursor: pointer; border: none; outline: none;
    position: relative; overflow: hidden;
}
.dw-btn::after { content: ''; position: absolute; inset: 0; background: currentColor; opacity: 0; transition: opacity 0.15s; }
.dw-btn:active::after { opacity: 0.08; }
.dw-btn-primary { background: var(--brand); color: #fff; }
.dw-btn-primary:hover { background: var(--brand-dark); box-shadow: 0 4px 12px rgba(249,115,22,0.3); }
.dw-btn-primary:disabled { background: var(--ink-lighter); cursor: not-allowed; box-shadow: none; }
.dw-btn-dark { background: var(--surface-dark); color: #fff; }
.dw-btn-dark:hover { background: var(--surface-dark-2); box-shadow: 0 4px 12px rgba(15,23,42,0.2); }
.dw-btn-outline { background: transparent; color: var(--ink); border: 1.5px solid var(--border); }
.dw-btn-outline:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-lighter); }
.dw-btn-danger { background: var(--error); color: #fff; }
.dw-btn-danger:hover { background: #B91C1C; }
.dw-btn-ghost { background: transparent; color: var(--ink-muted); padding: 0.5rem; }
.dw-btn-ghost:hover { color: var(--brand); background: var(--brand-lighter); }

/* ===== Input ===== */
.dw-input {
    width: 100%; padding: 0.75rem 1rem;
    border: 1.5px solid var(--border); border-radius: var(--radius);
    font-family: 'Tajawal', sans-serif; font-size: 0.9375rem;
    background: #fff; color: var(--ink);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}
.dw-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(249,115,22,0.08); }
.dw-input::placeholder { color: var(--ink-light); }

/* ===== Badge ===== */
.dw-badge { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.25rem 0.75rem; border-radius: 20px; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.01em; }
.dw-badge-success { background: var(--success-light); color: var(--success); }
.dw-badge-warning { background: var(--warning-light); color: var(--warning); }
.dw-badge-error { background: var(--error-light); color: var(--error); }
.dw-badge-info { background: var(--border-light); color: var(--ink-muted); }
.dw-badge-purple { background: #F3E8FF; color: #7C3AED; }

/* ===== Cart Badge ===== */
.dw-cart-badge {
    position: absolute;
    top: -2px;
    right: -6px;
    background: #F97316;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}
.dw-cart-badge-mobile {
    position: absolute;
    top: 2px;
    right: 50%;
    transform: translateX(12px);
    background: #F97316;
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
}

/* ===== Page Header (Mobile) ===== */
.dw-header {
    background: var(--surface-dark);
    color: #fff;
    padding: 1rem 1.25rem;
    position: sticky; top: 0; z-index: 40;
}

/* ===== Desktop Page Header (white bar) ===== */
.dw-desktop-header {
    display: none;
}

/* ===== Mobile Bottom Nav ===== */
.dw-bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: rgba(255,255,255,0.92); backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(0,0,0,0.04);
    display: flex; justify-content: space-around; align-items: center;
    padding: 0.375rem 0 calc(0.375rem + env(safe-area-inset-bottom));
}
.dw-nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: 0.625rem; font-weight: 600; color: var(--ink-light);
    text-decoration: none; padding: 0.375rem 0.875rem;
    transition: color 0.15s ease; border-radius: var(--radius);
    position: relative;
}
.dw-nav-item.active { color: var(--brand); }
.dw-nav-item.active::before {
    content: ''; position: absolute; top: -0.375rem; left: 50%; transform: translateX(-50%);
    width: 20px; height: 3px; background: var(--brand); border-radius: 0 0 3px 3px;
}
.dw-nav-item svg { width: 22px; height: 22px; }

/* ===== Desktop Sidebar (hidden on mobile) ===== */
.dw-sidebar { display: none; }

/* ===== Skeleton ===== */
.dw-skeleton {
    background: linear-gradient(90deg, var(--border-light) 25%, var(--border) 37%, var(--border-light) 63%);
    background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--radius);
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ===== Overlay ===== */
.dw-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,0.6); z-index: 50;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink-lighter); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-light); }

/* ===== Page Transition ===== */
.page-enter { animation: pageIn 0.35s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Utilities ===== */
.pb-nav { padding-bottom: calc(4.25rem + env(safe-area-inset-bottom)); }
.scrollbar-hide::-webkit-scrollbar { display: none; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dw-content-width { max-width: 100%; margin: 0 auto; }

/* ===== Install Banner ===== */
.dw-install-banner {
    background: linear-gradient(135deg, var(--surface-dark) 0%, var(--surface-dark-2) 100%);
    color: #fff; border-radius: var(--radius-lg); padding: 1rem 1.25rem;
    display: flex; align-items: center; gap: 0.75rem;
    border: 1px solid rgba(255,255,255,0.06);
}
.dw-install-banner button {
    background: var(--brand); color: #fff; font-weight: 700; border: none;
    border-radius: var(--radius); padding: 0.5rem 1.25rem; font-size: 0.8125rem;
    cursor: pointer; white-space: nowrap; transition: background 0.15s;
}
.dw-install-banner button:hover { background: var(--brand-dark); }

/* ===== Category Icon Container ===== */
.dw-cat-icon {
    width: 52px; height: 52px; border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--brand-lighter), #FFF);
    border: 1px solid rgba(249,115,22,0.08);
    transition: transform 0.2s ease;
}
.dw-card:hover .dw-cat-icon { transform: scale(1.05); }

/* ===== Desktop-only elements (hidden on mobile) ===== */
.dw-home-welcome-desktop { display: none; }
.dw-settings-header-desktop { display: none; }
.dw-search-header-desktop { display: none; }

/* ============================================
   RESPONSIVE: Desktop (≥1024px)
   ============================================ */
@media (min-width: 1024px) {
    .dw-app-shell { display: flex; min-height: 100dvh; }

    /* --- Sidebar --- */
    .dw-sidebar {
        display: flex; flex-direction: column;
        width: var(--sidebar-w); background: var(--surface-dark);
        position: fixed; top: 0; bottom: 0; right: 0; z-index: 45;
        overflow-y: auto; overflow-x: hidden;
        border-left: 1px solid rgba(255,255,255,0.04);
    }
    .dw-sidebar-header {
        padding: 1.5rem 1.25rem 1.25rem;
        border-bottom: 1px solid rgba(255,255,255,0.06);
    }
    .dw-sidebar-logo {
        display: flex; align-items: center; gap: 0.75rem;
    }
    .dw-sidebar-logo img { width: 38px; height: 38px; border-radius: 10px; }
    .dw-sidebar-logo-text { display: flex; flex-direction: column; }
    .dw-sidebar-logo-text strong { color: #fff; font-weight: 800; font-size: 1rem; line-height: 1.2; }
    .dw-sidebar-logo-text small { color: rgba(255,255,255,0.35); font-size: 0.6875rem; font-weight: 400; }

    .dw-sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 1rem 0.75rem; flex: 1; }
    .dw-sidebar-item {
        display: flex; align-items: center; gap: 0.75rem;
        padding: 0.625rem 0.875rem; border-radius: 10px;
        color: rgba(255,255,255,0.45); text-decoration: none;
        font-size: 0.8125rem; font-weight: 500;
        transition: all 0.15s ease;
    }
    .dw-sidebar-item:hover { color: rgba(255,255,255,0.85); background: rgba(255,255,255,0.06); }
    .dw-sidebar-item.active {
        color: #fff; background: rgba(249,115,22,0.15);
        font-weight: 700;
    }
    .dw-sidebar-item.active svg { color: var(--brand); }
    .dw-sidebar-item svg { width: 19px; height: 19px; flex-shrink: 0; }

    .dw-sidebar-divider { height: 1px; background: rgba(255,255,255,0.06); margin: 0.5rem 0.75rem; }

    .dw-sidebar-footer {
        padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,0.06);
        margin-top: auto;
    }
    .dw-sidebar-footer p { color: rgba(255,255,255,0.2); font-size: 0.625rem; text-align: center; }

    /* --- Main Content --- */
    .dw-main-content {
        margin-right: var(--sidebar-w); flex: 1; min-height: 100dvh;
        background: var(--surface);
    }

    .dw-bottom-nav { display: none; }
    .pb-nav { padding-bottom: 2.5rem; }
    .dw-content-width { max-width: 880px; padding-left: 1.5rem; padding-right: 1.5rem; }

    /* --- Hide dark mobile header on desktop --- */
    .dw-header {
        display: none;
    }

    /* --- Desktop white page header bar --- */
    .dw-desktop-header {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 1.25rem 2rem;
        background: var(--surface-card);
        border-bottom: 1px solid var(--border-light);
        position: sticky; top: 0; z-index: 35;
    }
    .dw-desktop-header .dw-dh-back {
        width: 36px; height: 36px; border-radius: 10px;
        display: flex; align-items: center; justify-content: center;
        background: var(--surface); border: 1px solid var(--border);
        color: var(--ink-muted); cursor: pointer;
        transition: all 0.15s ease; flex-shrink: 0;
    }
    .dw-desktop-header .dw-dh-back:hover {
        background: var(--brand-lighter); border-color: var(--brand-light); color: var(--brand);
    }
    .dw-desktop-header .dw-dh-title {
        font-size: 1.125rem; font-weight: 800; color: var(--ink);
        flex: 1; min-width: 0;
    }
    .dw-desktop-header .dw-dh-badge {
        font-size: 0.75rem; font-weight: 600; color: var(--ink-muted);
        background: var(--surface); border: 1px solid var(--border);
        padding: 0.25rem 0.75rem; border-radius: 20px;
    }

    /* --- Home page desktop welcome section --- */
    .dw-home-welcome-desktop {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1.5rem;
        padding: 2rem;
        background: var(--surface-card);
        border-bottom: 1px solid var(--border-light);
        position: sticky; top: 0; z-index: 35;
    }
    .dw-home-welcome-desktop .dw-hw-info {
        display: flex; align-items: center; gap: 1rem;
    }
    .dw-home-welcome-desktop .dw-hw-avatar {
        width: 44px; height: 44px; border-radius: 12px;
        overflow: hidden; flex-shrink: 0;
        border: 2px solid var(--border-light);
    }
    .dw-home-welcome-desktop .dw-hw-avatar img {
        width: 100%; height: 100%; object-fit: cover;
    }
    .dw-home-welcome-desktop .dw-hw-greeting {
        color: var(--ink-muted); font-size: 0.8125rem; font-weight: 500;
    }
    .dw-home-welcome-desktop .dw-hw-name {
        color: var(--ink); font-size: 1.125rem; font-weight: 800; margin-top: 1px;
    }
    .dw-home-welcome-desktop .dw-hw-search {
        position: relative; width: 320px; flex-shrink: 0;
    }
    .dw-home-welcome-desktop .dw-hw-search input {
        width: 100%; padding: 0.625rem 2.5rem 0.625rem 1rem;
        border: 1.5px solid var(--border); border-radius: var(--radius);
        font-family: 'Tajawal', sans-serif; font-size: 0.875rem;
        background: var(--surface); color: var(--ink);
        transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
        outline: none;
    }
    .dw-home-welcome-desktop .dw-hw-search input:focus {
        border-color: var(--brand); box-shadow: 0 0 0 3px rgba(249,115,22,0.08);
        background: #fff;
    }
    .dw-home-welcome-desktop .dw-hw-search input::placeholder { color: var(--ink-light); }
    .dw-home-welcome-desktop .dw-hw-search svg {
        position: absolute; right: 0.875rem; top: 50%; transform: translateY(-50%);
        width: 16px; height: 16px; color: var(--ink-light); pointer-events: none;
    }

    /* --- Settings desktop profile header --- */
    .dw-settings-header-desktop {
        display: flex;
        align-items: center;
        gap: 1rem;
        padding: 1.5rem 2rem;
        background: var(--surface-card);
        border-bottom: 1px solid var(--border-light);
        position: sticky; top: 0; z-index: 35;
    }
    .dw-settings-header-desktop .dw-sh-avatar {
        width: 52px; height: 52px; border-radius: 50%;
        background: linear-gradient(135deg, var(--brand), var(--brand-dark));
        display: flex; align-items: center; justify-content: center;
        color: #fff; font-size: 1.25rem; font-weight: 800;
        flex-shrink: 0;
        box-shadow: 0 4px 12px rgba(249,115,22,0.2);
    }
    .dw-settings-header-desktop .dw-sh-info { flex: 1; min-width: 0; }
    .dw-settings-header-desktop .dw-sh-name {
        font-size: 1.125rem; font-weight: 800; color: var(--ink);
    }
    .dw-settings-header-desktop .dw-sh-phone {
        font-size: 0.8125rem; color: var(--ink-muted); margin-top: 2px;
    }
    .dw-settings-header-desktop .dw-sh-label {
        font-size: 0.8125rem; font-weight: 600; color: var(--ink-muted);
    }

    /* --- Search desktop header --- */
    .dw-search-header-desktop {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 1.25rem 2rem;
        background: var(--surface-card);
        border-bottom: 1px solid var(--border-light);
        position: sticky; top: 0; z-index: 35;
    }
    .dw-search-header-desktop .dw-dh-back {
        width: 36px; height: 36px; border-radius: 10px;
        display: flex; align-items: center; justify-content: center;
        background: var(--surface); border: 1px solid var(--border);
        color: var(--ink-muted); cursor: pointer;
        transition: all 0.15s ease; flex-shrink: 0;
    }
    .dw-search-header-desktop .dw-dh-back:hover {
        background: var(--brand-lighter); border-color: var(--brand-light); color: var(--brand);
    }
    .dw-search-header-desktop .dw-sh-input-wrap {
        position: relative; flex: 1; max-width: 480px;
    }
    .dw-search-header-desktop .dw-sh-input-wrap input {
        width: 100%; padding: 0.625rem 2.5rem 0.625rem 1rem;
        border: 1.5px solid var(--border); border-radius: var(--radius);
        font-family: 'Tajawal', sans-serif; font-size: 0.875rem;
        background: var(--surface); color: var(--ink);
        transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
        outline: none;
    }
    .dw-search-header-desktop .dw-sh-input-wrap input:focus {
        border-color: var(--brand); box-shadow: 0 0 0 3px rgba(249,115,22,0.08);
        background: #fff;
    }
    .dw-search-header-desktop .dw-sh-input-wrap input::placeholder { color: var(--ink-light); }
    .dw-search-header-desktop .dw-sh-input-wrap svg {
        position: absolute; right: 0.875rem; top: 50%; transform: translateY(-50%);
        width: 16px; height: 16px; color: var(--ink-light); pointer-events: none;
    }
}

/* ===== Large Desktop (≥1440px) ===== */
@media (min-width: 1440px) {
    :root { --sidebar-w: 280px; }
    .dw-content-width { max-width: 1000px; }
    .dw-home-welcome-desktop .dw-hw-search { width: 380px; }
}

/* ===== Tablet (768-1023px) ===== */
@media (min-width: 768px) and (max-width: 1023px) {
    .dw-content-width { max-width: 680px; margin: 0 auto; }
}
