/* ============================================================
   theme-switcher.css
   نماذج الألوان الموحّدة لكل شاشات ORGA_SOFT (افتراضي / أخضر / داكن).
   يُضاف <link> لهذا الملف مبكرًا في <head> مع <script src="theme-switcher.js">.
   التبديل عبر السمة data-theme على <html> (يديرها theme-switcher.js + سواتش عائم أسفل الشاشة).
   محلي بالكامل (localStorage على جهاز المستخدم) - لا علاقة له بشاشة إعدادات التطبيق (app-settings.html).
   أي صفحة عندها متغيرات CSS بنفس الأسماء في <style> خاص بها (مثل sales-invoice-2.html)
   تفوز قيمها الخاصة تلقائيًا لأن ملفها يأتي بعد هذا الملف في <head>.
   ============================================================ */

:root {
    --brand: #4f46e5;
    --brand-2: #6366f1;
    --ok: #059669;
    --danger: #dc2626;
    --warn: #d97706;

    --page-bg: #eef1f8;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-label: #475569;
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    --input-text: #1e293b;
    --tile-bg: #f8fafc;
    --row-alt-bg: #f8fafc;
    --hover-bg: #eef2ff;
    --hover-border: #c7d2fe;
    --hover-text: #4338ca;
}

/* ===== نموذج الألوان: أخضر ===== */
html[data-theme="emerald"] {
    --brand: #059669;
    --brand-2: #10b981;
    --hover-bg: #ecfdf5;
    --hover-border: #a7f3d0;
    --hover-text: #047857;
}
html[data-theme="emerald"] body .text-indigo-500,
html[data-theme="emerald"] body .text-indigo-600,
html[data-theme="emerald"] body .text-blue-500,
html[data-theme="emerald"] body .text-blue-600 { color: #059669 !important; }
html[data-theme="emerald"] body .bg-indigo-600,
html[data-theme="emerald"] body .bg-blue-600 { background-color: #059669 !important; }

/* ===== نموذج الألوان: داكن (أسود) ===== */
html[data-theme="dark"] {
    color-scheme: dark;
    --brand: #6366f1;
    --brand-2: #818cf8;
    --page-bg: #0b1220;
    --card-bg: #111827;
    --card-border: #1f2937;
    --text-main: #e5e7eb;
    --text-muted: #94a3b8;
    --text-label: #cbd5e1;
    --input-bg: #1f2937;
    --input-border: #374151;
    --input-text: #f1f5f9;
    --tile-bg: #1e293b;
    --row-alt-bg: #0f172a;
    --hover-bg: #1e293b;
    --hover-border: #334155;
    --hover-text: #93c5fd;
}

/* ===== تغطية عامة تعمل على أي صفحة حتى بدون تصميم خاص بالثيم ===== */
html[data-theme="dark"] body,
html[data-theme="emerald"] body {
    background: var(--page-bg) !important;
}
html[data-theme="dark"] body { color: var(--text-main); }

html[data-theme="dark"] body .bg-white,
html[data-theme="dark"] body .bg-gray-50,
html[data-theme="dark"] body .bg-gray-100,
html[data-theme="dark"] body .bg-slate-50,
html[data-theme="dark"] body .bg-slate-100 {
    background-color: var(--card-bg) !important;
}
html[data-theme="dark"] body .text-gray-500,
html[data-theme="dark"] body .text-gray-600,
html[data-theme="dark"] body .text-gray-700,
html[data-theme="dark"] body .text-gray-800,
html[data-theme="dark"] body .text-slate-500,
html[data-theme="dark"] body .text-slate-600,
html[data-theme="dark"] body .text-slate-700,
html[data-theme="dark"] body .text-slate-800 {
    color: var(--text-muted) !important;
}
html[data-theme="dark"] body .border,
html[data-theme="dark"] body .border-gray-200,
html[data-theme="dark"] body .border-gray-300,
html[data-theme="dark"] body .border-slate-200 {
    border-color: var(--card-border) !important;
}
html[data-theme="dark"] body .text-indigo-500,
html[data-theme="dark"] body .text-indigo-600,
html[data-theme="dark"] body .text-blue-500,
html[data-theme="dark"] body .text-blue-600 {
    color: var(--brand-2) !important;
}
html[data-theme="dark"] body .bg-indigo-600,
html[data-theme="dark"] body .bg-blue-600 {
    background-color: var(--brand) !important;
}
html[data-theme="dark"] body input[type="text"],
html[data-theme="dark"] body input[type="number"],
html[data-theme="dark"] body input[type="date"],
html[data-theme="dark"] body input[type="password"],
html[data-theme="dark"] body input[type="email"],
html[data-theme="dark"] body input[type="search"],
html[data-theme="dark"] body input[type="tel"],
html[data-theme="dark"] body select,
html[data-theme="dark"] body textarea {
    background-color: var(--input-bg) !important;
    color: var(--input-text) !important;
    border-color: var(--input-border) !important;
}
html[data-theme="dark"] body table tbody tr:hover { background: var(--hover-bg) !important; }
html[data-theme="dark"] body table tbody tr:nth-child(even) { background: rgba(255,255,255,.03) !important; }
html[data-theme="dark"] body table thead th { filter: brightness(.82); }

/* ===== تخطي لون الخط القادم من نظام إعدادات التطبيق (theme-loader.js) عند اختيار أخضر/داكن =====
   theme-loader.js يفرض لون خط ثابت (من app-settings) بـ !important على body وعناصر النص الشائعة
   (h1..h6, p, label, li, td, th, ...)، فيتعارض مع خلفية النموذج المختار ويصبح غير واضح.
   theme-switcher.js يضيف كلاس has-theme-loader على <html> فقط للصفحات اللي فعليًا بتحمّل theme-loader.js،
   والقاعدة هنا بتتفعّل فقط في أخضر/داكن - النموذج الافتراضي يفضل خاضع لإعدادات التطبيق زي ما هو دايمًا. */
html.has-theme-loader[data-theme="dark"] body,
html.has-theme-loader[data-theme="emerald"] body {
    color: var(--text-main) !important;
}
html.has-theme-loader[data-theme="dark"] body h1,
html.has-theme-loader[data-theme="dark"] body h2,
html.has-theme-loader[data-theme="dark"] body h3,
html.has-theme-loader[data-theme="dark"] body h4,
html.has-theme-loader[data-theme="dark"] body h5,
html.has-theme-loader[data-theme="dark"] body h6,
html.has-theme-loader[data-theme="dark"] body p,
html.has-theme-loader[data-theme="dark"] body label,
html.has-theme-loader[data-theme="dark"] body li,
html.has-theme-loader[data-theme="dark"] body td,
html.has-theme-loader[data-theme="dark"] body th,
html.has-theme-loader[data-theme="dark"] body dt,
html.has-theme-loader[data-theme="dark"] body dd,
html.has-theme-loader[data-theme="dark"] body legend,
html.has-theme-loader[data-theme="dark"] body figcaption,
html.has-theme-loader[data-theme="dark"] body blockquote,
html.has-theme-loader[data-theme="dark"] body small,
html.has-theme-loader[data-theme="dark"] body strong,
html.has-theme-loader[data-theme="dark"] body em,
html.has-theme-loader[data-theme="emerald"] body h1,
html.has-theme-loader[data-theme="emerald"] body h2,
html.has-theme-loader[data-theme="emerald"] body h3,
html.has-theme-loader[data-theme="emerald"] body h4,
html.has-theme-loader[data-theme="emerald"] body h5,
html.has-theme-loader[data-theme="emerald"] body h6,
html.has-theme-loader[data-theme="emerald"] body p,
html.has-theme-loader[data-theme="emerald"] body label,
html.has-theme-loader[data-theme="emerald"] body li,
html.has-theme-loader[data-theme="emerald"] body td,
html.has-theme-loader[data-theme="emerald"] body th,
html.has-theme-loader[data-theme="emerald"] body dt,
html.has-theme-loader[data-theme="emerald"] body dd,
html.has-theme-loader[data-theme="emerald"] body legend,
html.has-theme-loader[data-theme="emerald"] body figcaption,
html.has-theme-loader[data-theme="emerald"] body blockquote,
html.has-theme-loader[data-theme="emerald"] body small,
html.has-theme-loader[data-theme="emerald"] body strong,
html.has-theme-loader[data-theme="emerald"] body em {
    color: var(--text-main) !important;
}

/* ===== سواتش عائم لاختيار النموذج - يُحقن تلقائيًا من theme-switcher.js ===== */
.app-theme-switcher {
    position: fixed; bottom: 16px; left: 16px; z-index: 99999;
    display: flex; align-items: center; gap: 6px;
    background: rgba(15,23,42,.75); backdrop-filter: blur(6px);
    padding: 7px 9px; border-radius: 999px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.app-theme-swatch {
    width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5);
    cursor: pointer; padding: 0; transition: transform .15s ease;
}
.app-theme-swatch:hover { transform: scale(1.15); }
.app-theme-swatch.active { border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.5); }
.app-theme-swatch[data-theme-choice="default"] { background: linear-gradient(135deg,#3730a3,#6366f1); }
.app-theme-swatch[data-theme-choice="emerald"] { background: linear-gradient(135deg,#065f46,#10b981); }
.app-theme-swatch[data-theme-choice="dark"] { background: linear-gradient(135deg,#000000,#334155); }
