/* Novture — shared design system. Same component structure/class names as every other
   project on this stack (kisikarti.com etc.) — only --brand/--accent/--accent2 change. */

:root {
  --brand:    #14163a;
  --accent:   #6366f1;
  --accent2:  #818cf8;
  --ink:      #1f1f1f;
  --muted:    #6b7280;
  --bg:       #f8f9fa;
  --card-bg:  #ffffff;
  --border:   #e5e7eb;
  --radius:   14px;
  --shadow:   0 4px 24px rgba(0,0,0,.08);
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 68px;
}

[data-theme="dark"] {
  --ink:     #f1f5f9;
  --muted:   #94a3b8;
  --bg:      #0f172a;
  --card-bg: #1e293b;
  --border:  #334155;
  --shadow:  0 4px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
a { color: var(--accent); text-decoration: none; }
.fade-in { animation: nv-fade-in .2s ease-out; }
@keyframes nv-fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Layout ---------- */
.kk-sidebar {
  width: var(--sidebar-w);
  background: var(--brand);
  min-height: 100vh;
  padding: 16px 0;
  position: fixed;
  left: 0; top: 0;
  display: flex;
  flex-direction: column;
  transition: width .18s ease;
  z-index: 50;
  overflow-x: hidden;
}
.kk-sidebar.kk-sidebar--collapsed { width: var(--sidebar-w-collapsed); }

.kk-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px 20px;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  white-space: nowrap;
}
.kk-sidebar-toggle {
  margin-left: auto;
  background: transparent;
  border: none;
  color: rgba(255,255,255,.7);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 16px;
}
.kk-sidebar-toggle:hover { color: #fff; }

.kk-sidebar a, .kk-sidebar .kk-sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: rgba(255,255,255,.7);
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  border-left: 3px solid transparent;
}
.kk-sidebar a:hover { color: #fff; background: rgba(255,255,255,.06); }
.kk-sidebar a.active { color: #fff; background: rgba(255,255,255,.1); border-left-color: var(--accent2); }
.kk-sidebar .kk-sidebar-icon { width: 20px; text-align: center; flex-shrink: 0; }
.kk-sidebar--collapsed .kk-sidebar-label,
.kk-sidebar--collapsed .kk-sidebar-brand span { display: none; }
.kk-sidebar--collapsed a, .kk-sidebar--collapsed .kk-sidebar-link { justify-content: center; padding: 12px 0; }

.kk-main {
  margin-left: var(--sidebar-w);
  padding: 28px;
  min-height: 100vh;
  transition: margin-left .18s ease;
}

/* Collapse state is a class on <html> (set by an inline script in <head>, before the
   sidebar/main even exist in the DOM) so there is zero flash-of-wrong-width on load —
   same trick as the dark-mode flash-prevention script below. */
html.kk-sidebar-collapsed .kk-sidebar { width: var(--sidebar-w-collapsed); }
html.kk-sidebar-collapsed .kk-main { margin-left: var(--sidebar-w-collapsed); }
html.kk-sidebar-collapsed .kk-sidebar-label,
html.kk-sidebar-collapsed .kk-sidebar-brand span { display: none; }
html.kk-sidebar-collapsed .kk-sidebar a,
html.kk-sidebar-collapsed .kk-sidebar .kk-sidebar-link { justify-content: center; padding: 12px 0; }

.kk-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 24px;
}

/* ---------- Cards ---------- */
.kk-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 20px;
}
.kk-card-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 24px;
  font-weight: 700;
  font-size: 18px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-align: center;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-brand { background: var(--brand); color: #fff; }
.btn-secondary { background: var(--card-bg); color: var(--ink); border-color: var(--border); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 24px; font-size: 16px; }
.btn-block { display: block; width: 100%; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--card-bg);
  color: var(--ink);
}
.form-control:focus { outline: none; border-color: var(--accent); }
.invalid-feedback { color: #dc2626; font-size: 12px; margin-top: 4px; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 8px; border: 1px solid transparent; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-danger  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-info    { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-muted   { background: #f1f5f9; color: #475569; }

/* ---------- Utility ---------- */
.text-muted { color: var(--muted); }
.fw-bold { font-weight: 700; }
.d-flex { display: flex; }
.gap-2 { gap: 8px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 16px; } .mb-4 { margin-bottom: 24px; }
.mt-1 { margin-top: 4px; }  .mt-2 { margin-top: 8px; }  .mt-3 { margin-top: 16px; }  .mt-4 { margin-top: 24px; }

/* ---------- Admin gear menu (Motadata-style categorized grid) ---------- */
.nv-gear-btn {
  position: fixed; top: 16px; right: 24px; z-index: 60;
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card-bg); box-shadow: var(--shadow); font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.nv-gear-btn:hover { border-color: var(--accent); }
html[dir="rtl"] .nv-gear-btn { right: auto; left: 24px; }
.nv-admin-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 9999;
  align-items: flex-start; justify-content: center; padding: 60px 24px;
}
.nv-admin-overlay.open { display: flex; }
.nv-admin-overlay-box {
  background: var(--bg); border-radius: 14px; width: 100%; max-width: 1100px; max-height: 82vh;
  overflow-y: auto; box-shadow: 0 24px 80px rgba(0,0,0,.4);
}
.nv-admin-overlay-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px; border-bottom: 1px solid var(--border); background: var(--card-bg);
  position: sticky; top: 0; border-radius: 14px 14px 0 0;
}
.nv-admin-overlay-header h2 { margin: 0; font-size: 20px; }
.nv-admin-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px; padding: 28px;
}
.nv-admin-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px;
}
.nv-admin-card-header {
  font-weight: 700; font-size: 15px; color: var(--accent); display: flex; align-items: center;
  gap: 8px; padding-bottom: 12px; margin-bottom: 8px; border-bottom: 1px solid var(--border);
}
.nv-admin-card a { display: block; padding: 6px 0; font-size: 14px; color: var(--ink); }
.nv-admin-card a:hover { color: var(--accent); }

/* ---------- Phone widget (country code + number) ---------- */
.phone-input-wrap { display: flex; gap: 6px; align-items: center; }
.phone-flag-btn { flex-shrink: 0; height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card-bg); color: var(--ink); font-size: 13px; cursor: pointer; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.phone-flag-btn:hover { border-color: var(--accent); }
.phone-num-input { flex: 1; min-width: 0; }
#countryPickerOverlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 9999; align-items: center; justify-content: center; }
#countryPickerOverlay.open { display: flex; }
#countryPickerBox { background: var(--card-bg); border-radius: 12px; width: 340px; max-height: 480px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 80px rgba(0,0,0,.45); }
#countryPickerBox input { border: none; border-bottom: 1px solid var(--border); padding: 12px 16px; font-size: 14px; background: transparent; color: var(--ink); outline: none; }
#countryList { overflow-y: auto; flex: 1; }
.cp-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; cursor: pointer; font-size: 13px; color: var(--ink); }
.cp-item:hover { background: rgba(99,102,241,.08); }
.cp-item .cp-flag { font-size: 20px; line-height: 1; }
.cp-item .cp-name { flex: 1; }
.cp-item .cp-code { color: var(--muted); font-weight: 600; }

/* ---------- Permission tree (Role editor) ---------- */
.nv-perm-tree ul { list-style: none; margin: 0; padding-left: 22px; }
.nv-perm-tree > ul { padding-left: 0; }
.nv-perm-tree label { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 14px; }
.nv-perm-module-list { display: flex; flex-direction: column; gap: 2px; min-width: 180px; }
.nv-perm-module-list button { text-align: left; background: transparent; border: none; padding: 10px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--ink); }
.nv-perm-module-list button.active { background: var(--accent); color: #fff; }

/* ---------- Dark mode overrides ---------- */
[data-theme="dark"] body            { background: var(--bg); color: var(--ink); }
[data-theme="dark"] .kk-card        { background: var(--card-bg); border-color: var(--border); }
[data-theme="dark"] .kk-main        { background: var(--bg); }
[data-theme="dark"] .alert-success  { background: #052e16; border-color: #166534; color: #86efac; }
[data-theme="dark"] .alert-danger   { background: #2d1010; border-color: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .alert-info     { background: #0c1a3a; border-color: #1e40af; color: #93c5fd; }
[data-theme="dark"] .alert-warning  { background: #2c1a03; border-color: #92400e; color: #fcd34d; }
[data-theme="dark"] .badge-muted    { background: #1e293b; color: #94a3b8; }
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea { background: #1e293b; border-color: #334155; color: #f1f5f9; }
[data-theme="dark"] .form-control   { background: #1e293b; border-color: #334155; color: #f1f5f9; }
[data-theme="dark"] .nv-perm-module-list button { color: var(--ink); }

/* ---------- RTL (Arabic) — basic mirroring, not yet a full RTL audit ---------- */
html[dir="rtl"] .kk-sidebar { left: auto; right: 0; }
html[dir="rtl"] .kk-sidebar a.active { border-left-color: transparent; border-right: 3px solid var(--accent2); }
html[dir="rtl"] .kk-main { margin-left: 0; margin-right: var(--sidebar-w); }
html[dir="rtl"].kk-sidebar-collapsed .kk-main { margin-right: var(--sidebar-w-collapsed); margin-left: 0; }
html[dir="rtl"] .kk-sidebar-toggle { margin-left: 0; margin-right: auto; }

@media (max-width: 768px) {
  .kk-sidebar { width: var(--sidebar-w-collapsed); }
  .kk-sidebar .kk-sidebar-label, .kk-sidebar .kk-sidebar-brand span { display: none; }
  .kk-main { margin-left: var(--sidebar-w-collapsed); padding: 16px; }
}
