/* Eyeen Desk: Arabic right-to-left, no inline styles (the CSP forbids them).
   Colors follow the Eyeen Cloud app (--c-primary #845EC2, --c-primary-deep #5E3A99); the typeface comes from
   the eyeen.net landing page. */

@font-face {
  font-family: "Handicrafts";
  src: url("/static/handicrafts-medium.otf") format("opentype");
  font-weight: 400 600;
  font-display: swap;
}
@font-face {
  font-family: "Handicrafts";
  src: url("/static/handicrafts-bold.otf") format("opentype");
  font-weight: 700 900;
  font-display: swap;
}

:root {
  --violet: #5e3a99;     /* Eyeen primary, deep: text on light, surfaces */
  --iris: #845ec2;       /* Eyeen primary */
  --grad: linear-gradient(135deg, #845ec2, #5e3a99);
  --lilac: #b39cd0;      /* lines on purple */
  --violet-tint: #efe8fb;
  --mist: #f6f4fb;       /* page surface */
  --line: #e2dfea;
  --line-strong: #d3cce3;
  --ink: #2d2d2d;
  --muted: #615d66;
  --clay: #c34a36;       /* danger */
  --clay-ink: #a63a28;
  --clay-tint: #fbe9e6;
  --radius-panel: 14px;
  --radius-field: 12px;
  --pill: 999px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Handicrafts", "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.65;
  color: var(--ink);
  background: var(--mist);
}

h1 { font-size: 2rem; font-weight: 800; line-height: 1.25; margin: 0 0 1.5rem; }
h2 { font-size: 1.25rem; font-weight: 800; line-height: 1.35; margin: 2.5rem 0 1rem; }
p { margin: 0 0 1rem; max-width: 70ch; }

a { color: var(--violet); text-underline-offset: 0.2em; }
a:hover { color: var(--iris); }

:focus-visible { outline: 3px solid var(--iris); outline-offset: 2px; }

/* ---------- Signed-in pages: the violet rail on the start side ---------- */

.page-app {
  display: grid;
  grid-template-columns: 15.5rem minmax(0, 1fr);
  min-height: 100vh;
}

.top {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: 1.5rem 1rem;
  background: var(--violet);
  color: #fff;
}

.brand { display: flex; align-items: center; gap: 0.7rem; padding-inline: 0.5rem; font-weight: 800; font-size: 1.1rem; }
.brand img { flex: none; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35); }

.top nav { display: flex; flex-direction: column; gap: 0.25rem; }
.top nav a {
  display: block;
  padding: 0.55rem 1rem;
  border-radius: var(--pill);
  color: #fff;
  text-decoration: none;
  opacity: 0.85;
}
.top nav a:hover { opacity: 1; background: rgba(255, 255, 255, 0.1); color: #fff; }
.top nav a[aria-current="page"] { opacity: 1; background: #fff; color: var(--violet); font-weight: 800; }
.top nav a:focus-visible { outline-color: #fff; }

.top .logout {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 1rem 0.5rem 0;
  border-top: 1px solid rgba(179, 156, 208, 0.45);
}
.top .logout .who { font-size: 0.95rem; color: #fff; }
.top .logout button {
  background: transparent;
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
  height: 2.25rem;
  padding-inline: 1.25rem;
}
.top .logout button:hover { filter: none; background: rgba(255, 255, 255, 0.12); }
.top .logout button:focus-visible { outline-color: #fff; }

.page-app main { padding: 2.5rem clamp(1rem, 4vw, 3.5rem) 4rem; max-width: 76rem; width: 100%; }

/* ---------- Controls ---------- */

label { display: block; margin-bottom: 1rem; font-size: 0.95rem; }

input, select {
  display: block;
  width: 100%;
  height: 2.75rem;
  margin-top: 0.35rem;
  padding: 0 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-field);
  background: #fff;
  color: var(--ink);
  font: inherit;
}
input:hover, select:hover { border-color: var(--lilac); }
input:focus, select:focus { outline: none; border-color: var(--iris); box-shadow: 0 0 0 3px rgba(132, 94, 194, 0.3); }
input[type="date"] { min-width: 10rem; }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2.75rem;
  padding: 0 1.75rem;
  border: 0;
  border-radius: var(--pill);
  background: var(--grad);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: filter 0.15s ease;
}
button:hover { filter: brightness(1.08); }

button.quiet {
  height: 2rem;
  padding: 0 0.9rem;
  background: #fff;
  color: var(--violet);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
button.quiet:hover { filter: none; background: var(--violet-tint); box-shadow: inset 0 0 0 1px var(--lilac); }
button.quiet.danger { color: var(--clay-ink); }
button.quiet.danger:hover { filter: none; background: var(--clay-tint); box-shadow: inset 0 0 0 1px #f0c9c1; }

.hint { color: var(--muted); font-size: 0.875rem; margin-top: -0.6rem; }

.error {
  color: var(--clay-ink);
  background: var(--clay-tint);
  border-inline-start: 4px solid var(--clay);
  border-radius: 10px;
  padding: 0.75rem 1rem;
}

/* ---------- Panels, tables, chips ---------- */

.card {
  max-width: 30rem;
  padding: 1.75rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
}
.card > button:last-child, .card form > button:last-child { margin-top: 0.5rem; }

.table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.8rem 1rem; text-align: start; vertical-align: middle; }
th {
  background: var(--mist);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
td { border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfaff; }
td[dir="ltr"] { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.audit td { vertical-align: top; }

.chip {
  display: inline-block;
  padding: 0.1rem 0.7rem;
  border-radius: var(--pill);
  font-size: 0.8rem;
  line-height: 1.7;
  white-space: nowrap;
}
.chip-on { background: var(--violet-tint); color: var(--violet); }
.chip-off { background: #eeedf0; color: var(--muted); }
.chip-warn { background: var(--clay-tint); color: var(--clay-ink); }

.actions { display: flex; flex-wrap: nowrap; gap: 0.4rem; }
form.inline { display: inline; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
}
.filters label { margin: 0; min-width: 9rem; flex: 1 1 9rem; }
.filters button { flex: none; }

details summary { cursor: pointer; color: var(--violet); font-size: 0.9rem; }
details pre {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 24rem;
  overflow: auto;
  margin: 0.5rem 0 0;
  padding: 0.75rem;
  background: var(--mist);
  border-radius: 10px;
  font-size: 0.85rem;
}

.empty { color: var(--muted); padding: 2rem 0; }
.more { margin-top: 1.25rem; }

.secret {
  font-family: Consolas, "Cascadia Mono", "Courier New", monospace;
  font-size: 1.2rem;
  letter-spacing: 0.12em;
  text-align: center;
  padding: 0.75rem 1rem;
  background: var(--mist);
  border: 1px dashed var(--lilac);
  border-radius: 10px;
}

.qr svg {
  display: block;
  margin: 1.25rem auto;
  padding: 0.75rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-field);
}

/* ---------- Login and TOTP enrollment: brand panel beside the form ---------- */

.page-auth { background: #fff; }

.auth {
  display: grid;
  grid-template-columns: minmax(20rem, 42%) minmax(0, 1fr);
  min-height: 100vh;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(2rem, 5vw, 4rem);
  background: var(--violet);
  color: #fff;
}

.auth-mark { border-radius: 50%; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3); margin-bottom: 1.25rem; }
.auth-name { font-size: 2rem; font-weight: 800; line-height: 1.2; margin: 0 0 0.5rem; }
.auth-tagline { color: #e4dcfa; max-width: 22rem; margin: 0; }

.page-auth main {
  align-self: center;
  justify-self: center;
  width: min(26rem, 100% - 2rem);
  padding: 3rem 0;
}
.page-auth .card { padding: 0; border: 0; background: none; max-width: none; }
.page-auth .logout {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-bottom: 2rem;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}
.page-auth .logout button { height: 2rem; padding: 0 1rem; background: #fff; color: var(--violet); font-weight: 500; box-shadow: inset 0 0 0 1px var(--line-strong); }
.page-auth .logout button:hover { filter: none; background: var(--violet-tint); }
.page-auth form:not(.logout) > button[type="submit"] { width: 100%; margin-top: 0.5rem; }

/* ---------- Small screens ---------- */

@media (max-width: 760px) {
  .page-app { grid-template-columns: minmax(0, 1fr); }
  .top {
    position: sticky;
    height: auto;
    z-index: 1;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
  }
  .brand span { display: none; }
  .top nav { flex-direction: row; overflow-x: auto; flex: 1; scrollbar-width: none; }
  .top nav::-webkit-scrollbar { display: none; }
  .top nav a { white-space: nowrap; padding: 0.35rem 0.9rem; }
  .top .logout { margin-top: 0; flex-direction: row; align-items: center; padding: 0; border: 0; }
  .top .logout .who { display: none; }
  .page-app main { padding-top: 1.5rem; }
  h1 { font-size: 1.6rem; }

  .auth { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .auth-brand { padding: 1.5rem; }
  .auth-name { font-size: 1.5rem; }
  .page-auth main { align-self: start; padding: 2rem 0; }
}

@media (prefers-reduced-motion: reduce) {
  button { transition: none; }
}
