/* ==========================================================================
   الصولجان - تصميم مبسط واحترافي (Minimal & Premium)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&display=swap');

:root {
    /* باليت الألوان العصرية */
    --primary: #4f46e5;
    /* أزرق نيلي احترافي */
    --primary-hover: #4338ca;
    --secondary: #f1f5f9;
    /* رمادي فاتح للأزرار الثانوية */
    --secondary-hover: #e2e8f0;
    --danger: #ef4444;
    /* أحمر للحذف والتنبيهات */
    --success: #10b981;
    /* أخضر للنجاح والمكتمل */
    --warning: #f59e0b;
    /* برتقالي للمعلق */

    /* ألوان الواجهة والخلفيات */
    --bg-main: #f8fafc;
    /* خلفية التطبيق رمادي نقي جداً */
    --bg-card: #ffffff;
    /* لون البطاقات أبيض ناصع */
    --sidebar-bg: #0f172a;
    /* كحلي داكن جداً للقائمة الجانبية */
    --sidebar-hover: #1e293b;
    --sidebar-active: #2563eb;

    /* ألوان النصوص */
    --text-dark: #0f172a;
    --text-main: #334155;
    --text-muted: #64748b;
    --border-light: #e2e8f0;

    /* المسافات والظلال */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.03);
    --shadow-hover: 0 10px 25px rgba(0, 0, 0, 0.08);

    /* انتقالات الحركة */
    --transition: all 0.25s ease;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    direction: rtl;
    line-height: 1.6;
}

/* Scrollbar أنيق */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ── أزرار عامة (Buttons) ── */
button {
    font-family: 'Cairo', sans-serif;
    cursor: pointer;
    border: none;
    outline: none;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary);
    color: #fff;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 15px;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: var(--secondary);
    color: var(--text-dark);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 15px;
}

.btn-secondary:hover {
    background-color: var(--secondary-hover);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-outline-dashed {
    background: transparent;
    border: 2px dashed #cbd5e1;
    color: var(--text-muted);
    padding: 12px;
    border-radius: var(--radius-md);
    width: 100%;
    font-weight: 600;
}

.btn-outline-dashed:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #eff6ff;
}

.btn-danger {
    background-color: #fef2f2;
    color: var(--danger);
}

.btn-danger:hover {
    background-color: #fee2e2;
}

/* ── حقول الإدخال (Inputs) ── */
.input-field,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-family: 'Cairo', sans-serif;
    font-size: 14px;
    color: var(--text-dark);
    background-color: #fff;
    transition: var(--transition);
}

.input-field:focus,
input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
    outline: none;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-dark);
    font-size: 14px;
}

.mt-2 {
    margin-top: 10px;
}

/* ── شاشة تسجيل الدخول (Login) ── */
#login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f1f5f9;
}

.login-box {
    background: var(--bg-card);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-hover);
    width: 100%;
    max-width: 420px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    color: var(--primary);
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 5px;
}

.login-header p {
    color: var(--text-muted);
}

.error-message {
    background: #fef2f2;
    color: var(--danger);
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    text-align: center;
    font-size: 14px;
}

#login-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    margin-top: 10px;
}

/* ── الهيكل الأساسي (Layout) ── */
#app-screen {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 30px 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}

.admin-name {
    color: #94a3b8;
    font-size: 13px;
}

.sidebar-nav {
    flex: 1;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: #cbd5e1;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    cursor: pointer;
    font-weight: 500;
}

.sidebar-nav a:hover {
    background-color: var(--sidebar-hover);
    color: #fff;
}

.sidebar-nav a.active {
    background-color: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
}

.sidebar-nav .icon {
    margin-left: 12px;
    font-size: 18px;
}

.sidebar-footer {
    padding: 20px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-logout {
    width: 100%;
    background: transparent;
    color: #f87171;
    border: 1px solid rgba(248, 113, 113, 0.2);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.btn-logout:hover {
    background: rgba(248, 113, 113, 0.1);
}

.main-content {
    flex: 1;
    margin-right: 260px;
    padding: 40px;
}

/* ── رؤوس الصفحات (Headers) ── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-title {
    font-size: 28px;
    color: var(--text-dark);
    font-weight: 800;
    line-height: 1.2;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 15px;
    margin-top: 6px;
}

/* ── الرئيسية (Dashboard) ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-soft);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    margin-left: 20px;
}

.stat-icon.blue {
    background: #eff6ff;
    color: #3b82f6;
}

.stat-icon.purple {
    background: #f5f3ff;
    color: #8b5cf6;
}

.stat-icon.orange {
    background: #fffbeb;
    color: #f59e0b;
}

.stat-icon.green {
    background: #f0fdf4;
    color: #10b981;
}

.stat-details p {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.stat-details h3 {
    font-size: 28px;
    color: var(--text-dark);
    font-weight: 800;
}

.loading-state {
    text-align: center;
    padding: 60px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ── المنتجات (Products) ── */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
}

.product-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
    border: 1px solid var(--border-light);
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.product-image {
    width: 100%;
    height: 220px;
    background: #f1f5f9;
    position: relative;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-brand-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.9);
    padding: 4px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.product-brand-badge img {
    max-width: 40px;
    max-height: 24px;
    object-fit: contain;
}

.product-info {
    padding: 20px;
}

.product-info h3 {
    font-size: 16px;
    color: var(--text-dark);
    margin-bottom: 4px;
    font-weight: 700;
}

.product-brand,
.product-category {
    font-size: 13px;
    color: var(--text-muted);
}

.product-price {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
    margin: 12px 0 20px;
}

.product-actions {
    display: flex;
    gap: 8px;
}

.product-actions button {
    flex: 1;
    padding: 8px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
}

.edit-btn {
    background: var(--secondary);
    color: var(--text-dark);
    border: none;
}

.edit-btn:hover {
    background: #e2e8f0;
}

.delete-btn {
    background: #fef2f2;
    color: var(--danger);
    border: none;
}

.delete-btn:hover {
    background: #fee2e2;
}

/* ── الطلبات (Orders) ── */
.filters-container {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.filter-group {
    display: flex;
    background: #fff;
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.filter-btn {
    background: transparent;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 14px;
}

.filter-btn:hover {
    color: var(--text-dark);
}

.filter-btn.active {
    background: var(--secondary);
    color: var(--text-dark);
}

.orders-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.order-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-light);
    position: relative;
}

.card-close-btn {
    position: absolute;
    top: 16px;
    left: 16px;
    background: #fef2f2;
    color: var(--danger);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 18px;
    border: none;
    cursor: pointer;
    transition: 0.2s;
}

.card-close-btn:hover {
    background: var(--danger);
    color: #fff;
}

.order-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 16px;
    margin-bottom: 20px;
}

.order-header h3 {
    font-size: 18px;
    color: var(--text-dark);
    font-weight: 700;
    margin-bottom: 4px;
}

.order-date {
    font-size: 13px;
    color: var(--text-muted);
}

.order-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
}

/* سيتم تلوين الحالات برمجياً، لكن يمكن ضبط ألوان افتراضية هنا */

.order-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
    margin-bottom: 20px;
}

.info-section h4 {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.info-section p {
    font-size: 14px;
    margin-bottom: 6px;
}

.info-section strong {
    color: var(--text-dark);
}

.order-item {
    background: #f8fafc;
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    border: 1px solid var(--border-light);
}

.item-price {
    font-weight: 700;
    color: var(--primary);
}

.seller-highlight {
    background: #f0fdf4;
    border: 1px dashed #86efac;
    border-radius: var(--radius-sm);
    padding: 16px;
    display: flex;
    gap: 24px;
    margin-top: 16px;
}

.seller-highlight .label {
    font-size: 12px;
    color: #166534;
}

.seller-highlight strong {
    font-size: 18px;
    color: #14532d;
    display: block;
    margin-top: 4px;
}

.order-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8fafc;
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-top: 20px;
}

.status-select {
    max-width: 200px;
}

/* ── البائعون (Sellers) ── */
.search-actions {
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 400px;
}

.sellers-stats-bar {
    display: flex;
    gap: 16px;
    background: var(--bg-card);
    padding: 16px 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    margin-bottom: 24px;
    border: 1px solid var(--border-light);
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 15px;
}

.stat-item .label {
    color: var(--text-muted);
}

.stat-item strong {
    color: var(--text-dark);
    font-size: 18px;
    font-weight: 800;
}

.stat-item.success strong {
    color: var(--success);
}

.stat-item.warning strong {
    color: var(--danger);
}

.stat-item.highlight strong {
    color: var(--primary);
}

.sellers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.seller-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-light);
    position: relative;
}

.seller-header {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 20px;
}

.avatar {
    width: 50px;
    height: 50px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
}

.seller-header h3 {
    font-size: 16px;
    color: var(--text-dark);
    margin-bottom: 2px;
}

.seller-header p {
    font-size: 13px;
    color: var(--text-muted);
}

.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    margin-right: auto;
}

.status-badge.active {
    background: #dcfce7;
    color: #166534;
}

.status-badge.inactive {
    background: #fee2e2;
    color: #991b1b;
}

.profit-box {
    text-align: center;
    background: #eff6ff;
    padding: 20px;
    border-radius: var(--radius-sm);
    margin: 20px 0;
}

.profit-box .label {
    color: #3b82f6;
    font-size: 13px;
    font-weight: 600;
}

.profit-box h2 {
    color: var(--primary);
    font-size: 28px;
    font-weight: 800;
    margin: 5px 0;
}

.seller-actions {
    display: flex;
    gap: 10px;
}

.seller-actions button {
    flex: 1;
}

/* ── الإعدادات (Configuration) ── */
.config-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    max-width: 900px;
}

.config-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-light);
}

.card-title {
    font-size: 18px;
    color: var(--text-dark);
    margin-bottom: 20px;
    font-weight: 700;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 12px;
}

.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 12px;
    margin-bottom: 20px;
}

.card-header-flex .card-title {
    border: none;
    padding: 0;
    margin: 0;
}

.input-action-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.prefix {
    background: #f1f5f9;
    padding: 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 13px;
    border-right: none;
}

.news-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.news-item {
    display: flex;
    gap: 8px;
}

.images-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.gallery-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.image-item {
    width: 100px;
    height: 100px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-light);
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-image-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
}

.upload-placeholder {
    width: 100px;
    height: 100px;
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.2s;
    background: #f8fafc;
}

.upload-placeholder:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.upload-placeholder span {
    font-size: 24px;
    font-weight: 300;
}

.upload-placeholder mini {
    width: 80px;
    height: 80px;
}

/* ── النوافذ المنبثقة (Modals) ── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-title {
    font-size: 22px;
    color: var(--text-dark);
    margin-bottom: 24px;
    font-weight: 800;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

.image-upload-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
}

.img-preview-mini {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    border: 1px solid var(--border-light);
}

.additional-images-wrapper {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

.modal-actions button {
    min-width: 120px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar {
        width: 70px;
    }

    .sidebar-header h2,
    .admin-name,
    .nav-text,
    .btn-logout span:not(.icon) {
        display: none;
    }

    .sidebar-nav a {
        justify-content: center;
        padding: 12px;
    }

    .sidebar-nav .icon {
        margin: 0;
        font-size: 22px;
    }

    .main-content {
        margin-right: 70px;
        padding: 20px;
    }

    .form-grid-2,
    .form-grid-3 {
        grid-template-columns: 1fr;
    }

    .order-header {
        flex-direction: column;
        gap: 12px;
    }

    .search-actions {
        max-width: 100%;
        flex-direction: column;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}