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

body {
    font-family: 'Tahoma', 'Segoe UI', sans-serif;
    background: #f4f6f9;
    color: #222;
    direction: rtl;
}

/* ---------- صفحات الدخول ---------- */
.auth-page {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3c72, #2a5298);
}
.auth-box {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    width: 360px;
    box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.auth-box h2 { margin-bottom: 20px; text-align: center; color: #1e3c72; }
.auth-box label { display: block; margin: 12px 0 4px; font-size: 14px; }
.auth-box input {
    width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px;
}
.auth-box button {
    width: 100%; margin-top: 20px; padding: 12px; border: none; border-radius: 6px;
    background: #1e3c72; color: #fff; font-size: 15px; cursor: pointer;
}
.auth-box button:hover { background: #16305c; }
.alert { background: #fdecea; color: #b3261e; padding: 10px; border-radius: 6px; margin-bottom: 10px; font-size: 14px; }
.alert-error { background: #fdecea; color: #b3261e; }

/* ---------- الداشبورد ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 230px; background: #1e293b; color: #fff; padding: 20px 0; flex-shrink: 0;
}
.sidebar h3 { text-align: center; margin-bottom: 20px; font-size: 18px; color: #93c5fd; }
.sidebar a {
    display: block; padding: 12px 20px; color: #cbd5e1; text-decoration: none; font-size: 14px;
}
.sidebar a:hover, .sidebar a.active { background: #334155; color: #fff; }
.sidebar .logout { margin-top: 20px; border-top: 1px solid #334155; color: #f87171; }

.main-content { flex: 1; padding: 25px; min-width: 0; }

.topbar {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}
.topbar h1 { font-size: 20px; color: #1e293b; }

/* زر فتح القائمة (يظهر بالموبايل بس) */
.menu-toggle-btn {
    display: none; background: #1e293b; color: #fff; border: none; border-radius: 8px;
    width: 40px; height: 40px; font-size: 18px; cursor: pointer; flex-shrink: 0;
}
.sidebar-overlay { display: none; }

@media (max-width: 800px) {
    .app-shell { position: relative; overflow-x: hidden; }
    .sidebar {
        position: fixed; top: 0; right: 0; height: 100vh; width: 250px; z-index: 1001;
        transform: translateX(100%); transition: transform .25s ease; overflow-y: auto;
        box-shadow: -4px 0 20px rgba(0,0,0,.3);
    }
    .sidebar.sidebar-open { transform: translateX(0); }
    .menu-toggle-btn { display: inline-flex; align-items: center; justify-content: center; }
    .main-content { padding: 16px; width: 100%; }
    .topbar h1 { font-size: 17px; }
    .sidebar-overlay.active {
        display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000;
    }
}

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 25px; }
.card {
    background: #fff; padding: 18px; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.06);
    border-right: 4px solid #1e3c72;
}
.card .label { font-size: 13px; color: #64748b; margin-bottom: 6px; }
.card .value { font-size: 22px; font-weight: bold; color: #1e293b; }
.card.positive { border-color: #16a34a; }
.card.negative { border-color: #dc2626; }
.card.warning { border-color: #d97706; }

/* ألوان مخصصة لكل بنك */
.card.bank-blue   { border-color: #2563eb; background: linear-gradient(0deg, #eff6ff, #ffffff); }
.card.bank-red    { border-color: #dc2626; background: linear-gradient(0deg, #fef2f2, #ffffff); }
.card.bank-yellow { border-color: #d97706; background: linear-gradient(0deg, #fffbeb, #ffffff); }
.card.bank-green  { border-color: #16a34a; background: linear-gradient(0deg, #f0fdf4, #ffffff); }
.card.bank-purple { border-color: #7c3aed; background: linear-gradient(0deg, #f5f3ff, #ffffff); }

table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; }
table th, table td { padding: 10px 12px; text-align: right; font-size: 14px; border-bottom: 1px solid #eee; white-space: nowrap; }
table th { background: #f1f5f9; color: #334155; }
table tr:hover { background: #f8fafc; }

/* ---------- منطقة سحب الجداول - تجربة متل تطبيق حقيقي ---------- */
.table-scroll {
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* سكرول ناعم على آيفون */
    scrollbar-width: thin;
    border-radius: 8px;
}
.table-scroll::-webkit-scrollbar { height: 6px; }
.table-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
.table-scroll::-webkit-scrollbar-track { background: transparent; }
.table-scroll table { margin: 0; }

/* ظل خفيف على الحافة يلي في محتوى مخفي ورا، بيختفي أوتوماتيك لما توصل للنهاية */
.table-scroll::before, .table-scroll::after {
    content: ''; position: absolute; top: 0; bottom: 0; width: 24px;
    pointer-events: none; z-index: 2; opacity: 0; transition: opacity .2s ease;
}
.table-scroll::before {
    right: 0; background: linear-gradient(to left, rgba(0,0,0,.10), transparent);
}
.table-scroll::after {
    left: 0; background: linear-gradient(to right, rgba(0,0,0,.10), transparent);
}
.table-scroll.has-more-right::before { opacity: 1; }
.table-scroll.has-more-left::after { opacity: 1; }

.panel { background: #fff; border-radius: 10px; padding: 20px; margin-bottom: 20px; box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.panel h2 { font-size: 16px; margin-bottom: 15px; color: #1e293b; }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.form-row > div { flex: 1; min-width: 150px; }
.form-row label { display: block; font-size: 13px; margin-bottom: 4px; color: #475569; }
.form-row input, .form-row select, .form-row textarea {
    width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px;
}
.btn {
    background: #1e3c72; color: #fff; border: none; padding: 10px 20px; border-radius: 6px;
    cursor: pointer; font-size: 14px;
}
.btn:hover { background: #16305c; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
a.btn { display: inline-block; text-decoration: none; }
.btn-active { background: #16305c; box-shadow: inset 0 0 0 2px #fff3; }
.btn-icon { background: none; border: none; cursor: pointer; font-size: 16px; }

.badge { padding: 3px 8px; border-radius: 10px; font-size: 12px; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef9c3; color: #854d0e; }

/* ---------- الشات بوت ---------- */
.chat-widget {
    position: fixed; bottom: 20px; left: 20px; width: 350px; max-width: calc(100vw - 40px); z-index: 999;
    box-shadow: 0 10px 30px rgba(0,0,0,.2); border-radius: 12px; overflow: hidden;
    background: #fff; display: flex; flex-direction: column; max-height: 500px;
}
.chat-header {
    background: #1e3c72; color: #fff; padding: 12px 15px; font-size: 14px;
    display: flex; justify-content: space-between; align-items: center; cursor: pointer;
}
.chat-body { flex: 1; overflow-y: auto; padding: 12px; font-size: 13px; max-height: 320px; }
.chat-msg { margin-bottom: 10px; padding: 8px 12px; border-radius: 8px; max-width: 85%; }
.chat-msg.user { background: #1e3c72; color: #fff; margin-right: auto; margin-left: 0; text-align: left; }
.chat-msg.bot { background: #f1f5f9; color: #222; }
.chat-input-row { display: flex; border-top: 1px solid #eee; }
.chat-input-row input {
    flex: 1; border: none; padding: 10px; font-size: 13px; outline: none;
}
.chat-input-row button {
    background: #1e3c72; color: #fff; border: none; padding: 0 15px; cursor: pointer;
}
.chat-mic-btn {
    background: #f1f5f9 !important; color: #1e3c72 !important; font-size: 16px; padding: 0 12px !important;
    border-right: 1px solid #eee; border-left: 1px solid #eee; transition: background .2s;
}
.chat-mic-btn.recording {
    background: #fee2e2 !important; color: #dc2626 !important;
    animation: mic-pulse 1s infinite;
}
@keyframes mic-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}
.chat-quick-replies { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; border-top: 1px solid #eee; }
.chat-quick-replies button {
    background: #eef2ff; color: #1e3c72; border: 1px solid #dbe3ff; border-radius: 16px;
    padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.chat-quick-replies button:hover { background: #dbe3ff; }
.chat-confirm-row { display: flex; gap: 8px; margin: -4px 0 10px 0; }
.chat-confirm-row button {
    border: none; border-radius: 6px; padding: 6px 14px; font-size: 13px; cursor: pointer;
}
.chat-confirm-row .chat-confirm-yes { background: #16a34a; color: #fff; }
.chat-confirm-row .chat-confirm-no { background: #e2e8f0; color: #222; }
.chat-collapsed .chat-body, .chat-collapsed .chat-input-row, .chat-collapsed .chat-quick-replies { display: none; }

/* ---------- الشات بوت على الموبايل ---------- */
@media (max-width: 600px) {
    .chat-widget {
        left: 10px; right: 10px; bottom: 10px; width: auto;
        max-height: 70vh; border-radius: 14px;
    }
    .chat-header { padding: 14px 15px; font-size: 15px; }
    .chat-body { max-height: 45vh; font-size: 14px; }
    .chat-input-row input { font-size: 15px; padding: 12px; }
    .chat-input-row button, .chat-mic-btn { padding: 0 14px; font-size: 15px; }
    .chat-msg { max-width: 90%; }
}

/* أزرار تصدير التقارير */
.btn-export {
    display: inline-flex; align-items: center; gap: 6px;
    background: #16a34a; color: #fff; border: none; padding: 10px 16px;
    border-radius: 6px; cursor: pointer; text-decoration: none; font-size: 14px;
}
.btn-export:hover { background: #15803d; }
.panel form button[type="submit"] {
    background: #1e3c72; color: #fff; border: none; padding: 10px 16px;
    border-radius: 6px; cursor: pointer; font-size: 14px;
}
.alert-success { background: #eafaf1; color: #14532d; }

/* ---------- نافذة التعديل المنبثقة ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,.55);
    display: none; align-items: center; justify-content: center;
    z-index: 2000; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: #fff; border-radius: 12px; padding: 22px; width: 100%; max-width: 480px;
    max-height: 90vh; overflow-y: auto; box-shadow: 0 15px 40px rgba(0,0,0,.25);
}
.modal-box h3 { margin-bottom: 16px; color: #1e293b; font-size: 17px; }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; }

/* ---------- أزرار تعديل/حذف بجداول الحركات ---------- */
.row-actions { display: flex; gap: 6px; white-space: nowrap; }
.btn-edit { background: #0f766e; }
.btn-edit:hover { background: #0d5f59; }
.btn-delete { background: #dc2626; }
.btn-delete:hover { background: #b91c1c; }
.btn-cancel { background: #94a3b8; }
.btn-cancel:hover { background: #64748b; }

/* ---------- زر تبديل الوضع الليلي/النهاري ---------- */
.topbar-right { display: flex; align-items: center; gap: 12px; }
.theme-toggle-btn {
    background: #e2e8f0; border: none; border-radius: 50%; width: 38px; height: 38px;
    font-size: 17px; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background .2s;
}
.theme-toggle-btn:hover { background: #cbd5e1; }

/* =====================================================================
   الوضع الليلي (Dark Mode)
   ===================================================================== */
body.dark-mode { background: #0f172a; color: #e2e8f0; }

body.dark-mode .sidebar { background: #0b1220; }
body.dark-mode .sidebar a { color: #94a3b8; }
body.dark-mode .sidebar a:hover, body.dark-mode .sidebar a.active { background: #1e293b; color: #fff; }
body.dark-mode .sidebar .logout { border-top-color: #1e293b; }

body.dark-mode .topbar h1 { color: #e2e8f0; }
body.dark-mode .theme-toggle-btn { background: #1e293b; color: #fbbf24; }
body.dark-mode .theme-toggle-btn:hover { background: #334155; }

body.dark-mode .card { background: #1e293b; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
body.dark-mode .card .label { color: #94a3b8; }
body.dark-mode .card .value { color: #f1f5f9; }
body.dark-mode .card.bank-blue   { background: linear-gradient(0deg, #172554, #1e293b); }
body.dark-mode .card.bank-red    { background: linear-gradient(0deg, #450a0a, #1e293b); }
body.dark-mode .card.bank-yellow { background: linear-gradient(0deg, #422006, #1e293b); }
body.dark-mode .card.bank-green  { background: linear-gradient(0deg, #052e16, #1e293b); }
body.dark-mode .card.bank-purple { background: linear-gradient(0deg, #2e1065, #1e293b); }

body.dark-mode .panel { background: #1e293b; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
body.dark-mode .panel h2 { color: #f1f5f9; }

body.dark-mode table { color: #e2e8f0; background: #1e293b; }
body.dark-mode table th { background: #0f172a; color: #94a3b8; }
body.dark-mode table td, body.dark-mode table th { border-color: #334155; }
body.dark-mode table tr:hover { background: #263449; }

body.dark-mode .form-row label { color: #94a3b8; }
body.dark-mode .form-row input,
body.dark-mode .form-row select,
body.dark-mode .form-row textarea {
    background: #0f172a; color: #e2e8f0; border-color: #334155;
}

body.dark-mode .modal-box { background: #1e293b; }
body.dark-mode .modal-box h3 { color: #f1f5f9; }

body.dark-mode .chat-widget { background: #1e293b; box-shadow: 0 4px 20px rgba(0,0,0,.4); }
body.dark-mode .chat-body { background: #1e293b; }
body.dark-mode .chat-msg.bot { background: #334155; color: #e2e8f0; }
body.dark-mode .chat-input-row { border-top-color: #334155; }
body.dark-mode .chat-input-row input { background: #0f172a; color: #e2e8f0; border-color: #334155; }
body.dark-mode .chat-quick-replies { border-top-color: #334155; }
body.dark-mode .chat-quick-replies button { background: #334155; color: #e2e8f0; }
body.dark-mode .chat-quick-replies button:hover { background: #475569; }

body.dark-mode .auth-box { background: #1e293b; }
body.dark-mode .auth-box h2 { color: #93c5fd; }
body.dark-mode .auth-box label { color: #94a3b8; }
body.dark-mode .auth-box input { background: #0f172a; color: #e2e8f0; border-color: #334155; }
