/* ============================================================
   VAIMAN EMBER LIGHT — Components
   Depends on: ember-light.css (custom properties + base)
   ============================================================ */


/* ── Cards ─────────────────────────────────────────────────── */

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: 16px;
  transition:
    transform var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease),
    border-color var(--duration) var(--ease);
}

@media (min-width: 600px) {
  .card {
    padding: 24px;
  }
}

.card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
  border-color: var(--border-strong);
}

.card-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(199, 102, 25, 0.10) 0%, rgba(199, 102, 25, 0.04) 100%);
  flex-shrink: 0;
}

.card-icon img,
.card-icon svg {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.card-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  line-height: 1.3;
}

.card-subtitle {
  font-family: 'Manrope', sans-serif;
  font-weight: 500;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.4;
}

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

@media (min-width: 480px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 768px) {
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1200px) {
  .card-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}


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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 0.875rem;
  line-height: 1;
  white-space: nowrap;
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    transform var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease),
    background var(--duration) var(--ease),
    border-color var(--duration) var(--ease),
    opacity var(--duration) var(--ease);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.96);
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-ember) 0%, var(--accent-ember-dark) 100%);
  color: var(--bg-tertiary);
  box-shadow: 0 4px 14px rgba(199, 102, 25, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(199, 102, 25, 0.35);
}

.btn-primary:active {
  transform: scale(0.96);
  box-shadow: 0 2px 8px rgba(199, 102, 25, 0.20);
}

.btn-secondary {
  background: var(--bg-secondary);
  border-color: var(--border-light);
  color: var(--text-primary);
}

.btn-secondary:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.btn-secondary:active {
  transform: scale(0.96);
}

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

.btn-ghost:hover {
  background: var(--bg-secondary);
}

.btn-ghost:active {
  transform: scale(0.96);
}

.btn-danger {
  background: var(--danger);
  color: var(--bg-tertiary);
}

.btn-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(200, 90, 90, 0.25);
}

.btn-danger:active {
  transform: scale(0.96);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn-icon.btn-sm {
  width: 32px;
  height: 32px;
}

.btn-icon.btn-lg {
  width: 48px;
  height: 48px;
}


/* ── Forms ─────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-family: 'Manrope', sans-serif;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 0.9375rem;
  color: var(--text-primary);
  transition:
    border-color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease);
  appearance: none;
  -webkit-appearance: none;
}

.form-input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-ember);
  box-shadow: 0 0 0 3px rgba(199, 102, 25, 0.10);
}

.form-textarea {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 0.9375rem;
  color: var(--text-primary);
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
  transition:
    border-color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease);
  appearance: none;
  -webkit-appearance: none;
}

.form-textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.form-textarea:focus {
  outline: none;
  border-color: var(--accent-ember);
  box-shadow: 0 0 0 3px rgba(199, 102, 25, 0.10);
}

.form-select {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px 38px 12px 14px;
  font-size: 0.9375rem;
  color: var(--text-primary);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%238B7866' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  transition:
    border-color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease);
}

.form-select:focus {
  outline: none;
  border-color: var(--accent-ember);
  box-shadow: 0 0 0 3px rgba(199, 102, 25, 0.10);
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: 4px;
}

.form-input.is-error,
.form-textarea.is-error,
.form-select.is-error {
  border-color: var(--danger);
}

.form-input.is-error:focus,
.form-textarea.is-error:focus,
.form-select.is-error:focus {
  box-shadow: 0 0 0 3px rgba(200, 90, 90, 0.10);
}


/* ── Tabs ──────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-light);
}

.tab {
  padding: 10px 16px;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-family: 'Manrope', sans-serif;
  font-weight: 500;
  font-size: 0.875rem;
  transition:
    color var(--duration) var(--ease),
    border-color var(--duration) var(--ease),
    background var(--duration) var(--ease);
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.tab:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.tab.active {
  color: var(--text-primary);
  font-weight: 700;
  border-bottom-color: var(--accent-ember);
  background: var(--bg-tertiary);
}


/* ── Toggle / Switch ───────────────────────────────────────── */

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--border-light);
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--duration) var(--ease);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--bg-tertiary);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(42, 24, 16, 0.12);
  transition: transform var(--duration) var(--ease);
}

.toggle.active {
  background: var(--accent-ember);
}

.toggle.active::after {
  transform: translateX(20px);
}


/* ── Modals ────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(42, 24, 16, 0.4);
  z-index: var(--z-modal-backdrop);
  animation: fadeIn var(--duration) var(--ease) both;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-tertiary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-3);
  max-width: 480px;
  width: calc(100% - 32px);
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  z-index: var(--z-modal);
  animation: slideUp var(--duration) var(--ease) both;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-header .h3 {
  flex: 1;
  min-width: 0;
}

.modal-body {
  padding: 16px 24px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 24px 20px;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  flex-shrink: 0;
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease);
}

.modal-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 16px));
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}


/* ── Toasts ────────────────────────────────────────────────── */

/* Тосты СВЕРХУ по центру (решение Шурика 09.06: сверху бросается в глаза,
   снизу легко не заметить). Шапка 60px → тост под ней + safe-area («чёлка»). */
.toast-container {
  position: fixed;
  top: calc(72px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 400px;
}

.toast {
  background: var(--bg-tertiary);
  border-left: 4px solid var(--text-muted);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  padding: 12px 16px;
  pointer-events: auto;
  animation: toastIn 0.3s var(--ease) both;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.875rem;
  line-height: 1.4;
}

.toast-success {
  border-left-color: var(--success);
}

.toast-error {
  border-left-color: var(--danger);
}

.toast-info {
  border-left-color: var(--teal);
}

.toast-dismiss {
  animation: toastOut 0.2s var(--ease) both;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-12px); /* тост теперь сверху — въезжает вниз */
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}


/* ── Progress ──────────────────────────────────────────────── */

.progress-bar {
  height: 8px;
  background: var(--border-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-ember) 0%, var(--accent-ember-light) 100%);
  border-radius: var(--radius-sm);
  transition: width 0.3s var(--ease);
}

.progress-label {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--text-primary);
}


/* ── Badges / Tags ─────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-family: 'Manrope', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1;
  white-space: nowrap;
}

.badge-ember {
  background: rgba(199, 102, 25, 0.12);
  color: var(--accent-ember);
}

.badge-teal {
  background: rgba(63, 102, 107, 0.12);
  color: var(--teal);
}

.badge-success {
  background: rgba(42, 136, 104, 0.12);
  color: var(--success);
}

.badge-danger {
  background: rgba(200, 90, 90, 0.12);
  color: var(--danger);
}


/* ── Avatar ────────────────────────────────────────────────── */

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--bg-tertiary);
  flex-shrink: 0;
}

.avatar-sm {
  width: 32px;
  height: 32px;
}

.avatar-lg {
  width: 56px;
  height: 56px;
}

.avatar-xl {
  width: 80px;
  height: 80px;
}

.avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(199, 102, 25, 0.15) 0%, rgba(63, 102, 107, 0.10) 100%);
  color: var(--accent-ember);
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
}


/* ── Dropdown ──────────────────────────────────────────────── */

.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  min-width: 180px;
  z-index: var(--z-dropdown);
  padding: 4px 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition:
    opacity var(--duration) var(--ease),
    transform var(--duration) var(--ease),
    visibility var(--duration);
}

.dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-primary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background var(--duration) var(--ease);
  white-space: nowrap;
}

.dropdown-item:hover {
  background: var(--bg-secondary);
}

.dropdown-item svg,
.dropdown-item img {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.dropdown-divider {
  height: 1px;
  background: var(--border-light);
  margin: 4px 0;
}


/* ── Skeleton Loading ──────────────────────────────────────── */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-secondary) 25%,
    rgba(199, 102, 25, 0.06) 50%,
    var(--bg-secondary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
}

.skeleton-text:last-child {
  width: 60%;
}

.skeleton-heading {
  height: 20px;
  width: 50%;
  margin-bottom: 12px;
}

.skeleton-circle {
  border-radius: 50%;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}


/* ── Divider ───────────────────────────────────────────────── */

.divider {
  height: 1px;
  background: var(--border-light);
  margin: 16px 0;
  border: none;
}


/* ── Upload Area ───────────────────────────────────────────── */

.upload-zone {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition:
    border-color var(--duration) var(--ease),
    background var(--duration) var(--ease);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent-ember);
  background: rgba(199, 102, 25, 0.04);
}

.upload-zone-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  color: var(--text-muted);
}

.upload-zone-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.upload-zone-text strong {
  color: var(--accent-ember);
}

.upload-preview {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, 1fr);
}

@media (min-width: 600px) {
  .upload-preview {
    grid-template-columns: repeat(4, 1fr);
  }
}

.upload-preview-item {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 1;
}

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

.upload-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--danger);
  color: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(42, 24, 16, 0.2);
  transition:
    transform var(--duration) var(--ease),
    opacity var(--duration) var(--ease);
  opacity: 0;
}

.upload-preview-item:hover .upload-remove {
  opacity: 1;
}

.upload-remove:active {
  transform: scale(0.90);
}


/* ── Generator Result ──────────────────────────────────────── */

.result-container {
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}

.result-image {
  width: 100%;
  display: block;
  border-radius: var(--radius-lg);
}

.result-video {
  width: 100%;
  display: block;
  border-radius: var(--radius-lg);
}

.result-audio {
  width: 100%;
  padding: 16px;
}

.result-audio audio {
  width: 100%;
  height: 44px;
}

.result-actions {
  display: flex;
  gap: 8px;
  padding: 12px;
  flex-wrap: wrap;
}


/* ── Spinner ───────────────────────────────────────────────── */

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(199, 102, 25, 0.2);
  border-top-color: var(--accent-ember);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-sm {
  width: 14px;
  height: 14px;
}

.spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

.spinner-white {
  border-color: rgba(255, 253, 247, 0.3);
  border-top-color: var(--bg-tertiary);
}

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


/* ── Tooltip ───────────────────────────────────────────────── */

.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: var(--bg-tertiary);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  z-index: var(--z-tooltip);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--duration) var(--ease),
    visibility var(--duration);
  pointer-events: none;
}

.tooltip:hover::after {
  opacity: 1;
  visibility: visible;
}


/* ── Scrollbar ─────────────────────────────────────────────── */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(199, 102, 25, 0.18);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(199, 102, 25, 0.30);
}


/* ============================================================
   EMBER DARK — полировка компонентов под визуал мини-аппов TG
   (стеклянные тёплые карточки, ember-бордюры, глубокие тени)
   ============================================================ */

[data-theme="dark"] .card {
  background: linear-gradient(160deg, rgba(56, 32, 20, 0.40), rgba(17, 30, 44, 0.52));
  border-color: rgba(232, 151, 101, 0.20);
  box-shadow: inset 0 1px 0 rgba(232, 151, 101, 0.10), var(--shadow-1);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

[data-theme="dark"] .card:hover {
  border-color: rgba(232, 151, 101, 0.45);
  box-shadow: inset 0 1px 0 rgba(232, 151, 101, 0.18), 0 12px 30px rgba(0, 0, 0, 0.42);
}

[data-theme="dark"] .card-icon {
  background: radial-gradient(circle at 30% 25%, rgba(232, 151, 101, 0.18), transparent 65%), rgba(11, 24, 33, 0.42);
  border: 1px solid rgba(232, 151, 101, 0.20);
  box-shadow: inset 0 1px 0 rgba(232, 151, 101, 0.16);
}

[data-theme="dark"] .form-input,
[data-theme="dark"] .form-textarea,
[data-theme="dark"] .form-select {
  background: rgba(17, 30, 44, 0.62);
}

[data-theme="dark"] .btn-secondary {
  background: rgba(30, 58, 70, 0.5);
}

[data-theme="dark"] .btn-secondary:hover {
  background: rgba(36, 66, 80, 0.6);
}

[data-theme="dark"] .toast {
  background: rgba(24, 42, 58, 0.96);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

[data-theme="dark"] .modal {
  background: linear-gradient(160deg, rgba(30, 50, 66, 0.98), rgba(17, 30, 44, 0.98));
}

[data-theme="dark"] .dropdown-menu {
  background: rgba(24, 42, 58, 0.98);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

/* Скролл-бар в тёмной теме — тёплый ember */
[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(232, 151, 101, 0.22);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(232, 151, 101, 0.38);
}
