/* ===== المتغيرات والأساسيات ===== */
:root {
    --primary: #1a7a5a;
    --primary-dark: #145e45;
    --primary-light: #e8f5f0;
    --secondary: #f59e0b;
    --danger: #ef4444;
    --success: #22c55e;
    --info: #3b82f6;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --nav-height: 64px;
    --header-height: 56px;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    direction: rtl;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* === ترويسة الرئيسية === */
.home-welcome {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 14px;
    box-shadow: var(--shadow-lg);
}

.home-logo {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.home-title {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 2px;
}

.home-subtitle {
    font-size: 13px;
    opacity: 0.85;
}

/* ===== شاشة التحميل ===== */
#splash-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s;
}

#splash-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.splash-content {
    text-align: center;
    color: white;
}

.splash-content h1 {
    font-size: 32px;
    margin-bottom: 8px;
}

.splash-content p {
    font-size: 16px;
    opacity: 0.9;
}

.splash-loader {
    width: 40px;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    margin: 24px auto 0;
    overflow: hidden;
    position: relative;
}

.splash-loader::after {
    content: '';
    position: absolute;
    inset: 0;
    background: white;
    border-radius: 2px;
    animation: loading 1.2s ease-in-out infinite;
}

.splash-logo {
    width: 140px;
    height: 140px;
    border-radius: 28px;
    margin-bottom: 16px;
    animation: pulse 1.5s ease-in-out infinite;
    /* ظل خفيف للشعار */
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.3));
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes loading {
    0% { transform: translateX(100%); }
    50% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

/* ===== شاشة الدخول ===== */
#login-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #f0fdf4, #e8f5f0);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    background: white;
    border-radius: 20px;
    padding: 40px 30px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}
/* === شاشة الدخول === */
.login-logo {
    width: 120px;
    height: 120px;
    border-radius: 24px;
    margin-bottom: 16px;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));
}

.login-header h1 {
    color: var(--primary);
    font-size: 28px;
}

.login-header p {
    color: var(--gray-500);
    margin-top: 4px;
}

.login-hint {
    text-align: center;
    margin-top: 20px;
    color: var(--gray-500);
    background: var(--gray-50);
    padding: 10px;
    border-radius: var(--radius-sm);
}

/* ===== الشريط العلوي ===== */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

#current-page-title {
    font-size: 18px;
    font-weight: 700;
}

.user-badge {
    font-size: 13px;
    background: rgba(255,255,255,0.2);
    padding: 4px 10px;
    border-radius: 20px;
    margin-left: 8px;
}

.icon-btn {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 4px;
}
.top-bar-logo {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    margin-left: 10px;
    /* حافة بيضاء خفيفة */
    border: 1.5px solid rgba(255, 255, 255, 0.3);
}

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

/* ===== المحتوى الرئيسي ===== */
#main-content {
    padding-top: calc(var(--header-height) + 12px);
    padding-bottom: calc(var(--nav-height) + 20px);
    padding-left: 12px;
    padding-right: 12px;
    max-width: 800px;
    margin: 0 auto;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* ===== الإحصائيات ===== */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s;
    border-right: 4px solid var(--primary);
}

.stat-card:active {
    transform: scale(0.97);
}

.stat-donations { border-right-color: var(--success); }
.stat-cases { border-right-color: var(--info); }
.stat-spent { border-right-color: var(--secondary); }
.stat-balance { border-right-color: var(--primary); }

.stat-icon {
    font-size: 28px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--primary-dark);
}

.stat-label {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 2px;
}

/* ===== البطاقات والأقسام ===== */
.section-card {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.section-title {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--primary-dark);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.page-header h2 {
    font-size: 20px;
    color: var(--primary-dark);
}

/* ===== الأزرار ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

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

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
    padding: 12px;
}

.btn-icon-sm {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

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

/* === الشعار في النوافذ المنبثقة (اختياري) === */
.modal-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    margin-left: 10px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--gray-100);
}

/* === تنسيق عام للصور === */
img {
    -webkit-user-drag: none;
    user-select: none;
}

/* ===== النماذج ===== */
.form-group {
    margin-bottom: 14px;
}

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

.required {
    color: var(--danger);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.form-actions .btn {
    flex: 1;
}

/* ===== الفلاتر ===== */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.filter-bar input,
.filter-bar select {
    flex: 1;
    min-width: 120px;
    padding: 8px 12px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
}

.filter-bar input:focus,
.filter-bar select:focus {
    outline: none;
    border-color: var(--primary);
}

.summary-bar {
    background: var(--primary-light);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 10px;
    text-align: center;
    color: var(--primary-dark);
}

/* ===== قوائم السجلات ===== */
.records-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.record-card {
    background: white;
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    transition: transform 0.2s;
}

.record-card:active {
    transform: scale(0.99);
}

.record-info {
    flex: 1;
}

.record-name {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 4px;
}

.record-meta {
    font-size: 12px;
    color: var(--gray-500);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.record-amount {
    font-size: 18px;
    font-weight: 800;
    color: var(--primary);
    white-space: nowrap;
}

.record-actions {
    display: flex;
    gap: 6px;
    align-self: center;
}

/* ===== الشارات ===== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-new { background: #dbeafe; color: #1d4ed8; }
.badge-progress { background: #fef3c7; color: #92400e; }
.badge-done { background: #d1fae5; color: #065f46; }
.badge-urgent { background: #fee2e2; color: #991b1b; }
.badge-orphan { background: #e0e7ff; color: #3730a3; }
.badge-bills { background: #fef3c7; color: #92400e; }
.badge-clothes { background: #fce7f3; color: #9d174d; }

/* ===== النافذة المنبثقة ===== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    padding: 0;
}

.modal-content {
    background: white;
    border-radius: 20px 20px 0 0;
    padding: 20px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal-lg {
    max-height: 95vh;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--gray-100);
}

.modal-header h3 {
    color: var(--primary-dark);
    font-size: 18px;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--gray-100);
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== التنقل السفلي ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: white;
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
    z-index: 100;
}

.nav-item {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 12px;
    color: var(--gray-500);
    transition: all 0.2s;
    font-family: inherit;
    position: relative;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    width: 24px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 3px 3px;
}

.nav-icon {
    font-size: 22px;
}

.nav-label {
    font-size: 10px;
    font-weight: 600;
}

/* ===== رسائل التنبيه ===== */
.toast {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-900);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 14px;
    z-index: 2000;
    animation: toastIn 0.3s ease;
    text-align: center;
    max-width: 90%;
}

.toast.toast-success { background: var(--success); }
.toast.toast-error { background: var(--danger); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== الرسوم البيانية (CSS فقط) ===== */
.chart-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chart-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-bar-label {
    width: 90px;
    font-size: 12px;
    text-align: left;
    color: var(--gray-700);
    font-weight: 600;
}

.chart-bar-track {
    flex: 1;
    height: 24px;
    background: var(--gray-100);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.chart-bar-fill {
    height: 100%;
    border-radius: 12px;
    transition: width 0.6s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 8px;
    font-size: 11px;
    font-weight: 700;
    color: white;
    min-width: fit-content;
}

.bar-urgent { background: linear-gradient(90deg, #ef4444, #f87171); }
.bar-orphan { background: linear-gradient(90deg, #6366f1, #818cf8); }
.bar-bills { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.bar-clothes { background: linear-gradient(90deg, #ec4899, #f472b6); }

/* ===== نشاط آخر العمليات ===== */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.activity-icon {
    font-size: 20px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: white;
}

.activity-text {
    flex: 1;
}

.activity-date {
    font-size: 11px;
    color: var(--gray-500);
}

/* ===== التقارير ===== */
.report-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.report-controls .form-group {
    flex: 1;
    min-width: 120px;
    margin-bottom: 0;
}

.report-output {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

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

.report-section h4 {
    color: var(--primary-dark);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--primary-light);
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.report-table th {
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 8px;
    text-align: right;
    font-weight: 700;
}

.report-table td {
    padding: 8px;
    border-bottom: 1px solid var(--gray-200);
}

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

.report-total-row td {
    font-weight: 800;
    background: var(--gray-50);
    color: var(--primary-dark);
}

.report-summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.report-summary-item {
    background: var(--gray-50);
    padding: 12px;
    border-radius: var(--radius-sm);
    text-align: center;
}

.report-summary-item .value {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
}

.report-summary-item .label {
    font-size: 12px;
    color: var(--gray-500);
}

/* ===== التفاصيل ===== */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.detail-item {
    background: var(--gray-50);
    padding: 10px;
    border-radius: var(--radius-sm);
}

.detail-item .label {
    font-size: 11px;
    color: var(--gray-500);
}

.detail-item .value {
    font-weight: 700;
    margin-top: 2px;
}

.detail-full {
    grid-column: span 2;
}

/* ===== حالات الفراغ ===== */
.empty-msg {
    text-align: center;
    color: var(--gray-500);
    padding: 30px;
    font-size: 14px;
}

.hidden {
    display: none !important;
}

/* ===== تجاوب ===== */
@media (min-width: 600px) {
    .modal {
        align-items: center;
        padding: 20px;
    }
    
    .modal-content {
        border-radius: 20px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
/* ===== رابط العودة في شاشة الدخول ===== */
.back-to-landing {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 20px;
    padding: 8px 0;
    transition: all 0.2s;
}

.back-to-landing:hover {
    color: var(--primary-dark);
    gap: 10px;
}

.back-to-landing span {
    font-size: 18px;
    transition: transform 0.2s;
}

.back-to-landing:hover span {
    transform: translateX(4px);
}

/* ===== روابط أسفل شاشة الدخول ===== */
.login-links {
    text-align: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}

.login-links a {
    color: var(--primary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: color 0.2s;
}

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