﻿:root {
  --bg-1: #0f172a;
  --bg-2: #111827;
  --bg-3: #0b1020;
  --card: rgba(255, 255, 255, 0.08);
  --card-strong: rgba(255, 255, 255, 0.12);
  --text: #eef2ff;
  --muted: #cbd5f5;
  --accent: #f97316;
  --accent-2: #22d3ee;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --font-ar: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
  --font-en: "Space Grotesk", "Segoe UI", Tahoma, Arial, sans-serif;
}

html[data-theme="light"] {
  --bg-1: #f1f5f9;
  --bg-2: #e2e8f0;
  --bg-3: #cbd5f5;
  --card: rgba(255, 255, 255, 0.85);
  --card-strong: rgba(255, 255, 255, 0.95);
  --text: #0f172a;
  --muted: #475569;
  --accent: #f97316;
  --accent-2: #0ea5e9;
  --shadow: 0 20px 60px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}


body {
  margin: 0;
  font-family: var(--font-ar);
  color: var(--text);
  background: radial-gradient(circle at top, #1e1b4b 0%, var(--bg-1) 40%, var(--bg-3) 100%);
  min-height: 100vh;
  transition: color 320ms ease, background 420ms ease;
}

html[data-theme="light"] body {
  background: radial-gradient(circle at top, #ffffff 0%, var(--bg-1) 45%, var(--bg-3) 100%);
}

body, button, input, select, textarea {
  font-family: var(--font-ar);
}

.uploader,
.image-preview,
.palette,
.tip,
.file-row,
.btn-ghost,
.theme-switch-wrap,
.theme-switch-track,
.theme-switch-thumb,
.lang-switch,
.swatch,
.gradient,
.dropzone,
.toast {
  transition:
    background-color 280ms ease,
    border-color 280ms ease,
    color 220ms ease,
    box-shadow 320ms ease,
    transform 220ms ease,
    opacity 200ms ease;
}

html[data-lang="en"] body {
  font-family: var(--font-en);
}

.hero h1 {
  font-family: var(--font-ar);
}

html[data-lang="en"] .hero h1 {
  font-family: "Fraunces", serif;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 24px 80px;
  position: relative;
  z-index: 2;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  background: radial-gradient(1200px 400px at 50% -10%, rgba(255, 255, 255, 0.16), transparent 70%);
  transition: opacity 420ms ease;
}

html[data-theme="light"] body::before {
  background: radial-gradient(1200px 420px at 50% -10%, rgba(14, 165, 233, 0.1), transparent 70%);
}

body.theme-animating::before {
  opacity: 1;
}

::selection {
  background: rgba(34, 211, 238, 0.35);
}

:focus-visible {
  outline: 3px solid rgba(34, 211, 238, 0.6);
  outline-offset: 3px;
  border-radius: 10px;
}

.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(0px);
  opacity: 0.5;
  z-index: 1;
  pointer-events: none;
}

.orb-1 {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, rgba(34,211,238,0.5), transparent 65%);
  top: -140px;
  left: -120px;
}

.orb-2 {
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, rgba(249,115,22,0.4), transparent 65%);
  bottom: -200px;
  right: -160px;
}

.orb-3 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(129,140,248,0.5), transparent 60%);
  top: 40%;
  right: 10%;
}

html[data-theme="light"] .orb-1 {
  background: radial-gradient(circle, rgba(14,165,233,0.35), transparent 65%);
}

html[data-theme="light"] .orb-2 {
  background: radial-gradient(circle, rgba(249,115,22,0.25), transparent 65%);
}

html[data-theme="light"] .orb-3 {
  background: radial-gradient(circle, rgba(99,102,241,0.25), transparent 60%);
}

.hero {
  text-align: center;
  margin-bottom: 40px;
}

.tool-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.tool-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
  font-weight: 600;
  transition: transform 180ms ease, color 180ms ease, background-color 220ms ease, border-color 220ms ease;
}

.tool-nav-link:hover {
  color: var(--text);
  transform: translateY(-1px);
}

.tool-nav-link.is-active {
  color: var(--text);
  background: rgba(34, 211, 238, 0.16);
  border-color: rgba(34, 211, 238, 0.38);
}

html[data-theme="light"] .tool-nav-link {
  background: rgba(15, 23, 42, 0.03);
  border-color: rgba(15, 23, 42, 0.1);
}

html[data-theme="light"] .tool-nav-link.is-active {
  background: rgba(14, 165, 233, 0.14);
  border-color: rgba(14, 165, 233, 0.35);
}

.top-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.lang-switch {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}

.lang-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}

.lang-btn.is-active {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text);
}

.theme-switch-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
}

html[data-theme="light"] .theme-switch-wrap {
  border-color: rgba(15, 23, 42, 0.14);
  background: rgba(255, 255, 255, 0.72);
}

.theme-switch-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.theme-switch-track {
  width: 50px;
  height: 28px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.22);
  position: relative;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.28);
}

html[data-theme="light"] .theme-switch-track {
  background: rgba(14, 165, 233, 0.18);
  border-color: rgba(14, 165, 233, 0.38);
}

.theme-switch-thumb {
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fff7b1, #ffc62a);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.24);
  transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1), background 240ms ease;
}

html[data-theme="light"] .theme-switch-thumb {
  transform: translateX(22px);
  background: linear-gradient(135deg, #dbeafe, #60a5fa);
}

html[dir="rtl"][data-theme="light"] .theme-switch-thumb {
  transform: translateX(-22px);
}

.theme-switch-icon {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  opacity: 0.55;
}

.theme-switch-icon-moon {
  border: 2px solid rgba(226, 232, 240, 0.9);
  border-top-color: transparent;
  border-right-color: transparent;
  transform: rotate(35deg);
}

.theme-switch-icon-sun {
  background: radial-gradient(circle, #fff0a8 0%, #fbbf24 70%);
}

html[data-theme="light"] .theme-switch-icon-sun {
  opacity: 1;
}

html[data-theme="dark"] .theme-switch-icon-moon {
  opacity: 1;
}

.theme-switch-input:focus-visible + .theme-switch .theme-switch-track {
  outline: 3px solid rgba(34, 211, 238, 0.58);
  outline-offset: 3px;
}

.theme-switch-wrap:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
}

.theme-indicator {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.eyebrow {
  letter-spacing: 4px;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

.hero h1 {
  font-size: clamp(32px, 5vw, 56px);
  margin: 0 0 12px;
}

.lead {
  color: var(--muted);
  font-size: 18px;
  max-width: 680px;
  margin: 0 auto;
}

.uploader {
  background: var(--card);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 32px;
}

.dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: 18px;
  padding: 28px;
  text-align: center;
  position: relative;
  transition: border-color 0.3s ease, background 0.3s ease;
}

.dropzone:hover {
  border-color: rgba(34, 211, 238, 0.55);
}

.dropzone.dragover {
  border-color: var(--accent-2);
  background: rgba(34, 211, 238, 0.08);
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.drop-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 26px;
}

.drop-title {
  font-size: 20px;
  font-weight: 600;
}

.drop-sub {
  color: var(--muted);
  font-size: 14px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
}

.control {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.control select {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 10px;
}

.control.toggle input {
  accent-color: var(--accent-2);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0b1020;
  border: none;
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

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

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
}

.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 14px;
  margin-top: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

html[data-theme="light"] .file-row {
  background: rgba(255, 255, 255, 0.65);
  border-color: rgba(15, 23, 42, 0.08);
}

.file-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.file-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-sub {
  color: var(--muted);
  font-size: 13px;
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 36px;
}

.image-preview {
  background: var(--card);
  border-radius: 20px;
  padding: 16px;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.image-preview img {
  max-width: 100%;
  border-radius: 16px;
  display: none;
}

.loader {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  display: grid;
  place-items: center;
  gap: 10px;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

html[data-theme="light"] .loader {
  background: rgba(248, 250, 252, 0.85);
  color: #0f172a;
}

.loader.is-active {
  opacity: 1;
  pointer-events: auto;
}

.spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--accent-2);
  animation: spin 1s linear infinite;
}

html[data-theme="light"] .spinner {
  border-color: rgba(15, 23, 42, 0.2);
  border-top-color: var(--accent-2);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.progress {
  width: min(360px, 75%);
  height: 10px;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

html[data-theme="light"] .progress {
  background: rgba(15, 23, 42, 0.08);
  border-color: rgba(15, 23, 42, 0.12);
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.2s ease;
}

.status {
  color: var(--muted);
}

.palette {
  background: var(--card-strong);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.palette-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.palette h2 {
  margin: 0;
}

.palette-guide {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  margin-bottom: 10px;
}

.guide-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

html[data-theme="light"] .guide-pill {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.1);
}

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
}

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

.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.swatch {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 8px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s ease;
  color: inherit;
  animation: swatchIn 0.35s ease both;
}

.swatch:hover {
  transform: translateY(-3px);
}

.swatch:active {
  transform: translateY(-1px) scale(0.99);
}

.swatch .color {
  height: 70px;
  border-radius: 10px;
  margin-bottom: 8px;
}

.swatch .hex {
  font-weight: 600;
  font-size: 13px;
}

@keyframes swatchIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.gradient-wrap {
  margin-top: 18px;
}

.gradient {
  height: 60px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
  padding: 0;
  appearance: none;
  display: block;
}

.gradient:hover {
  transform: translateY(-2px);
}

.gradient:active {
  transform: translateY(-1px);
  opacity: 0.95;
}

.gradient-label {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

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

.tip {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

html[data-theme="light"] .tip {
  background: rgba(255, 255, 255, 0.7);
}

.tip h3 {
  margin: 0 0 8px;
}

.footer {
  text-align: center;
  margin-top: 40px;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 20;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  max-width: min(520px, calc(100vw - 32px));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html[dir="rtl"] .toast {
  left: auto;
  right: 16px;
}

html[data-theme="light"] .toast {
  background: rgba(15, 23, 42, 0.88);
}

.toast.is-active {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
  body::before {
    display: none;
  }
}

@media (max-width: 720px) {
  .tool-nav {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }
  .dropzone-content {
    flex-direction: column;
  }
  .controls {
    justify-content: center;
  }
  .top-controls {
    flex-direction: column;
    gap: 12px;
  }
}
