/* ---------------------------------------------------------------------------
   Vazirmatn (self-hosted)
   --------------------------------------------------------------------------- */
@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---------------------------------------------------------------------------
   Base
   --------------------------------------------------------------------------- */
:root {
  color-scheme: light;

  --bg: #f2f5fb;
  --bg-soft: #ffffff;
  --panel: #ffffff;
  --panel-2: #eaf0f9;
  --border: #d7e0ee;
  --text: #1b2434;
  --text-soft: #263247;
  --muted: #5d6b82;
  --accent: #2563eb;
  --accent-strong: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #1f9d5c;
  --success-strong: #1a8f52;
  --success-strong-hover: #157a46;
  --success-text: #14764a;
  --danger: #dc3b52;
  --danger-strong: #c22f45;
  --danger-strong-hover: #a9283c;
  --warning: #b7791f;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(23, 43, 77, 0.1);
  --btn-hover: #dfe7f4;
  --ghost-hover: rgba(37, 99, 235, 0.08);
  --chip-bg: rgba(37, 99, 235, 0.06);
  --image-bg: #e9eef6;
  --focus-ring: rgba(37, 99, 235, 0.18);
  --glow-primary: rgba(37, 99, 235, 0.12);
  --glow-secondary: rgba(31, 157, 92, 0.1);
  --glow-auth: rgba(37, 99, 235, 0.14);
  --alert-error-bg: #fdecee;
  --alert-error-border: #f2b3bc;
  --alert-error-text: #9c1c2e;
  --alert-success-bg: #e6f8ee;
  --alert-success-border: #8fd3ac;
  --alert-success-text: #12603c;
  --badge-pending-bg: #fdf3d8;
  --badge-pending-border: #e9c464;
  --badge-pending-text: #7a5200;
  --badge-approved-bg: #e2f7ec;
  --badge-approved-border: #7cc9a0;
  --badge-approved-text: #12603c;
  --badge-rejected-bg: #fde8eb;
  --badge-rejected-border: #f0a7b1;
  --badge-rejected-text: #97192b;
  --badge-image-bg: #e8f0ff;
  --badge-image-border: #a3c0fb;
  --badge-image-text: #1a4cae;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0b1220;
  --bg-soft: #111a2c;
  --panel: #16213a;
  --panel-2: #1c2a47;
  --border: #273952;
  --text: #e8eefb;
  --text-soft: #dce6fa;
  --muted: #9aa9c3;
  --accent: #6ea2ff;
  --accent-strong: #2f72f0;
  --accent-hover: #2a66d6;
  --success: #2fbf71;
  --success-strong: #1f8f56;
  --success-strong-hover: #1b7c4b;
  --success-text: #8be8b4;
  --danger: #ef5a6f;
  --danger-strong: #b93b4d;
  --danger-strong-hover: #a33344;
  --warning: #f0b429;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --btn-hover: #25365a;
  --ghost-hover: rgba(255, 255, 255, 0.06);
  --chip-bg: rgba(255, 255, 255, 0.05);
  --image-bg: #080d16;
  --focus-ring: rgba(110, 162, 255, 0.18);
  --glow-primary: rgba(47, 114, 240, 0.18);
  --glow-secondary: rgba(47, 191, 113, 0.1);
  --glow-auth: rgba(47, 114, 240, 0.2);
  --alert-error-bg: rgba(239, 90, 111, 0.12);
  --alert-error-border: rgba(239, 90, 111, 0.45);
  --alert-error-text: #ffb8c1;
  --alert-success-bg: rgba(47, 191, 113, 0.12);
  --alert-success-border: rgba(47, 191, 113, 0.45);
  --alert-success-text: #a9f0c9;
  --badge-pending-bg: rgba(240, 180, 41, 0.16);
  --badge-pending-border: rgba(240, 180, 41, 0.4);
  --badge-pending-text: #ffd67a;
  --badge-approved-bg: rgba(47, 191, 113, 0.14);
  --badge-approved-border: rgba(47, 191, 113, 0.4);
  --badge-approved-text: #8be8b4;
  --badge-rejected-bg: rgba(239, 90, 111, 0.14);
  --badge-rejected-border: rgba(239, 90, 111, 0.4);
  --badge-rejected-text: #ff9daa;
  --badge-image-bg: rgba(110, 162, 255, 0.14);
  --badge-image-border: rgba(110, 162, 255, 0.4);
  --badge-image-text: #a9c8ff;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Vazirmatn", Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.9;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  line-height: 1.5;
  margin: 0 0 12px;
  font-weight: 700;
}

h1 {
  font-size: clamp(1.5rem, 2.4vw, 2rem);
}

h2 {
  font-size: 1.2rem;
}

p {
  margin: 0 0 12px;
}

ul {
  margin: 0;
}

/* ---------------------------------------------------------------------------
   Display page
   --------------------------------------------------------------------------- */
.display-page {
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
  background:
    radial-gradient(circle at 15% 10%, var(--glow-primary), transparent 45%),
    radial-gradient(circle at 85% 90%, var(--glow-secondary), transparent 45%),
    var(--bg);
}

.display-page.is-idle,
.display-page.is-idle * {
  cursor: none;
}

.slideshow {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2vh 4vw;
}

.slide {
  --fit-scale: 1;
  width: min(92vw, 1800px);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 1.4em;
  text-align: right;
  font-size: calc(clamp(1rem, 1.15vw, 2.2rem) * var(--fit-scale));
}

.slide.slide-enter {
  animation: slide-fade 0.55s ease;
}

@keyframes slide-fade {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.project-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35em;
  text-align: center;
}

.slide .slide-title {
  margin: 0;
  font-size: 2.4em;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.student-name {
  margin: 0;
  color: var(--muted);
  font-size: 1.05em;
}

.tech-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4em;
  margin-top: 0.15em;
}

.tech-tag {
  font-size: 0.82em;
  line-height: 1.8;
  color: var(--accent);
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05em 0.85em;
  white-space: nowrap;
}

.project-main {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  align-items: center;
  gap: 2em;
  min-height: 0;
}

.slide:not(.has-image) .project-main {
  grid-template-columns: minmax(0, 1fr);
}

.slide.image-only .project-main {
  grid-template-columns: minmax(0, 1fr);
}

.slide.image-only .image-frame {
  width: min(100%, calc(62vh * 4 / 3));
}

.project-sections {
  display: grid;
  gap: 1em;
  align-content: center;
  min-height: 0;
}

.project-sections.no-image {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: center;
}

.project-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.9em;
  padding: 0.85em 1.15em;
}

.section-title {
  margin: 0 0 0.2em;
  font-size: 1.1em;
  color: var(--accent);
}

.section-content {
  margin: 0;
  font-size: 1.15em;
  line-height: 1.85;
  color: var(--text-soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.slide-image-wrap {
  margin: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.55em;
}

.image-frame {
  width: min(100%, calc(50vh * 4 / 3));
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5em;
  border-radius: 0.9em;
  background: var(--image-bg);
  box-shadow: var(--shadow);
}

.slide-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0.6em;
}

.slide-image.image-swap {
  animation: image-fade 0.5s ease;
}

@keyframes image-fade {
  from {
    opacity: 0.15;
  }
  to {
    opacity: 1;
  }
}

.image-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}

.image-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.25s ease, transform 0.25s ease;
}

.image-dot.is-active {
  background: var(--accent);
  transform: scale(1.2);
}

.image-caption {
  margin: 0;
  font-size: 0.95em;
  color: var(--muted);
  text-align: center;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
  color: var(--muted);
  font-size: clamp(1.1rem, 2vw, 1.5rem);
}

.empty-state p {
  margin: 0;
}

/* ---------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  padding: 9px 20px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.btn:hover {
  background: var(--btn-hover);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent-strong);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-success {
  background: var(--success-strong);
  color: #ffffff;
}

.btn-success:hover {
  background: var(--success-strong-hover);
}

.btn-danger {
  background: var(--danger-strong);
  color: #ffffff;
}

.btn-danger:hover {
  background: var(--danger-strong-hover);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  background: var(--ghost-hover);
  border-color: var(--accent);
}

.btn-sm {
  padding: 4px 12px;
  font-size: 0.88rem;
  border-radius: 8px;
}

.btn-block {
  width: 100%;
}

/* ---------------------------------------------------------------------------
   Layout & cards
   --------------------------------------------------------------------------- */
.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 72px;
}

.page-wide {
  max-width: 1160px;
}

.topbar,
.admin-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.subtitle {
  color: var(--muted);
  margin: 4px 0 0;
  max-width: 62ch;
}

.topbar-links,
.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.topbar-links a {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.9rem;
}

.topbar-links a:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
}

.card + .card {
  margin-top: 24px;
}

.card > h2:not(:first-child) {
  margin-top: 4px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

.hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 4px 0 0;
}

.label-en {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 400;
}

/* ---------------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}

.field label {
  font-weight: 500;
}

.field-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.field-counter {
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.optional-tag {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 400;
}

.field-compact {
  margin-bottom: 0;
  gap: 4px;
}

.field-compact textarea {
  min-height: 84px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0 20px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"],
textarea {
  width: 100%;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  font: inherit;
  line-height: 1.7;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input[type="file"] {
  cursor: pointer;
  color: var(--muted);
  padding: 9px 12px;
}

input::file-selector-button {
  font: inherit;
  margin-inline-end: 10px;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.image-previews {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 4px 0 24px;
}

.image-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

.image-preview-thumb {
  flex: none;
  width: 96px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--image-bg);
}

.image-preview-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.image-preview-name {
  color: var(--muted);
  font-size: 0.85rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-preview-body input {
  width: 100%;
}

.hint-warning {
  color: var(--warning);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

/* ---------------------------------------------------------------------------
   Theme picker
   --------------------------------------------------------------------------- */
.theme-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.theme-option:hover {
  border-color: var(--accent);
}

.theme-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.theme-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent-strong);
  cursor: pointer;
}

.theme-option-text {
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

.theme-option-hint {
  color: var(--muted);
  font-size: 0.82rem;
}

/* ---------------------------------------------------------------------------
   Alerts & badges
   --------------------------------------------------------------------------- */
.alert {
  border-radius: 10px;
  padding: 12px 18px;
  margin-bottom: 20px;
  border: 1px solid;
}

.alert-error {
  background: var(--alert-error-bg);
  border-color: var(--alert-error-border);
  color: var(--alert-error-text);
}

.alert-success {
  background: var(--alert-success-bg);
  border-color: var(--alert-success-border);
  color: var(--alert-success-text);
}

.alert-list {
  margin: 0;
  padding-inline-start: 20px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge-pending {
  background: var(--badge-pending-bg);
  color: var(--badge-pending-text);
  border: 1px solid var(--badge-pending-border);
}

.badge-approved,
.badge-text {
  background: var(--badge-approved-bg);
  color: var(--badge-approved-text);
  border: 1px solid var(--badge-approved-border);
}

.badge-rejected {
  background: var(--badge-rejected-bg);
  color: var(--badge-rejected-text);
  border: 1px solid var(--badge-rejected-border);
}

.badge-image {
  background: var(--badge-image-bg);
  color: var(--badge-image-text);
  border: 1px solid var(--badge-image-border);
}

/* ---------------------------------------------------------------------------
   Auth page
   --------------------------------------------------------------------------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 15%, var(--glow-auth), transparent 45%),
    var(--bg);
}

.auth-wrap {
  width: min(440px, 100%);
}

.auth-card h1 {
  text-align: center;
  margin-bottom: 20px;
}

.auth-footer {
  text-align: center;
  margin: 20px 0 0;
  font-size: 0.9rem;
}

/* ---------------------------------------------------------------------------
   Admin dashboard
   --------------------------------------------------------------------------- */
.project-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.project-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}

.project-title {
  font-size: 1.12rem;
  margin: 0 0 2px;
}

.project-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.project-side {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.project-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.project-actions form {
  margin: 0;
}

.project-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  padding: 16px 20px;
  margin-bottom: 20px;
  color: var(--muted);
}

.empty-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.success-card h2 {
  color: var(--success-text);
}

/* ---------------------------------------------------------------------------
   Slide editor
   --------------------------------------------------------------------------- */
.slide-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.editor-group + .editor-group {
  margin-top: 28px;
}

.editor-group-title {
  font-size: 1.05rem;
  margin: 0 0 12px;
  color: var(--muted);
}

.slide-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}

.slide-order {
  flex: none;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
}

.slide-thumb {
  flex: none;
  width: 100px;
  height: 68px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--image-bg);
  border: 1px solid var(--border);
}

.slide-thumb-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.slide-body {
  flex: 1;
  min-width: 0;
}

.slide-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.slide-title {
  font-weight: 500;
}

.slide-preview {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.slide-controls {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
}

.toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-strong);
  cursor: pointer;
}

.move-buttons {
  display: flex;
  gap: 4px;
}

.move-buttons .btn {
  width: 32px;
  height: 30px;
  padding: 0;
  font-size: 0.9rem;
}

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .project-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .slide-image-wrap {
    order: -1;
  }

  .project-sections.no-image {
    grid-template-columns: minmax(0, 1fr);
  }

  .image-frame {
    width: min(100%, calc(38vh * 4 / 3));
  }
}

@media (max-width: 640px) {
  .page {
    padding: 20px 14px 56px;
  }

  .card {
    padding: 20px 16px;
  }

  .slideshow {
    padding: 12px 16px;
  }

  .slide {
    gap: 1em;
  }

  .slide-item {
    flex-wrap: wrap;
  }

  .slide-body {
    flex-basis: calc(100% - 140px);
  }

  .slide-controls {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .project-side {
    width: 100%;
    justify-content: space-between;
  }
}
