/* VaultGuard Admin — Clean Light Enterprise UI (LTR + Arabic RTL) */
:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel2: #f8fafc;
  --border: #dfe5ec;
  --fg: #1e293b;
  --dim: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --err: #dc2626;
  --err-bg: #fee2e2;
  --sidebar-bg: #1e293b;
  --sidebar-hover: #293548;
  --sidebar-fg: #cbd5e1;
  --sidebar-fg-bright: #ffffff;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.55 "Segoe UI", system-ui, -apple-system, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #0f172a;
  border-radius: 4px;
  padding: 1px 6px;
  font: 12px Consolas, monospace;
}

/* ---------- auth pages ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef2f7 0%, #dbe6f4 100%);
  padding: 20px;
}
.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 36px;
  width: 400px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
}
.auth-card h1 { margin: 0 0 4px; font-size: 22px; color: #0f172a; }
.auth-card .sub { color: var(--dim); margin-bottom: 22px; font-size: 13px; }
.auth-card label { display: block; margin: 12px 0 4px; color: var(--fg); font-size: 12.5px; font-weight: 600; }
.auth-card input {
  width: 100%;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: var(--fg);
  padding: 9px 12px;
  font-size: 14px;
}
.auth-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14); }
.auth-card button {
  width: 100%;
  margin-top: 20px;
  background: var(--accent);
  color: #ffffff;
  border: 0;
  border-radius: 6px;
  padding: 10px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}
.auth-card button:hover { background: var(--accent-hover); }
.auth-err { background: var(--err-bg); border: 1px solid #fca5a5; color: #991b1b; border-radius: 6px; padding: 9px 12px; margin: 12px 0; font-size: 13px; }
.auth-ok { background: var(--ok-bg); border: 1px solid #86efac; color: #166534; border-radius: 6px; padding: 9px 12px; margin: 12px 0; font-size: 13px; }

/* ---------- admin shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px;
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  padding: 18px 0 12px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.sidebar .brand {
  padding: 0 20px 16px;
  font-weight: 700;
  font-size: 17px;
  color: var(--sidebar-fg-bright);
  border-bottom: 1px solid #334155;
  margin-bottom: 8px;
}
.sidebar .brand span { color: #94a3b8; font-weight: 400; font-size: 11.5px; display: block; margin-top: 2px; }
.sidebar a.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  color: var(--sidebar-fg);
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background 0.12s ease;
}
.sidebar a.nav:hover { color: #ffffff; background: var(--sidebar-hover); text-decoration: none; }
.sidebar a.nav.active {
  color: #ffffff;
  border-left-color: #3b82f6;
  background: var(--sidebar-hover);
  font-weight: 600;
}
[dir="rtl"] .sidebar a.nav { border-left: 0; border-right: 3px solid transparent; }
[dir="rtl"] .sidebar a.nav.active { border-right-color: #3b82f6; }

.sidebar .spacer { flex: 1; }
.sidebar .who {
  padding: 14px 20px 6px;
  border-top: 1px solid #334155;
  font-size: 12px;
  color: #94a3b8;
}
.sidebar .who b { color: #ffffff; display: block; font-size: 13.5px; margin-bottom: 2px; }
.sidebar form { display: inline; }
.sidebar .logout {
  background: none;
  border: 0;
  color: #f87171;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  font-weight: 600;
}
.sidebar .logout:hover { text-decoration: underline; }

.main { flex: 1; padding: 26px 32px; min-width: 0; }
.main h1 { font-size: 22px; margin: 0 0 18px; color: #0f172a; font-weight: 700; }
.main h2 { font-size: 16px; margin: 24px 0 10px; color: #0f172a; font-weight: 600; }

/* ---------- quick actions & alerts ---------- */
.quick-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  align-items: center;
}
.alert-banner {
  padding: 11px 15px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.alert-banner.err { background: var(--err-bg); border: 1px solid #fca5a5; color: #991b1b; }
.alert-banner.warn { background: var(--warn-bg); border: 1px solid #fcd34d; color: #92400e; }

/* ---------- stat cards & tables ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat .num { font-size: 26px; font-weight: 700; color: #0f172a; line-height: 1.2; }
.stat .lbl { color: var(--dim); font-size: 12px; margin-top: 4px; font-weight: 500; }
.stat.warn .num { color: var(--warn); }
.stat.err .num { color: var(--err); }
.stat.ok .num { color: var(--ok); }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
th, td {
  padding: 10px 13px;
  text-align: left;
  border-bottom: 1px solid #eef2f6;
  font-size: 13px;
  vertical-align: middle;
}
[dir="rtl"] th, [dir="rtl"] td { text-align: right; }
th {
  background: var(--panel2);
  color: var(--dim);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border);
}
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #f8fafc; }

/* ---------- badges & buttons ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge.active, .badge.new, .badge.ok { background: var(--ok-bg); color: #166534; }
.badge.revoked, .badge.rejected, .badge.err { background: var(--err-bg); color: #991b1b; }
.badge.pending, .badge.warn { background: var(--warn-bg); color: #92400e; }
.badge.muted { background: #e2e8f0; color: #475569; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #ffffff;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 7px 14px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s ease;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; color: #ffffff; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.ghost { background: #ffffff; color: var(--fg); border: 1px solid #cbd5e1; }
.btn.ghost:hover { background: #f1f5f9; color: #0f172a; }
.btn.danger { background: #ffffff; color: var(--err); border: 1px solid #fca5a5; }
.btn.danger:hover { background: var(--err-bg); color: #991b1b; }
.btn.ok { background: #ffffff; color: var(--ok); border: 1px solid #86efac; }
.btn.ok:hover { background: var(--ok-bg); color: #166534; }

form.inline { display: inline; }
input[type=text], input[type=password], input[type=date], input[type=number], select, textarea {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: var(--fg);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
textarea { width: 100%; min-height: 85px; font-family: Consolas, monospace; font-size: 12px; }
label.f { display: block; margin: 12px 0 4px; color: var(--fg); font-size: 12.5px; font-weight: 600; }
label.f input, label.f select, label.f textarea { width: 100%; margin-top: 4px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
  .sidebar { width: 185px; }
  .main { padding: 18px; }
}
.flash-ok { background: var(--ok-bg); border: 1px solid #86efac; color: #166534; border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; white-space: pre-line; }
.flash-err { background: var(--err-bg); border: 1px solid #fca5a5; color: #991b1b; border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; white-space: pre-line; }
.muted { color: var(--dim); }
.small { font-size: 12px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input[type=text] { width: 250px; }
pre.keybox {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  font-size: 11px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: #334155;
}

/* language switcher */
.lang-switch { display: inline-flex; gap: 6px; align-items: center; margin: 8px 0 4px; font-size: 12px; }
.lang-switch a { color: #94a3b8; text-decoration: none; padding: 2px 7px; border-radius: 4px; }
.lang-switch a.on { color: #ffffff; background: #334155; font-weight: 600; }
.lang-switch a:hover { color: #ffffff; }
header .lang-switch a { color: var(--dim); }
header .lang-switch a.on { color: #ffffff; background: var(--accent); }
[dir="rtl"] .sidebar { text-align: right; }

/* ---------- form cards, sidebar icons, feature chips & modal ---------- */
.sidebar a.nav .nav-lbl { display: inline-flex; align-items: center; gap: 10px; }
.sidebar a.nav svg { width: 16px; height: 16px; opacity: 0.8; flex-shrink: 0; }
.sidebar a.nav.active svg { opacity: 1; color: #60a5fa; }

.form-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px 26px;
  max-width: 760px;
  box-shadow: var(--shadow);
}
.form-section {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: 18px 0 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid #eef2f6;
}
.form-section:first-child { margin-top: 0; }

.chips-box {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 40px;
  padding: 6px 8px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
}
.chip button {
  background: none;
  border: 0;
  color: #1d4ed8;
  cursor: pointer;
  font-weight: 700;
  padding: 0 2px;
  font-size: 13px;
  line-height: 1;
}
.chip button:hover { color: var(--err); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: 580px;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.2);
  overflow: hidden;
}
.modal-head {
  padding: 14px 20px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-head h3 { margin: 0; font-size: 16px; color: #0f172a; }
.modal-body { padding: 16px 20px; max-height: 65vh; overflow-y: auto; }
.modal-foot {
  padding: 12px 20px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.feat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
@media (max-width: 600px) { .feat-grid { grid-template-columns: 1fr; } }
.feat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  background: #ffffff;
}
.feat-item:hover { background: #f8fafc; border-color: #93c5fd; }
.feat-item input { margin: 0; width: auto !important; }
.copy-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  cursor: pointer;
  margin-inline-start: 4px;
}
.copy-btn:hover { background: #e2e8f0; }
