/* Neubrutalist admin chrome, borrowed from the game's design handoff:
   no border radius, 3-5px ink borders, hard offset shadows (no blur),
   slight rotations on playful surfaces only. */

:root {
  --green: #8DC63F;
  --green-dark: #7ab32f;
  --ink: #111111;
  --paper: #F7F3E8;
  --white: #FFFFFF;
  --yellow: #F2B705;
  --orange: #F26430;
  --teal: #4FB3BF;
  --danger: #D84315;
  --locked: #ddd6c4;
  --shadow: 6px 6px 0 var(--ink);
  --shadow-sm: 4px 4px 0 var(--ink);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  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; letter-spacing: .5px; }
h1 { font-size: 2.4rem; margin: 0 0 .25rem; }
h2 { font-size: 1.6rem; margin: 0 0 .75rem; }
h3 { font-size: 1.2rem; margin: 0 0 .5rem; }
a { color: var(--ink); }

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

.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: var(--paper); padding: 1.5rem 1.25rem; }
.sidebar .brand { font-family: Lalezar, sans-serif; font-size: 1.9rem; color: var(--green); line-height: 1.1; }
.sidebar .brand small { display: block; font-family: inherit; font-size: .7rem; color: var(--paper); opacity: .6; letter-spacing: 2px; }
.sidebar nav { margin-top: 2rem; display: flex; flex-direction: column; gap: .5rem; }
.sidebar nav a {
  color: var(--paper); text-decoration: none; padding: .6rem .8rem;
  border: 3px solid transparent; font-weight: 600;
}
.sidebar nav a:hover { border-color: var(--green); }
.sidebar nav a.active { background: var(--green); color: var(--ink); border-color: var(--paper); }
.sidebar .who { margin-top: 2rem; font-size: .8rem; opacity: .7; }
.sidebar .who a { color: var(--green); }
.sidebar .who .role { text-transform: uppercase; letter-spacing: 1px; font-size: .65rem; margin-top: .15rem; }

main { padding: 2rem 2.5rem 4rem; max-width: 1100px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-head p { margin: 0; max-width: 60ch; opacity: .75; }

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

.card {
  background: var(--white); border: 4px solid var(--ink);
  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(260px, 1fr)); }

.stat { background: var(--white); border: 4px solid var(--ink); box-shadow: var(--shadow-sm); 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-tile { border: 4px solid var(--ink); box-shadow: var(--shadow); padding: 1rem; text-decoration: none; display: block; }
.deck-tile:hover { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 var(--ink); }
.deck-tile .ar { font-family: Lalezar, sans-serif; font-size: 1.8rem; direction: rtl; }
.deck-tile .en { font-size: .9rem; opacity: .8; }
.deck-tile .meta { margin-top: .6rem; font-size: .8rem; display: flex; gap: .5rem; flex-wrap: wrap; }

.pill { border: 3px solid var(--ink); padding: .1rem .5rem; background: var(--white); font-size: .75rem; font-weight: 700; }
.pill.premium { background: var(--yellow); }
.pill.warn { background: var(--yellow); }
.pill.error { background: var(--danger); color: var(--white); }
.pill.ok { background: var(--green); }

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

label { display: block; font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: 1px; margin-bottom: .3rem; }
input[type=text], input[type=number], input[type=password], select, textarea {
  width: 100%; padding: .6rem .7rem; border: 3px solid var(--ink);
  background: var(--white); font: inherit; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 4px solid var(--green); outline-offset: 0; }
input[dir=rtl] { text-align: right; 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; }

.btn {
  display: inline-block; border: 4px solid var(--ink); background: var(--green);
  box-shadow: var(--shadow-sm); padding: .55rem 1.1rem; font: inherit; font-weight: 700;
  cursor: pointer; text-decoration: none; color: var(--ink);
}
.btn:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.btn:disabled { background: var(--locked); cursor: not-allowed; box-shadow: none; opacity: .7; }
.btn.ghost { background: var(--white); }
.btn.danger { background: var(--danger); color: var(--white); }
.btn.small { padding: .25rem .6rem; border-width: 3px; box-shadow: 3px 3px 0 var(--ink); font-size: .8rem; }

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

table { width: 100%; border-collapse: collapse; }
th, td { border: 3px solid var(--ink); padding: .45rem .6rem; text-align: left; vertical-align: middle; }
th { background: var(--ink); color: var(--paper); text-transform: uppercase; font-size: .75rem; letter-spacing: 1px; }
td input[type=text] { border-width: 2px; padding: .35rem .45rem; }
tr.dragging { opacity: .4; }

/* ---------- 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 ---------- */

.preview-wrap { position: sticky; top: 2rem; }
.preview {
  aspect-ratio: 3 / 4; border: 5px solid var(--ink); box-shadow: 10px 10px 0 var(--ink);
  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: 4px solid var(--ink); }
.preview .word { font-family: Lalezar, sans-serif; font-size: 2.6rem; text-align: center; direction: rtl; line-height: 1.2; }

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

/* Confirmation for anything that can't be undone. The backdrop is ink at 60%
   rather than a blur: the design language has no soft edges anywhere else. */
.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: 5px solid var(--ink); box-shadow: 10px 10px 0 var(--ink);
  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: 4px solid var(--ink); box-shadow: var(--shadow-sm); padding: .8rem 1rem; margin-bottom: 1.25rem; font-weight: 600; }
.toast.ok { background: var(--green); }
.toast.bad { background: var(--danger); color: var(--white); }
.toast.info { background: var(--teal); }

.issue { border: 3px solid var(--ink); padding: .5rem .7rem; margin-bottom: .5rem; background: var(--white); font-size: .9rem; }
.issue.error { border-left: 10px solid var(--danger); }
.issue.warning { border-left: 10px solid var(--yellow); }

code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }
pre { background: var(--ink); color: var(--paper); padding: 1rem; overflow: auto; border: 4px solid var(--ink); }
.muted { opacity: .65; }
.swatch { display: inline-block; width: 1.1rem; height: 1.1rem; border: 3px solid var(--ink); vertical-align: -.2rem; }

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