/* ===== Design System — حلي أسوان (RTL) ===== */
@font-face {
  font-family: 'Cairo';
  src: url('/assets/fonts/Cairo-Variable.ttf') format('truetype');
  font-weight: 200 1000;
  font-display: swap;
}

:root {
  --primary: #0F6E5C; --primary-dark: #0A4A3E; --primary-light: #E3F2EE;
  --accent: #C99A2E; --danger: #C0392B; --danger-light: #FDEDEB;
  --success: #1E8E5A; --success-light: #E7F6EF;
  --warning: #B7791F; --warning-light: #FCF3E3;
  --info: #2563EB; --info-light: #E8F0FE;
  --bg: #F4F6F5; --surface: #FFFFFF; --border: #DDDDD7;
  --text: #1F2933; --muted: #6B7280;
  --sidebar-bg: #122B26; --sidebar-text: #CFE0DB;
  --radius: 10px; --radius-sm: 7px;
  --shadow: 0 1px 3px rgba(31, 41, 51, .08);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Cairo', Tahoma, 'Segoe UI', sans-serif; }
html, body { height: 100%; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
button { cursor: pointer; }

/* ===== شاشة الدخول ===== */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0A4A3E, #122B26); }
.login-card { background: var(--surface); border-radius: 16px; padding: 40px 36px; width: 400px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-logo { font-size: 46px; }
.login-card h1 { font-size: 17px; margin: 8px 0 2px; }
.login-sub { color: var(--muted); font-size: 12px; margin-bottom: 22px; }
.login-fields input[type=text], .login-fields input[type=password] { width: 100%; margin-bottom: 12px; }
.password-wrap { position: relative; }
.password-wrap .ghost-btn { position: absolute; left: 8px; top: 7px; border: none; background: none; font-size: 15px; }
.remember { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.login-hint { margin-top: 14px; font-size: 10.5px; color: var(--muted); }

/* ===== الهيكل ===== */
.main-screen { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 225px; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; flex-shrink: 0; }
.brand { font-size: 16px; font-weight: 800; color: #fff; padding: 18px 16px 2px; }
.brand-sub { font-size: 10px; color: var(--sidebar-text); padding: 0 16px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.nav-btn { display: block; width: 100%; text-align: right; background: none; border: none; color: var(--sidebar-text); padding: 9px 14px; font-size: 12.5px; border-radius: 8px; margin-bottom: 2px; }
.nav-btn:hover { background: #1C3B34; color: #fff; }
.nav-btn.active { background: var(--primary); color: #fff; font-weight: 700; }
.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 22px; display: flex; align-items: center; justify-content: space-between; }
.topbar h2 { font-size: 16px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.user-info { color: var(--muted); font-size: 11.5px; }
#page-content { flex: 1; overflow-y: auto; padding: 18px 22px; }

/* ===== مكونات عامة ===== */
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: var(--radius-sm); padding: 7px 15px; font-size: 12px; transition: .15s; }
.btn:hover { border-color: var(--primary); color: var(--primary-dark); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 700; }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; font-weight: 700; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { padding: 4px 10px; font-size: 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 11px; font-size: 12.5px; background: var(--surface); color: var(--text); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
input[type=number] { direction: ltr; text-align: center; }

.page-header { margin-bottom: 14px; }
.page-header h3 { font-size: 17px; }
.page-header p { color: var(--muted); font-size: 11.5px; }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.toolbar input[type=text] { width: 260px; }

/* ===== الجداول ===== */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead th { background: var(--primary-light); color: var(--primary-dark); font-weight: 700; padding: 9px 10px; text-align: center; position: sticky; top: 0; white-space: nowrap; }
tbody td { padding: 8px 10px; text-align: center; border-top: 1px solid #EEF1F0; white-space: nowrap; }
tbody tr:nth-child(even) { background: #F7F9F8; }
tbody tr:hover { background: var(--primary-light); }
tbody tr.clickable { cursor: pointer; }
td.num { font-variant-numeric: tabular-nums; direction: ltr; }

.pagination { display: flex; align-items: center; gap: 10px; margin-top: 10px; color: var(--muted); font-size: 11.5px; }

/* ===== الشارات ===== */
.badge { display: inline-block; border-radius: 12px; padding: 2px 11px; font-size: 11px; font-weight: 700; }
.badge.success { background: var(--success-light); color: var(--success); }
.badge.danger { background: var(--danger-light); color: var(--danger); }
.badge.warning { background: var(--warning-light); color: var(--warning); }
.badge.muted { background: var(--bg); color: var(--muted); }
.badge.info { background: var(--info-light); color: var(--info); }

/* ===== البطاقات ===== */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); display: flex; justify-content: space-between; align-items: center; }
.stat-card .t { color: var(--muted); font-size: 11px; }
.stat-card .v { font-size: 17px; font-weight: 800; margin-top: 3px; }
.stat-card .icon { font-size: 24px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.panel h4 { font-size: 13.5px; margin-bottom: 12px; }

/* ===== Toast ===== */
#toast-container { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 3000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--info); color: #fff; border-radius: 9px; padding: 10px 22px; font-size: 12.5px; font-weight: 700; box-shadow: 0 6px 20px rgba(0,0,0,.25); animation: slideDown .25s ease; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes slideDown { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; } }

/* ===== الحواريات ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 40, 35, .45); z-index: 2000; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px; box-shadow: 0 24px 70px rgba(0,0,0,.3); animation: slideDown .2s ease; }
.modal.wide { max-width: 860px; }
.modal-header { padding: 16px 20px 10px; display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 14.5px; }
.modal-close { border: none; background: none; font-size: 18px; color: var(--muted); }
.modal-body { padding: 10px 20px; max-height: 65vh; overflow-y: auto; }
.modal-footer { padding: 12px 20px 18px; display: flex; gap: 8px; justify-content: flex-start; }

/* ===== النماذج ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 11.5px; color: var(--muted); font-weight: 700; }
.form-group input, .form-group select, .form-group textarea { width: 100%; }
.hint { font-size: 10.5px; color: var(--muted); }

/* ===== محرر البنود ===== */
.lines-editor table td { padding: 4px 6px; }
.lines-editor input, .lines-editor select { width: 100%; min-width: 70px; }
.line-total { font-weight: 700; color: var(--primary-dark); }

/* ===== Dashboard ===== */
.charts-row { display: grid; grid-template-columns: 3fr 2fr; gap: 14px; margin-bottom: 14px; }
.bar-chart { display: flex; align-items: flex-end; gap: 10px; height: 190px; padding: 10px 6px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.bar { width: 70%; background: linear-gradient(180deg, var(--primary), var(--primary-dark)); border-radius: 5px 5px 0 0; min-height: 3px; }
.bar-label { font-size: 10px; color: var(--muted); }
.bar-value { font-size: 10px; color: var(--text); font-weight: 700; }
.legend-list { display: flex; flex-direction: column; gap: 9px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.legend-dot { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; }
.donut-wrap { display: flex; align-items: center; gap: 16px; }
.donut { width: 130px; height: 130px; border-radius: 50%; position: relative; flex-shrink: 0; }
.donut-center { position: absolute; inset: 26px; border-radius: 50%; background: var(--surface); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; flex-direction: column; }

/* تبويبات */
.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.tab-btn { border: none; background: none; padding: 9px 18px; font-size: 12.5px; color: var(--muted); border-bottom: 2.5px solid transparent; }
.tab-btn.active { color: var(--primary-dark); font-weight: 800; border-bottom-color: var(--primary); }

/* فحص الصلاحيات */
.center-msg { text-align: center; padding: 60px 20px; color: var(--muted); font-size: 14px; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .charts-row { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
