/**
 * نظام التصميم والتنسيق المتكامل الفخم - متجر محلات السفير مستغانم
 * RTL Dark & Light Theme System + Natural Compact Table Layout (No Scrollbar Needed)
 * Developer: SDZ 🚀
 */

:root[data-theme="dark"] {
    --bg-main: #0b0f19;
    --bg-card: rgba(18, 26, 44, 0.85);
    --bg-card-hover: rgba(30, 41, 59, 0.9);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.08);
    --accent-gold: #f59e0b;
    --accent-gold-hover: #d97706;
    --accent-blue: #3b82f6;
    --accent-emerald: #10b981;
    --accent-rose: #ef4444;
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --transition-fast: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

:root[data-theme="light"] {
    --bg-main: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: rgba(0, 0, 0, 0.08);
    --accent-gold: #d97706;
    --accent-gold-hover: #b45309;
    --accent-blue: #2563eb;
    --accent-emerald: #059669;
    --accent-rose: #dc2626;
    --glass-shadow: 0 8px 30px rgba(0,0,0,0.08);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --transition-fast: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Cairo', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    direction: rtl;
    min-height: 100vh;
}

.container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Navbar Header */
.navbar {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 14px 0;
}

.nav-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-main);
}

.brand-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-hover));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #000;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.brand-info h1 {
    font-size: 18px;
    font-weight: 800;
    line-height: 1.2;
}

.brand-info span {
    font-size: 11px;
    color: var(--text-muted);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    text-decoration: none;
    transition: var(--transition-fast);
}

.btn-icon:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.btn-wholesale-login {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.3));
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-radius: var(--radius-md);
    color: var(--accent-blue);
    font-family: 'Cairo', sans-serif;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-wholesale-login:hover {
    background: var(--accent-blue);
    color: #fff;
}

.user-badge-logged {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--accent-emerald);
}

.btn-logout-link {
    color: var(--accent-rose);
    text-decoration: none;
    font-weight: 700;
    margin-right: 4px;
}

.cart-btn {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
}

.cart-badge {
    position: absolute;
    top: -6px;
    left: -6px;
    background: var(--accent-rose);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Page Layout & Search Section */
.page-content {
    padding: 30px 0;
}

.search-section {
    margin-bottom: 25px;
}

.search-box {
    position: relative;
    max-width: 780px;
    margin: 0 auto;
}

.search-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 22px;
    color: var(--accent-gold);
}

.search-input {
    width: 100%;
    padding: 16px 56px 16px 50px;
    font-family: 'Cairo', sans-serif;
    font-size: 15px;
    font-weight: 600;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-main);
    box-shadow: var(--glass-shadow);
    transition: var(--transition-fast);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.2);
}

.clear-btn {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
}

.dictionary-notice {
    max-width: 780px;
    margin: 12px auto 0 auto;
    padding: 10px 16px;
    background: rgba(245, 158, 11, 0.12);
    border: 1px dashed var(--accent-gold);
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--accent-gold);
    text-align: center;
}

/* Catalog Header & Categories */
.catalog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 15px;
}

.catalog-title h2 {
    font-size: 22px;
    font-weight: 800;
}

.candidate-badge {
    font-size: 12px;
    color: var(--accent-gold);
    background: rgba(245, 158, 11, 0.1);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.category-filters {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
}

.cat-chip {
    padding: 8px 16px;
    border-radius: 30px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-muted);
    font-family: 'Cairo', sans-serif;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition-fast);
}

.cat-chip.active, .cat-chip:hover {
    background: var(--accent-gold);
    color: #000;
    border-color: var(--accent-gold);
}

/* Products Grid System */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
}

.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--glass-shadow);
    transition: var(--transition-fast);
}

.product-card:hover {
    transform: translateY(-6px);
    border-color: rgba(245, 158, 11, 0.4);
}

html.hide-images-mode .product-img-wrapper {
    display: none !important;
}

.product-img-wrapper {
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.5);
    position: relative;
}

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

.product-card:hover .product-img {
    transform: scale(1.08);
}

.product-info {
    padding: 18px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.product-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.product-sku {
    font-family: 'Outfit', sans-serif;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    background: rgba(255,255,255,0.05);
    padding: 2px 8px;
    border-radius: 6px;
}

.badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
}

.badge-stock { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.badge-preorder { background: rgba(245, 158, 11, 0.15); color: var(--accent-gold); }
.badge-out { background: rgba(239, 68, 68, 0.15); color: var(--accent-rose); }

.product-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 42px;
}

.product-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.price-container {
    display: flex;
    align-baseline: baseline;
    gap: 4px;
}

.price-amount {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    font-weight: 800;
    color: var(--accent-gold);
}

.price-currency {
    font-size: 12px;
    color: var(--text-muted);
}

.btn-add-cart {
    padding: 8px 14px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--accent-gold);
    color: #000;
    font-family: 'Cairo', sans-serif;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-fast);
}

.btn-add-cart:hover {
    background: var(--accent-gold-hover);
    transform: scale(1.04);
}

.btn-add-cart.disabled {
    background: var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Modals & Overlay */
.modal-overlay {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-fast);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    padding: 28px;
    box-shadow: var(--glass-shadow);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.btn-close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-main);
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 12px 14px;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-family: 'Cairo', sans-serif;
    font-size: 14px;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent-gold);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    border-radius: var(--radius-md);
    border: none;
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-hover));
    color: #000;
    font-family: 'Cairo', sans-serif;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Cart Drawer */
.cart-drawer {
    position: fixed;
    top: 0;
    left: -420px;
    width: 400px;
    height: 100vh;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    box-shadow: var(--glass-shadow);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.cart-drawer.active {
    left: 0;
}

.drawer-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.drawer-body {
    padding: 20px;
    flex-grow: 1;
    overflow-y: auto;
}

.drawer-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.drawer-overlay {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    display: none;
}

.drawer-overlay.active {
    display: block;
}

.cart-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.cart-item-info h4 {
    font-size: 13px;
    font-weight: 700;
}

.cart-item-price {
    font-size: 13px;
    color: var(--accent-gold);
    font-family: 'Outfit', sans-serif;
}

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-qty {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    color: var(--text-main);
    cursor: pointer;
    font-weight: 800;
}

.btn-remove {
    background: none;
    border: none;
    color: var(--accent-rose);
    cursor: pointer;
    font-size: 16px;
    margin-right: 6px;
}

.summary-line {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    margin-bottom: 8px;
}

.total-line {
    font-size: 17px;
    font-weight: 800;
    color: var(--accent-gold);
}

/* Compact Table Layout (Fits all columns naturally without scrollbar) */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    margin-bottom: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.data-table th, .data-table td {
    padding: 10px 10px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    vertical-align: middle;
}

.data-table th {
    background: rgba(15, 23, 42, 0.7);
    color: var(--accent-gold);
    font-weight: 800;
    white-space: nowrap;
}

.table-prod-title {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
}

.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 30px 0;
    margin-top: 60px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

.dev-badge {
    margin-top: 8px;
    font-weight: 800;
    color: var(--accent-gold);
}
