/* Основные переменные */
:root {
  --primary-color: #667eea;
  --primary-dark: #5a67d8;
  --secondary-color: #764ba2;
  --accent-color: #f093fb;
  
  --bg-primary: #ffffff;
  --bg-secondary: #f7fafc;
  --bg-tertiary: #edf2f7;
  
  --text-primary: #2d3748;
  --text-secondary: #718096;
  --text-tertiary: #a0aec0;
  
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Сброс стилей */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Основные стили */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow-x: hidden;
}

/* Контейнер приложения */
.app-container {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  position: relative;
  overflow: hidden;
}

/* Декоративные фоновые элементы */
.bg-decoration {
  position: absolute;
  border-radius: 50%;
  opacity: 0.1;
  pointer-events: none;
  z-index: 0;
}

.bg-circle-1 {
  width: 600px;
  height: 600px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  top: -200px;
  right: -200px;
  animation: float 20s ease-in-out infinite;
}

.bg-circle-2 {
  width: 400px;
  height: 400px;
  background: linear-gradient(225deg, var(--secondary-color), var(--accent-color));
  bottom: -150px;
  left: -150px;
  animation: float 15s ease-in-out infinite reverse;
}

.bg-circle-3 {
  width: 300px;
  height: 300px;
  background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
  top: 50%;
  right: 10%;
  animation: float 25s ease-in-out infinite;
}

@keyframes float {
  0%, 100% {
    transform: translate(0, 0) scale(1);
  }
  33% {
    transform: translate(30px, -30px) scale(1.1);
  }
  66% {
    transform: translate(-20px, 20px) scale(0.9);
  }
}

@media (max-width: 1200px) {
  .bg-circle-1,
  .bg-circle-2,
  .bg-circle-3 {
    display: none;
  }
}

/* Заголовок */
.header {
  padding: 30px 60px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  color: white;
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
  .header {
    padding: 20px;
  }
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Language Switcher */
.language-switcher {
  position: relative;
}

.lang-dropdown-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
  color: white;
  font-size: 13px;
  font-weight: 500;
}

.lang-dropdown-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.lang-dropdown-btn .flag {
  font-size: 16px;
  line-height: 1;
}

.lang-dropdown-btn .lang-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.lang-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: white;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  z-index: 1000;
  min-width: 150px;
}

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

.lang-option {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-primary);
  transition: background 0.2s;
  text-align: left;
}

.lang-option:hover {
  background: var(--bg-secondary);
}

.lang-option .flag {
  font-size: 18px;
  line-height: 1;
}

.logo-icon {
  width: 64px;
  height: 64px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
}

.logo-icon svg {
  width: 56px;
  height: 56px;
  color: white;
}

.logo-text h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0;
  letter-spacing: 2px;
}

.logo-text p {
  font-size: 12px;
  opacity: 0.9;
  margin: 0;
}

/* Основной контент */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 60px 40px;
  padding-bottom: 80px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 0;
  position: relative;
}

.content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 32px;
  max-width: 700px;
  width: 100%;
  position: relative;
  z-index: 1;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .content-wrapper {
    max-width: 100%;
  }
  
  .main-content {
    padding: 20px 16px;
  }
}

/* Секции */
.section {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 36px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
  position: relative;
  overflow: hidden;
}

/* Все секции в одну колонку по центру */
.image-section,
.prompt-section,
.result-section,
.history-section,
.generate-btn-wrapper {
  width: 100%;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.step-number {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Загрузка изображения */
.upload-container {
  position: relative;
}

.upload-area {
  display: block;
  width: 100%;
  min-height: 340px;
  border: 3px dashed var(--border-color);
  border-radius: 20px;
  background: linear-gradient(135deg, #fafbff 0%, #f0f4ff 100%);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

@media (max-width: 768px) {
  .upload-area {
    min-height: 240px;
  }
}

.upload-area:hover {
  border-color: var(--primary-color);
  background: linear-gradient(135deg, #f0f4ff 0%, #e8efff 100%);
}

.upload-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  pointer-events: none;
}

.upload-placeholder svg {
  color: var(--primary-color);
  opacity: 0.6;
  filter: drop-shadow(0 4px 8px rgba(102, 126, 234, 0.2));
}

.upload-text {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 2px;
}

.upload-hint {
  font-size: 12px;
  color: var(--text-tertiary);
}

.preview-image {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 98%;
  max-height: 98%;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.remove-image-btn {
  position: absolute;
  top: 6px;
  right: 2px;
  width: 24px;
  height: 24px;
  background: rgba(0, 0, 0, 0.7);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  transition: var(--transition);
  padding: 0;
}

.remove-image-btn:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.1);
}

.remove-image-btn svg {
  width: 14px;
  height: 14px;
  display: block;
  margin: 0;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Промпт */
.prompt-textarea {
  width: 100%;
  min-height: 120px;
  padding: 16px;
  border: 2px solid var(--border-color);
  border-radius: 16px;
  background: linear-gradient(135deg, #fafbff 0%, #f0f4ff 100%);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.6;
  resize: vertical;
  transition: var(--transition);
}

.prompt-textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
  background: white;
}

.prompt-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.suggestion-chip {
  padding: 10px 18px;
  border: 2px solid var(--border-color);
  border-radius: 24px;
  background: white;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.suggestion-chip:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
}

/* API ключ */
.api-input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.api-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  font-family: 'Courier New', monospace;
  font-size: 13px;
  transition: var(--transition);
}

.api-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.toggle-visibility {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.toggle-visibility:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.api-link {
  font-size: 13px;
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
}

.api-link:hover {
  color: var(--primary-dark);
}

/* Обертка кнопки генерации */
.generate-btn-wrapper {
  padding: 0;
  width: 100%;
}

/* Кнопка генерации */
.generate-btn {
  width: 100%;
  padding: 20px 24px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  box-sizing: border-box;
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
}

.generate-btn:hover:not(:disabled) {
  box-shadow: 0 12px 32px rgba(102, 126, 234, 0.5);
}

.generate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.btn-icon {
  width: 20px;
  height: 20px;
}

.loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
}

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

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

@keyframes pulseAttention {
  0% {
    box-shadow: 0 0 0 0 rgba(109, 213, 237, 0.7);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 15px rgba(109, 213, 237, 0);
    transform: scale(1.02);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(109, 213, 237, 0);
    transform: scale(1);
  }
}

.pulse-attention {
  animation: pulseAttention 1s ease-out 2;
}

.result-ready {
  border-color: var(--primary-color) !important;
  background: linear-gradient(to bottom, rgba(109, 213, 237, 0.05), transparent) !important;
}

/* Результат */
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.result-header .section-title {
  margin-bottom: 0;
}

.result-date {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.video-wrapper {
  position: relative;
  width: 100%;
  margin: 20px auto 0;
  border-radius: 20px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 16 / 9;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.result-video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}


.video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

/* Скрываем кнопку полноэкранного режима в стандартном плеере */
.result-video::-webkit-media-controls-fullscreen-button {
  display: none !important;
}

.result-video::-webkit-media-controls-download-button {
  display: none !important;
}

.result-video::-webkit-media-controls-volume-control-container,
.result-video::-webkit-media-controls-mute-button,
.result-video::-webkit-media-controls-volume-slider {
  display: none !important;
}

/* Для Firefox */
.result-video::-moz-media-controls-fullscreen-button {
  display: none !important;
}

.result-video::-moz-media-controls-mute-button,
.result-video::-moz-media-controls-volume-slider {
  display: none !important;
}

.processing-message {
  text-align: center;
}

.processing-message p {
  margin-top: 16px;
  font-size: 14px;
  font-weight: 500;
}

.pulse-loader {
  width: 60px;
  height: 60px;
  margin: 0 auto 16px;
  background: var(--primary-color);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
  position: relative;
}

.pulse-loader::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  background: white;
  border-radius: 50%;
  opacity: 0.3;
}

@keyframes pulse {
  0% { transform: scale(0.8); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.5; }
  100% { transform: scale(0.8); opacity: 1; }
}

/* Кнопки действий */
.action-buttons {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.action-btn {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--transition);
}

.action-btn:hover:not(:disabled) {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.action-btn.primary {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

.action-btn.primary:hover:not(:disabled) {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.action-btn svg {
  width: 16px;
  height: 16px;
}

/* Сообщения */
.message-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  z-index: 1000;
}

.message {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  font-size: 13px;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.message.success {
  background: #48bb78;
  color: white;
}

.message.error {
  background: #f56565;
  color: white;
}

.message.info {
  background: var(--primary-color);
  color: white;
}

/* Футер */
.footer {
  padding: 24px 60px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  margin-top: auto;
}

@media (max-width: 768px) {
  .footer {
    padding: 20px;
  }
}

.footer-text {
  font-size: 12px;
  color: var(--text-tertiary);
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
}

.footer-links a:hover {
  color: var(--primary-color);
}

.separator {
  color: var(--text-tertiary);
}

/* История видео */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.history-header .section-title {
  margin-bottom: 0;
}

.clear-history-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.clear-history-btn:hover {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.05);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-history {
  text-align: center;
  color: var(--text-tertiary);
  padding: 20px;
  font-size: 14px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.history-item:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

.history-thumbnail-wrapper {
  position: relative;
  width: 60px;
  height: 60px;
  flex-shrink: 0;
}

.history-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.history-thumbnail-placeholder {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-loader-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.history-info {
  flex: 1;
  min-width: 0;
}

.history-prompt {
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-date {
  font-size: 11px;
  color: var(--text-tertiary);
}

.history-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.history-play,
.history-download,
.history-copy,
.history-view-generating {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.history-view-generating {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: rgba(102, 126, 234, 0.1);
}

.history-play:hover,
.history-download:hover,
.history-copy:hover,
.history-view-generating:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: rgba(102, 126, 234, 0.05);
}

.history-task-id {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: monospace;
  margin: 2px 0;
}

.history-credits {
  font-size: 11px;
  color: var(--text-secondary);
  margin: 2px 0;
}

.history-warning {
  font-size: 11px;
  color: #ff6b6b;
  margin: 2px 0;
  font-weight: 500;
}

.history-status {
  font-size: 11px;
  color: var(--primary-color);
  margin: 2px 0;
  font-weight: 500;
}

/* Пагинация */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.pagination-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pagination-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: rgba(102, 126, 234, 0.05);
}

.pagination-btn.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

.pagination-btn.active:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.pagination-prev,
.pagination-next {
  font-size: 16px;
}

.pagination-dots {
  color: var(--text-tertiary);
  padding: 0 4px;
  user-select: none;
}

/* Скроллбар - скрываем */
.main-content::-webkit-scrollbar {
  display: none;
}

.main-content {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}
