/**
 * Taban24 Core Design System & CSS Variables
 * Pure Vanilla CSS - No frameworks used
 * Custom RTL & Modern Marketplace Styling
 */

@import url('fonts.css');
@import url('../fonts/FontAwesome/css/all.css');

:root {
    /* Color Palette */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: rgba(79, 70, 229, 0.1);
    --secondary: #0ea5e9;
    --secondary-hover: #0284c7;
    
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.12);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.12);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.12);
    --info: #3b82f6;
    --info-light: rgba(59, 130, 246, 0.12);

    /* Neutral Colors (Light mode default) */
    --bg-page: #f8fafc;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --sidebar-active-bg: rgba(255, 255, 255, 0.08);

    --border-color: #e2e8f0;
    --border-subtle: #f1f5f9;

    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-subtle: #94a3b8;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

    /* Dimensions & Spacing */
    --sidebar-width: 260px;
    --header-height: 68px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-page: #0b0f19;
    --bg-surface: #111827;
    --bg-card: #1f2937;
    --bg-sidebar: #0b0f19;
    --border-color: #374151;
    --border-subtle: #1f2937;
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --text-subtle: #6b7280;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* Reset & Box Sizing */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Yekan Bakh FaNum', 'YekanBakhFaNum', 'YekanBakhFaNum2', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
    direction: rtl;
    text-align: right;
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.6;
    font-size: 14.5px;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

ul, ol {
    list-style: none;
}

/* Layout Utilities */
.container {
    width: 100%;
    max-width: 1300px;
    margin-inline: auto;
    padding-inline: 1.25rem;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

.grid {
    display: grid;
    gap: 1.25rem;
}
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1024px) {
    .grid-cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-cols-3 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .grid-cols-4, .grid-cols-2 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
    .container { padding-inline: 0.75rem; }
}

/* Typography Helpers */
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.85rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-black { font-weight: 900; }

.text-primary { color: var(--primary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
    text-align: center;
    line-height: 1.2;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
}
.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 6px 14px rgba(79, 70, 229, 0.35);
}

.btn-secondary {
    background-color: var(--bg-surface);
    color: var(--text-main);
    border-color: var(--border-color);
}
.btn-secondary:hover {
    background-color: var(--border-subtle);
}

.btn-danger {
    background-color: var(--danger);
    color: #ffffff;
}
.btn-danger:hover {
    background-color: #dc2626;
}

.btn-success {
    background-color: var(--success);
    color: #ffffff;
}
.btn-success:hover {
    background-color: #059669;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}
.btn-lg {
    padding: 0.85rem 1.75rem;
    font-size: 1.05rem;
    border-radius: var(--radius-md);
}

/* Form Controls */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1.15rem;
}

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.95rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-control::placeholder {
    color: var(--text-subtle);
}

.form-error {
    color: var(--danger);
    font-size: 0.75rem;
    margin-top: 0.2rem;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-primary { background: var(--primary-light); color: var(--primary); }

/* Card Component */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.35rem;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.15rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: right;
}

.table th {
    background-color: var(--bg-page);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.table td {
    padding: 0.95rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.88rem;
    vertical-align: middle;
}

.table tbody tr:hover td {
    background-color: rgba(79, 70, 229, 0.02);
}

/* Alerts */
.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1.1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
}
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid rgba(16, 185, 129, 0.2); }
.alert-danger { background: var(--danger-light); color: #991b1b; border: 1px solid rgba(239, 68, 68, 0.2); }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid rgba(245, 158, 11, 0.2); }
.alert-info { background: var(--info-light); color: #1e40af; border: 1px solid rgba(59, 130, 246, 0.2); }

/* ==========================================================================
   Modern Theme Toggle Button
   ========================================================================== */
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.22rem 0.65rem 0.22rem 0.35rem;
    background: var(--bg-surface, #ffffff);
    border: 1.5px solid var(--border-color, #e2e8f0);
    border-radius: 9999px;
    color: var(--text-main, #334155);
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    font-family: inherit;
    line-height: 1;
}

.theme-toggle-btn:hover {
    border-color: var(--primary, #4f46e5);
    color: var(--primary, #4f46e5);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
    transform: translateY(-1px);
}

.theme-toggle-btn:active {
    transform: scale(0.96);
}

.theme-toggle-btn .theme-icon-circle {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    background: rgba(79, 70, 229, 0.1);
    color: #4f46e5;
}

.theme-toggle-btn .icon-moon {
    display: inline-block;
    font-size: 0.78rem;
    transition: transform 0.3s ease;
}

.theme-toggle-btn .icon-sun {
    display: none;
}

.theme-toggle-btn .theme-label-dark {
    display: inline;
}

.theme-toggle-btn .theme-label-light {
    display: none;
}

/* Dark mode styling */
[data-theme="dark"] .theme-toggle-btn {
    background: rgba(30, 41, 59, 0.85);
    border-color: rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .theme-toggle-btn:hover {
    border-color: #f59e0b;
    color: #f59e0b;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.25);
}

[data-theme="dark"] .theme-toggle-btn .theme-icon-circle {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

[data-theme="dark"] .theme-toggle-btn .icon-moon {
    display: none;
}

[data-theme="dark"] .theme-toggle-btn .icon-sun {
    display: inline-block;
    font-size: 0.82rem;
    animation: sunSpin 0.5s ease-out;
}

[data-theme="dark"] .theme-toggle-btn .theme-label-dark {
    display: none;
}

[data-theme="dark"] .theme-toggle-btn .theme-label-light {
    display: inline;
    color: #f1f5f9;
}

@keyframes sunSpin {
    from {
        transform: rotate(-90deg) scale(0.7);
    }
    to {
        transform: rotate(0deg) scale(1);
    }
}

@media (max-width: 640px) {
    .theme-toggle-btn .theme-label-dark,
    .theme-toggle-btn .theme-label-light {
        display: none !important;
    }
    .theme-toggle-btn {
        padding: 0.25rem;
        border-radius: 50%;
    }
}
