/* =========================================
   إعدادات عامة (Global Reset & Body)
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #2d3748;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 15px 40px;
}

.phone-country-row select {
    width: 100%;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #cbd5e0;
    font-size: 0.9em;
}


/* قسم الاشتراك في العروض */
.subscription-section {
    margin-top: 24px;
    margin-bottom: 16px;
    padding: 16px 14px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15), rgba(118, 75, 162, 0.2));
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.subscription-text {
    font-size: 0.9em;
    color: #e2e8f0;
    margin: 4px 0 10px;
}

.subscription-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.subscription-form .field-group {
    margin-bottom: 0;
}

.subscription-message {
    margin-top: 6px;
    font-size: 0.8em;
    min-height: 1.2em;
}

.subscription-message.success {
    color: #9ae6b4;
}

.subscription-message.error {
    color: #feb2b2;
}

/* تحسين بسيط للموبايل */
@media (max-width: 600px) {
    .subscription-section {
        padding: 12px 10px;
        border-radius: 12px;
    }
}


/* =========================================
   الهيدر والشعار (Header & Logo)
   ========================================= */
header {
    text-align: center;
    margin-bottom: 25px;
    position: relative;
    padding-top: 30px;
}

header h1 {
    font-size: 1.8em;
    color: white;
    margin-bottom: 5px;
}

header p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.95em;
}

.logo-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
}

.logo-wrapper img {
    max-height: 60px;
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
    background: #fff;
    padding: 4px;
}

/* =========================================
   الأقسام (Categories)
   ========================================= */
.top-bar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
}

.categories {
    display: flex;
    overflow-x: auto;
    padding-bottom: 5px;
    gap: 8px;
    scrollbar-width: thin;
}

.categories::-webkit-scrollbar {
    height: 5px;
}

.categories::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.4);
    border-radius: 10px;
}

.category-btn {
    border: none;
    padding: 7px 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.9);
    color: #4a5568;
    font-size: 0.85em;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    transition: all 0.2s ease;
}

.category-btn:hover {
    background: #667eea;
    color: white;
}

.category-btn.active {
    background: #667eea;
    color: white;
}

/* =========================================
   شريط الفلاتر (Filter Bar)
   ========================================= */
.filters-bar {
    margin: 8px 0 18px;
    background: rgba(255,255,255,0.96);
    border-radius: 16px;
    padding: 10px 10px 8px;
    box-shadow: 0 6px 14px rgba(0,0,0,0.12);
}

.filters-row {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.filters-row:last-child {
    margin-bottom: 0;
}

.filters-bar input[type="text"],
.filters-bar select {
    flex: 1;
    min-width: 120px;
    padding: 7px 9px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    font-size: 0.85em;
    outline: none;
}

.filters-bar input[type="text"]:focus,
.filters-bar select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 1px rgba(102,126,234,0.35);
}

.filters-label {
    font-size: 0.8em;
    color: #4a5568;
    margin-bottom: 3px;
}

.filters-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* =========================================
   شبكة المنتجات (Products Grid)
   ========================================= */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 15px;
}

.product-card {
    background: rgba(255, 255, 255, 0.96);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0,0,0,0.16);
    display: flex;
    flex-direction: column;
}

.product-image {
    position: relative;
    width: 100%;
    background: #edf2f7;
    overflow: hidden;
}

/* الشارات (Badges) */
.badge-new {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #38a169;
    color: #fff;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.75em;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    z-index: 2;
}

.badge-offer {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #e53e3e;
    color: #fff;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.75em;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    z-index: 2;
}

.placeholder {
    width: 100%;
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3em;
    color: #a0aec0;
}

/* معلومات المنتج */
.product-info {
    padding: 14px 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.product-name {
    font-weight: 700;
    font-size: 1em;
    color: #2d3748;
}

.product-category {
    font-size: 0.8em;
    color: #718096;
}

.product-description {
    font-size: 0.85em;
    color: #4a5568;
}

.product-price {
    margin-top: 5px;
    font-weight: 700;
    font-size: 1.1em;
    color: #2b6cb0;
}

/* =========================================
   أزرار المنتج (Actions)
   ========================================= */
.product-actions {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    align-items: stretch;
}

.product-actions button {
    width: 100%;
    border-radius: 999px;
    padding: 9px 12px;
    font-size: 0.85em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease, background-color 0.15s ease;
}

.product-actions button span:first-child {
    font-size: 1.15em;
}

.product-actions button span:last-child {
    font-weight: 600;
}

.whatsapp-btn {
    background: #25d366;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35);
}

.cart-btn {
    background: #3182ce;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(49, 130, 206, 0.35);
}

.share-btn {
    background: #edf2f7;
    color: #2d3748;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.10);
}

.product-actions button:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
}

.whatsapp-btn:hover {
    box-shadow: 0 5px 14px rgba(37, 211, 102, 0.45);
}

.cart-btn:hover {
    box-shadow: 0 5px 14px rgba(49, 130, 206, 0.45);
}

.share-btn:hover {
    background: #e2e8f0;
}

/* =========================================
   الأزرار العائمة (Floating Buttons)
   ========================================= */
/* زر إضافة منتج (مدير) */
.add-product-btn {
    position: fixed;
    bottom: 80px;
    right: 16px;
    left: auto;
    transform: none;
    background: #ffb347;
    color: #2d3748;
    border: none;
    border-radius: 30px;
    padding: 10px 20px;
    font-size: 0.95em;
    font-weight: 600;
    box-shadow: 0 8px 20px rgba(0,0,0,0.25);
    cursor: pointer;
    display: none;
    gap: 8px;
    align-items: center;
    z-index: 10;
}

.add-product-btn.show {
    display: inline-flex;
}

.add-product-btn span:first-child {
    font-size: 1.4em;
}

.add-product-btn:hover {
    filter: brightness(1.05);
}

/* زر السلة */
.cart-fab {
    position: fixed;
    bottom: 20px;
    right: 16px;
    background: #2b6cb0;
    color: #ffffff;
    border: none;
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 0.9em;
    font-weight: 600;
    box-shadow: 0 8px 20px rgba(0,0,0,0.25);
    cursor: pointer;
    display: none;
    gap: 6px;
    align-items: center;
    z-index: 11;
}

.cart-fab span:first-child {
    font-size: 1.2em;
}

.cart-fab:hover {
    filter: brightness(1.05);
}

/* =========================================
   لوحة التحكم والعناصر (Admin & Inputs)
   ========================================= */
.section-title {
    color: white;
    font-size: 1.1em;
    margin: 15px 0 8px;
    font-weight: 600;
}

.admin-panel {
    margin-bottom: 20px;
    display: none;
}

.admin-card {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 18px;
    padding: 16px 14px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 5px;
}

.field-group label {
    font-size: 0.85em;
    color: #4a5568;
}

.field-group input,
.field-group textarea {
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    font-size: 0.9em;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field-group input:focus,
.field-group textarea:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 1px rgba(102, 126, 234, 0.4);
}

.field-group textarea {
    resize: vertical;
    min-height: 60px;
}

.two-cols {
    display: grid;
    grid-template-columns: 1.3fr 0.7fr;
    gap: 10px;
}

.admin-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 6px;
}

/* الأزرار العامة */
.btn {
    border: none;
    padding: 7px 12px;
    border-radius: 10px;
    font-size: 0.85em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn.small {
    padding: 6px 10px;
    font-size: 0.8em;
}

.btn.primary {
    background: #667eea;
    color: white;
}

.btn.secondary {
    background: #edf2f7;
    color: #4a5568;
}

.btn.danger {
    background: #fff5f5;
    color: #c53030;
}

.btn.primary:hover {
    background: #5a67d8;
}

.btn.secondary:hover {
    background: #e2e8f0;
}

.btn.danger:hover {
    background: #feb2b2;
    color: #742a2a;
}

/* =========================================
   النوافذ المنبثقة (Modals)
   ========================================= */
.admin-login {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.admin-login-card {
    background: white;
    padding: 20px 18px 16px;
    border-radius: 16px;
    width: 92%;
    max-width: 350px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.admin-login-card h2 {
    margin-bottom: 2px;
    font-size: 1.05em;
    color: #2d3748;
}

.admin-login-card p {
    font-size: 0.85em;
    color: #718096;
    margin-bottom: 10px;
}

.admin-login-actions {
    margin-top: 8px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.admin-login input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    font-size: 0.9em;
    margin-top: 5px;
    outline: none;
}

.admin-login input:focus {
    border-color: #667eea;
}

/* =========================================
   الرفع والمعاينة (Upload & Preview)
   ========================================= */
.upload-options {
    display: flex;
    margin-top: 6px;
    margin-bottom: 8px;
    background: #edf2f7;
    border-radius: 10px;
    padding: 3px;
}

.upload-options button {
    flex: 1;
    border: none;
    background: transparent;
    padding: 6px 4px;
    border-radius: 8px;
    font-size: 0.8em;
    cursor: pointer;
}

.upload-options button.active {
    background: white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.upload-area {
    border: 1px dashed #cbd5e0;
    border-radius: 10px;
    padding: 10px;
    background: #f7fafc;
}

.upload-area input[type="file"] {
    width: 100%;
    font-size: 0.85em;
}

.upload-hint {
    font-size: 0.78em;
    color: #718096;
    margin-top: 6px;
}

.preview-container {
    margin-top: 10px;
    display: none;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 6px;
}

.preview-item {
    position: relative;
    border-radius: 9px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: white;
}

.preview-item img,
.preview-item video {
    width: 100%;
    height: 70px;
    object-fit: cover;
}

.preview-remove {
    position: absolute;
    top: 2px;
    left: 2px;
    background: rgba(229,62,62,0.9);
    border: none;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.8em;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-all {
    margin-top: 6px;
    font-size: 0.8em;
    color: #e53e3e;
    cursor: pointer;
    text-align: left;
}

/* =========================================
   المعرض (Gallery)
   ========================================= */
.gallery-container {
    position: relative;
    width: 100%;
    height: 220px;
    overflow: hidden;
}

.gallery-item {
    width: 100%;
    height: 100%;
    position: relative;
    background: #000;
}

.gallery-item img,
.gallery-item video,
.gallery-item iframe {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.45);
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1em;
}

.gallery-nav.prev {
    right: 8px;
}

.gallery-nav.next {
    left: 8px;
}

.gallery-dots {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
}

.gallery-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: rgba(255,255,255,0.6);
    cursor: pointer;
}

.gallery-dot.active {
    background: #667eea;
}

.gallery-thumbs {
    display: flex;
    gap: 6px;
    padding: 6px 8px 8px;
    background: #f7fafc;
    border-top: 1px solid #e2e8f0;
    overflow-x: auto;
}

.gallery-thumbs::-webkit-scrollbar {
    height: 4px;
}
.gallery-thumbs::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 10px;
}

.gallery-thumb {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid #e2e8f0;
    background: #000;
    position: relative;
    cursor: pointer;
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-thumb-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
    color: #fff;
    background: rgba(0,0,0,0.7);
}

.gallery-thumb.active {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102,126,234,0.5);
}

/* =========================================
   مكبر الصور (Lightbox)
   ========================================= */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 30;
}

.lightbox-content-wrapper {
    position: relative;
    max-width: 95%;
    max-height: 95vh;
    width: 900px;
}

.lightbox-content {
    width: 100%;
    max-height: 80vh;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 10px;
}

.lightbox-content img,
.lightbox-content video,
.lightbox-content iframe {
    max-width: 100%;
    max-height: 80vh;
}

.lightbox-close {
    position: absolute;
    top: -40px;
    left: 0;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.5em;
    cursor: pointer;
}

.lightbox-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #fff;
    font-size: 2em;
    cursor: pointer;
}

.lightbox-arrow.prev {
    right: -25px;
}

.lightbox-arrow.next {
    left: -25px;
}

/* =========================================
   قوائم وإحصائيات المدير (Admin Lists)
   ========================================= */
.admin-products-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-top-stats {
    display: none;
    margin: 10px 0 12px;
    background: rgba(255,255,255,0.97);
    border-radius: 16px;
    padding: 10px 12px 8px;
    box-shadow: 0 6px 14px rgba(0,0,0,0.16);
}

.admin-top-stats-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 4px;
    margin-bottom: 8px;
    font-size: 0.85em;
    color: #4a5568;
}

.admin-top-stats-header span:first-child {
    font-weight: 600;
    color: #2d3748;
}

.admin-top-stats-small {
    font-size: 0.78em;
    color: #718096;
}

.admin-top-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 6px;
}

.admin-top-card {
    background: #f7fafc;
    border-radius: 12px;
    padding: 7px 8px;
}

.admin-top-label {
    font-size: 0.78em;
    color: #718096;
    margin-bottom: 2px;
}

.admin-top-value {
    font-size: 1.05em;
    font-weight: 700;
    color: #2d3748;
}

.admin-top-filters {
    font-size: 0.78em;
    color: #718096;
    border-top: 1px dashed #e2e8f0;
    padding-top: 5px;
}

.admin-product-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 10px;
    background: #f7fafc;
}

.admin-product-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.admin-product-name {
    font-size: 0.95em;
    font-weight: 600;
    color: #2d3748;
}

.admin-product-meta {
    font-size: 0.8em;
    color: #718096;
}

.admin-product-actions {
    display: flex;
    gap: 6px;
}

/* =========================================
   التصفح الصفحي (Pagination)
   ========================================= */
.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 5px;
}

.pagination-info {
    font-size: 0.8em;
    color: #edf2f7;
    margin-inline: 6px;
}

.pagination button {
    border: none;
    padding: 5px 9px;
    border-radius: 8px;
    font-size: 0.8em;
    cursor: pointer;
    background: rgba(255,255,255,0.9);
    color: #4a5568;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.pagination button.active {
    background: #667eea;
    color: #fff;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: default;
    box-shadow: none;
}

/* =========================================
   الفوتر (Footer)
   ========================================= */
.site-footer {
    margin-top: 25px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.25);
    text-align: center;
    font-size: 0.8em;
    color: rgba(255,255,255,0.85);
}

.site-footer #storeNameFooter {
    font-weight: 600;
}

.site-footer .admin-link {
    margin-top: 6px;
    border: none;
    background: none;
    color: rgba(255,255,255,0.85);
    cursor: pointer;
    font-size: 0.8em;
    text-decoration: underline;
    display: inline-block;
}

.site-footer .admin-link.logout-btn {
    color: #fed7d7;
    text-decoration: none;
}

/* =========================================
   التجاوب مع الشاشات (Media Queries)
   ========================================= */
@media (max-width: 768px) {
    .admin-top-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    
    header {
        padding-top: 30px;
    }
    
    .products-grid {
        grid-template-columns: 1fr;
    }
    
    .two-cols {
        grid-template-columns: 1fr;
    }

    .gallery-container {
        height: 210px;
    }

    .lightbox-content-wrapper {
        width: 100%;
    }

    .lightbox-arrow.prev {
        right: 5px;
    }

    .lightbox-arrow.next {
        left: 5px;
    }

    .lightbox-close {
        top: -35px;
        left: 5px;
    }

    .admin-product-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .admin-product-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .pagination-info {
        width: 100%;
        text-align: center;
        margin-top: 4px;
    }
}

@media (max-width: 480px) {
    .product-actions {
        grid-template-columns: 1fr;
    }
}