/* ===== التصميم الأساسي والمتغيرات ===== */

:root {
    /* الألوان الأساسية */
    --primary-color: #4f46e5;
    /* Indigo 600 */
    --primary-light: #818cf8;
    /* Indigo 400 */
    --primary-dark: #4338ca;
    /* Indigo 700 */
    --secondary-color: #ec4899;
    /* Pink 500 */
    --accent-color: #f59e0b;
    /* Amber 500 */

    /* ألوان الخلفية */
    --bg-body: #f3f4f6;
    /* Gray 100 */
    --bg-card: #ffffff;
    --bg-sidebar: #1e1b4b;
    /* Indigo 950 */
    --bg-input: #f9fafb;
    /* Gray 50 */

    /* ألوان النصوص */
    --text-primary: #111827;
    /* Gray 900 */
    --text-secondary: #4b5563;
    /* Gray 600 */
    --text-muted: #9ca3af;
    /* Gray 400 */
    --text-light: #f3f4f6;
    /* Gray 100 */

    /* الحالات */
    --success-bg: #dcfce7;
    --success-text: #166534;
    --warning-bg: #fef3c7;
    --warning-text: #92400e;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
    --info-bg: #dbeafe;
    --info-text: #1e40af;

    /* الحدود والظلال */
    --border-color: #e5e7eb;
    /* Gray 200 */
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* أخرى */
    --sidebar-width: 280px;
    --header-height: 70px;
    --transition-speed: 0.3s;
}

/* الوضع الداكن (مستقبلاً) */
[data-theme="dark"] {
    --bg-body: #111827;
    --bg-card: #1f2937;
    --bg-sidebar: #0f172a;
    --bg-input: #374151;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --border-color: #374151;
}

/* ===== الإعدادات العامة ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', 'Tajawal', sans-serif;
    direction: rtl;
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 16px;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color var(--transition-speed);
}

ul {
    list-style: none;
}

/* ===== التخطيط (Layout) ===== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* القائمة الجانبية */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    right: 0;
    top: 0;
    z-index: 1000;
    transition: width var(--transition-speed);
    box-shadow: -4px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    gap: 10px;
}

/* Toggle button inside sidebar header */
#sidebar-toggle-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}

#sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-header h2,
.sidebar-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    letter-spacing: 1px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition-speed), max-width var(--transition-speed);
    max-width: 200px;
}

.sidebar-nav {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Scrollbar styling inside sidebar */
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

.sidebar-nav ul {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--border-radius-md);
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    transition: all 0.2s ease;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateX(-5px);
}

.sidebar-nav a i {
    margin-left: 12px;
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

/* المحتوى الرئيسي */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    width: calc(100% - var(--sidebar-width));
    transition: margin-right var(--transition-speed), width var(--transition-speed);
}

/* Sidebar Collapsed State (Desktop) */
body.sidebar-collapsed .sidebar {
    width: 72px;
}

body.sidebar-collapsed .sidebar-title {
    max-width: 0;
    opacity: 0;
    overflow: hidden;
}

body.sidebar-collapsed .sidebar-nav a span {
    display: none;
}

body.sidebar-collapsed .sidebar-nav a {
    justify-content: center;
    padding: 12px 8px;
}

body.sidebar-collapsed .sidebar-nav a i {
    margin-left: 0;
    font-size: 1.4rem;
}

body.sidebar-collapsed .sidebar-nav a:hover,
body.sidebar-collapsed .sidebar-nav a.active {
    transform: none;
}

body.sidebar-collapsed .main-content {
    margin-right: 72px;
    width: calc(100% - 72px);
}

/* Mobile: sidebar slides in from right */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
        transition: transform var(--transition-speed);
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
    }

    .main-content {
        margin-right: 0 !important;
        width: 100% !important;
    }

    .menu-toggle {
        display: flex !important;
        background: none;
        border: none;
        font-size: 1.4rem;
        cursor: pointer;
        color: var(--text-primary);
    }

    #sidebar-toggle-btn {
        display: none;
    }
}

.top-bar {
    height: var(--header-height);
    background-color: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 40px;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 900;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
}

.user-info span {
    font-weight: 600;
    color: var(--text-primary);
}

.user-info i {
    color: var(--primary-color);
}

.content-wrapper {
    padding: 40px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ===== المكونات (Components) ===== */

/* البطاقات */
.card {
    background-color: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    padding: 24px;
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

/* إحصائيات */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.bg-primary-light {
    background-color: #e0e7ff;
    color: var(--primary-color);
}

.bg-success-light {
    background-color: #dcfce7;
    color: var(--success-text);
}

.bg-warning-light {
    background-color: #fef3c7;
    color: var(--warning-text);
}

.bg-info-light {
    background-color: #dbeafe;
    color: var(--info-text);
}

.stat-info h3 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.stat-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* الجداول */
.table-container {
    overflow-x: auto;
    padding: 0;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th {
    background-color: var(--bg-input);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 16px 24px;
    text-align: right;
    border-bottom: 2px solid var(--border-color);
}

.data-table td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background-color: #f9fafb;
}

/* الأزرار */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    background-color: transparent;
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.4);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: white;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background-color: var(--bg-input);
    border-color: var(--text-secondary);
}

.btn-success {
    background-color: #10b981;
    color: white;
}

.btn-success:hover {
    background-color: #059669;
}

.btn-danger {
    background-color: #ef4444;
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-warning {
    background-color: #f59e0b;
    color: white;
}

.btn-info {
    background-color: #3b82f6;
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 6px;
}

/* النماذج */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-label.required::after {
    content: "*";
    color: var(--danger-text);
    margin-right: 4px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-input);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
    background-color: white;
}

/* Badges */
.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    display: inline-block;
}

.badge-success {
    background-color: var(--success-bg);
    color: var(--success-text);
}

.badge-warning {
    background-color: var(--warning-bg);
    color: var(--warning-text);
}

.badge-danger {
    background-color: var(--danger-bg);
    color: var(--danger-text);
}

.badge-info {
    background-color: var(--info-bg);
    color: var(--info-text);
}

.badge-secondary {
    background-color: var(--bg-input);
    color: var(--text-secondary);
}

.badge-active {
    background-color: var(--success-bg);
    color: var(--success-text);
}

.badge-cancelled {
    background-color: var(--bg-input);
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        width: 0;
        overflow: hidden;
    }

    .main-content {
        margin-right: 0;
        width: 100%;
    }

    .sidebar.active {
        width: var(--sidebar-width);
    }
}

/* Status Badges for Payments */
.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 700;
    display: inline-block;
}

.status-paid {
    background-color: var(--success-bg);
    color: var(--success-text);
}

.status-partial {
    background-color: var(--warning-bg);
    color: var(--warning-text);
}

.status-pending {
    background-color: var(--danger-bg);
    color: var(--danger-text);
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.tab-btn {
    padding: 10px 20px;
    cursor: pointer;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.3s;
}

.tab-btn:hover {
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}