:root {
    --bg-color: #f1f5f9;
    --card-bg: #ffffff;
    --text-color: #0f172a;
    --text-muted: #64748b;
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --border-color: #e2e8f0;
    --sidebar-bg: #0f172a;
    --sidebar-text: #f8fafc;
    --shadow: 0 1px 3px rgba(0,0,0,0.05);
}

@media (prefers-color-scheme: dark) {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --primary-color: #3b82f6;
    --primary-hover: #60a5fa;
    --border-color: #334155;
    --sidebar-bg: #020617;
    --sidebar-text: #f8fafc;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }

body { background-color: var(--bg-color); color: var(--text-color); direction: rtl; display: flex; min-height: 100vh; transition: background 0.3s, color 0.3s; }

/* ===== تسجيل الدخول ===== */
.login-container { display: flex; justify-content: center; align-items: center; min-height: 100vh; width: 100%; padding: 20px; }
.login-box { background: var(--card-bg); padding: 40px 30px; border-radius: 16px; box-shadow: 0 10px 25px rgba(0,0,0,0.08); width: 100%; max-width: 400px; border: 1px solid var(--border-color); transition: background 0.3s; }
.login-box h2 { text-align: center; margin-bottom: 20px; color: var(--primary-color); }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 14px; }
.form-group input { width: 100%; padding: 12px; border: 1px solid var(--border-color); background: var(--bg-color); color: var(--text-color); border-radius: 8px; font-size: 16px; transition: 0.2s; outline: none; }
.form-group input:focus { border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.btn { display: inline-block; width: 100%; padding: 14px; background: var(--primary-color); color: white; border: none; border-radius: 8px; font-size: 16px; font-weight: bold; cursor: pointer; transition: background 0.3s; }
.btn:hover { background: var(--primary-hover); }
.alert { padding: 12px; background: #fee2e2; color: #dc2626; border-radius: 8px; margin-bottom: 18px; font-size: 14px; text-align: center; border: 1px solid #fecaca; }

/* ===== السايدبار ===== */
.sidebar { width: 250px; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; transition: right 0.3s ease, transform 0.3s ease; height: 100vh; position: sticky; top: 0; overflow-y: auto; flex-shrink: 0; z-index: 100; }
.sidebar-header { padding: 24px 20px; font-size: 22px; font-weight: bold; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-header span { margin-left: 8px; }
.sidebar-menu { list-style: none; padding: 16px 0; flex: 1; }
.sidebar-menu li { margin: 2px 10px; }
.sidebar-menu li a { display: block; padding: 12px 16px; border-radius: 10px; color: var(--sidebar-text); text-decoration: none; transition: 0.2s; font-size: 15px; }
.sidebar-menu li a:hover { background: rgba(255,255,255,0.08); }
.sidebar-menu li a:active { background: rgba(255,255,255,0.15); }

/* ===== المحتوى الرئيسي ===== */
.main-content { flex: 1; display: flex; flex-direction: column; min-height: 100vh; width: calc(100% - 250px); }
.topbar { background: var(--card-bg); padding: 16px 24px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); transition: background 0.3s; flex-shrink: 0; }
.content-area { padding: 24px; flex: 1; overflow-y: auto; }
.content-area.inbox-content { min-height: 0; overflow: hidden; }


/* ===== البطاقات (Cards) ===== */
.card { background: var(--card-bg); padding: 20px; border-radius: 12px; border: 1px solid var(--border-color); box-shadow: var(--shadow); transition: background 0.3s, border-color 0.3s; }
.card h2 { margin-top: 0; margin-bottom: 16px; font-size: 20px; }
.card h3 { margin-top: 0; margin-bottom: 12px; font-size: 18px; }
.card h4 { margin: 0; }

/* ===== القائمة ===== */
.menu-toggle { display: none; background: none; border: none; font-size: 26px; color: var(--text-color); cursor: pointer; padding: 4px 8px; }

/* ===== الاستجابة للهواتف (Mobile First) ===== */
@media (max-width: 768px) {
    .sidebar { position: fixed; top: 0; right: -280px; width: 280px; height: 100vh; z-index: 1000; box-shadow: 2px 0 15px rgba(0,0,0,0.2); transition: right 0.3s ease; }
    .sidebar.active { right: 0; }
    .main-content { width: 100%; }
    .menu-toggle { display: block !important; }
    .topbar { padding: 12px 16px; }
    .content-area { padding: 16px; }
    .content-area.inbox-content { padding: 0; min-height: 0; overflow: hidden; }
    .login-box { padding: 30px 20px; }
}

/* تحسين اللمس على الهواتف */
@media (max-width: 480px) {
    .sidebar-menu li a { padding: 14px 16px; font-size: 16px; }
    .btn { padding: 16px; font-size: 18px; }
    .form-group input { font-size: 18px; padding: 14px; }
}

/* ===== تحسين شامل للتوافق مع الهواتف ===== */
@media (max-width: 768px) {
    .main-content { min-width: 0; }
    .content-area { min-width: 0; overflow-x: hidden; }
    .card { width: 100%; max-width: 100%; }
    .table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table { min-width: 640px; }
    .form-group, form { max-width: 100%; }
    button, .btn, input, select, textarea { touch-action: manipulation; }
    .topbar > div { min-width: 0; }
}
@media (max-width: 480px) {
    .content-area { padding: 8px; }
    .card { padding: 12px; border-radius: 10px; }
    .data-table { min-width: 620px; }
}
