/* ===========================================
   ANIME OF THE DECADE - Persona-4-inspired reskin
   Bold yellow/black base, red accents, manga-panel energy.
   =========================================== */

:root {
  /* --- Palette (Milestone 5) - the only hardcoded hex in this file.
     Every rule below references these variables, never raw hex, so the
     palette stays swappable. --- */
  --color-bg: #0d0d0d;
  --color-bg-panel: #1a1a1a;
  --color-primary: #f9dc24;
  --color-primary-dark: #d4b800;
  --color-accent-red: #e0122e;
  --color-white: #f5f5f0;
  --color-text-on-yellow: #0d0d0d;
  --color-border: #0d0d0d;
  --color-success: #f9dc24;

  /* --- Derived tokens: built FROM the palette above via color-mix(), not
     new hardcoded hex. Fill in semantic slots the old theme needed
     (secondary/muted text, a lifted-panel shade, hover overlays). --- */
  --color-text-secondary: color-mix(in srgb, var(--color-white) 78%, var(--color-bg));
  --color-text-muted: color-mix(in srgb, var(--color-white) 55%, var(--color-bg));
  --color-bg-panel-alt: color-mix(in srgb, var(--color-bg-panel) 82%, var(--color-white));
  --gradient-primary: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  --overlay-primary-10: color-mix(in srgb, var(--color-primary) 12%, transparent);
  --overlay-primary-20: color-mix(in srgb, var(--color-primary) 22%, transparent);
  --overlay-red-10: color-mix(in srgb, var(--color-accent-red) 15%, transparent);

  /* White text on --color-accent-red measures ~4.47:1 (verified by hand,
     luminance-based) - just under WCAG AA's 4.5:1 for normal-weight text.
     This darkened variant (~5.8:1) is what white text sits on; the raw
     --color-accent-red stays reserved for borders/icons/large fills where
     only the 3:1 non-text UI-contrast rule applies. */
  --color-accent-red-text-safe: color-mix(in srgb, var(--color-accent-red) 85%, black);

  /* --- Backward-compat aliases: static/js/*.js still reference the old
     variable names in a few inline styles (Toastify colors, focus rings).
     This reskin's scope is templates + this file, not the JS - aliasing
     keeps those references resolving to the new palette instead of
     breaking, without editing JS. --- */
  --primary-purple: var(--color-primary);
  --primary-dark: var(--color-primary-dark);
  --primary-light: var(--color-primary);
  --secondary-purple: var(--color-primary-dark);
  --background-dark: var(--color-bg);
  --surface-dark: var(--color-bg-panel);
  --surface-light: var(--color-bg-panel-alt);
  --text-primary: var(--color-white);
  --text-secondary: var(--color-text-secondary);
  --text-muted: var(--color-text-muted);
  --success: var(--color-success);
  --warning: var(--color-accent-red);
  --danger: var(--color-accent-red);
  --info: var(--color-primary);
  --border-color: var(--color-border);
  --gradient-purple: var(--gradient-primary);
  --gradient-light: var(--gradient-primary);
}

/* CSS Reset & Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Cairo', sans-serif;
  background-color: var(--color-bg);
  color: var(--color-white);
  direction: rtl;
  min-height: 100vh;
  padding: 20px;
  line-height: 1.6;
}

/* Reusable halftone/screentone texture: small black dots at low opacity,
   generated via repeating-radial-gradient (no image asset) so it stays
   swappable through --color-border like everything else. */
.screentone {
  position: relative;
}

.screentone::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background-image: repeating-radial-gradient(
    circle at 4px 4px,
    color-mix(in srgb, var(--color-border) 20%, transparent) 0,
    color-mix(in srgb, var(--color-border) 20%, transparent) 1.4px,
    transparent 1.4px,
    transparent 8px
  );
  background-size: 8px 8px;
  opacity: 0.6;
}

/* Main Container */
.container {
  max-width: 800px;
  margin: 0 auto;
  background: var(--color-bg-panel);
  border-radius: 4px;
  padding: 30px;
  border: 4px solid var(--color-border);
  box-shadow: 8px 8px 0 var(--color-border);
}

.container.admin-mode {
  max-width: 98vw;
  margin: 0 auto;
  padding: 10px;
}

/* Headers */
h1 {
  text-align: center;
  color: var(--color-primary);
  margin-bottom: 20px;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

h1 i {
  color: var(--color-primary);
  margin-left: 10px;
}

h2 {
  text-align: center;
  color: var(--color-primary);
  margin-bottom: 30px;
  font-size: 1.5rem;
  font-weight: 600;
}

h3 {
  font-size: 1.3rem;
  color: var(--color-white);
  margin-bottom: 15px;
  font-weight: 600;
}

/* Desktop Header - angled divider under the hero, mirrored for RTL per
   Milestone 5 (never rely on default RTL handling for clip-path shapes). */
.header {
  text-align: center;
  margin-bottom: 30px;
  position: relative;
  padding-bottom: 1.75rem;
}

.header::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 1.5rem;
  background: var(--color-primary);
  clip-path: polygon(0 100%, 100% 0, 100% 100%);
}

[dir="rtl"] .header::after {
  clip-path: polygon(0 0, 100% 100%, 0 100%);
}

.theme-tag {
  display: inline-block;
  background: var(--color-bg);
  color: var(--color-primary);
  border: 2px solid var(--color-border);
  padding: 5px 15px;
  border-radius: 20px;
  font-size: 0.9rem;
  margin-top: 10px;
  font-weight: 600;
}

/* Mobile Banner */
.mobile-banner {
  background: var(--color-primary);
  color: var(--color-text-on-yellow);
  padding: 12px;
  text-align: center;
  font-weight: 700;
  border: 3px solid var(--color-border);
  border-radius: 4px;
  margin-bottom: 20px;
  display: none;
}

/* Progress Indicator */
.progress-indicator {
  margin: 30px 0;
}

.progress-bar {
  height: 8px;
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: 3px;
  margin-bottom: 20px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--color-primary);
  width: 33%;
  transition: width 0.3s ease;
}

.progress-steps {
  display: flex;
  justify-content: space-between;
  position: relative;
}

.progress-steps::before {
  content: '';
  position: absolute;
  top: 20px;
  right: 10%;
  left: 10%;
  height: 2px;
  background: var(--color-bg-panel-alt);
  z-index: 1;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 2;
}

.step-number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-bg-panel-alt);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1rem;
  margin-bottom: 8px;
  border: 3px solid var(--color-border);
  transition: all 0.3s ease;
}

.step.active .step-number {
  background: var(--color-primary);
  color: var(--color-text-on-yellow);
  border-color: var(--color-border);
}

.step span {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.step.active span {
  color: var(--color-white);
}

/* Input Cards */
.input-card, .voting-card {
  background: var(--color-bg-panel);
  border-radius: 4px;
  padding: 25px;
  margin-bottom: 20px;
  border: 3px solid var(--color-border);
}

.input-header, .voting-header {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--color-border);
}

.input-header i, .voting-header i {
  font-size: 1.5rem;
  color: var(--color-text-on-yellow);
  background: var(--color-primary);
  padding: 10px;
  border-radius: 4px;
  border: 2px solid var(--color-border);
}

.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--color-text-secondary);
  font-weight: 600;
}

.input-with-icon {
  position: relative;
}

.input-with-icon .input-icon {
  position: absolute;
  left: 15px !important;
  right: auto !important;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
}

.input-with-icon input {
  padding-right: 15px !important;
  padding-left: 50px !important;
  color: #000000 !important;
}

.input-hint {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-top: 5px;
}

/* Form Inputs - kept light-on-white for legibility against typed content,
   deliberately independent of the dark page theme. */
input, select, textarea, input::placeholder, .selection-input {
  width: 100%;
  padding: 15px;
  background: white !important;
  border: 2px solid #ddd;
  border-radius: 4px;
  color: #000000 !important;
  font-family: 'Cairo', sans-serif;
  font-size: 1rem;
  transition: all 0.3s ease;
  text-align: right;
  direction: rtl;
}

input:focus, select:focus, textarea:focus, .selection-input:focus {
  outline: none;
  border-color: var(--color-primary-dark);
  box-shadow: 0 0 0 3px var(--overlay-primary-20);
}

input::placeholder, .selection-input::placeholder {
  color: #666666 !important;
  opacity: 1;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23666666' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 15px center;
  background-size: 16px;
  padding-left: 45px;
}

/* Buttons - yellow is the high-emphasis CTA color per Milestone 5 usage
   rules; secondary actions are outlined, not filled. */
.btn-primary, .btn-secondary, .btn-submit, button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 15px;
  border: 3px solid var(--color-border);
  border-radius: 4px;
  font-family: 'Cairo', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  text-decoration: none;
  width: 100%;
  margin-top: 15px;
}

.btn-primary, .btn-submit, button[type="submit"] {
  background: var(--color-primary);
  color: var(--color-text-on-yellow);
  box-shadow: 4px 4px 0 var(--color-border);
}

.btn-primary:hover, .btn-submit:hover, button[type="submit"]:hover {
  background: var(--color-primary-dark);
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--color-border);
}

.btn-secondary {
  background: var(--color-bg);
  color: var(--color-white);
}

.btn-secondary:hover {
  background: var(--color-bg-panel-alt);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.form-actions {
  display: flex;
  gap: 15px;
  margin-top: 25px;
}

.form-actions button {
  flex: 1;
}

.input-icon {
  position: absolute;
  left: 15px !important;
  right: auto !important;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  opacity: 0;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.input-icon.visible {
  opacity: 1;
}

.input-icon.visible[data-valid="true"] {
  background-color: var(--color-success);
  border-color: var(--color-border);
  color: var(--color-text-on-yellow);
}

.input-icon.visible[data-valid="false"] {
  background-color: var(--color-accent-red-text-safe);
  border-color: var(--color-border);
  color: var(--color-white);
}

.spinner .fa-spin {
  font-size: 2.5rem;
  color: var(--color-primary);
  margin-bottom: 1.5rem;
  animation: fa-spin 2s infinite linear;
}

@keyframes fa-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Error / duplicate messages - the one place red text sits directly on a
   dark background; ~3.98:1 against --color-bg, which meets the 3:1 bar
   for large/bold text (this block is bold, 15px+) but not the stricter
   4.5:1 normal-text minimum, so the icon+border carry the "danger" signal
   and the message text itself stays --color-white for guaranteed contrast. */
.duplicate-error, .error-msg {
  background: var(--overlay-red-10);
  border: 3px solid var(--color-accent-red);
  border-radius: 4px;
  padding: 15px;
  margin: 20px 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--color-white);
  line-height: 1.5;
}

.error-msg {
  flex-direction: column;
  align-items: center;
  text-align: center;
  font-weight: 600;
}

.duplicate-error i, .error-msg i {
  font-size: 1.2rem;
  margin-top: 2px;
  color: var(--color-accent-red);
}

/* Footer */
.theme-footer {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 3px solid var(--color-border);
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.footer-content {
  max-width: 600px;
  margin: 0 auto;
}

.footer-content p {
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.footer-content a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.3s ease;
}

.footer-content a:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
}

/* Vote Counter */
.vote-counter {
  background: var(--color-primary);
  color: var(--color-text-on-yellow);
  border: 2px solid var(--color-border);
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: bold;
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* ===========================================
   Results Page Specific Styles
   =========================================== */
.user-header {
  text-align: center;
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  background: var(--color-primary);
  border-radius: 4px;
  border: 4px solid var(--color-border);
  box-shadow: 6px 6px 0 var(--color-border);
}

.user-header h2 {
  color: var(--color-text-on-yellow);
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

.user-header p, #user-info p {
  color: var(--color-text-on-yellow);
  font-size: 1rem;
  margin: 5px 0;
  opacity: 0.85;
}

#user-id {
  color: var(--color-text-on-yellow);
  font-weight: 600;
  background: rgba(13, 13, 13, 0.1);
  padding: 5px 15px;
  border-radius: 20px;
  display: inline-block;
  margin-top: 10px;
}

.timestamp {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-top: 30px;
  padding-top: 15px;
  border-top: 2px solid var(--color-border);
}

.animate__animated {
  animation-duration: 0.6s;
  animation-fill-mode: both;
}

.animate__fadeInDown {
  animation-name: fadeInDown;
}

.animate__fadeIn {
  animation-name: fadeIn;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translate3d(0, -20px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===========================================
   Voting Section Styles
   =========================================== */
.voting-header-info {
  text-align: center;
  margin-bottom: 2rem;
  padding: 1rem;
  background: var(--color-bg-panel-alt);
  border-radius: 4px;
  border: 3px solid var(--color-primary);
}

.voting-subtitle {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.categories-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.category-card {
  background: var(--color-bg-panel);
  border-radius: 4px;
  padding: 1.5rem;
  border: 3px solid var(--color-border);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.category-card:hover {
  box-shadow: 5px 5px 0 var(--color-primary);
  transform: translate(-2px, -2px);
}

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.category-title {
  color: var(--color-white);
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0;
}

.category-badge {
  background: var(--color-primary);
  color: var(--color-text-on-yellow);
  border: 2px solid var(--color-border);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
}

.category-description {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.category-selections {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.selection-field {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.selection-field label {
  min-width: 80px;
  font-weight: 600;
  color: var(--color-white);
  font-size: 1rem;
}

.input-container {
  flex: 1;
  position: relative;
}

/* Per-field year filter (each anime picker gets its own, not one shared
   across a whole category - a shared filter meant picking a year for one
   field silently narrowed another field's results too, which read as "I
   can't find this anime" when really the filter was just stale). */
.input-container--with-year {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.anime-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 0;
}

.inline-year-select {
  flex: 0 0 auto;
  width: 100px;
  appearance: auto;
  background-image: none;
  padding: 0.6rem 0.4rem;
  border: 2px solid #ddd;
  border-radius: 4px;
  font-family: 'Cairo', sans-serif;
  font-size: 0.85rem;
  background-color: white;
  color: #000000;
}

.selection-input {
  width: 100%;
  padding: 0.8rem 1rem 0.8rem 3rem !important;
  border: 2px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  font-family: 'Cairo', sans-serif;
  transition: all 0.3s ease;
  background: white !important;
  color: #000000 !important;
  text-align: right;
  direction: rtl;
}

.selection-input:focus {
  outline: none;
  border-color: var(--color-primary-dark);
  box-shadow: 0 0 0 3px var(--overlay-primary-20);
}

/* Duplicate-selection flag: makes it obvious in red exactly which ranked
   picks collide, live as the voter selects/clears (see checkRankedDuplicates
   in index.js), not just as a generic error at submit time. */
.selection-input.duplicate-selection {
  border-color: var(--color-accent-red) !important;
  background: color-mix(in srgb, var(--color-accent-red) 12%, white) !important;
  box-shadow: 0 0 0 2px var(--color-accent-red) !important;
}

.selection-icon {
  position: absolute;
  left: 1rem !important;
  right: auto !important;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.selection-icon.visible {
  opacity: 1;
}

.selection-icon[data-valid="true"] {
  background: var(--color-success);
  color: var(--color-text-on-yellow);
}

.selection-icon[data-valid="false"] {
  background: var(--color-accent-red-text-safe);
  color: var(--color-white);
}

/* Single selection category styles */
.category-card.single-selection .selection-field {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.category-card.single-selection .selection-field label {
  min-width: auto;
  font-size: 1.1rem;
  color: var(--color-white);
}

.category-card.single-selection .selection-input {
  padding: 1rem 1rem 1rem 3rem !important;
  font-size: 1.1rem;
  border: 2px solid #ddd;
}

.category-card.single-selection .selection-input:focus {
  border-color: var(--color-primary-dark);
  box-shadow: 0 0 0 3px var(--overlay-primary-20);
}

/* ===========================================
   Results Page - category sections
   =========================================== */
.category-section {
  background: var(--color-bg-panel);
  border-radius: 4px;
  padding: 20px;
  margin-bottom: 20px;
  border: 3px solid var(--color-border);
  animation: fadeIn 0.6s ease-out;
}

/* "Worst Series Finale" - negative-context red accent per Milestone 5
   usage rules. results.js adds this class by matching the category's
   Arabic display name (see displayResults()). */
.category-section--negative {
  border-color: var(--color-accent-red);
}

.category-section--negative .category-title {
  color: var(--color-accent-red);
}

.selections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 15px;
}

.selection-card {
  background: var(--color-bg-panel-alt);
  border-radius: 4px;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
  border: 2px solid var(--color-border);
}

.selection-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-3px);
}

.selection-rank {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

/* Rank badges are always primary yellow per Milestone 5 usage rules
   ("rank badges" explicitly listed as a high-emphasis use). results.js
   still sets a per-index inline background color (out of this reskin's
   scope - templates + CSS only); this default only shows through where
   no inline override is present. */
.rank-badge {
  background: var(--color-primary);
  color: var(--color-text-on-yellow);
  border: 2px solid var(--color-border);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.rank-label {
  font-weight: 600;
  color: var(--color-white);
  font-size: 1rem;
}

.selection-content {
  margin: 10px 0;
}

.selection-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-white);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.selection-points {
  background: var(--overlay-primary-10);
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.9rem;
  display: inline-block;
  margin-top: 0.3rem;
}

.total-stats-card {
  background: var(--color-primary);
  border-radius: 4px;
  padding: 2rem;
  margin: 2rem 0;
  color: var(--color-text-on-yellow);
  text-align: center;
  border: 4px solid var(--color-border);
  box-shadow: 6px 6px 0 var(--color-border);
}

.total-stats-title {
  font-size: 1.4rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.total-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 20px;
}

.total-stat-item {
  background: rgba(13, 13, 13, 0.08);
  padding: 1.2rem;
  border-radius: 4px;
  border: 2px solid var(--color-border);
  transition: transform 0.2s ease;
}

.total-stat-item:hover {
  transform: translateY(-2px);
}

.total-stat-value {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  color: var(--color-text-on-yellow);
}

.total-stat-label {
  font-size: 0.95rem;
  opacity: 0.85;
}

.empty-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-secondary);
}

.empty-results i {
  font-size: 4rem;
  color: var(--color-text-muted);
  margin-bottom: 20px;
}

.empty-results h3 {
  color: var(--color-white);
  margin-bottom: 10px;
}

.point-system-info {
  background: var(--color-bg-panel-alt);
  border: 3px solid var(--color-primary);
  border-radius: 4px;
  padding: 1.2rem;
  margin: 1.5rem 0;
  text-align: center;
}

.point-system-title {
  color: var(--color-primary);
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 1.1rem;
}

.point-system-details {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.5rem;
}

.point-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  padding: 0.6rem 1rem;
  border-radius: 20px;
  color: var(--color-white);
}

/* ===========================================
   Admin Page Styles
   =========================================== */
.admin-wide-container {
  width: 100%;
  max-width: 98vw;
  margin: 0 auto;
  padding: 20px;
  background-color: var(--color-bg);
}

#admin-password {
  width: 100%;
  padding: 15px;
  margin: 15px 0;
  border: 2px solid #ddd;
  border-radius: 4px;
  background: white !important;
  color: #000000 !important;
  font-family: 'Cairo', sans-serif;
  font-size: 1rem;
  text-align: right;
  direction: rtl;
}

#admin-password:focus {
  outline: none;
  border-color: var(--color-primary-dark);
  box-shadow: 0 0 0 3px var(--overlay-primary-20);
}

#admin-panel {
  margin-top: 30px;
  width: 100%;
  max-width: 100%;
}

.full-width-section {
  width: 100%;
  max-width: 100%;
}

.admin-input-container {
  margin-bottom: 20px;
}

.admin-input-container label {
  display: block;
  margin-bottom: 8px;
  color: var(--color-text-secondary);
  font-weight: 600;
  font-size: 1.1rem;
}

.admin-input-large, .admin-input-extra-wide {
  width: 100%;
  padding: 16px;
  font-size: 1.1rem;
  background: white !important;
  border: 2px solid #ddd;
  border-radius: 4px;
  color: #000000 !important;
  font-family: 'Cairo', sans-serif;
  margin-bottom: 15px;
  text-align: right;
  direction: rtl;
  transition: all 0.3s ease;
}

.admin-input-extra-wide {
  max-width: 900px;
  min-width: 300px;
}

.admin-input-large:focus, .admin-input-extra-wide:focus {
  outline: none;
  border-color: var(--color-primary-dark);
  box-shadow: 0 0 0 3px var(--overlay-primary-20);
}

.admin-input-large::placeholder {
  color: #666666 !important;
}

#table-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23666666' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 15px center;
  background-size: 16px;
}

/* Data table */
.admin-table-container {
  overflow-x: auto;
  width: 100%;
  max-width: 100%;
  margin: 25px 0;
  border: 4px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg-panel);
}

#admin-table {
  width: 100%;
  min-width: 1300px;
  border-collapse: collapse;
  font-size: 15px;
}

#admin-table th, #admin-table td {
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  vertical-align: middle;
  min-width: 120px;
  text-align: center;
}

#admin-table th {
  background: var(--color-primary);
  color: var(--color-text-on-yellow);
  font-weight: 700;
  font-size: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 3px solid var(--color-border);
}

/* Sticky actions column (RTL: last DOM column renders on the visual LEFT
   edge, so "left: 0", not "right: 0" - see admin.js/admin.html). */
#admin-table thead th:last-child {
  position: sticky;
  left: 0;
  z-index: 101;
}

#admin-table tr:nth-child(even) {
  background-color: var(--overlay-primary-10);
}

#admin-table tr:hover {
  background-color: var(--overlay-primary-20);
}

#admin-table input[type="text"], #admin-table input[type="number"],
#admin-table td[contenteditable="true"], .admin-table-input, .editable-cell {
  padding: 10px 12px !important;
  font-size: 16px !important;
  min-height: 40px !important;
  background: white !important;
  border: 2px solid #ddd;
  border-radius: 4px;
  color: #000000 !important;
  text-align: right;
  direction: rtl;
  font-family: 'Cairo', sans-serif;
  transition: all 0.3s ease;
}

#admin-table input[type="number"] {
  width: 90px !important;
  text-align: center;
}

#admin-table td[contenteditable="true"]:focus, .editable-cell:focus {
  outline: none;
  border-color: var(--color-primary-dark) !important;
  box-shadow: 0 0 0 3px var(--overlay-primary-20);
  background-color: var(--overlay-primary-10) !important;
}

.selection-cell-wide {
  min-width: 500px !important;
  max-width: 600px;
}

.selection-cell-wide input[type="text"] {
  width: 100% !important;
  min-width: 480px !important;
  max-width: 580px !important;
}

.category-name-cell {
  min-width: 220px !important;
  font-weight: 700;
  color: var(--color-primary);
  background-color: var(--overlay-primary-10);
  text-align: right;
  direction: rtl;
}

/* Actions column - sticky so edit/delete stay reachable without
   horizontal-scrolling the whole table (known bug fix, kept from the
   pre-reskin version). */
.table-actions-container {
  min-width: 200px !important;
  white-space: nowrap;
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  position: sticky;
  left: 0;
  z-index: 10;
  background: var(--color-bg-panel);
  box-shadow: 4px 0 8px rgba(0, 0, 0, 0.4);
}

.table-actions-container button {
  min-width: 90px;
  padding: 10px 15px;
  font-size: 14px;
  font-weight: 700;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* "save" action: yellow. "delete" action: red - destructive-context use
   of the accent color per Milestone 5 usage rules. */
.table-actions-container button:first-child,
#admin-table button:first-of-type {
  background: var(--color-primary);
  color: var(--color-text-on-yellow);
}

.table-actions-container button:last-child,
#admin-table button:last-of-type {
  background: var(--color-accent-red-text-safe);
  color: var(--color-white);
}

.table-actions-container button:hover, #admin-table button:hover {
  transform: translateY(-2px);
}

#pagination {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 30px 0;
  flex-wrap: wrap;
}

#pagination button {
  padding: 10px 18px;
  border-radius: 4px;
  background: var(--color-bg-panel-alt);
  border: 2px solid var(--color-border);
  color: var(--color-white);
  font-family: 'Cairo', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 45px;
  font-size: 15px;
}

#pagination button:hover {
  background: var(--color-primary);
  color: var(--color-text-on-yellow);
  border-color: var(--color-border);
}

#pagination button.active {
  background: var(--color-primary);
  color: var(--color-text-on-yellow);
}

/* Excel download button - success = yellow (spec: "reuse primary yellow
   rather than introducing green"). */
#download-btn {
  width: 100%;
  padding: 15px;
  margin: 10px 0;
  background: var(--color-primary);
  color: var(--color-text-on-yellow);
  border: 3px solid var(--color-border);
  border-radius: 4px;
  font-family: 'Cairo', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease;
  box-shadow: 4px 4px 0 var(--color-border);
}

#download-btn:hover {
  background: var(--color-primary-dark);
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--color-border);
}

.stats-card, .add-category-container, .point-system {
  background: var(--color-bg-panel);
  border-radius: 4px;
  padding: 20px;
  margin-bottom: 20px;
  border: 3px solid var(--color-border);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-top: 15px;
}

.stat-item {
  background: var(--color-bg-panel-alt);
  padding: 20px;
  border-radius: 4px;
  text-align: center;
  border: 2px solid var(--color-border);
  transition: transform 0.2s ease;
}

.stat-item:hover {
  transform: translateY(-3px);
  border-color: var(--color-primary);
}

.stat-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--color-primary);
  margin-bottom: 5px;
}

.stat-label {
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  font-weight: 600;
}

.point-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.point-item {
  background: var(--color-bg-panel-alt);
  padding: 10px;
  border-radius: 4px;
  text-align: center;
}

.point-rank {
  font-weight: 700;
  color: var(--color-primary);
}

.point-value {
  font-weight: 600;
  color: var(--color-white);
}

.add-category-title, .category-management-title {
  font-size: 1.2rem;
  color: var(--color-white);
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.add-category-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.category-management {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 3px solid var(--color-border);
}

.form-row {
  display: flex;
  gap: 20px;
  margin-bottom: 15px;
  width: 100%;
  flex-wrap: wrap;
}

.form-row input {
  flex: 1;
  min-width: 250px;
}

.clear-search-btn {
  background: var(--color-bg-panel-alt) !important;
  color: var(--color-white) !important;
  border: 2px solid var(--color-border) !important;
}

.clear-search-btn:hover {
  background: var(--color-bg) !important;
  border-color: var(--color-primary) !important;
}

/* ===========================================
   Autocomplete Styles
   =========================================== */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white !important;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 4px 4px 0 var(--color-border);
}

.autocomplete-dropdown div {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
  color: #000000 !important;
  text-align: right;
  direction: rtl;
  font-family: 'Cairo', sans-serif;
}

.autocomplete-dropdown div:hover {
  background-color: var(--overlay-primary-20);
}

/* ===========================================
   Utility Classes
   =========================================== */
.hidden {
  display: none !important;
}

.mobile-only {
  display: none;
}

.desktop-only {
  display: block;
}

.loading-state {
  text-align: center;
  padding: 3rem;
  color: var(--color-text-secondary);
}

.success-highlight {
  background-color: var(--overlay-primary-20) !important;
  border-color: var(--color-primary) !important;
  animation: pulse 0.5s ease;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

/* ===========================================
   Toastify Customization
   =========================================== */
.toastify {
  font-family: 'Cairo', sans-serif !important;
  border-radius: 4px !important;
  padding: 15px 20px !important;
  font-weight: 600 !important;
  text-align: center !important;
  border: 3px solid var(--color-border) !important;
  direction: rtl !important;
}

.toastify.toastify-success {
  background: var(--color-primary) !important;
  color: var(--color-text-on-yellow) !important;
}

.toastify.toastify-error {
  background: var(--color-accent-red-text-safe) !important;
  color: var(--color-white) !important;
}

.toastify.toastify-info {
  background: var(--color-bg-panel) !important;
  color: var(--color-white) !important;
}

/* ===========================================
   Responsive Design
   =========================================== */
@media (max-width: 768px) {
  body { padding: 10px; }
  .container { padding: 20px; }
  .mobile-only { display: block; }
  .desktop-only { display: none; }
  .mobile-banner { display: block; }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.1rem; }

  .input-card, .voting-card { padding: 20px; }
  .progress-steps { font-size: 0.8rem; }
  .step-number { width: 35px; height: 35px; font-size: 0.9rem; }
  .form-actions { flex-direction: column; }

  .category-card { padding: 1rem; }
  .category-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .category-badge { align-self: flex-start; }
  .selection-field { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .selection-field label { min-width: auto; }
  .selection-input { padding: 0.7rem 0.7rem 0.7rem 2.5rem !important; font-size: 16px !important; }
  .selection-icon { left: 0.7rem !important; }

  .input-container--with-year { flex-direction: column; }
  .inline-year-select { width: 100%; }

  .selections-grid { grid-template-columns: 1fr; }
  .total-stats-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
  .total-stat-value { font-size: 1.8rem; }

  /* Admin - table becomes horizontally scrollable, min-width narrows but
     stays scrollable rather than trying to cram 14 columns into 375px. */
  .admin-wide-container { padding: 10px; }
  #admin-table { min-width: 1000px; font-size: 14px; }
  #admin-table th, #admin-table td { padding: 10px 12px; font-size: 14px; }
  .admin-input-large, .admin-input-extra-wide { padding: 14px; font-size: 1rem; min-width: unset; }
  .admin-table-input { padding: 10px; font-size: 0.95rem; }
  #admin-table input[type="text"] { font-size: 14px !important; padding: 8px 10px !important; min-height: 35px !important; max-width: 200px !important; }
  #admin-table td[contenteditable="true"] { font-size: 14px !important; padding: 8px !important; min-width: 100px; }
  .selection-cell-wide input[type="text"] { min-width: 280px !important; }
  .add-category-container { padding: 20px; }
  .form-row { flex-direction: column; gap: 10px; }
  .table-actions-container { flex-direction: column; gap: 5px; }
  .table-actions-container button { width: 100%; }
  #pagination button { padding: 8px 12px; min-width: 40px; font-size: 14px; }

  #username { padding: 0.7rem 0.7rem 0.7rem 2.5rem !important; font-size: 16px !important; }
  .input-with-icon .input-icon { left: 12px !important; }
}

@media (max-width: 480px) {
  .container { padding: 15px; }
  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.1rem; }
  .input-card, .voting-card { padding: 15px; }
  .btn-primary, .btn-secondary, .btn-submit { padding: 12px; font-size: 0.95rem; }
  .selection-input { font-size: 16px !important; }
  .total-stats-grid { grid-template-columns: 1fr; }
  .category-header { flex-direction: column; text-align: center; gap: 1rem; padding: 1rem; }
  .category-header > div:last-child { text-align: center !important; margin-top: 0.5rem; }

  #admin-table { min-width: 900px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 1.8rem; }
}

/* Print styles for admin */
@media print {
  .admin-wide-container { max-width: 100% !important; padding: 0 !important; }
  #admin-table { min-width: 100% !important; font-size: 12px !important; }
  #admin-table th, #admin-table td { padding: 8px !important; }
  .btn-primary, .btn-secondary, .btn-submit,
  #search-button, #pagination, .table-actions-container, #download-btn {
    display: none !important;
  }
}

@media print {
  body * { visibility: hidden; }
  .container, .container * { visibility: visible; }
  .container {
    position: absolute; left: 0; top: 0; width: 100%;
    padding: 0; margin: 0; box-shadow: none;
    background: white; color: black; border: none;
  }
  .btn-primary, .btn-secondary, .btn-submit,
  .mobile-banner, .theme-footer a, .point-system-info, button {
    display: none !important;
  }
  .category-section { break-inside: avoid; page-break-inside: avoid; }
  h1, h2, h3 { color: black !important; }
  .selection-card { border: 1px solid #ddd !important; box-shadow: none !important; background: white !important; color: black !important; }
  .total-stats-card { background: #f5f5f5 !important; color: black !important; border: 1px solid #ddd !important; }
  .theme-footer { display: none; }
}
