/* ============================================
   نظام الفوترة الإلكترونية - JoFotara
   التنسيقات الرئيسية
   مستوحى من بوابة Hakeem Claim
   ============================================ */

/* ── استيراد الخطوط ── */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/icon?family=Material+Icons+Outlined');

/* ── متغيرات CSS ── */
:root {
    /* الألوان الأساسية */
    --primary: #00538E;
    --primary-dark: #003D6B;
    --primary-light: #1a6fad;
    --primary-50: #e6f0f7;
    --primary-100: #cce1ef;
    --primary-200: #99c3df;
    --primary-300: #66a5cf;
    --primary-400: #3387bf;
    --primary-500: #00538E;
    --primary-600: #004a7f;
    --primary-700: #003D6B;
    --primary-800: #002e51;
    --primary-900: #001f37;
    
    /* تدرجات */
    --gradient-primary: linear-gradient(135deg, #00538E 0%, #1a6fad 50%, #2d8bc9 100%);
    --gradient-header: linear-gradient(90deg, #003D6B 0%, #00538E 30%, #1a6fad 70%, #3a9fd5 100%);
    --gradient-sidebar: linear-gradient(180deg, #00538E 0%, #003D6B 100%);
    
    /* ألوان الحالة */
    --success: #10B981;
    --success-light: #D1FAE5;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --info: #3B82F6;
    --info-light: #DBEAFE;
    
    /* ألوان محايدة */
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    
    /* الخلفيات */
    --bg-body: #EFF3F8;
    --bg-card: #FFFFFF;
    --bg-sidebar: var(--primary);
    
    /* النصوص */
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --text-white: #FFFFFF;
    
    /* الحدود */
    --border-color: #E5E7EB;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;
    --border-radius-xl: 24px;
    
    /* الظلال */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --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);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* الحركة */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;
    
    /* القياسات */
    --sidebar-width: 280px;
    --sidebar-collapsed: 72px;
    --header-height: 64px;
    --content-max-width: 1400px;
}

/* ── إعادة تعيين ── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'IBM Plex Sans Arabic', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    direction: rtl;
    text-align: right;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    height: auto;
}

/* ── صفحة تسجيل الدخول ── */
.auth-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-body);
}

.auth-header {
    background: var(--gradient-header);
    padding: 12px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
    position: relative;
    z-index: 10;
    box-shadow: var(--shadow-md);
}

.auth-header .support-info {
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.auth-header .support-info a {
    color: white;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.auth-header .support-info a:hover {
    opacity: 0.85;
}

.auth-header .logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.auth-header .logo img {
    height: 42px;
}

.auth-header .logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.auth-header .logo-sub {
    font-size: 0.7rem;
    font-weight: 400;
    opacity: 0.9;
    margin-top: -4px;
}

.auth-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.auth-container {
    display: flex;
    width: 100%;
    max-width: 1100px;
    min-height: 500px;
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-xl);
}

.auth-info {
    flex: 1;
    background: linear-gradient(135deg, #f0f4f8 0%, #e8edf3 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 40px;
    text-align: center;
    position: relative;
}

.auth-info::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 40%, rgba(0, 83, 142, 0.04) 0%, transparent 50%),
                radial-gradient(circle at 70% 80%, rgba(0, 83, 142, 0.03) 0%, transparent 50%);
}

.auth-info > * {
    position: relative;
    z-index: 1;
}

.auth-disclaimer {
    color: var(--primary);
    font-size: 1.15rem;
    font-weight: 500;
    line-height: 1.8;
    margin-bottom: 30px;
    max-width: 350px;
}

.auth-disclaimer-en {
    color: var(--gray-500);
    font-size: 0.85rem;
    line-height: 1.7;
    max-width: 350px;
    margin-bottom: 40px;
    font-family: 'Inter', sans-serif;
    direction: ltr;
    text-align: center;
}

.auth-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.auth-logo .logo-icon {
    width: 60px;
    height: 60px;
    color: var(--primary);
    opacity: 0.3;
}

.auth-logo .logo-name {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-400);
    letter-spacing: -1px;
}

.auth-logo .logo-label {
    font-size: 0.7rem;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.auth-form-container {
    flex: 1;
    background: var(--gray-100);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 60px 50px;
    position: relative;
}

.auth-form-container::before {
    content: '';
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(0, 83, 142, 0.04);
}

.auth-form-container h1 {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 32px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.auth-form-container h1 .material-icons-outlined {
    font-size: 1.8rem;
    color: var(--primary);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 14px 16px;
    font-size: 0.95rem;
    font-family: inherit;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius-sm);
    background: white;
    color: var(--text-primary);
    transition: var(--transition);
    outline: none;
    direction: ltr;
    text-align: left;
}

.form-control.rtl-input {
    direction: rtl;
    text-align: right;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 83, 142, 0.15);
}

.form-control::placeholder {
    color: var(--gray-400);
}

.password-wrapper {
    position: relative;
}

.password-toggle {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    padding: 4px;
    font-size: 1.2rem;
    transition: var(--transition-fast);
}

.password-toggle:hover {
    color: var(--gray-600);
}

.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
}

.form-actions a {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--primary);
}

.form-actions a:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn .material-icons-outlined {
    font-size: 1.2rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    min-width: 200px;
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
    color: white;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
    padding: 8px 16px;
}

.btn-ghost:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    min-width: auto;
}

.btn-lg {
    padding: 16px 36px;
    font-size: 1.05rem;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* ── التنبيهات / Flash Messages ── */
.alert {
    padding: 14px 20px;
    border-radius: var(--border-radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success {
    background: var(--success-light);
    color: #065F46;
    border: 1px solid #6EE7B7;
}

.alert-danger {
    background: var(--danger-light);
    color: #991B1B;
    border: 1px solid #FCA5A5;
}

.alert-warning {
    background: var(--warning-light);
    color: #92400E;
    border: 1px solid #FCD34D;
}

.alert-info {
    background: var(--info-light);
    color: #1E40AF;
    border: 1px solid #93C5FD;
}

/* ── التخطيط الرئيسي (بعد تسجيل الدخول) ── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── القائمة الجانبية ── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--gradient-sidebar);
    color: white;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

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

.sidebar-header .logo-icon {
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.sidebar-header .logo-text h2 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 2px;
    white-space: nowrap;
}

.sidebar-header .logo-text span {
    font-size: 0.7rem;
    opacity: 0.7;
}

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

.sidebar-user .user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-user .user-info {
    overflow: hidden;
}

.sidebar-user .user-name {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user .user-role {
    font-size: 0.75rem;
    opacity: 0.7;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.45);
    padding: 0 12px;
    margin-bottom: 8px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    color: rgba(255, 255, 255, 0.8);
    transition: var(--transition);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 2px;
    position: relative;
}

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

.nav-item.active {
    background: rgba(255, 255, 255, 0.18);
    color: white;
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: white;
    border-radius: 0 3px 3px 0;
}

.nav-item .material-icons-outlined {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.nav-item .badge {
    margin-right: auto;
    margin-left: 0;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ── المحتوى الرئيسي ── */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── الشريط العلوي ── */
.top-bar {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.page-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--gray-800);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--gray-400);
}

.breadcrumb a {
    color: var(--gray-500);
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb .separator {
    color: var(--gray-300);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-600);
    font-size: 1.5rem;
    padding: 4px;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--gray-500);
    transition: var(--transition-fast);
    position: relative;
}

.icon-btn:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.icon-btn .notification-dot {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid white;
}

/* ── منطقة المحتوى ── */
.content-area {
    flex: 1;
    padding: 28px;
    max-width: var(--content-max-width);
    width: 100%;
}

/* ── البطاقات (Cards) ── */
.card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: var(--transition);
}

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

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.card-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header h3 .material-icons-outlined {
    color: var(--primary);
    font-size: 1.3rem;
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--gray-50);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

/* ── بطاقات الإحصائيات ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 24px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    border-radius: 0 0 4px 0;
}

.stat-card.blue::after { background: var(--primary); }
.stat-card.green::after { background: var(--success); }
.stat-card.orange::after { background: var(--warning); }
.stat-card.red::after { background: var(--danger); }

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-info h4 {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--gray-500);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-info .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1;
    margin-bottom: 6px;
}

.stat-info .stat-change {
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--danger); }

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.blue { background: var(--primary-50); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }

/* ── الجداول ── */
.table-container {
    overflow-x: auto;
    border-radius: var(--border-radius);
}

table {
    width: 100%;
    border-collapse: collapse;
}

table thead th {
    background: var(--gray-50);
    padding: 14px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
    text-align: right;
    white-space: nowrap;
}

table tbody td {
    padding: 14px 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

table tbody tr {
    transition: var(--transition-fast);
}

table tbody tr:hover {
    background: var(--gray-50);
}

table tbody tr:last-child td {
    border-bottom: none;
}

/* ── شارات الحالة ── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-badge.draft { background: var(--gray-100); color: var(--gray-600); }
.status-badge.draft::before { background: var(--gray-400); }

.status-badge.sent { background: var(--success-light); color: #065F46; }
.status-badge.sent::before { background: var(--success); }

.status-badge.failed { background: var(--danger-light); color: #991B1B; }
.status-badge.failed::before { background: var(--danger); }

.status-badge.pending { background: var(--warning-light); color: #92400E; }
.status-badge.pending::before { background: var(--warning); }

/* ── النماذج (Forms) ── */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 4px;
}

.form-section {
    margin-bottom: 32px;
}

.form-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary-50);
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-section-title .material-icons-outlined {
    color: var(--primary);
    font-size: 1.2rem;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    background-size: 18px;
    padding-left: 40px;
    direction: rtl;
    text-align: right;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
    direction: rtl;
    text-align: right;
}

.form-hint {
    font-size: 0.78rem;
    color: var(--gray-400);
    margin-top: 4px;
}

.form-error {
    font-size: 0.78rem;
    color: var(--danger);
    margin-top: 4px;
}

/* ── بنود الفاتورة ── */
.invoice-items-table {
    margin-top: 16px;
}

.invoice-items-table .add-item-btn {
    margin-top: 12px;
    width: 100%;
    border: 2px dashed var(--gray-300);
    background: var(--gray-50);
    color: var(--gray-500);
    padding: 14px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
}

.invoice-items-table .add-item-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-50);
}

.remove-item-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--danger-light);
    border: none;
    cursor: pointer;
    color: var(--danger);
    transition: var(--transition-fast);
    font-size: 1.1rem;
}

.remove-item-btn:hover {
    background: var(--danger);
    color: white;
}

/* ── ملخص الفاتورة ── */
.invoice-summary {
    background: var(--gray-50);
    border-radius: var(--border-radius-sm);
    padding: 24px;
    margin-top: 24px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 0.92rem;
}

.summary-row.total {
    border-top: 2px solid var(--gray-300);
    margin-top: 8px;
    padding-top: 16px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
}

/* ── طباعة الفاتورة ── */
.print-invoice {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    padding: 40px;
}

.print-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 3px solid var(--primary);
}

.print-qr {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px dashed var(--gray-300);
}

.print-qr img {
    max-width: 150px;
    margin: 0 auto 10px;
}

/* ── Grid Helpers ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

/* ── المساحات ── */
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.p-0 { padding: 0; }

/* ── المحاذاة ── */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-400); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }

/* ── صفحة فارغة ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-400);
}

.empty-state .material-icons-outlined {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: var(--gray-500);
}

.empty-state p {
    font-size: 0.9rem;
    margin-bottom: 24px;
}

/* ── Spinner / Loading ── */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.loading-overlay .spinner {
    width: 56px;
    height: 56px;
    border-width: 4px;
}

.loading-overlay p {
    margin-top: 16px;
    font-size: 1rem;
    color: var(--gray-600);
    font-weight: 500;
}

/* ── Toast Notifications ── */
.toast-container {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    border-radius: var(--border-radius-sm);
    padding: 16px 20px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 320px;
    animation: toastSlide 0.3s ease;
    border-right: 4px solid;
}

@keyframes toastSlide {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }

.toast .toast-close {
    margin-right: auto;
    margin-left: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    font-size: 1.2rem;
}

/* ── Overlay Sidebar (Mobile) ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    backdrop-filter: blur(2px);
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        margin-right: 0;
    }

    .menu-toggle {
        display: flex;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-3, .grid-4 {
        grid-template-columns: 1fr 1fr;
    }

    .auth-container {
        flex-direction: column;
    }

    .auth-info {
        padding: 30px 20px;
    }
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .content-area {
        padding: 16px;
    }

    .top-bar {
        padding: 0 16px;
    }

    .card-body {
        padding: 16px;
    }

    .auth-form-container {
        padding: 30px 24px;
    }

    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-primary {
        min-width: auto;
    }
}

/* ── طباعة ── */
@media print {
    .sidebar,
    .top-bar,
    .no-print {
        display: none !important;
    }

    .main-content {
        margin: 0 !important;
    }

    .content-area {
        padding: 0 !important;
    }

    body {
        background: white;
    }

    .card {
        box-shadow: none;
        border: none;
    }
}
