@font-face {
  font-family: "ATHULUTH";
  src: url("../assets/fonts/ATHULUTH.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --midnight: #050b2e;
  --deep: #09143d;
  --cobalt: #14265f;
  --ivory: #f7ecd8;
  --ivory-soft: #e9dcc6;
  --gold: #d9b26f;
  --gold-bright: #f7d99a;
  --gold-deep: #b58a45;
  --rose: #ffb4a8;
  --muted: rgba(247, 236, 216, 0.64);
  --line: rgba(217, 178, 111, 0.22);
  --line-strong: rgba(217, 178, 111, 0.42);
  --panel: rgba(9, 20, 61, 0.76);
  --panel-solid: #0b1742;
  --danger: #ff9f93;
  --success: #9ad8b0;
  --font-display: "ATHULUTH", "Aref Ruqaa", "Amiri", serif;
  --font-body: "Amiri", "Noto Naskh Arabic", serif;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--midnight);
  color: var(--ivory);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

::selection {
  background: rgba(217, 178, 111, 0.34);
  color: #fffaf0;
}

:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.admin-atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 76% 8%, rgba(40, 67, 145, 0.42), transparent 44%),
    radial-gradient(ellipse at 14% 88%, rgba(181, 138, 69, 0.13), transparent 46%),
    linear-gradient(160deg, #050b2e, #09143d 48%, #050b2e);
}

.admin-atmosphere::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 16% 22%, rgba(247, 217, 154, 0.55) 0 1px, transparent 1.6px),
    radial-gradient(circle at 68% 14%, rgba(226, 235, 255, 0.5) 0 1px, transparent 1.5px),
    radial-gradient(circle at 86% 62%, rgba(247, 217, 154, 0.42) 0 1px, transparent 1.5px),
    radial-gradient(circle at 34% 74%, rgba(226, 235, 255, 0.38) 0 1px, transparent 1.5px),
    radial-gradient(circle at 52% 42%, rgba(247, 217, 154, 0.25) 0 1px, transparent 1.4px);
  background-size: 320px 280px, 420px 360px, 360px 320px, 500px 420px, 280px 260px;
  opacity: 0.8;
}

.admin-atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 49.8%, rgba(217, 178, 111, 0.06) 50%, transparent 50.2%),
    linear-gradient(180deg, transparent 49.8%, rgba(217, 178, 111, 0.05) 50%, transparent 50.2%);
}

.admin-shell {
  width: min(1240px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.2rem 0 2rem;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 76px;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: inherit;
  text-decoration: none;
}

.admin-brand img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  filter: drop-shadow(0 6px 18px rgba(247, 217, 154, 0.14));
}

.admin-brand span {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
}

.admin-brand__eyebrow,
.admin-eyebrow {
  color: var(--gold);
  font-size: 0.72rem;
}

.admin-brand strong {
  color: var(--ivory);
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 400;
  line-height: 1.4;
}

.admin-header__actions,
.admin-toolbar__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.admin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 40px;
  padding: 0.46rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: rgba(217, 178, 111, 0.06);
  color: var(--ivory-soft);
  font-size: 0.82rem;
  line-height: 1.4;
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s var(--ease);
}

.admin-btn:hover {
  border-color: var(--gold);
  background: rgba(217, 178, 111, 0.12);
  transform: translateY(-1px);
}

.admin-btn--gold {
  border-color: var(--gold);
  background: var(--gold);
  color: #081033;
  font-weight: 700;
}

.admin-btn--gold:hover {
  background: var(--gold-bright);
}

.admin-btn--ghost {
  background: transparent;
}

.admin-btn--icon {
  width: 40px;
  padding: 0;
  font-size: 1.1rem;
}

.admin-btn--small {
  min-height: 32px;
  padding: 0.25rem 0.65rem;
  font-size: 0.76rem;
}

.admin-btn[disabled] {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.login-card {
  position: relative;
  width: min(100%, 460px);
  margin: clamp(2rem, 10vh, 7rem) auto;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  border: 1px solid var(--line);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(20, 38, 95, 0.56), rgba(9, 20, 61, 0.84)),
    var(--panel);
  box-shadow: var(--shadow);
  text-align: center;
}

.login-card__ornament {
  margin-bottom: 0.3rem;
  color: var(--gold-bright);
  font-size: 1.7rem;
  text-shadow: 0 0 24px rgba(247, 217, 154, 0.4);
}

.login-card h1 {
  margin: 0.25rem 0 0.55rem;
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.7rem);
  font-weight: 400;
  line-height: 1.5;
}

.login-card__lead {
  margin: 0 auto 1.5rem;
  max-width: 34ch;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  text-align: start;
}

.login-card label,
.admin-dialog label {
  color: var(--ivory-soft);
  font-size: 0.82rem;
}

.password-field {
  display: flex;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: rgba(5, 11, 46, 0.58);
  overflow: hidden;
}

.password-field:focus-within {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 3px rgba(247, 217, 154, 0.09);
}

.password-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0.68rem 0.8rem;
  outline: 0;
}

.password-field button {
  border: 0;
  border-inline-start: 1px solid var(--line);
  background: rgba(217, 178, 111, 0.07);
  padding-inline: 0.75rem;
  color: var(--gold);
  font-size: 0.75rem;
}

.login-card .admin-btn {
  margin-top: 0.45rem;
  min-height: 44px;
}

.login-card__back {
  display: inline-block;
  margin-top: 1.4rem;
  color: var(--muted);
  font-size: 0.78rem;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.form-error {
  margin: 0.2rem 0 0;
  color: var(--danger);
  font-size: 0.78rem;
}

.form-hint {
  margin: -0.15rem 0 0.2rem;
  color: var(--muted);
  font-size: 0.73rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.7rem;
  margin-bottom: 1.2rem;
}

.stat-card {
  min-height: 92px;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(180deg, rgba(20, 38, 95, 0.44), rgba(9, 20, 61, 0.66));
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
}

.stat-card strong {
  display: block;
  margin-top: 0.3rem;
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 3vw, 2.15rem);
  font-weight: 400;
  line-height: 1.2;
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(9, 20, 61, 0.54);
}

.admin-search {
  flex: 1 1 210px;
}

.admin-search input,
.admin-filter select,
.admin-dialog input,
.admin-dialog textarea,
.programme-row input,
.programme-row select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 11, 46, 0.58);
  padding: 0.5rem 0.65rem;
  color: var(--ivory);
  outline: 0;
}

.admin-search input:focus,
.admin-filter select:focus,
.admin-dialog input:focus,
.admin-dialog textarea:focus,
.programme-row input:focus,
.programme-row select:focus {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 3px rgba(247, 217, 154, 0.08);
}

.admin-filter select {
  min-width: 145px;
}

.table-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(9, 20, 61, 0.62);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.16);
}

.table-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
}

.table-card__head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 400;
}

.table-card__head span {
  color: var(--muted);
  font-size: 0.75rem;
}

.table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid rgba(217, 178, 111, 0.1);
  text-align: start;
  vertical-align: middle;
}

.admin-table th {
  background: rgba(5, 11, 46, 0.4);
  color: var(--gold);
  font-size: 0.7rem;
  font-weight: 400;
  white-space: nowrap;
}

.admin-table tbody tr {
  transition: background 0.18s ease;
}

.admin-table tbody tr:hover {
  background: rgba(217, 178, 111, 0.045);
}

.admin-table tbody tr:last-child td {
  border-bottom: 0;
}

.guest-cell {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 135px;
}

.guest-cell strong {
  color: var(--ivory);
  font-weight: 400;
}

.guest-cell span {
  color: var(--muted);
  font-size: 0.68rem;
  direction: ltr;
  text-align: end;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.18rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.68rem;
  white-space: nowrap;
}

.status-badge--active {
  border-color: rgba(154, 216, 176, 0.35);
  color: var(--success);
}

.status-badge--revoked {
  border-color: rgba(255, 159, 147, 0.35);
  color: var(--danger);
}

.status-badge--yes {
  border-color: rgba(154, 216, 176, 0.35);
  color: var(--success);
}

.status-badge--no {
  border-color: rgba(255, 159, 147, 0.35);
  color: var(--danger);
}

.cell-muted {
  color: var(--muted);
  font-size: 0.76rem;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  min-width: 245px;
}

.mini-btn {
  min-height: 30px;
  padding: 0.2rem 0.48rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(5, 11, 46, 0.44);
  color: var(--ivory-soft);
  font-size: 0.68rem;
  line-height: 1.4;
}

.mini-btn:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
}

.mini-btn--gold {
  border-color: rgba(217, 178, 111, 0.4);
  color: var(--gold-bright);
}

.mini-btn--danger {
  border-color: rgba(255, 159, 147, 0.28);
  color: var(--danger);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3.5rem 1rem;
  color: var(--muted);
  text-align: center;
}

.empty-state span {
  color: var(--gold);
  font-size: 1.8rem;
}

.empty-state strong {
  margin-top: 0.4rem;
  color: var(--ivory);
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
}

.empty-state p {
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
}

.admin-note {
  display: flex;
  gap: 0.65rem;
  margin-top: 1.1rem;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(217, 178, 111, 0.16);
  border-radius: 11px;
  background: rgba(9, 20, 61, 0.4);
  color: var(--muted);
  font-size: 0.76rem;
}

.admin-note span {
  color: var(--gold);
}

.admin-note p {
  margin: 0;
}

.admin-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
}

.admin-footer a {
  color: var(--gold);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.admin-dialog {
  width: min(92vw, 480px);
  max-height: 90vh;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--panel-solid);
  color: var(--ivory);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
  overflow: auto;
}

.admin-dialog--wide {
  width: min(94vw, 760px);
}

.admin-dialog::backdrop {
  background: rgba(2, 6, 24, 0.78);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.admin-dialog form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1.2rem;
}

.admin-dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.3rem;
}

.admin-dialog__head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 400;
}

.admin-dialog__close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
}

.admin-dialog textarea {
  min-height: 130px;
  resize: vertical;
}

.admin-dialog__actions {
  display: flex;
  justify-content: end;
  gap: 0.55rem;
  margin-top: 0.7rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.settings-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.settings-grid__full {
  grid-column: 1 / -1;
}

.programme-editor {
  margin-top: 0.9rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
}

.programme-editor__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.55rem;
}

.programme-editor__head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 400;
}

#programmeRows {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.programme-row {
  display: grid;
  grid-template-columns: 0.65fr 1fr 1.55fr 0.8fr auto;
  gap: 0.35rem;
  align-items: center;
  padding: 0.45rem;
  border: 1px solid rgba(217, 178, 111, 0.12);
  border-radius: 9px;
  background: rgba(5, 11, 46, 0.28);
}

.programme-row input,
.programme-row select {
  min-height: 34px;
  padding: 0.3rem 0.4rem;
  font-size: 0.75rem;
}

.programme-row__remove {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 159, 147, 0.25);
  border-radius: 7px;
  background: transparent;
  color: var(--danger);
  font-size: 1rem;
}

.admin-toast {
  position: fixed;
  right: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 200;
  max-width: min(90vw, 440px);
  padding: 0.65rem 1rem;
  border: 1px solid rgba(217, 178, 111, 0.4);
  border-radius: 10px;
  background: rgba(9, 20, 61, 0.98);
  color: var(--ivory);
  font-size: 0.8rem;
  text-align: center;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translate(50%, 16px);
  transition: opacity 0.25s ease, transform 0.25s var(--ease);
  pointer-events: none;
}

.admin-toast.is-visible {
  opacity: 1;
  transform: translate(50%, 0);
}

@media (max-width: 1050px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .admin-shell {
    width: calc(100% - 1rem);
    padding-top: 0.6rem;
  }

  .admin-header {
    min-height: 64px;
    margin-bottom: 1rem;
  }

  .admin-brand img {
    width: 44px;
    height: 44px;
  }

  .admin-brand strong {
    font-size: 1.2rem;
  }

  .admin-header__actions .admin-btn:first-child {
    display: none;
  }

  .admin-btn {
    min-height: 38px;
    padding-inline: 0.7rem;
    font-size: 0.76rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-card {
    min-height: 80px;
  }

  .admin-toolbar {
    align-items: stretch;
  }

  .admin-toolbar__actions {
    width: 100%;
  }

  .admin-toolbar__actions .admin-btn {
    flex: 1 1 auto;
  }

  .table-wrap {
    overflow: visible;
  }

  .admin-table {
    min-width: 0;
  }

  .admin-table thead {
    display: none;
  }

  .admin-table tbody {
    display: flex;
    flex-direction: column;
  }

  .admin-table tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem 0.7rem;
    padding: 0.8rem;
    border-bottom: 1px solid var(--line);
  }

  .admin-table tbody tr:last-child {
    border-bottom: 0;
  }

  .admin-table td {
    display: block;
    padding: 0;
    border: 0;
    font-size: 0.8rem;
  }

  .admin-table td::before {
    content: attr(data-label);
    display: block;
    color: var(--gold);
    font-size: 0.64rem;
    line-height: 1.4;
  }

  .admin-table td:first-child {
    grid-column: 1 / -1;
  }

  .admin-table td:last-child {
    grid-column: 1 / -1;
  }

  .admin-table td:empty {
    display: none;
  }

  .row-actions {
    min-width: 0;
    padding-top: 0.2rem;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-grid__full {
    grid-column: auto;
  }

  .programme-row {
    grid-template-columns: 1fr 1fr;
  }

  .programme-row > :nth-child(3) {
    grid-column: 1 / -1;
  }

  .programme-row__remove {
    grid-column: 2;
    justify-self: end;
  }

  .admin-dialog {
    width: calc(100% - 1rem);
    max-height: 94vh;
  }

  .admin-dialog form {
    padding: 1rem;
  }

  .admin-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
  }
}

@media (max-width: 440px) {
  .admin-brand__eyebrow {
    display: none;
  }

  .stats-grid {
    gap: 0.5rem;
  }

  .stat-card {
    padding: 0.7rem;
  }

  .stat-card strong {
    font-size: 1.55rem;
  }

  .admin-toolbar__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .admin-toolbar__actions .admin-btn {
    width: 100%;
  }

  .admin-toolbar__actions .admin-btn--icon {
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
