/* ========================
   APP PAGE STYLES
   CloneOS Avatar Creator
   ======================== */

/* ======= APP NAVBAR ======= */
.app-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 48px;
  border-bottom: 1px solid var(--border);
  background: rgba(8,8,15,0.85);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav-left { display: flex; align-items: center; gap: 12px; }
.nav-sep { color: var(--fg-dim); font-size: 1.2rem; }
.nav-page { font-size: 0.85rem; color: var(--fg-muted); font-family: var(--font-body); }
.nav-home-link {
  font-size: 0.85rem;
  color: var(--accent-bright);
  text-decoration: none;
  transition: opacity 0.2s;
}
.nav-home-link:hover { opacity: 0.7; }

/* ======= APP CONTAINER ======= */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 64px 48px 100px;
}
.app-header { text-align: center; margin-bottom: 56px; }
.app-title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
}
.app-subtitle { font-size: 1rem; color: var(--fg-muted); }

/* ======= APP LAYOUT ======= */
.app-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 48px;
  align-items: start;
}

/* ======= INPUT PANEL ======= */
.input-panel { display: flex; flex-direction: column; gap: 20px; }

.step-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}
.step-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.step-num {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent-bright);
  background: var(--accent-dim);
  border: 1px solid rgba(124,58,237,0.3);
  padding: 4px 10px;
  border-radius: 999px;
}
.step-label {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Photo upload */
.photo-upload-zone {
  border: 2px dashed rgba(124,58,237,0.3);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
  overflow: hidden;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-upload-zone:hover,
.photo-upload-zone.drag-over {
  border-color: var(--accent-bright);
  background: var(--accent-dim);
}
.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--fg-muted);
  padding: 24px;
  text-align: center;
}
.upload-placeholder svg { color: var(--accent-bright); opacity: 0.6; }
.upload-placeholder p { font-size: 0.9rem; }
.upload-hint { font-size: 0.75rem; color: var(--fg-dim); }

.photo-preview {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#previewImg {
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  object-fit: contain;
}
.photo-remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,0.7);
  color: white;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.photo-remove-btn:hover { background: rgba(255,0,0,0.8); }

/* Script input */
.script-area-wrap { position: relative; margin-bottom: 16px; }
.script-input {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.6;
  padding: 14px 16px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  min-height: 140px;
}
.script-input:focus { border-color: var(--accent); }
.script-input::placeholder { color: var(--fg-dim); }
.char-count {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 0.72rem;
  color: var(--fg-dim);
}

/* Language selector */
.language-row { display: flex; align-items: center; gap: 12px; }
.field-label { font-size: 0.8rem; color: var(--fg-muted); white-space: nowrap; }
.field-select {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 8px 12px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}
.field-select:focus { border-color: var(--accent); }

/* Format grid */
.format-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.format-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: rgba(255,255,255,0.02);
}
.format-option:hover { border-color: rgba(124,58,237,0.5); }
.format-option.selected { border-color: var(--accent); background: var(--accent-dim); }
.format-preview {
  background: rgba(124,58,237,0.2);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 4px;
}
.fmt-9x16 { width: 32px; height: 57px; }
.fmt-16x9 { width: 60px; height: 34px; }
.fmt-1x1  { width: 48px; height: 48px; }
.format-label {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
}
.format-desc { font-size: 0.68rem; color: var(--fg-muted); text-align: center; }

/* Generate button */
.generate-btn {
  width: 100%;
  padding: 16px 24px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-bright) 100%);
  border: none;
  border-radius: 12px;
  color: white;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  letter-spacing: -0.01em;
}
.generate-btn:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
.generate-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}
.btn-loading { display: flex; align-items: center; justify-content: center; gap: 10px; }
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ======= RESULT PANEL ======= */
.result-panel {
  position: sticky;
  top: 100px;
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  overflow: hidden;
}

/* Empty state */
.result-empty { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 20px; }
.result-avatar-ring { position: relative; width: 160px; height: 160px; display: flex; align-items: center; justify-content: center; }
.result-core {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  z-index: 2;
  box-shadow: 0 0 40px var(--accent-glow);
}
.result-face-icon { color: var(--accent-bright); }
.result-wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 12px;
}
.result-wave span {
  width: 2px;
  background: var(--accent-bright);
  border-radius: 999px;
  animation: wave 1.2s ease-in-out infinite;
}
.result-wave span:nth-child(2) { animation-delay: 0.1s; }
.result-wave span:nth-child(3) { animation-delay: 0.2s; }
.result-wave span:nth-child(4) { animation-delay: 0.3s; }
.result-wave span:nth-child(5) { animation-delay: 0.4s; }
@keyframes wave {
  0%, 100% { height: 3px; }
  50% { height: 12px; }
}
.result-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(124,58,237,0.2);
}
.result-ring-1 { width: 120px; height: 120px; animation: spin 10s linear infinite; }
.result-ring-2 { width: 160px; height: 160px; animation: spin 16s linear infinite reverse; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.result-hint { font-size: 0.85rem; color: var(--fg-dim); }

/* Ready state */
.result-ready { width: 100%; display: flex; flex-direction: column; gap: 20px; }
.video-wrapper {
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#avatarVideo {
  width: 100%;
  max-height: 360px;
  display: block;
}
.result-actions { display: flex; gap: 12px; align-items: center; }
.btn-download {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-bright) 100%);
  border-radius: 10px;
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.2s;
}
.btn-download:hover { opacity: 0.85; }
.btn-reset {
  padding: 10px 20px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--fg-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-reset:hover { background: rgba(255,255,255,0.1); }

/* Error state */
.result-error { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px; color: var(--fg-muted); }
.error-msg { font-size: 0.9rem; max-width: 280px; }
.btn-retry {
  padding: 10px 24px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--fg);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-retry:hover { background: rgba(255,255,255,0.1); }

/* ======= RESPONSIVE ======= */
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .result-panel { position: static; }
  .app-container { padding: 40px 24px 80px; }
  .app-navbar { padding: 20px 24px; }
}