/* ===== RESET & VARIABLES ===== (SQ-1.0) */
:root {
  --primary-color: #00d4ff;
  --primary-hover: #00a8cc;
  --secondary-color: #ff6b6b;
  --bg-dark: #0a0a0a;
  --bg-dark-secondary: #1a1a1a;
  --bg-card: #141414;
  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --border-color: #2a2a2a;
  --success-color: #4caf50;
  --error-color: #ff5252;
  --gradient-primary: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
  --gradient-bg: linear-gradient(180deg, #0a0a0a 0%, #1a1a1a 100%);
  --shadow-xl: 0 20px 40px rgba(0, 212, 255, 0.1);
  --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.5);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ===== BASE STYLES ===== */
body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

/* ===== HERO SECTION ===== */
.hero-section {
  min-height: 100vh;
  background: var(--gradient-bg);
  position: relative;
}

.gradient-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 300px;
  background: linear-gradient(
    180deg,
    rgba(0, 212, 255, 0.1) 0%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 1;
}

/* ===== HEADER ===== */
header {
  padding: 2rem;
  position: relative;
  z-index: 10;
}

.logo-container {
  text-align: center;
  margin-bottom: 3rem;
}

.logo {
  font-size: 3rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}

.logo-subtitle {
  font-size: 1.2rem;
  color: var(--text-secondary);
  font-weight: 400;
}

/* ===== MAIN NAVIGATION ===== */
.main-nav {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 2rem;
}

.nav-button {
  background: var(--bg-dark-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: var(--transition);
}

.nav-button:hover {
  background: var(--bg-dark);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.nav-button.active {
  background: var(--gradient-primary);
  color: white;
  border-color: var(--primary-color);
  box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3);
}

/* ===== MAIN CONTAINER ===== */
.main-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem 2rem;
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 2rem;
  position: relative;
  z-index: 10;
}

/* ===== GENERATOR SECTION ===== */
.generator-section {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 3rem;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-color);
}

.section-title {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.section-description {
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

/* ===== IMAGE SELECTION ===== */
.image-selection {
  margin-bottom: 3rem;
}

.image-selection h3 {
  font-size: 1.2rem;
  margin-bottom: 1.5rem;
  color: var(--primary-color);
  font-weight: 500;
}

/* Container für Bildauswahl und Heldenbeschreibung */
.hero-selection-container {
  display: grid;
  grid-template-columns: 2fr 3fr;
  gap: 2rem;
  align-items: start;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1rem;
}

/* Wenn ein Held ausgewählt ist */
.hero-selection-container.hero-selected .image-grid {
  display: flex;
  justify-content: center;
}

.hero-selection-container.hero-selected #image-container img {
  display: none;
}

.hero-selection-container.hero-selected #image-container img.selected {
  display: block;
  max-height: 200px;
  width: auto;
}

#image-container img {
  max-height: 120px;
  aspect-ratio: 9/16;
  object-fit: cover;
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition);
  border: 3px solid transparent;
  filter: brightness(0.8);
}

#image-container img:hover {
  transform: translateY(-5px);
  filter: brightness(1);
  box-shadow: 0 10px 30px rgba(0, 212, 255, 0.3);
}

#image-container img.selected {
  border-color: var(--primary-color);
  filter: brightness(1);
  box-shadow: 0 0 0 5px rgba(0, 212, 255, 0.2);
}

/* ===== INPUT SECTION ===== */
.input-section {
  margin-bottom: 3rem;
}

.input-section h3 {
  font-size: 1.2rem;
  margin-bottom: 1.5rem;
  color: var(--primary-color);
  font-weight: 500;
}

.textarea-wrapper {
  position: relative;
}

#description {
  width: 100%;
  min-height: 150px;
  padding: 1.5rem;
  background: var(--bg-dark-secondary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  transition: var(--transition);
}

#description:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.1);
}

#description::placeholder {
  color: var(--text-secondary);
}

.character-count {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ===== ACTION SECTION ===== */
.action-section {
  display: flex;
  align-items: center;
  gap: 2rem;
  margin-bottom: 3rem;
}

.generate-btn {
  background: var(--gradient-primary);
  color: white;
  border: none;
  padding: 1rem 2.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 20px rgba(0, 212, 255, 0.3);
}

.generate-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(0, 212, 255, 0.4);
}

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

.btn-icon {
  font-size: 1.2rem;
  transition: transform 0.3s ease;
}

.generate-btn:hover:not(:disabled) .btn-icon {
  transform: translateX(5px);
}

.countdown {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
  min-width: 80px;
  text-align: center;
  opacity: 0;
  animation: fadeIn 0.3s forwards;
}

.countdown.hidden {
  display: none;
}

/* ===== RESULT SECTION ===== */
.result-section {
  background: var(--bg-dark-secondary);
  padding: 2rem;
  border-radius: 12px;
  text-align: center;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border-color);
}

.comic-preview {
  margin: 1rem 0;
  max-width: 100%;
}

.preview-image {
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s ease;
}

.preview-image:hover {
  transform: scale(1.05);
}

.result-section a {
  display: inline-block;
  background: var(--gradient-primary);
  color: white;
  padding: 1rem 2rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
}

.result-section a:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 212, 255, 0.3);
}

/* ===== HISTORY SECTION ===== */
.history-section {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-color);
  height: fit-content;
  position: sticky;
  top: 2rem;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.history-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
}

.history-count {
  background: var(--bg-dark-secondary);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.history-content {
  max-height: 400px;
  overflow-y: auto;
}

#history-list {
  list-style: none;
}

#history-list li {
  margin-bottom: 0.75rem;
}

#history-list a {
  display: block;
  padding: 0.75rem 1rem;
  background: var(--bg-dark-secondary);
  border-radius: 8px;
  color: var(--text-primary);
  text-decoration: none;
  transition: var(--transition);
  border: 1px solid transparent;
}

#history-list a:hover {
  background: var(--bg-dark);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

.empty-state p {
  margin-bottom: 0.5rem;
}

.empty-state-hint {
  font-size: 0.875rem;
  opacity: 0.7;
}

/* ===== QR CODE SECTION ===== */
.qr-code-section {
  margin-top: 2rem;
  padding: 1.5rem;
  background: var(--bg-dark-secondary);
  border-radius: 12px;
  text-align: center;
  border: 1px solid var(--border-color);
}

.qr-code-section h3 {
  color: var(--primary-color);
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

.qr-code-image {
  max-width: 180px;
  margin: 1rem auto;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s ease;
}

.qr-code-image:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 20px rgba(0, 212, 255, 0.3);
}

.qr-code-section p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 1rem;
}

/* ===== FOOTER ===== */
.footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1024px) {
  .main-container {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .history-section {
    position: static;
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  .logo {
    font-size: 2rem;
  }

  .generator-section {
    padding: 2rem;
  }

  .image-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .action-section {
    flex-direction: column;
    align-items: stretch;
  }

  .generate-btn {
    justify-content: center;
  }

  .auth-section {
    padding: 2rem;
    margin: 3rem auto;
  }

  .gallery-controls {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 480px) {
  .main-container {
    padding: 0 1rem 1rem;
  }
}

/* ===== UTILITY CLASSES ===== */
.hidden {
  display: none !important;
}

/* ===== AUTH SECTION ===== */
.auth-section {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 3rem;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-color);
  max-width: 500px;
  margin: 5rem auto;
  text-align: center;
}

.auth-section .section-title {
  margin-bottom: 2rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.auth-form input {
  width: 100%;
  padding: 1rem 1.5rem;
  background: var(--bg-dark-secondary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  transition: var(--transition);
}

.auth-form input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.1);
}

.auth-btn {
  background: var(--gradient-primary);
  color: white;
  border: none;
  padding: 1rem 2.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 20px rgba(0, 212, 255, 0.3);
}

.auth-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(0, 212, 255, 0.4);
}

.auth-btn.secondary {
  background: var(--bg-dark-secondary);
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
  box-shadow: none;
}

.auth-btn.secondary:hover {
  background: var(--primary-color);
  color: var(--text-primary);
  box-shadow: 0 6px 30px rgba(0, 212, 255, 0.4);
}

.auth-message {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.auth-message.success {
  color: var(--success-color);
}

.auth-message.error {
  color: var(--error-color);
}

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

/* ===== GALLERY SECTION ===== */
.gallery-section {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 3rem;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-color);
}

.gallery-controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  align-items: center;
}

.gallery-controls select,
.gallery-controls input[type="text"] {
  padding: 0.75rem 1rem;
  background: var(--bg-dark-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  flex-grow: 1;
  min-width: 150px;
}

.gallery-controls select:focus,
.gallery-controls input[type="text"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.gallery-controls .action-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: var(--transition);
}

.gallery-controls .action-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.gallery-image-item {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s ease;
}

.gallery-image-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 212, 255, 0.3);
}

.gallery-image-item img {
  width: 100%;
  height: 200px; /* Fixed height for consistency */
  object-fit: cover;
  display: block;
}

.gallery-image-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  padding: 0.75rem;
  display: flex;
  justify-content: space-around;
  gap: 0.5rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gallery-image-item:hover .gallery-image-actions {
  opacity: 1;
}

.gallery-image-actions button {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition);
  flex-grow: 1;
}

.gallery-image-actions button:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.gallery-image-actions button.delete-btn {
  background: var(--secondary-color);
}

.gallery-image-actions button.delete-btn:hover {
  background: #cc5252;
}
