/* ==========================================================================
   Parilem — Admin panel
   Uses the colour tokens from style.css (purple / white / red).
   ========================================================================== */

.adm { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }

/* 1. SIDEBAR -------------------------------------------------------------- */
.adm-sidebar {
  background: linear-gradient(170deg, var(--purple-800) 0%, var(--purple-900) 55%, #1c0a44 100%);
  color: #ded7ff; padding: 20px 16px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 22px; overflow-y: auto;
}
.adm-sidebar__logo { display: flex; align-items: center; gap: 10px; padding: 4px 6px 0; }
.adm-sidebar__logo .logo__wordmark { color: #fff; font-size: 20px; }
.adm-sidebar__logo .logo__tagline { color: rgba(255, 255, 255, .55); }

.adm-nav { display: flex; flex-direction: column; gap: 3px; }
.adm-nav__heading {
  font-size: 10.5px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  color: rgba(255, 255, 255, .42); padding: 16px 10px 7px;
}
.adm-nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--r-sm);
  font-size: 14.5px; font-weight: 600; color: #cfc6f5;
  transition: background var(--ease), color var(--ease), transform var(--ease);
}
.adm-nav a:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.adm-nav a.active { background: rgba(255, 255, 255, .14); color: #fff; box-shadow: inset 3px 0 0 var(--red-500); }
.adm-nav a svg { flex-shrink: 0; opacity: .9; }
.adm-nav__count {
  margin-left: auto; font-size: 11.5px; font-weight: 700;
  background: rgba(255, 255, 255, .14); padding: 2px 8px; border-radius: var(--r-full);
}

.adm-user {
  margin-top: auto; padding: 14px; border-radius: var(--r-md);
  background: rgba(0, 0, 0, .22); border: 1px solid rgba(255, 255, 255, .1);
}
.adm-user__head { display: flex; align-items: center; gap: 10px; }
.adm-user__name { font-size: 13.5px; font-weight: 700; color: #fff; line-height: 1.3; }
.adm-user__email { font-size: 11.5px; color: rgba(255, 255, 255, .55); word-break: break-all; }
.adm-user form { margin-top: 10px; }
.adm-logout {
  width: 100%; padding: 8px; border-radius: var(--r-sm); cursor: pointer;
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .16);
  color: #fff; font-size: 13px; font-weight: 600; transition: background var(--ease);
}
.adm-logout:hover { background: var(--red-600); border-color: transparent; }

/* 2. TOP BAR -------------------------------------------------------------- */
.adm-main { display: flex; flex-direction: column; background: var(--bg-alt); min-width: 0; }
.adm-topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 15px 28px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.adm-topbar__title { font-size: 21px; font-weight: 750; letter-spacing: -.02em; }
.adm-topbar__subtitle { font-size: 13px; color: var(--text-faint); margin-top: 2px; }
.adm-topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

.adm-content { padding: 26px 28px 60px; display: flex; flex-direction: column; gap: 22px; }

/* 3. PANEL / CARD --------------------------------------------------------- */
.adm-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 22px;
}
.adm-card__title {
  font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px;
}
.adm-card__title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.adm-card__title a { font-size: 12px; color: var(--brand); text-transform: none; letter-spacing: 0; }

.adm-grid { display: grid; gap: 20px; }
.adm-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.adm-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.adm-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* 4. STAT BOXES ----------------------------------------------------------- */
.adm-stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 18px 20px;
  display: flex; flex-direction: column; gap: 6px;
  position: relative; overflow: hidden; transition: transform var(--ease), box-shadow var(--ease);
}
.adm-stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.adm-stat::after {
  content: ""; position: absolute; right: -30px; top: -30px;
  width: 96px; height: 96px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--purple-500) 22%, transparent), transparent 70%);
}
.adm-stat--red::after { background: radial-gradient(circle, color-mix(in srgb, var(--red-500) 22%, transparent), transparent 70%); }
.adm-stat__label { font-size: 12.5px; font-weight: 600; color: var(--text-faint); }
.adm-stat__value { font-size: 30px; font-weight: 800; letter-spacing: -.035em; line-height: 1; }
.adm-stat__extra { font-size: 12px; color: var(--text-faint); }

/* 5. TABLE ---------------------------------------------------------------- */
.adm-table-wrap { overflow-x: auto; border-radius: var(--r-md); border: 1px solid var(--line); }
.adm-table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--surface); }
.adm-table th {
  text-align: left; padding: 12px 14px; white-space: nowrap;
  font-size: 11.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-faint); background: var(--bg-alt); border-bottom: 1px solid var(--line);
}
.adm-table td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.adm-table tr:last-child td { border-bottom: 0; }
.adm-table tbody tr { transition: background var(--ease); }
.adm-table tbody tr:hover { background: var(--bg-alt); }
.adm-table__name { font-weight: 650; line-height: 1.35; }
.adm-table__name a:hover { color: var(--brand); }
.adm-table__sub { font-size: 12.5px; color: var(--text-faint); margin-top: 3px; }
.adm-table__end { text-align: right; white-space: nowrap; }
.adm-table__narrow { width: 1%; white-space: nowrap; }

.adm-actions { display: flex; gap: 6px; justify-content: flex-end; }
.adm-action {
  display: inline-grid; place-items: center; width: 32px; height: 32px;
  border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--text-soft);
  cursor: pointer; transition: all var(--ease);
}
.adm-action:hover { color: var(--brand); border-color: var(--purple-300); background: var(--bg-alt); }
.adm-action--delete:hover { color: #fff; background: var(--red-500); border-color: transparent; }
.adm-action--approve:hover { color: #fff; background: var(--purple-600); border-color: transparent; }

/* 6. BADGES --------------------------------------------------------------- */
.adm-status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--r-full);
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.adm-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.adm-status--live { background: color-mix(in srgb, #16a34a 16%, transparent); color: #15803d; }
.adm-status--draft { background: var(--gray-100); color: var(--gray-600); }
.adm-status--cover { background: color-mix(in srgb, var(--red-500) 15%, transparent); color: var(--red-600); }
[data-theme="dark"] .adm-status--live { color: #4ade80; }
[data-theme="dark"] .adm-status--draft { background: var(--surface-2); color: var(--text-faint); }
[data-theme="dark"] .adm-status--cover { color: var(--red-400); }

.adm-swatch { width: 22px; height: 22px; border-radius: 7px; display: inline-block; flex-shrink: 0; }

/* 7. FORM ----------------------------------------------------------------- */
.adm-form { display: flex; flex-direction: column; gap: 20px; }
.adm-field { display: flex; flex-direction: column; gap: 7px; }
.adm-field label { font-size: 13.5px; font-weight: 650; }
.adm-field label .required { color: var(--accent); }
.adm-field input[type="text"],
.adm-field input[type="email"],
.adm-field input[type="password"],
.adm-field input[type="number"],
.adm-field input[type="datetime-local"],
.adm-field select,
.adm-field textarea {
  width: 100%; padding: 10px 13px;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text);
  font-size: 14.5px; transition: border-color var(--ease), box-shadow var(--ease);
}
.adm-field textarea { resize: vertical; min-height: 110px; line-height: 1.6; }
.adm-field textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; min-height: 340px; }
.adm-field input:focus, .adm-field select:focus, .adm-field textarea:focus {
  outline: none; border-color: var(--purple-400);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--purple-500) 18%, transparent);
}
.adm-field input[type="color"] {
  width: 46px; height: 38px; padding: 3px; cursor: pointer;
  border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface);
}
.adm-field input[type="file"] {
  width: 100%; padding: 8px; cursor: pointer;
  border: 1px dashed var(--line-2); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text-faint); font-size: 13.5px;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.adm-field input[type="file"]:hover { border-color: var(--purple-400); }
.adm-field--invalid input[type="file"] { border-color: var(--red-400); }
.adm-field input[type="file"]::file-selector-button {
  margin-right: 12px; padding: 7px 14px; cursor: pointer;
  border: 0; border-radius: calc(var(--r-sm) - 2px);
  background: color-mix(in srgb, var(--purple-500) 14%, transparent); color: var(--purple-600);
  font: inherit; font-weight: 650;
}
.adm-hint { font-size: 12.5px; color: var(--text-faint); line-height: 1.5; }
.adm-error { font-size: 12.5px; color: var(--accent); font-weight: 600; }
.adm-field--invalid input, .adm-field--invalid select, .adm-field--invalid textarea { border-color: var(--red-400); }

.adm-row { display: grid; gap: 16px; }
.adm-row--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.adm-row--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.adm-check { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.adm-check input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--purple-600); cursor: pointer; }
.adm-check label { cursor: pointer; }

.adm-form-footer {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-top: 18px; border-top: 1px solid var(--line);
}
.adm-form-footer .align-end { margin-left: auto; display: flex; gap: 8px; }

.adm-form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }

/* 8. FILTER BAR ----------------------------------------------------------- */
.adm-filter {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 12px 14px;
}
.adm-filter input[type="search"], .adm-filter select {
  padding: 8px 12px; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--bg); color: var(--text); font-size: 14px;
}
.adm-filter input[type="search"] { min-width: 240px; flex: 1; }
.adm-filter input:focus, .adm-filter select:focus { outline: none; border-color: var(--purple-400); }
.adm-filter__result { margin-left: auto; font-size: 13px; color: var(--text-faint); }

/* 9. ALERTS --------------------------------------------------------------- */
.adm-alert {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 13px 16px; border-radius: var(--r-md);
  font-size: 14px; font-weight: 550; border: 1px solid;
}
.adm-alert--success { background: color-mix(in srgb, #16a34a 12%, var(--surface)); border-color: color-mix(in srgb, #16a34a 35%, transparent); color: #14663a; }
.adm-alert--error { background: var(--red-50); border-color: color-mix(in srgb, var(--red-500) 35%, transparent); color: var(--red-700); }
.adm-alert--info { background: var(--purple-50); border-color: var(--purple-200); color: var(--purple-800); }
[data-theme="dark"] .adm-alert--success { color: #86efac; }
[data-theme="dark"] .adm-alert--error { background: color-mix(in srgb, var(--red-500) 14%, var(--surface)); color: var(--red-400); }
[data-theme="dark"] .adm-alert--info { background: var(--surface-2); color: var(--purple-300); border-color: var(--line-2); }

/* 10. EMPTY STATE --------------------------------------------------------- */
.adm-empty { text-align: center; padding: 54px 20px; color: var(--text-faint); }
.adm-empty__glyph { font-size: 40px; margin-bottom: 12px; }
.adm-empty strong { display: block; font-size: 17px; color: var(--text); margin-bottom: 6px; }

/* 11. LOGIN PAGE ---------------------------------------------------------- */
.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(60% 60% at 15% 10%, color-mix(in srgb, var(--purple-500) 30%, transparent), transparent 60%),
    radial-gradient(50% 50% at 85% 20%, color-mix(in srgb, var(--red-500) 22%, transparent), transparent 60%),
    var(--bg-alt);
}
.login-box {
  width: 100%; max-width: 412px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); padding: 34px 30px;
  box-shadow: var(--shadow-lg);
}
.login-box__logo { display: flex; justify-content: center; margin-bottom: 20px; }
.login-box h1 { font-size: 23px; text-align: center; margin-bottom: 7px; }
.login-box__footer { font-size: 14px; color: var(--text-faint); text-align: center; margin-bottom: 26px; }
.login-box .adm-form { gap: 16px; }
.login-footer { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-faint); }
.login-footer a { color: var(--brand); font-weight: 600; }

/* 12. RESPONSIVE ---------------------------------------------------------- */
@media (max-width: 1080px) {
  .adm-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .adm-form-layout { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .adm { grid-template-columns: 1fr; }
  .adm-sidebar {
    position: static; height: auto; flex-direction: row; align-items: center;
    gap: 12px; overflow-x: auto; padding: 12px 14px;
  }
  .adm-sidebar__logo { padding: 0; }
  .adm-nav { flex-direction: row; gap: 4px; }
  .adm-nav__heading, .adm-nav__count, .adm-user__head, .adm-sidebar .logo__tagline { display: none; }
  .adm-nav a { padding: 8px 11px; font-size: 13.5px; white-space: nowrap; }
  .adm-user { margin: 0 0 0 auto; padding: 0; background: none; border: 0; }
  .adm-user form { margin: 0; }
  .adm-topbar, .adm-content { padding-inline: 16px; }
  .adm-grid--2, .adm-grid--3, .adm-grid--4, .adm-row--2, .adm-row--3 { grid-template-columns: 1fr; }
}

/* 13. TRANSLATION PANEL --------------------------------------------------- */
.adm-translation { border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: 10px; overflow: hidden; }
.adm-translation > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 15px; background: var(--bg-alt);
  font-size: 14px; transition: background var(--ease);
}
.adm-translation > summary::-webkit-details-marker { display: none; }
.adm-translation > summary:hover { background: var(--surface-2); }
.adm-translation > summary strong { font-weight: 650; }
.adm-translation > summary svg { margin-left: auto; opacity: .55; transition: transform var(--ease); }
.adm-translation[open] > summary { border-bottom: 1px solid var(--line); }
.adm-translation[open] > summary svg { transform: rotate(180deg); }
.adm-translation__body { padding: 18px 15px; }

/* 15. AI PANEL ------------------------------------------------------------- */
.adm-alert--warning {
  background: color-mix(in srgb, #d97706 11%, var(--surface));
  border-color: color-mix(in srgb, #d97706 38%, transparent);
  color: #92400e;
  margin: 14px 0;
}
[data-theme="dark"] .adm-alert--warning {
  background: color-mix(in srgb, #d97706 14%, var(--surface));
  color: #fbbf24;
}
.adm-alert--running { margin-bottom: 16px; align-items: center; }

.adm-status--failed {
  background: color-mix(in srgb, var(--red-500) 15%, transparent);
  color: var(--red-700);
}
[data-theme="dark"] .adm-status--failed { color: var(--red-400); }

/* Small spinner shown while a job is queued */
.adm-spinner {
  width: 14px; height: 14px; flex-shrink: 0;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor; border-radius: 50%;
  animation: adm-spin .7s linear infinite;
}
@keyframes adm-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .adm-spinner { animation-duration: 2.4s; } }

.ai-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.ai-block h4 { font-size: 15.5px; margin-bottom: 6px; }
.ai-block .adm-hint { margin-bottom: 14px; }
.ai-block .btn { margin-top: 4px; }

.ai-lang-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.ai-lang {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--line);
  border-radius: var(--r-sm); font-size: 14px; cursor: pointer;
  transition: border-color var(--ease), background var(--ease);
}
.ai-lang:hover { border-color: var(--purple-400); background: var(--surface-2); }
.ai-lang__name { font-weight: 600; }
.ai-lang .adm-status { margin-left: auto; }
.ai-lang input { accent-color: var(--purple-600); cursor: pointer; }

.ai-notes { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.ai-notes h4 { font-size: 14.5px; margin-bottom: 10px; display: flex; gap: 10px; align-items: baseline; }
.ai-notes ul { display: flex; flex-direction: column; gap: 7px; }
.ai-notes li {
  font-size: 14px; line-height: 1.6; color: var(--text-soft);
  padding-left: 2px;
}
.ai-notes .ai-note--warning { color: #92400e; font-weight: 550; }
[data-theme="dark"] .ai-notes .ai-note--warning { color: #fbbf24; }

.ai-history { margin-top: 18px; }
.ai-history > summary {
  cursor: pointer; font-size: 13.5px; font-weight: 650;
  color: var(--text-faint); padding: 8px 0;
}
.ai-history > summary:hover { color: var(--brand); }
.ai-history .chip {
  display: inline-block; padding: 2px 7px; margin-left: 6px;
  border-radius: var(--r-xs); background: var(--surface-2);
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
}

@media (max-width: 860px) {
  .ai-grid { grid-template-columns: 1fr; gap: 26px; }
}

/* 16. TEAM PORTRAIT ------------------------------------------------------- */
.photo-field { display: flex; gap: 16px; align-items: flex-start; }
.photo-field__input { flex: 1; min-width: 0; }
.photo-field input[type="file"] { font-size: 13.5px; max-width: 100%; }
.photo-preview {
  width: 72px; height: 72px; flex-shrink: 0;
  border-radius: 50%; object-fit: cover;
  border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line);
}
.photo-thumb {
  width: 30px; height: 30px; border-radius: 50%; object-fit: cover;
  box-shadow: 0 0 0 1px var(--line);
}
.photo-remove {
  display: inline-flex; align-items: center; gap: 7px; margin-top: 10px;
  font-size: 13.5px; font-weight: 600; color: var(--text-soft); cursor: pointer;
}
.photo-remove input { accent-color: var(--red-500); cursor: pointer; }

/* 17. APPLICATION DETAILS ------------------------------------------------- */
.application-doc { display: grid; grid-template-columns: 160px 1fr; gap: 12px 20px; }
.application-doc dt { font-size: 13px; font-weight: 700; color: var(--text-faint); }
.application-doc dd { font-size: 14.5px; line-height: 1.65; }
.application-doc__text { white-space: pre-wrap; }
@media (max-width: 620px) {
  .application-doc { grid-template-columns: 1fr; gap: 4px 0; }
  .application-doc dd { margin-bottom: 12px; }
}
