@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap');

:root {
    --primary: #8e44ad;
    --secondary: #2c3e50;
    --sidebar-bg: #1a1a1a;
    --sidebar-hover: #2a2a2a;
    --bg-color: #cbd3db;      
    --card-bg: #e2e7ed;       
    --action-card-bg: #b6c2ce; 
    --input-bg: #f0f3f7;      
    --topbar-bg: #e2e7ed;     
    --danger: #e74c3c;
    --warning: #f39c12;
    --success: #2ecc71;
    --text-dark: #2c3e50;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Cairo', sans-serif; }

/* 1. صفحة تسجيل الدخول */
.login-body { background: linear-gradient(135deg, #1a1a1a 0%, #2c3e50 100%); height: 100vh; display: flex; justify-content: center; align-items: center; }
.login-container { background: var(--card-bg); padding: 40px; border-radius: 15px; box-shadow: 0 10px 25px rgba(0,0,0,0.3); width: 100%; max-width: 400px; text-align: center; }
.login-container h2 { color: var(--secondary); margin-bottom: 10px; }
.login-container h2 span { color: var(--primary); }
.login-container p { color: #555; margin-bottom: 30px; }
.input-group input { width: 100%; padding: 12px; margin-bottom: 15px; border: 1px solid #b0b9c2; border-radius: 8px; font-size: 16px; background: var(--input-bg); color: var(--text-dark); }
.input-group input:focus { outline: none; border-color: var(--primary); }
#loginBtn { width: 100%; padding: 12px; background: var(--primary); color: #fff; border: none; border-radius: 8px; font-size: 18px; cursor: pointer; transition: 0.3s; font-weight: 600; }
#loginBtn:hover { background: #6a1b9a; }
.error-msg { color: var(--danger); margin-top: 15px; font-weight: 600; }

/* 2. الهيكل العام (Dashboard Layout) */
.dashboard-body { background: var(--bg-color); display: flex; min-height: 100vh; }
.sidebar { width: 260px; background: var(--sidebar-bg); color: #fff; position: fixed; top: 0; right: 0; height: 100vh; overflow-y: auto; box-shadow: -2px 0 10px rgba(0,0,0,0.1); z-index: 1000; transition: transform 0.3s ease-in-out, width 0.3s ease-in-out; }
.sidebar-header { background: var(--primary); padding: 20px; text-align: center; }
.sidebar-header h2 { font-size: 24px; color: #fff; }
.sidebar-header h2 span { color: #f1c40f; }
.sidebar-menu { list-style: none; padding: 20px 0; }
.sidebar-menu .menu-header { padding: 10px 20px; font-size: 12px; color: #888; text-transform: uppercase; margin-top: 10px; }
.sidebar-menu li a { display: flex; align-items: center; padding: 12px 20px; color: #ccc; text-decoration: none; transition: 0.3s; font-size: 15px; }
.sidebar-menu li a i { margin-left: 10px; width: 20px; text-align: center; }
.sidebar-menu li a:hover, .sidebar-menu li.active a { background: var(--sidebar-hover); color: #fff; border-right: 3px solid var(--primary); }

.main-content { margin-right: 260px; width: calc(100% - 260px); display: flex; flex-direction: column; transition: margin-right 0.3s ease-in-out, width 0.3s ease-in-out; }

/* تأثير إخفاء القائمة الجانبية */
body.sidebar-collapsed .sidebar { transform: translateX(100%); }
body.sidebar-collapsed .main-content { margin-right: 0; width: 100%; }

.topbar { background: var(--topbar-bg); padding: 15px 80px 15px 30px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 10px rgba(0,0,0,0.05); position: relative; z-index: 999; }
.user-info span { font-weight: 600; color: var(--text-dark); font-size: 18px; }
.badge-pro { background: #000; color: #fff; padding: 5px 15px; border-radius: 20px; font-weight: bold; font-size: 14px; }

.toggle-sidebar-btn { background: none; border: none; font-size: 22px; color: var(--text-dark); cursor: pointer; padding: 5px 10px; display: flex; align-items: center; justify-content: center; transition: 0.3s; margin-left: 10px; }
.toggle-sidebar-btn:hover { color: var(--primary); }
body.dark-mode .toggle-sidebar-btn { color: #ecf0f1; }

/* 3. البطاقات الإحصائية (Cards) */
.dashboard-container { padding: 30px; }
.cards-grid { display: grid; gap: 20px; margin-bottom: 30px; }
.three-cols { grid-template-columns: repeat(3, 1fr); }
.two-cols { grid-template-columns: repeat(2, 1fr); }
.one-col { grid-template-columns: 1fr; }

.stat-card { background: var(--card-bg); padding: 25px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.04); text-align: center; border-top: 4px solid #b0b9c2; }
.stat-card h3 { font-size: 16px; color: #4a5a6a; margin-bottom: 15px; font-weight: 600; }
.stat-number { font-size: 36px; font-weight: 700; }
.border-danger { border-top-color: var(--danger); }
.border-warning { border-top-color: var(--warning); }
.border-success { border-top-color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }

.quick-actions { display: flex; gap: 20px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.btn { padding: 12px 25px; border: none; border-radius: 8px; font-size: 16px; font-weight: 600; cursor: pointer; transition: 0.3s; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #6a1b9a; }
.btn-secondary { background: var(--warning); color: #fff; }
.btn-secondary:hover { background: #d68910; }

/* تم إصلاح تعارض الألوان هنا (حذف !important) */
.action-card { background: var(--card-bg); color: var(--text-dark); border: 1px solid #a3b1bf; box-shadow: 0 4px 10px rgba(0,0,0,0.05); transition: all 0.3s ease; border-radius: 10px; padding: 20px 15px; text-align: center; text-decoration: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.action-card:hover { background: #d5dde5; transform: translateY(-3px); box-shadow: 0 8px 15px rgba(0,0,0,0.08); border-color: var(--primary); }
body.dark-mode .action-card { background: #1e1e1e; color: #ecf0f1; border-color: #333; }
body.dark-mode .action-card:hover { background: #2a2a2a; border-color: var(--primary); }

/* 4. الجداول والنماذج */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.search-bar { display: flex; gap: 10px; margin-bottom: 20px; }
.search-bar input, .search-bar select { padding: 10px 15px; border: 1px solid #b0b9c2; border-radius: 8px; font-size: 15px; background: var(--input-bg); color: var(--text-dark); }
.search-bar input { flex: 1; }
.table-container { background: var(--card-bg); border-radius: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.04); overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; text-align: right; }
.data-table th, .data-table td { padding: 15px; border-bottom: 1px solid #c4ced8; }
.data-table th { background: #d1d8e0; color: #3b4b5b; font-weight: 600; white-space: nowrap; }
.data-table tr:hover { background: #d5dde5; }
.row-expired { background-color: #f8d7da !important; }
.row-critical { background-color: #fff3cd !important; }
.data-table tr:hover { background-color: #d5dde5 !important; }
.status-badge { padding: 5px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; color: #fff; display: inline-block; white-space: nowrap; }
.status-Active { background: var(--success); }
.status-Critical { background: var(--warning); }
.status-Expired { background: var(--danger); }
.action-btn { padding: 6px 10px; border: none; border-radius: 6px; cursor: pointer; margin: 0 2px; color: #fff; display: inline-flex; justify-content: center; align-items: center; }
.btn-edit { background: #3498db; }
.btn-delete { background: var(--danger); }
.btn-whatsapp { background: #25D366; }

/* 5. النافذة المنبثقة */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: center; }
.modal-content { background: var(--card-bg); padding: 30px; border-radius: 12px; width: 100%; max-width: 500px; position: relative; max-height: 90vh; overflow-y: auto; }
.close { position: absolute; top: 15px; left: 20px; font-size: 28px; cursor: pointer; color: #777; }
.close:hover { color: var(--danger); }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 600; color: #3b4b5b; }
.form-group input, .form-group select { width: 100%; padding: 10px; border: 1px solid #b0b9c2; border-radius: 8px; font-size: 15px; background: var(--input-bg); color: var(--text-dark); }
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--primary); }

/* 6. التجاوب مع الهواتف */
@media (max-width: 768px) {
    .sidebar { transform: translateX(100%); width: 250px; }
    .sidebar.active { transform: translateX(0); }
    .main-content { margin-right: 0; width: 100%; }
    .topbar { padding: 10px 60px 10px 15px; flex-direction: column; gap: 10px; text-align: center; }
    .dashboard-container { padding: 15px; }
    .three-cols, .two-cols { grid-template-columns: 1fr; }
    .stat-number { font-size: 28px; }
    .stat-card { padding: 15px; }
    .btn { font-size: 14px; padding: 10px 15px; width: 100%; justify-content: center; }
    .quick-actions { flex-direction: column; }
    .data-table th, .data-table td { padding: 10px; font-size: 13px; }
    .action-btn { padding: 5px 8px; font-size: 12px; }
    .modal-content { padding: 20px; width: 95%; }
}

/* 7. وضع الليل (Dark Mode) */
body.dark-mode {
    --bg-color: #121212;
    --secondary: #ecf0f1;
    --sidebar-bg: #0a0a0a;
    --sidebar-hover: #1a1a1a;
    --text-dark: #ecf0f1;
}
body.dark-mode .dashboard-body { background: var(--bg-color); }
body.dark-mode .topbar { background: #1e1e1e; color: #fff; }
body.dark-mode .stat-card, body.dark-mode .table-container, body.dark-mode .tx-form-container, body.dark-mode .search-container, body.dark-mode .add-client-box, body.dark-mode .add-form-container, body.dark-mode .modal-content { background: #1e1e1e; color: #ecf0f1; box-shadow: 0 4px 15px rgba(0,0,0,0.3); }
body.dark-mode .data-table th { background: #2c2c2c; color: #bdc3c7; }
body.dark-mode .data-table td { border-bottom: 1px solid #333; }
body.dark-mode .data-table tr:hover { background: #2a2a2a !important; }
body.dark-mode .form-group input, body.dark-mode .form-group textarea, body.dark-mode .search-container input, body.dark-mode .search-bar input { background: #2c2c2c !important; color: #fff !important; border: 1px solid #444 !important; }
body.dark-mode .form-header h2, body.dark-mode .history-title, body.dark-mode .page-header h2, body.dark-mode h2, body.dark-mode h3 { color: #ecf0f1; }
body.dark-mode .text-dark { color: #ecf0f1 !important; }
.theme-toggle-btn { background: #f1c40f; color: #333; border: none; border-radius: 50%; width: 40px; height: 40px; cursor: pointer; font-size: 18px; display: flex; align-items: center; justify-content: center; transition: 0.3s; margin-left: 10px; }
body.dark-mode .theme-toggle-btn { background: #34495e; color: #f1c40f; }
body.dark-mode .row-expired { background-color: #3b1f1f !important; }
body.dark-mode .row-expired td { color: #ff8a80 !important; }
body.dark-mode .row-critical { background-color: #3b2f1f !important; }
body.dark-mode .row-critical td { color: #ffcc80 !important; }
body.dark-mode .data-table tr:hover { background: #2a2a2a !important; }
body.dark-mode .data-table tr:hover td { color: #ecf0f1 !important; }
body.dark-mode .status-Expired { background: #c0392b; }
body.dark-mode .status-Critical { background: #d35400; }
body.dark-mode .status-Active { background: #27ae60; }

/* 9. التنبيهات */
#notifDropdown { background: var(--card-bg) !important; border: 1px solid #b0b9c2; color: var(--text-dark); }
body.dark-mode #notifDropdown { background: #1e1e1e !important; border: 1px solid #333; color: #ecf0f1; }
body.dark-mode #notifDropdown a { color: #ecf0f1 !important; border-bottom: 1px solid #333 !important; }
body.dark-mode #notifDropdown a:hover { background: #2a2a2a !important; }
#bellBtn { color: var(--text-dark) !important; transition: transform 0.2s; }
#bellBtn:hover { transform: scale(1.1); }
body.dark-mode #bellBtn { color: #ecf0f1 !important; }

/* 10. القوائم المنسدلة في الوضع الليلي */
body.dark-mode select, body.dark-mode .form-group select, body.dark-mode .search-bar select, body.dark-mode .search-container select, body.dark-mode #filterPlace, body.dark-mode #filterType { background-color: #2c2c2c !important; color: #ffffff !important; border: 1px solid #555 !important; -webkit-appearance: none !important; -moz-appearance: none !important; appearance: none !important; background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") !important; background-repeat: no-repeat !important; background-position: left 10px center !important; background-size: 15px !important; padding-left: 30px !important; }
body.dark-mode select option, body.dark-mode #filterPlace option, body.dark-mode #filterType option { background-color: #2c2c2c !important; color: #ffffff !important; }

/* 11. إصلاح الصف السفلي */
body.dark-mode .data-table tfoot, body.dark-mode .data-table tfoot tr, body.dark-mode .data-table tfoot td, body.dark-mode .data-table tfoot th { background-color: #1e1e1e !important; color: #ecf0f1 !important; border-color: #333 !important; font-weight: 600; }
body.dark-mode .data-table tfoot td { border-top: 2px solid #444 !important; }
body.dark-mode .data-table tbody tr:last-child { background-color: #1e1e1e !important; color: #ecf0f1 !important; }
body.dark-mode .data-table tbody tr:last-child td { color: #ecf0f1 !important; border-top: 2px solid #444 !important; }

/* 12. زر تسجيل الخروج المميز للموبايل */
.mobile-logout-btn { display: none; background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%); color: #fff; border: none; width: 40px; height: 40px; border-radius: 50%; font-size: 16px; cursor: pointer; align-items: center; justify-content: center; margin-right: 10px; box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4); transition: all 0.3s ease; }
.mobile-logout-btn:hover, .mobile-logout-btn:active { transform: scale(0.95); box-shadow: 0 2px 8px rgba(231, 76, 60, 0.6); }
@media (max-width: 768px) { .mobile-logout-btn { display: flex; } }

/* 13. شاشة التحميل */
#splash-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #2c3e50; display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 9999; transition: opacity 0.8s ease, visibility 0.8s ease; }
#splash-screen.hidden { opacity: 0; visibility: hidden; }
.splash-logo { font-size: 40px; font-weight: 700; color: #fff; margin-bottom: 20px; letter-spacing: 2px; }
.splash-logo span { color: #f1c40f; }
.splash-loader { width: 50px; height: 50px; border: 5px solid rgba(255, 255, 255, 0.2); border-top-color: #8e44ad; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* إخفاء حقل المبلغ المتبقي في نافذة المعاملة السريعة بلوحة التحكم */
#quickTxRemaining { display: none !important; }
#quickTxRemaining + label { display: none !important; }