/**
 * SmartSocial - Main Stylesheet
 * التصميم الرئيسي
 */

/* ============================================================
   CSS Variables / المتغيرات
   ============================================================ */
:root {
    /* Primary Colors */
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --primary-200: #bfdbfe;
    --primary-300: #93c5fd;
    --primary-400: #60a5fa;
    --primary-500: #3b82f6;
    --primary-600: #2563eb;
    --primary-700: #1d4ed8;
    --primary-800: #1e40af;
    --primary-900: #1e3a8a;

    /* Gray Scale */
    --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;

    /* Semantic Colors */
    --success-50: #ecfdf5;
    --success-100: #d1fae5;
    --success-500: #10b981;
    --success-600: #059669;
    --success-700: #047857;

    --warning-50: #fffbeb;
    --warning-100: #fef3c7;
    --warning-500: #f59e0b;
    --warning-600: #d97706;
    --warning-700: #b45309;

    --error-50: #fef2f2;
    --error-100: #fee2e2;
    --error-200: #fecaca;
    --error-500: #ef4444;
    --error-600: #dc2626;
    --error-700: #b91c1c;

    --info-50: #ecfeff;
    --info-100: #cffafe;
    --info-500: #06b6d4;
    --info-600: #0891b2;

    /* Base Colors */
    --white: #ffffff;
    --black: #000000;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition: 200ms ease;
    --transition-slow: 300ms ease;

    /* Layout */
    --sidebar-width: 280px;
    --header-height: 70px;
}

/* ============================================================
   Reset / Base Styles
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
    background-color: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    cursor: pointer;
    font-family: inherit;
}

img {
    max-width: 100%;
    height: auto;
}

/* ============================================================
   Layout
   ============================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--gray-900) 0%, var(--gray-800) 100%);
    color: var(--white);
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-slow);
}

.sidebar__brand {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar__logo {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-700) 100%);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.sidebar__title {
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar__subtitle {
    font-size: 0.75rem;
    color: var(--gray-400);
}

.sidebar__nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section__title {
    padding: 0.5rem 1.5rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--gray-500);
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    color: var(--gray-300);
    transition: all var(--transition);
    border-right: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--white);
}

.nav-item.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary-400);
    border-right-color: var(--primary-500);
}

.nav-item__icon {
    width: 20px;
    height: 20px;
    opacity: 0.8;
}

.nav-item__text {
    font-size: 0.9rem;
    font-weight: 500;
}

.nav-item__badge {
    margin-right: auto;
    background: var(--primary-500);
    color: var(--white);
    font-size: 0.7rem;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.sidebar__footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar__user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-lg);
}

.sidebar__avatar {
    width: 40px;
    height: 40px;
    background: var(--primary-600);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.sidebar__username {
    font-size: 0.9rem;
    font-weight: 500;
}

.sidebar__role {
    font-size: 0.75rem;
    color: var(--gray-400);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    height: var(--header-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header__search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--gray-100);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-lg);
    width: 300px;
}

.header__search input {
    border: none;
    background: transparent;
    flex: 1;
    font-size: 0.9rem;
    font-family: inherit;
}

.header__search input:focus {
    outline: none;
}

.header__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header__btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--gray-100);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-600);
    transition: all var(--transition);
    position: relative;
}

.header__btn:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.header__btn--badge::after {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    width: 8px;
    height: 8px;
    background: var(--error-500);
    border-radius: var(--radius-full);
    border: 2px solid var(--white);
}

/* Page Content */
.page-content {
    flex: 1;
    padding: 1.5rem;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-800);
}

.fiscal-year-badge {
    background: var(--primary-100);
    color: var(--primary-700);
    padding: 0.375rem 0.875rem;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
}

/* ============================================================
   Stats Cards
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
    transition: all var(--transition);
    border: 1px solid var(--gray-100);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card__icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card--primary .stat-card__icon {
    background: var(--primary-100);
    color: var(--primary-600);
}

.stat-card--success .stat-card__icon {
    background: var(--success-100);
    color: var(--success-600);
}

.stat-card--warning .stat-card__icon {
    background: var(--warning-100);
    color: var(--warning-600);
}

.stat-card--info .stat-card__icon {
    background: var(--info-100);
    color: var(--info-600);
}

.stat-card__content {
    display: flex;
    flex-direction: column;
}

.stat-card__value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1.2;
    direction: ltr;
    text-align: right;
}

.stat-card__label {
    font-size: 0.85rem;
    color: var(--gray-500);
}

/* ============================================================
   Balance Cards
   ============================================================ */
.balance-section {
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 1rem;
}

.balance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

.balance-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    position: relative;
    overflow: hidden;
}

.balance-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 4px;
}

.balance-card--bank::before {
    background: linear-gradient(90deg, var(--primary-500), var(--primary-600));
}

.balance-card--post::before {
    background: linear-gradient(90deg, var(--success-500), var(--success-600));
}

.balance-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.balance-card__title {
    font-size: 0.9rem;
    color: var(--gray-600);
}

.balance-card__badge {
    background: var(--gray-100);
    color: var(--gray-600);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 600;
}

.balance-card__amount {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 0.25rem;
    direction: ltr;
    text-align: right;
}

.balance-card__label {
    font-size: 0.8rem;
    color: var(--gray-500);
}

/* ============================================================
   Quick Actions
   ============================================================ */
.quick-actions {
    margin-bottom: 2rem;
}

.actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.action-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.action-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-200);
}

.action-card__icon {
    font-size: 2rem;
}

.action-card span {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-700);
}

/* ============================================================
   Cards & Panels
   ============================================================ */
.card {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
}

.card__header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card__title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.card__body {
    padding: 1.5rem;
}

.card__footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-100);
    background: var(--gray-50);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ============================================================
   Tables
   ============================================================ */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: right;
    border-bottom: 1px solid var(--gray-100);
}

.data-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.85rem;
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

.data-table td {
    font-size: 0.9rem;
    color: var(--gray-700);
}

/* ============================================================
   Forms
   ============================================================ */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--gray-700);
    font-size: 0.9rem;
}

.form-label.required::after {
    content: ' *';
    color: var(--error-500);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all var(--transition);
    background: var(--white);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input.is-invalid,
.form-select.is-invalid {
    border-color: var(--error-500);
}

.form-error {
    color: var(--error-600);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.form-hint {
    color: var(--gray-500);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
}

.btn--primary {
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
    color: var(--white);
}

.btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn--secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn--secondary:hover {
    background: var(--gray-200);
}

.btn--success {
    background: linear-gradient(135deg, var(--success-500) 0%, var(--success-600) 100%);
    color: var(--white);
}

.btn--danger {
    background: linear-gradient(135deg, var(--error-500) 0%, var(--error-600) 100%);
    color: var(--white);
}

.btn--outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}

.btn--outline:hover {
    background: var(--gray-100);
}

.btn--sm {
    padding: 0.5rem 0.875rem;
    font-size: 0.8rem;
}

.btn--lg {
    padding: 1rem 1.5rem;
    font-size: 1rem;
}

.btn--block {
    width: 100%;
}

/* ============================================================
   Badges
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.badge--primary {
    background: var(--primary-100);
    color: var(--primary-700);
}

.badge--success {
    background: var(--success-100);
    color: var(--success-700);
}

.badge--warning {
    background: var(--warning-100);
    color: var(--warning-700);
}

.badge--error {
    background: var(--error-100);
    color: var(--error-700);
}

.badge--gray {
    background: var(--gray-100);
    color: var(--gray-700);
}

/* ============================================================
   Alerts
   ============================================================ */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.alert--success {
    background: var(--success-50);
    border: 1px solid var(--success-200);
    color: var(--success-700);
}

.alert--error {
    background: var(--error-50);
    border: 1px solid var(--error-200);
    color: var(--error-700);
}

.alert--warning {
    background: var(--warning-50);
    border: 1px solid var(--warning-200);
    color: var(--warning-700);
}

.alert--info {
    background: var(--info-50);
    border: 1px solid var(--info-200);
    color: var(--info-700);
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform var(--transition);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal__header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal__title {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal__close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    font-size: 1.25rem;
    cursor: pointer;
}

.modal__close:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}

.modal__body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.modal__footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-100);
    display: flex;
    justify-content: flex-start;
    gap: 0.75rem;
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state__icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state__title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.empty-state__text {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* ============================================================
   Loading
   ============================================================ */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary-500);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-right: 0;
    }
}

@media (max-width: 768px) {
    .page-content {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   RTL Number Fix - إصلاح عرض الأرقام
   ============================================================ */
/* Ensure numbers and currency amounts display correctly in RTL */
.currency,
.amount,
.number,
[data-type="number"],
[data-type="currency"] {
    direction: ltr;
    display: inline-block;
    text-align: right;
}

/* Fix table numeric cells */
.data-table td:nth-child(n) {
    unicode-bidi: plaintext;
}

/* Specific number formatting */
input[type="number"],
input[type="tel"] {
    direction: ltr;
    text-align: right;
}