/* ─── Dark Theme ─────────────────────────────────────────────────────────────
   Deep near-black backgrounds, purple accent, light typography.
   Single stylesheet shared by all pages.
   ─────────────────────────────────────────────────────────────────────────── */

:root {
  /* Brand */
  --primary:        #7B6FE8;
  --primary-light:  #9B8FF5;
  --primary-dark:   #5B4FD9;

  /* Dark surfaces */
  --bg:             #0F0F13;
  --bg-warm:        #16161E;
  --bg-card:        #1C1C28;

  /* Light typography */
  --text:           #E8E6F2;
  --text-soft:      #9B97B8;
  --text-muted:     #5C587A;

  /* Dark borders & shadows */
  --border:         #2A2A3E;
  --shadow-sm:      0 2px 8px  rgba(0, 0, 0, 0.30);
  --shadow-md:      0 4px 16px rgba(0, 0, 0, 0.40);
  --shadow-lg:      0 8px 28px rgba(0, 0, 0, 0.50);

  /* Feedback */
  --success:        #4E9070;
  --success-bg:     rgba(78, 144, 112, 0.12);
  --success-border: rgba(78, 144, 112, 0.30);
  --error:          #E05555;
  --error-bg:       rgba(224, 85, 85, 0.12);
  --error-border:   rgba(224, 85, 85, 0.30);
  --warning:        #D4943A;
  --warning-bg:     rgba(212, 148, 58, 0.12);
  --warning-border: rgba(212, 148, 58, 0.30);

  /* Shape */
  --radius-sm:  10px;
  --radius-md:  14px;
  --radius-lg:  22px;
  --radius-xl:  28px;

  /* Layout */
  --max-w: 620px;
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */

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

/* ─── Base ───────────────────────────────────────────────────────────────── */

html, body {
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overscroll-behavior: none;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */

header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  padding: 16px 20px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo {
  height: 34px;
  width: auto;
  border-radius: 8px;
  flex-shrink: 0;
}

.header-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  flex: 1;
}

/* Settings gear icon — shown in app header */
.header-settings {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.88);
  font-size: 1.35rem;
  text-decoration: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  transition: background 0.15s;
}
.header-settings:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* Back arrow link — shown on login and create-account pages */
.header-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  flex-shrink: 0;
}

.header-back:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.header-back svg {
  width: 22px;
  height: 22px;
  display: block;
}

/* ─── Page Wrapper ───────────────────────────────────────────────────────── */

.page-wrapper {
  flex: 1;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 24px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ─── Hero Section ───────────────────────────────────────────────────────── */

.hero {
  background: var(--bg-warm);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px 24px 32px;
  text-align: center;
}

.hero-logo {
  height: 64px;
  width: auto;
  margin-bottom: 18px;
  border-radius: 16px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.hero-title {
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  font-weight: 800;
  color: var(--text);
  line-height: 1.15;
  margin-bottom: 10px;
  letter-spacing: -0.4px;
}

.hero-copy {
  font-size: 1rem;
  color: var(--text-soft);
  line-height: 1.65;
  max-width: 380px;
  margin: 0 auto;
}

/* ─── Card ───────────────────────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ─── Form inside a card ────────────────────────────────────────────────── */

.card form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ─── Form Elements ──────────────────────────────────────────────────────── */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 13px 15px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text);
  transition: border-color 0.18s, box-shadow 0.18s;
  appearance: none;
  -webkit-appearance: none;
}

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

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(123, 111, 232, 0.12);
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */

.btn,
button.btn,
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px 22px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.18s, filter 0.18s;
  box-shadow: var(--shadow-sm);
  letter-spacing: 0.01em;
}

.btn:hover,
a.btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn:active,
a.btn:active {
  transform: translateY(0);
  filter: brightness(0.97);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

/* Outline variant */
.btn-outline,
a.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
  box-shadow: none;
}

.btn-outline:hover,
a.btn-outline:hover {
  background: rgba(123, 111, 232, 0.07);
  filter: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* ─── Two-button layout (home page) ─────────────────────────────────────── */

.action-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 360px) {
  .action-group {
    grid-template-columns: 1fr;
  }
}

/* ─── Status / feedback ──────────────────────────────────────────────────── */

.status {
  display: none;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.4;
}

.status.success {
  display: block;
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.status.error {
  display: block;
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error-border);
}

.status.info {
  display: block;
  background: rgba(123, 111, 232, 0.07);
  color: var(--primary);
  border: 1px solid rgba(123, 111, 232, 0.20);
}

/* ─── Helper text & links ────────────────────────────────────────────────── */

.helper-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

.link {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.link:hover {
  text-decoration: underline;
}

/* ─── Upload zone (app page) ─────────────────────────────────────────────── */

.upload-zone {
  min-height: 110px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-warm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s;
  text-align: center;
  padding: 20px;
  user-select: none;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--primary-light);
  background: rgba(123, 111, 232, 0.06);
}

.upload-zone.has-files {
  border-style: solid;
  border-color: var(--success);
  background: var(--success-bg);
}

.upload-zone-icon {
  font-size: 26px;
  pointer-events: none;
}

.upload-zone-text {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  pointer-events: none;
}

.upload-zone-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  pointer-events: none;
}

/* ─── Image / file preview grid (app page) ───────────────────────────────── */

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 10px;
  margin-top: 4px;
}

.preview-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-warm);
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Non-image file card */
.preview-item.file-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  gap: 5px;
}

.preview-item.file-card .file-icon {
  font-size: 24px;
  line-height: 1;
}

.preview-item.file-card .file-name {
  font-size: 0.6rem;
  color: var(--text-soft);
  text-align: center;
  word-break: break-all;
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.3;
}

/* Remove × button */
.preview-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.60);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: background 0.15s;
  font-family: inherit;
  font-weight: 700;
}

.preview-remove:hover {
  background: var(--error);
}

/* ─── Tag chips ──────────────────────────────────────────────────────────── */

.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(123, 111, 232, 0.07);
  color: var(--primary);
  border: 1.5px solid rgba(123, 111, 232, 0.30);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
  font-family: inherit;
}

.tag-chip:hover {
  background: rgba(123, 111, 232, 0.13);
}

.tag-chip .remove {
  font-weight: 800;
  opacity: 0.55;
  font-size: 0.9rem;
  line-height: 1;
}

.tag-chip .remove:hover {
  opacity: 1;
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */

footer {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 4px 20px 28px;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-align: center;
  width: 100%;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  header {
    padding: 13px 16px;
  }

  .page-wrapper {
    padding: 18px 16px 40px;
    gap: 16px;
  }

  .card {
    padding: 22px 18px;
    gap: 16px;
  }

  .hero {
    padding: 28px 18px 24px;
  }

  .hero-title {
    font-size: 1.65rem;
  }

  .preview-grid {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 8px;
  }
}

/* ─── Upload Progress Screen ────────────────────────────────────────────── */

@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.progress-section {
  display: none;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  padding-top: 8px;
}

.step-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, background 0.2s;
}

.step-icon {
  flex-shrink: 0;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  transition: background 0.2s;
}

.step-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: color 0.2s;
}

.step-error-text {
  display: none;
  font-size: 0.82rem;
  color: var(--error);
  margin-top: 0.2rem;
}

/* pending — default, already styled above */

/* active — shimmer sweep */
.step-card.active {
  border-color: var(--primary);
}
.step-card.active .step-icon {
  background: var(--primary-light);
}
.step-card.active .step-label {
  color: var(--text);
}
.step-card.active::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(123,111,232,0.12) 50%, transparent 100%);
  animation: shimmer 1.4s ease-in-out infinite;
}

/* complete */
.step-card.complete {
  border-color: var(--success-border);
  background: var(--success-bg);
}
.step-card.complete .step-icon {
  background: var(--success);
  color: #fff;
}
.step-card.complete .step-icon::after { content: '✓'; }
.step-card.complete .step-label { color: var(--success); }

/* failed */
.step-card.failed {
  border-color: var(--error-border);
  background: var(--error-bg);
  flex-wrap: wrap;
}
.step-card.failed .step-icon {
  background: var(--error);
  color: #fff;
}
.step-card.failed .step-icon::after { content: '✕'; }
.step-card.failed .step-label { color: var(--error); }
.step-card.failed .step-error-text { display: block; width: 100%; padding-left: 2.3rem; }

/* cached / warning */
.step-card.cached {
  border-color: var(--warning-border);
  background: var(--warning-bg);
}
.step-card.cached .step-icon {
  background: var(--warning);
  color: #fff;
}
.step-card.cached .step-icon::after { content: '~'; }
.step-card.cached .step-label { color: var(--warning); }

.return-btn {
  display: none;
  margin-top: 0.5rem;
  width: 100%;
}

/* ─── Accessibility ──────────────────────────────────────────────────────── */

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

/* Focus visible for keyboard nav */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}
