/* Arabic Dashboard CSS - RTL Support */
:root {
    --sidebar-width: 280px;
    --header-height: 70px;
    --primary-color: #1e40af;
    --secondary-color: #7c3aed;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --dark-bg: #1f2937;
    --light-bg: #f8fafc;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden;
    direction: rtl;
}

/* RTL Layout Container */
.dashboard-wrapper {
    display: flex;
    height: 100vh;
    direction: rtl;
}

/* Sidebar - RTL */
.sidebar {
    width: var(--sidebar-width);
    background: var(--dark-bg);
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: transform 0.3s ease;
    direction: rtl;
}

.sidebar.collapsed {
    transform: translateX(100%);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 15px;
    direction: rtl;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: bold;
    color: white;
    direction: rtl;
}

.logo-icon {
    width: 35px;
    height: 35px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
    direction: rtl;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.3s ease;
    border-right: 3px solid transparent;
    margin-bottom: 5px;
    direction: rtl;
    text-align: right;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-right-color: var(--primary-color);
}

.nav-item.active {
    background: var(--primary-color);
    color: white;
    border-right-color: var(--secondary-color);
}

.nav-icon {
    margin-left: 12px;
    font-size: 18px;
    width: 20px;
    text-align: center;
}

/* Main Content - RTL */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--light-bg);
    overflow-y: auto;
    direction: rtl;
}

/* Header - RTL */
.main-header {
    height: var(--header-height);
    background: white;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 100;
    direction: rtl;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
    direction: rtl;
}

.header-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
}

.refresh-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    direction: rtl;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
    direction: rtl;
}

.header-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    direction: rtl;
}

.header-btn:hover {
    background: var(--light-bg);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.notification-bell {
    position: relative;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-secondary);
}

.notification-badge {
    position: absolute;
    top: -5px;
    left: -5px;
    background: var(--danger-color);
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
}

/* Content Area - RTL */
.content-area {
    padding: 30px;
    flex: 1;
    direction: rtl;
}

/* Metrics Grid - RTL */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
    direction: rtl;
}

.metric-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-right: 4px solid transparent;
    text-align: right;
    direction: rtl;
}

.metric-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.metric-card.receivable {
    border-right-color: var(--primary-color);
}

.metric-card.revenue {
    border-right-color: var(--success-color);
}

.metric-card.payable {
    border-right-color: var(--warning-color);
}

.metric-card.ratio {
    border-right-color: var(--secondary-color);
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    direction: rtl;
}

.metric-title {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    text-align: right;
}

.metric-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.metric-icon.primary {
    background: rgba(30, 64, 175, 0.1);
    color: var(--primary-color);
}

.metric-icon.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.metric-icon.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.metric-icon.secondary {
    background: rgba(124, 58, 237, 0.1);
    color: var(--secondary-color);
}

.metric-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 5px;
    text-align: right;
    direction: rtl;
}

.metric-change {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: right;
    direction: rtl;
}

.metric-change.positive {
    color: var(--success-color);
}

.metric-change.negative {
    color: var(--danger-color);
}

/* Charts Section - RTL */
.charts-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 30px;
    direction: rtl;
}

.chart-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    direction: rtl;
}

.chart-card.full-width {
    grid-column: 1 / -1;
}

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

.chart-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
}

.chart-options {
    display: flex;
    gap: 10px;
    direction: rtl;
}

.chart-option {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    direction: rtl;
}

.chart-option:hover {
    background: var(--light-bg);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.chart-container {
    height: 300px;
    position: relative;
    direction: rtl;
}

/* Tables - RTL */
.table-container {
    overflow-x: auto;
    direction: rtl;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    direction: rtl;
}

.data-table th {
    background: var(--primary-color);
    color: white;
    padding: 12px 15px;
    text-align: right;
    font-weight: 600;
    direction: rtl;
}

.data-table td {
    padding: 12px 15px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
    direction: rtl;
}

.data-table tr:hover {
    background: var(--light-bg);
}

/* Mobile Menu Toggle - RTL */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    font-size: 18px;
}

/* Responsive Design - RTL */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        top: 0;
        right: 0;
        left: auto;
        height: 100vh;
        transform: translateX(100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-right: 0;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 15px;
    }
    
    .charts-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .metric-value {
        font-size: 28px;
    }
    
    .header-left {
        gap: 10px;
    }
    
    .header-title {
        font-size: 20px;
    }
}

/* Dark Mode for RTL */
body.dark-mode {
    --light-bg: #111827;
    --dark-bg: #f8fafc;
    --border-color: #374151;
}

body.dark-mode .main-content {
    background: #111827;
}

body.dark-mode .main-header {
    background: #1f2937;
    border-color: #374151;
}

body.dark-mode .metric-card,
body.dark-mode .chart-card {
    background: #1f2937;
    border-color: #374151;
}

body.dark-mode .header-title,
body.dark-mode .metric-value,
body.dark-mode .chart-title {
    color: #f8fafc;
}

body.dark-mode .metric-title,
body.dark-mode .metric-change {
    color: #d1d5db;
}

/* Fix for RTL text alignment */
.rtl .text-left {
    text-align: right !important;
}

.rtl .text-right {
    text-align: left !important;
}

/* Arabic font improvements */
.arabic-font {
    font-family: 'Segoe UI', 'Tahoma', 'Arial Unicode MS', sans-serif;
    font-size: 15px;
    line-height: 1.6;
}

/* Ensure proper RTL for all elements */
.rtl * {
    direction: rtl;
    text-align: right;
}

.rtl .flex {
    flex-direction: row-reverse;
}

.rtl .text-center {
    text-align: center;
}
