/* ═══════════════════════════════════════════════════════
   صندوق عائلة الخالدي الخيري - Alkhalidy.com
   Main Stylesheet
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700;800;900&display=swap');

:root {
    --primary: #1B5E20;
    --primary-light: #2E7D32;
    --primary-dark: #0D3B13;
    --accent: #C8A951;
    --accent-light: #D4BC6A;
    --accent-dark: #A88A35;
    --success: #2E7D32;
    --warning: #F57C00;
    --danger: #C62828;
    --info: #0277BD;
    --bg: #F5F5F0;
    --bg-card: #FFFFFF;
    --text: #1A1A1A;
    --text-muted: #6B6B6B;
    --border: #E0DDD5;
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(27,94,32,0.08);
    --shadow-lg: 0 8px 30px rgba(27,94,32,0.12);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    line-height: 1.7;
    min-height: 100vh;
}

/* ─── Login Page ─── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    position: relative;
    overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(200,169,81,0.15) 0%, transparent 70%);
    top: -200px; left: -200px;
}

.login-wrapper::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(200,169,81,0.1) 0%, transparent 70%);
    bottom: -100px; right: -100px;
}

.login-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 48px 40px;
    width: 420px;
    max-width: 95vw;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
    animation: slideUp 0.6s ease-out;
}

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

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .icon {
    width: 72px; height: 72px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    box-shadow: 0 4px 15px rgba(27,94,32,0.3);
}

.login-logo .icon svg {
    width: 36px; height: 36px;
    fill: white;
}

.login-logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 4px;
}

.login-logo p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ─── Forms ─── */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-family: 'Tajawal', sans-serif;
    font-size: 1rem;
    transition: var(--transition);
    background: var(--bg);
    direction: rtl;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(27,94,32,0.1);
}

.form-control.is-invalid {
    border-color: var(--danger);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B6B6B' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    padding-left: 36px;
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    box-shadow: 0 4px 12px rgba(27,94,32,0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(27,94,32,0.4);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: var(--primary-dark);
}

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

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

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

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
    border-radius: 8px;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ─── Layout ─── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary-dark), var(--primary));
    color: white;
    position: fixed;
    top: 0; right: 0;
    height: 100vh;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    box-shadow: -4px 0 20px rgba(0,0,0,0.1);
}

.sidebar-brand {
    padding: 28px 20px 22px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    text-align: center;
}

.sidebar-brand h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: 5px;
    color: #fff;
    margin: 0 0 6px;
    direction: ltr;
}

.sidebar-brand .logo-t {
    display: inline-block;
    color: var(--primary-dark);
    background: #fff;
    width: 32px;
    height: 32px;
    line-height: 32px;
    text-align: center;
    border-radius: 8px;
    font-size: 1.3rem;
    font-weight: 900;
    letter-spacing: 0;
    margin-left: 2px;
    vertical-align: middle;
    box-shadow: 0 2px 8px rgba(255,255,255,0.2);
}

.sidebar-brand small {
    font-size: 0.72rem;
    opacity: 0.55;
    display: block;
    font-family: 'Tajawal', sans-serif;
    letter-spacing: 0;
}

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

.nav-section {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.5;
    padding: 16px 12px 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border-radius: 10px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
}

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

.nav-link.active {
    background: rgba(200,169,81,0.2);
    color: var(--accent);
    font-weight: 700;
}

.nav-link svg {
    width: 20px; height: 20px;
    opacity: 0.8;
    flex-shrink: 0;
}

.nav-link.active svg { opacity: 1; }

.nav-badge {
    margin-right: auto;
    margin-left: 0;
    background: var(--danger);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.8rem;
}

.sidebar-footer a {
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    transition: var(--transition);
}

.sidebar-footer a:hover { color: white; }

/* ─── Main Content ─── */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    min-height: 100vh;
}

.top-bar {
    background: var(--bg-card);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(10px);
}

.top-bar h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

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

.notification-bell {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 10px;
    transition: var(--transition);
}

.notification-bell:hover { background: var(--bg); }

.notification-bell .count {
    position: absolute;
    top: 2px; left: 2px;
    background: var(--danger);
    color: white;
    width: 18px; height: 18px;
    border-radius: 50%;
    font-size: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.page-content {
    padding: 32px;
}

/* ─── Cards ─── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.card-body {
    padding: 24px;
}

/* ─── Stats Cards ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: var(--transition);
}

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

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.green { background: rgba(46,125,50,0.1); color: var(--success); }
.stat-icon.gold { background: rgba(200,169,81,0.15); color: var(--accent-dark); }
.stat-icon.red { background: rgba(198,40,40,0.1); color: var(--danger); }
.stat-icon.blue { background: rgba(2,119,189,0.1); color: var(--info); }

.stat-icon svg { width: 24px; height: 24px; }

.stat-info h4 {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-info .value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
}

.stat-info .sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ─── Tables ─── */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th {
    background: var(--bg);
    padding: 12px 16px;
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-align: right;
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
}

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

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

.data-table tbody tr:hover {
    background: rgba(27,94,32,0.02);
}

.data-table .actions {
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

/* ─── Badges ─── */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}

.bg-success { background: rgba(46,125,50,0.12); color: #1B5E20; }
.bg-danger { background: rgba(198,40,40,0.12); color: #C62828; }
.bg-warning { background: rgba(245,124,0,0.12); color: #E65100; }
.bg-info { background: rgba(2,119,189,0.12); color: #01579B; }
.bg-primary { background: rgba(27,94,32,0.12); color: #1B5E20; }
.bg-secondary { background: rgba(0,0,0,0.08); color: #555; }

/* ─── Alerts ─── */
.alert {
    padding: 14px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideDown 0.3s ease-out;
}

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

.alert-success { background: rgba(46,125,50,0.1); color: #1B5E20; border: 1px solid rgba(46,125,50,0.2); }
.alert-danger { background: rgba(198,40,40,0.1); color: #C62828; border: 1px solid rgba(198,40,40,0.2); }
.alert-warning { background: rgba(245,124,0,0.1); color: #E65100; border: 1px solid rgba(245,124,0,0.2); }
.alert-info { background: rgba(2,119,189,0.1); color: #01579B; border: 1px solid rgba(2,119,189,0.2); }

/* ─── Modal ─── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-overlay.show { display: flex; }

.modal-box {
    background: white;
    border-radius: 16px;
    width: 500px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

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

.modal-header h3 { font-weight: 700; }

.modal-close {
    background: none; border: none;
    font-size: 1.5rem; cursor: pointer;
    color: var(--text-muted);
    padding: 4px 8px; border-radius: 8px;
}

.modal-close:hover { background: var(--bg); }

.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: flex-start;
}

/* ─── Empty State ─── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 64px; height: 64px;
    opacity: 0.3;
    margin-bottom: 16px;
}

.empty-state h4 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text);
}

/* ─── Pagination ─── */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-top: 24px;
    list-style: none;
}

.pagination a, .pagination span {
    padding: 8px 14px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.85rem;
    color: var(--text);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .active { background: var(--primary); color: white; border-color: var(--primary); }

/* ─── Mobile Toggle ─── */
.mobile-toggle {
    display: none;
    background: none; border: none;
    cursor: pointer; padding: 8px;
}

.mobile-toggle svg { width: 24px; height: 24px; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
    }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-right: 0; }
    .mobile-toggle { display: block; }
    .page-content { padding: 16px; }
    .top-bar { padding: 12px 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .stat-card { padding: 16px; }
    .stat-info .value { font-size: 1.2rem; }
    .login-card { padding: 32px 24px; }
    .modal-box { margin: 16px; }
}

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

/* ─── WhatsApp Button ─── */
.btn-whatsapp {
    background: #25D366;
    color: #fff !important;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border-radius: var(--radius);
    padding: 5px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .2s, transform .15s;
}
.btn-whatsapp:hover {
    background: #128C7E;
    color: #fff !important;
    transform: translateY(-1px);
}

/* ─── Paid-By Badge ─── */
.badge-paidby {
    display: inline-block;
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffcc80;
    border-radius: 20px;
    padding: 2px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

/* ─── Print Header (screen: hidden / print: visible) ─── */
.print-header { display: none; }

/* ─── Print Styles ─── */
@media print {
    .sidebar,
    .topbar,
    .top-bar,
    .mobile-toggle,
    .no-print,
    .actions,
    .modal-overlay,
    .alert { display: none !important; }

    body {
        background: #fff !important;
        font-size: 11pt;
        color: #000 !important;
        direction: rtl;
    }

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

    .card {
        box-shadow: none !important;
        border: 1px solid #bbb !important;
        margin-bottom: 14px !important;
        break-inside: avoid;
    }

    .card-header {
        background: #efefef !important;
        color: #000 !important;
        padding: 8px 14px !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .data-table { font-size: 9.5pt; width: 100% !important; }

    .data-table th {
        background: #e0e0e0 !important;
        color: #000 !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .data-table tr { break-inside: avoid; }
    .table-responsive { overflow: visible !important; }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px !important;
    }

    .stat-card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        padding: 10px !important;
    }

    .stat-icon { display: none !important; }

    .print-header {
        display: block !important;
        text-align: center;
        margin-bottom: 20px;
        padding-bottom: 12px;
        border-bottom: 2px solid #1a5c3a;
    }

    .print-header h2 {
        margin: 0 0 4px;
        font-size: 15pt;
        color: #1a5c3a;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .print-header p { margin: 0; font-size: 10pt; color: #555; }

    .badge-paidby {
        background: transparent !important;
        border-color: #999 !important;
        color: #333 !important;
    }
}

/* ─── Utility ─── */
.text-center { text-align: center; }
.text-start { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.fw-bold { font-weight: 700; }
.mb-0 { margin-bottom: 0; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.d-flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
