/* ============================================================================
   style.css — تصميم نظام رواتب دائرة كهرباء ميسان (عربي / RTL)
   ============================================================================ */

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

:root {
  --primary: #0a6b5e;          /* أخضر/تركوازي رسمي */
  --primary-dark: #084f46;
  --primary-light: #e6f4f1;
  --accent: #c8a45a;           /* ذهبي خفيف */
  --ink: #1f2933;
  --muted: #6b7785;
  --line: #e3e8ee;
  --bg: #f4f6f8;
  --card: #ffffff;
  --ok: #1f9d6b;
  --warn: #d98324;
  --danger: #d64550;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
code {
  background: #eef1f4; padding: 1px 6px; border-radius: 6px;
  font-family: ui-monospace, monospace; font-size: .88em; direction: ltr; display: inline-block;
}
.muted { color: var(--muted); }
.center { text-align: center; }

/* ============================ الأزرار ============================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 10px;
  padding: 11px 18px; font: inherit; font-weight: 700; cursor: pointer;
  transition: .15s; text-decoration: none; line-height: 1;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-light { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-light:hover { background: #f7f9fb; }
.btn-danger { background: #fff; color: var(--danger); border-color: #f3c6ca; }
.btn-danger:hover { background: #fdf2f3; }
.btn-ok { background: #fff; color: var(--ok); border-color: #bfe6d4; }
.btn-ok:hover { background: #f1faf5; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: .85rem; border-radius: 8px; }

/* ============================ صفحات الدخول ============================ */
.auth-page {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 500px at 50% -10%, var(--primary-light), var(--bg));
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 32px 28px;
}
.auth-card h1 { font-size: 1.25rem; margin: 0 0 4px; }
.brand { text-align: center; margin-bottom: 22px; }
.brand-logo {
  width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 18px;
  background: var(--primary); color: #fff; display: grid; place-items: center;
  font-size: 30px; box-shadow: var(--shadow);
}
.brand-admin { background: #243b53; }
/* حاوية شعار صفحات الدخول */
.brand-logo-img {
  width: auto; height: 84px; margin: 0 auto 14px;
  display: grid; place-items: center;
}
.brand-logo-img img { max-height: 84px; max-width: 200px; object-fit: contain; }
/* شعار الشريط العلوي (خلفية بيضاء صغيرة ليظهر فوق اللون) */
.topbar-logo {
  height: 32px; width: auto; max-width: 120px; object-fit: contain;
  background: #fff; border-radius: 7px; padding: 3px 6px;
}
.auth-foot { margin-top: 18px; text-align: center; }
.muted-link { color: var(--muted); font-size: .9rem; }

label { display: block; margin-bottom: 14px; font-weight: 500; font-size: .92rem; }
input[type=text], input[type=password], input[type=file] {
  width: 100%; margin-top: 6px; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: 10px; font: inherit;
  background: #fff; transition: .15s;
}
input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* ============================ التنبيهات ============================ */
.alert { padding: 13px 16px; border-radius: 12px; margin-bottom: 16px; font-size: .94rem; }
.alert-error   { background: #fdf2f3; color: #a02934; border: 1px solid #f3c6ca; }
.alert-success { background: #f0faf5; color: #136c47; border: 1px solid #bfe6d4; }
.alert-warn    { background: #fef6ec; color: #8a531a; border: 1px solid #f6dcb4; }

/* ============================ الشريط العلوي ============================ */
.topbar { background: var(--primary); color: #fff; }
.topbar-admin { background: #243b53; }
.topbar-in {
  max-width: 1100px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar-title { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 10px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.who { font-size: .9rem; opacity: .92; }

/* ============================ صفحة الموظف ============================ */
.container { max-width: 1000px; margin: 24px auto; padding: 0 20px; }

.hero-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; border-radius: var(--radius); padding: 26px 28px;
  display: flex; flex-wrap: wrap; gap: 20px; align-items: center;
  justify-content: space-between; box-shadow: var(--shadow); margin-bottom: 22px;
}
.hero-label { font-size: .92rem; opacity: .85; }
.hero-amount { font-size: 2.4rem; font-weight: 700; margin-top: 4px; }
.hero-amount span { font-size: 1.1rem; font-weight: 500; opacity: .8; }
.hero-meta { display: flex; gap: 26px; }
.hero-meta div { display: flex; flex-direction: column; }
.hero-meta span { font-size: .8rem; opacity: .8; }
.hero-meta strong { font-size: .98rem; }

.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.panel-title {
  font-size: 1.05rem; margin: 0 0 16px; padding-bottom: 12px;
  border-bottom: 2px solid var(--line); position: relative;
}
.panel-title::before {
  content: ''; position: absolute; bottom: -2px; right: 0;
  width: 48px; height: 2px; background: var(--primary);
}
.panel-g2 .panel-title::before { background: var(--ok); }
.panel-g3 .panel-title::before { background: var(--danger); }
.panel-g4 .panel-title::before { background: var(--accent); }

.kv-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px;
}
.kv {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 11px 14px; background: #f9fafb; border: 1px solid var(--line); border-radius: 10px;
}
.kv-key { color: var(--muted); font-size: .9rem; }
.kv-val { font-weight: 700; text-align: left; direction: ltr; }
.panel-g4 .kv { background: #fbf7ee; }

.subhead { font-size: .92rem; color: var(--primary); margin: 16px 0 8px; }
.print-note { text-align: center; font-size: .82rem; margin-top: 20px; }

/* ============================ لوحة الإدارة ============================ */
.admin-shell { max-width: 1100px; margin: 0 auto; display: flex; gap: 22px; padding: 22px 20px; }
.sidenav { flex: 0 0 210px; display: flex; flex-direction: column; gap: 6px; }
.navlink {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-radius: 10px; color: var(--ink); font-weight: 500; transition: .15s;
}
.navlink:hover { background: #fff; }
.navlink.active { background: var(--primary); color: #fff; box-shadow: var(--shadow); }
.navicon { font-size: 1.1rem; }
.admin-main { flex: 1; min-width: 0; }
.page-h1 { font-size: 1.4rem; margin: 0 0 18px; }

.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.stat-num { font-size: 1.9rem; font-weight: 700; color: var(--primary); }
.stat-lbl { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.stat-warn .stat-num { color: var(--warn); }

/* البحث */
.searchbar { display: flex; gap: 10px; flex-wrap: wrap; }
.searchbar input { flex: 1; min-width: 220px; margin: 0; }
.result-count { margin: 12px 0 0; }

/* الجداول */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.table th, .table td { padding: 12px 14px; text-align: right; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 700; font-size: .85rem; background: #f9fafb; }
.table tbody tr:hover { background: #f9fafb; }

.badge { padding: 3px 10px; border-radius: 20px; font-size: .78rem; font-weight: 700; }
.badge-ok   { background: #e7f6ee; color: #136c47; }
.badge-warn { background: #fef0e0; color: #8a531a; }
.badge-off  { background: #f1f3f5; color: #6b7785; }

.pager { display: flex; gap: 6px; justify-content: center; margin-top: 18px; }
.page-btn { padding: 7px 13px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.two-col { display: grid; grid-template-columns: 1fr 1.2fr; gap: 18px; align-items: start; }
.back-link { display: inline-block; margin-bottom: 14px; color: var(--muted); }

.notes { margin: 0; padding-right: 20px; color: var(--muted); font-size: .92rem; }
.notes li { margin-bottom: 8px; }

/* منطقة رفع الملف */
.dropzone {
  position: relative; border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 34px; text-align: center; background: #fafbfc; transition: .15s; margin-bottom: 16px;
}
.dropzone.drag { border-color: var(--primary); background: var(--primary-light); }
.dropzone input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.dropzone-text { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dz-icon { font-size: 30px; }

/* ============================ الاستجابة للجوال ============================ */
@media (max-width: 820px) {
  .admin-shell { flex-direction: column; }
  .sidenav { flex-direction: row; overflow-x: auto; flex: none; }
  .navlink { white-space: nowrap; }
  .two-col { grid-template-columns: 1fr; }
  .hero-card { flex-direction: column; align-items: flex-start; }
  .hero-meta { gap: 18px; }
}

/* ============================ الطباعة ============================ */
@media print {
  .topbar, .no-print, .navlink, .sidenav { display: none !important; }
  body { background: #fff; }
  .panel, .hero-card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .hero-card { background: var(--primary) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .container { margin: 0; max-width: none; }
}

/* ===== إدارة المشرفين ===== */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 18px; }
.form-grid > label { margin-bottom: 12px; }
.form-grid > div, .form-grid > .check-row { grid-column: 1 / -1; }
.check-row { display: flex; align-items: center; gap: 8px; font-weight: 500; margin-bottom: 14px; }
.check-row input { width: auto; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.row-actions { position: relative; display: inline-block; }
.row-actions summary { cursor: pointer; list-style: none; display: inline-block; }
.row-actions summary::-webkit-details-marker { display: none; }
.row-actions-menu {
  position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 20;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.12); padding: 12px; width: 280px;
}
.mini-form {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 10px 0; border-bottom: 1px dashed var(--line);
}
.mini-form:last-child { border-bottom: 0; }
.mini-form input { flex: 1 1 110px; margin: 0; }
.mini-form .btn { margin: 0; }
.mini-form button[type=submit]:not(.btn-primary):not(.btn-danger) {
  background: #fff; border: 1px solid var(--line); color: var(--text, #1f2a37);
}
.mini-title { width: 100%; font-size: .8rem; font-weight: 700; color: var(--muted); }
