/* V2 admin chrome (design-handoff/v2, "Admin dashboard"): cream page, navy
   sidebar and text, white rounded cards with one soft shadow, yellow primary
   buttons, Lalezar headings. Slight rotations stay on the playful surfaces
   only (login, create/preview cards, modals). */

:root {
  --cream: #FFF8E9;
  --royal: #3A50A2;
  --navy: #252872;
  --yellow: #F2D857;
  --amber: #F2B705;
  --teal: #4FB3BF;
  --danger: #E5484D;
  --white: #FFFFFF;
  --disabled: #ddd6c4;
  --hairline: rgba(37, 40, 114, .12);
  --shadow: 0 1px 0 rgba(37, 40, 114, .06), 0 6px 18px rgba(37, 40, 114, .07);
  --r-card: 18px;
  --r-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--cream);
  color: var(--navy);
  font-family: "IBM Plex Sans Arabic", system-ui, -apple-system, sans-serif;
  font-size: 16px;
}

h1, h2, h3 { font-family: Lalezar, "IBM Plex Sans Arabic", system-ui, sans-serif; font-weight: 400; }
h1 { font-size: 2.4rem; margin: 0 0 .25rem; letter-spacing: .5px; }
h2 { font-size: 1.6rem; margin: 0 0 .75rem; }
h3 { font-size: 1.2rem; margin: 0 0 .5rem; }
a, a:hover { color: var(--navy); }

:focus-visible { outline: 4px solid var(--yellow); outline-offset: 0; }
/* Blazor's FocusOnNavigate focuses the page h1 (tabindex=-1) for screen
   readers; that is not a keyboard focus and should not draw the ring. */
[tabindex="-1"]:focus { outline: none; }

/* ---------- shell ---------- */

.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--navy); color: var(--cream); padding: 1.5rem 1.25rem; }
.sidebar .brand { display: flex; flex-direction: column; gap: .4rem; align-items: flex-start; }
.sidebar .brand img { height: 58px; width: auto; display: block; }
.sidebar .brand small { display: block; font-size: .7rem; color: var(--cream); opacity: .6; letter-spacing: 2px; }
.sidebar nav { margin-top: 2rem; display: flex; flex-direction: column; gap: .5rem; }
.sidebar nav a {
  color: var(--cream); text-decoration: none; padding: .6rem .9rem;
  border-radius: 12px; font-weight: 600;
}
.sidebar nav a:hover { background: rgba(255, 248, 233, .08); color: var(--cream); }
.sidebar nav a.active, .sidebar nav a.active:hover { background: var(--yellow); color: var(--navy); }
.sidebar .who { margin-top: 2rem; font-size: .8rem; opacity: .7; }
.sidebar .who a { color: var(--yellow); }
.sidebar .who .role { text-transform: uppercase; letter-spacing: 1px; font-size: .65rem; margin-top: .15rem; }

main { padding: 2rem 2.5rem 4rem; max-width: 1100px; width: 100%; }
main.signed-out { max-width: 420px; margin: 0 auto; padding: 12vh 1.25rem 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-head p { margin: 0; max-width: 60ch; opacity: .75; }
.page-head select { width: auto; }
.page-head .actions { display: flex; gap: .75rem; flex-wrap: wrap; flex: none; }

/* ---------- surfaces ---------- */

.card {
  background: var(--white); border: 0; border-radius: var(--r-card);
  box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.5rem;
}
.card.tilt { transform: rotate(-1deg); }
.card.tilt-r { transform: rotate(1deg); }

.grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-bottom: 1.5rem; }

.stat { background: var(--white); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 1rem 1.2rem; }
.stat .n { font-family: Lalezar, sans-serif; font-size: 2.6rem; line-height: 1; }
.stat .l { text-transform: uppercase; letter-spacing: 1px; font-size: .75rem; opacity: .7; }

/* ---------- deck tiles ---------- */

.deck-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.deck-tile {
  position: relative; background: var(--royal); color: var(--white);
  border-radius: var(--r-card); padding: 1rem; text-decoration: none;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  gap: .3rem; min-height: 200px; text-align: center;
}
.deck-tile:hover { color: var(--white); filter: brightness(1.08); }
.deck-tile .dot {
  position: absolute; top: .6rem; left: .6rem; width: 14px; height: 14px;
  border-radius: 7px; box-shadow: 0 0 0 2px var(--white);
}
.deck-tile .art {
  flex: 1; width: 100%; max-width: 75%; min-height: 60px; max-height: 100px; margin-top: 1rem;
  background: center / contain no-repeat;
}
.deck-tile .ar { font-family: Lalezar, sans-serif; font-size: 1.6rem; line-height: 1.3; direction: rtl; }
.deck-tile .en { font-size: .85rem; opacity: .85; }
.deck-tile .meta { font-size: .8rem; display: flex; gap: .4rem; flex-wrap: wrap; justify-content: center; }
.deck-tile .pill { background: var(--yellow); color: var(--navy); border-radius: 7px; }
.deck-tile .pill.premium { background: var(--navy); color: var(--yellow); white-space: nowrap; }
.deck-tile .pill.error { background: var(--danger); color: var(--white); border-radius: var(--r-sm); }

/* The reorder controls cannot live inside .deck-tile: it is an <a>, and a
   <button> nested in a link both fails validation and navigates on click. */
.deck-slot { display: flex; flex-direction: column; gap: .5rem; }
.deck-order { display: flex; align-items: center; justify-content: center; gap: .5rem; }
.deck-order button { min-width: 2.4rem; }
.deck-order .pill { background: var(--white); }

/* Default pill sits on white cards and table rows, so it takes the page
   cream rather than the prototype's white, which would vanish there. */
.pill {
  display: inline-block; border: 0; border-radius: var(--r-sm); padding: .1rem .5rem;
  background: var(--cream); color: var(--navy); font-size: .75rem; font-weight: 700;
}
.pill.premium { background: var(--navy); color: var(--yellow); }
.pill.warn { background: var(--amber); color: var(--navy); }
.pill.error { background: var(--danger); color: var(--white); }
.pill.ok { background: var(--yellow); color: var(--navy); }

/* ---------- forms ---------- */

label { display: block; font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: 1px; margin-bottom: .3rem; }
/* The prototype draws inputs borderless on white; a hairline keeps them
   visible on the white cards they actually sit on. */
input[type=text], input[type=number], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: .6rem .7rem; border: 1px solid var(--hairline); border-radius: var(--r-sm);
  background: var(--white); font: inherit; color: var(--navy);
}
input:focus, select:focus, textarea:focus { outline: 4px solid var(--yellow); outline-offset: 0; }
input[dir=rtl], textarea[dir=rtl] { text-align: right; }
input[dir=rtl] { font-family: Lalezar, sans-serif; font-size: 1.1rem; }
.field { margin-bottom: 1rem; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > .field { flex: 1 1 180px; }

input[type=file] { font: inherit; font-size: .8rem; color: var(--navy); }
input[type=file]::file-selector-button {
  border: 0; border-radius: var(--r-sm); background: var(--cream); color: var(--navy);
  padding: .4rem .8rem; margin-right: .5rem; font: inherit; cursor: pointer;
}
input[type=checkbox] { accent-color: var(--royal); }

.btn {
  display: inline-block; border: 0; border-radius: var(--r-card); background: var(--yellow);
  box-shadow: var(--shadow); padding: .55rem 1.1rem; font: inherit; font-weight: 700;
  cursor: pointer; text-decoration: none; color: var(--navy); line-height: 1.5;
  transition: transform .08s ease, filter .12s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.05); color: var(--navy); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { background: var(--disabled); color: var(--navy); cursor: not-allowed; opacity: .7; }
.btn.ghost { background: var(--white); }
.btn.danger, .btn.danger:hover:not(:disabled) { background: var(--danger); color: var(--white); }
.btn.small { padding: .25rem .6rem; border-radius: var(--r-sm); font-size: .8rem; }

/* ---------- tables ---------- */

table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--hairline); padding: .6rem .7rem; text-align: left; vertical-align: middle; }
th { background: var(--navy); color: var(--cream); text-transform: uppercase; font-size: .75rem; letter-spacing: 1px; }
td input[type=text] { padding: .35rem .45rem; }
tr.selected td { background: var(--cream); }
tr.dragging { opacity: .4; }
.row-actions { display: flex; gap: .3rem; flex-wrap: wrap; }
.bulk-bar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .75rem; padding: .5rem .75rem; background: var(--cream); border-radius: var(--r-sm); }
.account-actions { display: flex; flex-direction: column; align-items: stretch; gap: .4rem; min-width: 8.5rem; }
.account-actions .btn { white-space: nowrap; }
.thumb { width: 38px; height: 38px; object-fit: cover; border-radius: var(--r-sm); display: block; }

/* Deck picture in the editor: previewed on the deck's colour, contained like
   the tile art, so a transparent logo reads the way it will in the app. */
.deck-pic { display: flex; gap: .75rem; align-items: center; margin-top: .3rem; }
.deck-pic-tile { width: 96px; height: 72px; flex: none; border-radius: var(--r-sm); display: grid; place-items: center; }
.deck-pic-tile img { max-width: 80%; max-height: 80%; object-fit: contain; display: block; }

/* ---------- audit log ---------- */

/* Denser than the word tables: this is read by scanning down one column
   looking for the row that explains what happened, not cell by cell. */
table.audit td { font-size: .9rem; }
table.audit td:first-child { white-space: nowrap; }
table.audit .pill { white-space: nowrap; text-transform: capitalize; }

/* ---------- card preview ---------- */

.editor { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 2rem; align-items: start; }
.preview-wrap { position: sticky; top: 2rem; }
.preview {
  aspect-ratio: 3 / 4; border-radius: var(--r-card); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1rem; padding: 1.5rem; transform: rotate(-2deg); background: var(--white);
}
.preview img { max-width: 100%; max-height: 55%; object-fit: contain; border-radius: var(--r-card); }
.preview .word { font-family: Lalezar, sans-serif; font-size: 2.6rem; text-align: center; direction: rtl; line-height: 1.2; }

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(17, 17, 17, .6);
  display: flex; align-items: center; justify-content: center; padding: 1.5rem;
}
.modal {
  background: var(--white); border-radius: var(--r-card); box-shadow: var(--shadow);
  padding: 1.5rem; max-width: 520px; width: 100%; transform: rotate(-1deg);
}
.modal h2 { margin-top: 0; }
.modal-body p { margin: 0 0 .75rem; }
.modal-body p:last-child { margin-bottom: 0; }
.modal .field { margin-top: 1.25rem; }
.modal .field label { text-transform: none; letter-spacing: 0; font-size: .85rem; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* ---------- messages ---------- */

.toast { border-radius: var(--r-card); box-shadow: var(--shadow); padding: .8rem 1rem; margin-bottom: 1.25rem; font-weight: 600; }
.toast.ok { background: var(--yellow); color: var(--navy); }
.toast.bad { background: var(--danger); color: var(--white); }
.toast.bad a { color: var(--white); }
.toast.info { background: var(--teal); color: var(--navy); }

.issue { border-radius: var(--r-sm); padding: .5rem .7rem; margin-bottom: .5rem; background: var(--white); font-size: .9rem; }
.issue.error { border-left: 6px solid var(--danger); }
.issue.warning { border-left: 6px solid var(--amber); }

code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }
pre { background: var(--navy); color: var(--cream); padding: 1rem; overflow: auto; border-radius: var(--r-sm); }
.muted { opacity: .65; }
.text-danger { color: var(--danger); }
.swatch { display: inline-block; width: 1.1rem; height: 1.1rem; border-radius: var(--r-sm); vertical-align: -.2rem; }
.word-search label { display: block; font-weight: 700; margin-bottom: .35rem; text-transform: none; letter-spacing: 0; font-size: 1rem; }
.word-search input { width: 100%; background: var(--cream); border-color: transparent; }
.word-search > p { margin: .75rem 0 .5rem; }
.swatches { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.swatch-pick { width: 2rem; height: 2rem; padding: 0; border: 0; border-radius: var(--r-sm); cursor: pointer; }
.swatch-pick.on { box-shadow: 3px 3px 0 var(--navy); transform: translate(-2px, -2px); outline: 3px solid var(--cream); outline-offset: -6px; }
.swatch-custom { display: inline-flex; align-items: center; gap: .3rem; font-size: .85rem; cursor: pointer; }
.swatch-custom input[type=color] { width: 2rem; height: 2rem; padding: 0; border: 1px solid var(--hairline); border-radius: var(--r-sm); background: none; cursor: pointer; }

/* Deck sales: numbers line up, the deck column takes the slack. */
table.funnel td.n, table.funnel th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-scroll { overflow-x: auto; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  main { padding: 1.25rem; }
  .editor { grid-template-columns: 1fr; }
  .preview-wrap { position: static; max-width: 300px; }
}

/* Sections: the five V3 card colours, as a swatch in the list and a dot on deck tiles. */
.section-swatch { display: inline-block; width: 1.6rem; height: 1.6rem; border-radius: var(--r-sm); box-shadow: inset 0 0 0 2px var(--navy); }
.section-pill { display: inline-flex; align-items: center; gap: .35rem; }
.section-dot { width: .7rem; height: .7rem; border-radius: 999px; box-shadow: inset 0 0 0 1.5px var(--navy); flex: none; }

/* Integrations: one card per outside service. */
.integrations { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.integration h2 { margin: 0; }
.integration__head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.integration__facts { list-style: none; padding: 0; margin: .75rem 0; display: grid; gap: .35rem; font-size: .9rem; }
.integration__facts .dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 999px; margin-inline-end: .45rem; background: var(--danger); }
.integration__facts .dot.ok { background: #1F9D55; }
.integration__facts strong { margin-inline-end: .35rem; }
.integration__last { font-size: .85rem; margin: .5rem 0 0; }
.integration__last.bad { color: var(--danger); font-weight: 600; }
.integration__todo { font-size: .85rem; background: var(--cream); border-radius: var(--r-sm); padding: .6rem .75rem; margin: .75rem 0 0; }
.integration__test { align-items: flex-end; margin-top: 1rem; }

/* Servers & hosting: the monthly cost chart (inline SVG). */
.chart { width: 100%; height: auto; display: block; margin: .5rem 0; }
.chart__grid { stroke: var(--navy); stroke-opacity: .1; stroke-width: 1; }
.chart__base { stroke: var(--navy); stroke-opacity: .35; stroke-width: 1; }
.chart__axis { fill: var(--navy); fill-opacity: .6; font-size: 11px; }
.chart__value { fill: var(--navy); font-size: 12px; font-weight: 700; }
.chart__bar { fill: var(--royal); }
.chart__bar:hover { fill: var(--navy); }
.chart__projected { fill: none; stroke: var(--royal); stroke-width: 2; stroke-dasharray: 4 3; }
.chart__table { margin-top: .5rem; }
.chart__table summary { cursor: pointer; font-weight: 600; }
.chart__plan { fill: var(--yellow); }
.chart__legend { fill: var(--navy); font-size: 12px; }
