/* ═══════════════════════════════════════════════════════════════════════════════
   GENERATION MODULE — Styles
   Dark premium minimal UI, mobile-first, Telegram safe-area aware
   ═══════════════════════════════════════════════════════════════════════════════ */

.gen-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 0 16px 32px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.gen-header {
  text-align: center;
  padding: 8px 0 0;
}

.gen-header__title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary, #fff);
  margin: 0 0 4px;
}

.gen-header__subtitle {
  font-size: 13px;
  color: var(--text-secondary, rgba(255,255,255,0.55));
  margin: 0;
  line-height: 1.4;
}

/* ── Mode Tabs (Image / Video) ──────────────────────────────────────────────── */
.gen-mode-tabs {
  display: flex;
  gap: 0;
  background: rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 3px;
  position: relative;
}

.gen-mode-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 0;
  border: none;
  background: none;
  color: var(--text-secondary, rgba(255,255,255,0.5));
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.gen-mode-tab.active {
  background: rgba(255,255,255,0.12);
  color: var(--text-primary, #fff);
}

.gen-mode-tab.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.gen-mode-tab__badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #a855f7, #ec4899);
  color: #fff;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1.2;
}

/* ── Section Labels ─────────────────────────────────────────────────────────── */
.gen-section-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary, rgba(255,255,255,0.55));
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 8px;
}

.gen-section-label__required {
  color: rgba(168, 85, 247, 0.7);
  font-weight: 400;
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 6px;
}

/* ── Style Cards ────────────────────────────────────────────────────────────── */
.gen-section--styles {
  display: flex;
  flex-direction: column;
}

.gen-styles-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.gen-style-card {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  aspect-ratio: 3 / 4;
}

.gen-style-card:active {
  transform: scale(0.97);
}

.gen-style-card.selected {
  border-color: rgba(168, 85, 247, 0.8);
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.25), 0 0 6px rgba(168, 85, 247, 0.15);
}

.gen-style-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gen-style-card__overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px 10px 10px;
  background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, transparent 100%);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.gen-style-card__name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.gen-style-card__check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.gen-style-card.selected .gen-style-card__check {
  background: linear-gradient(135deg, #a855f7, #ec4899);
  border-color: transparent;
}

.gen-style-card__check svg {
  width: 12px;
  height: 12px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.gen-style-card.selected .gen-style-card__check svg {
  opacity: 1;
}

/* ── Prompt Textarea ────────────────────────────────────────────────────────── */
.gen-section--prompt {
  display: flex;
  flex-direction: column;
}

.gen-prompt-wrap {
  position: relative;
  background: rgba(255,255,255,0.06);
  border-radius: 14px;
  border: 1.5px solid rgba(255,255,255,0.08);
  transition: border-color 0.2s ease;
}

.gen-prompt-wrap:focus-within {
  border-color: rgba(168, 85, 247, 0.5);
}

.gen-prompt-textarea {
  width: 100%;
  min-height: 90px;
  max-height: 180px;
  padding: 12px 14px;
  padding-bottom: 28px;
  background: none;
  border: none;
  color: var(--text-primary, #fff);
  font-size: 15px;
  font-family: inherit;
  line-height: 1.45;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
  -webkit-text-size-adjust: 100%;
}

.gen-prompt-textarea::placeholder {
  color: rgba(255,255,255,0.28);
}

.gen-prompt-counter {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  pointer-events: none;
}

.gen-prompt-counter.warn {
  color: rgba(239, 68, 68, 0.7);
}

/* ── Reference Image Upload ─────────────────────────────────────────────────── */
.gen-section--reference {
  display: flex;
  flex-direction: column;
}

.gen-reference-zone {
  position: relative;
  border: 1.5px dashed rgba(255,255,255,0.15);
  border-radius: 14px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.gen-reference-zone:hover,
.gen-reference-zone.dragover {
  border-color: rgba(168, 85, 247, 0.5);
  background: rgba(168, 85, 247, 0.04);
}

.gen-reference-zone__icon {
  font-size: 24px;
  opacity: 0.5;
}

.gen-reference-zone__text {
  font-size: 13px;
  color: rgba(255,255,255,0.4);
  line-height: 1.4;
}

.gen-reference-zone.has-image {
  border-style: solid;
  border-color: rgba(168, 85, 247, 0.3);
  padding: 8px;
  flex-direction: row;
  gap: 12px;
  text-align: left;
}

.gen-reference-preview {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.gen-reference-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.gen-reference-info__name {
  font-size: 13px;
  color: var(--text-primary, #fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gen-reference-actions {
  display: flex;
  gap: 8px;
}

.gen-reference-actions button {
  font-size: 12px;
  color: rgba(168, 85, 247, 0.8);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 0;
  -webkit-tap-highlight-color: transparent;
}

.gen-reference-actions button:hover {
  color: #a855f7;
}

.gen-reference-input {
  display: none;
}

/* ── Aspect Ratio Chips ─────────────────────────────────────────────────────── */
.gen-section--aspect {
  display: flex;
  flex-direction: column;
}

.gen-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gen-chip {
  padding: 7px 14px;
  border-radius: 10px;
  border: 1.5px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary, rgba(255,255,255,0.55));
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.gen-chip:active {
  transform: scale(0.95);
}

.gen-chip.selected {
  border-color: rgba(168, 85, 247, 0.6);
  background: rgba(168, 85, 247, 0.12);
  color: #d8b4fe;
}

/* ── Resolution Toggle ──────────────────────────────────────────────────────── */
.gen-section--resolution {
  display: flex;
  flex-direction: column;
}

.gen-resolution-row {
  display: flex;
  gap: 8px;
}

.gen-resolution-btn {
  flex: 1;
  padding: 10px 0;
  border-radius: 10px;
  border: 1.5px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary, rgba(255,255,255,0.55));
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}

.gen-resolution-btn.selected {
  border-color: rgba(168, 85, 247, 0.6);
  background: rgba(168, 85, 247, 0.12);
  color: #d8b4fe;
}

/* ── Generate Button + Price ────────────────────────────────────────────────── */
.gen-action-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
}

.gen-price-label {
  font-size: 13px;
  color: var(--text-secondary, rgba(255,255,255,0.45));
}

.gen-price-value {
  color: #d8b4fe;
  font-weight: 600;
}

.gen-submit-btn {
  width: 100%;
  padding: 14px 0;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #a855f7, #ec4899);
  color: #fff;
}

.gen-submit-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.gen-submit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.3);
}

.gen-submit-btn.loading {
  pointer-events: none;
}

.gen-submit-btn__spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: gen-spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

.gen-submit-btn.loading .gen-submit-btn__spinner {
  display: inline-block;
}

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

/* ── Video Coming Soon Overlay ──────────────────────────────────────────────── */
.gen-video-soon {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  gap: 12px;
}

.gen-video-soon.visible {
  display: flex;
}

.gen-video-soon__icon {
  font-size: 48px;
  opacity: 0.5;
}

.gen-video-soon__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary, #fff);
}

.gen-video-soon__text {
  font-size: 14px;
  color: var(--text-secondary, rgba(255,255,255,0.5));
  max-width: 280px;
  line-height: 1.5;
}

.gen-video-soon__price {
  font-size: 13px;
  color: rgba(168, 85, 247, 0.6);
  margin-top: 4px;
}

/* ── Result Section ─────────────────────────────────────────────────────────── */
.gen-result {
  display: none;
  flex-direction: column;
  gap: 12px;
  animation: gen-fadeIn 0.35s ease;
}

.gen-result.visible {
  display: flex;
}

.gen-result__image-wrap {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255,255,255,0.04);
  cursor: pointer;
}

.gen-result__image {
  width: 100%;
  display: block;
  border-radius: 14px;
}

.gen-result__actions {
  display: flex;
  gap: 10px;
}

.gen-result__btn {
  flex: 1;
  padding: 11px 0;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  border: none;
}

.gen-result__btn--primary {
  background: linear-gradient(135deg, #a855f7, #ec4899);
  color: #fff;
}

.gen-result__btn--secondary {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary, #fff);
  border: 1.5px solid rgba(255,255,255,0.1);
}

.gen-result__btn:active {
  transform: scale(0.97);
}

/* ── Error Toast ────────────────────────────────────────────────────────────── */
.gen-error-toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(239, 68, 68, 0.9);
  color: #fff;
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: 340px;
  text-align: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.gen-error-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* ── Fullscreen Image Modal ─────────────────────────────────────────────────── */
.gen-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.92);
  display: none;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.gen-fullscreen.visible {
  display: flex;
}

.gen-fullscreen__img {
  max-width: 95vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
}

.gen-fullscreen__close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top, 12px));
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

/* ── Animations ─────────────────────────────────────────────────────────────── */
@keyframes gen-fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 380px) {
  .gen-container { padding: 0 12px 28px; gap: 16px; }
  .gen-header__title { font-size: 20px; }
  .gen-style-card__name { font-size: 12px; }
  .gen-chip { padding: 6px 10px; font-size: 12px; }
  .gen-submit-btn { font-size: 15px; padding: 12px 0; }
}

@media (min-width: 768px) {
  .gen-container { max-width: 560px; padding: 0 24px 40px; }
  .gen-styles-grid { gap: 14px; }
  .gen-prompt-textarea { min-height: 100px; }
}

@media (min-width: 1024px) {
  .gen-container { max-width: 600px; }
}
