/* ===== CSS VARIABLES & RESET ===== */
:root {
  /* Color Palette */
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --accent-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --dark-bg: #0a0a0f;
  --card-bg: rgba(255, 255, 255, 0.05);
  --card-border: rgba(255, 255, 255, 0.1);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.5);
  --success: #10b981;
  --glow-purple: rgba(102, 126, 234, 0.4);
  --glow-pink: rgba(245, 87, 108, 0.4);

  /* Spacing & Sizing */
  --border-radius: 16px;
  --border-radius-sm: 12px;
  --border-radius-lg: 24px;
  --spacing-xs: 8px;
  --spacing-sm: 16px;
  --spacing-md: 24px;
  --spacing-lg: 32px;
  --spacing-xl: 48px;

  /* Typography */
  --font-display: "Outfit", sans-serif;
  --font-body: "Inter", sans-serif;
}

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

body {
  font-family: var(--font-body);
  background: var(--dark-bg);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
  min-height: 100vh;
}

/* ===== ANIMATED BACKGROUND ===== */
.background-animation {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background: radial-gradient(
      circle at 20% 30%,
      var(--glow-purple) 0%,
      transparent 50%
    ),
    radial-gradient(circle at 80% 70%, var(--glow-pink) 0%, transparent 50%),
    radial-gradient(
      circle at 50% 50%,
      rgba(79, 172, 254, 0.2) 0%,
      transparent 50%
    );
  animation: bgShift 15s ease-in-out infinite;
}

@keyframes bgShift {
  0%,
  100% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(1.1);
  }
}

/* ===== GLASSMORPHISM CARDS ===== */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

/* ===== CONTAINER & LAYOUT ===== */
.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: var(--spacing-md);
}

/* ===== HEADER ===== */
.header {
  text-align: center;
  margin-bottom: var(--spacing-xl);
  padding: var(--spacing-lg) 0;
}

.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
}

.logo-icon {
  font-size: 3rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.logo-text {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1px;
}

.highlight {
  background: var(--secondary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 1.25rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin-bottom: var(--spacing-md);
}

/* ===== PARTICLE CANVAS ===== */
#particleCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

/* ===== I'M FEELING LUCKY BUTTON ===== */
.btn-lucky {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 50%, #feca57 100%);
  color: white;
  border: none;
  padding: 16px 40px;
  border-radius: 50px;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(245, 87, 108, 0.4);
  transition: all 0.3s ease;
  animation: luckyPulse 2s ease-in-out infinite;
}

.btn-lucky::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255,255,255,0.3), transparent);
  transform: rotate(45deg);
  animation: luckyShine 3s linear infinite;
}

.btn-lucky:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 12px 36px rgba(245, 87, 108, 0.6);
}

.btn-lucky:active {
  transform: translateY(-2px) scale(1.02);
}

.lucky-icon {
  font-size: 1.5rem;
  animation: luckyRotate 4s linear infinite;
}

.lucky-sparkle {
  font-size: 1.3rem;
  animation: luckySparkle 1.5s ease-in-out infinite;
}

@keyframes luckyPulse {
  0%, 100% {
    box-shadow: 0 8px 24px rgba(245, 87, 108, 0.4);
  }
  50% {
    box-shadow: 0 8px 32px rgba(245, 87, 108, 0.6), 0 0 40px rgba(245, 87, 108, 0.3);
  }
}

@keyframes luckyShine {
  0% {
    transform: translateX(-100%) rotate(45deg);
  }
  100% {
    transform: translateX(100%) rotate(45deg);
  }
}

@keyframes luckyRotate {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

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

/* ===== HEADER CONTROLS ===== */
.header-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-lg);
  margin: var(--spacing-md) 0;
  flex-wrap: wrap;
}

/* ===== DATE DISPLAY ===== */
.date-display {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.date-icon {
  font-size: 1.2rem;
}

/* ===== NSFW TOGGLE ===== */
.nsfw-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50px;
  padding: 10px 20px;
}

.toggle-switch {
  position: relative;
  width: 50px;
  height: 26px;
  display: inline-block;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.2);
  transition: 0.4s;
  border-radius: 26px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background: linear-gradient(135deg, #f5576c 0%, #ff6b6b 100%);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(24px);
}

.toggle-label {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

#nsfwStatus {
  color: var(--text-primary);
  font-weight: 700;
}

.nsfw-indicator {
  font-size: 1.1rem;
  transition: all 0.3s ease;
}

.nsfw-toggle.active .nsfw-indicator {
  animation: pulse 1s ease-in-out infinite;
}

/* ===== HISTORY BUTTON ===== */
.btn-history {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50px;
  padding: 10px 20px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.btn-history:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.history-icon {
  font-size: 1.2rem;
}

#historyCount {
  color: var(--text-primary);
  font-weight: 700;
}

/* ===== MODAL ===== */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  animation: fadeIn 0.3s ease;
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  max-width: 800px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-sm);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 2rem;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: rotate(90deg);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-sm) 0;
}

.empty-history {
  text-align: center;
  color: var(--text-muted);
  padding: var(--spacing-xl);
  font-style: italic;
}

.history-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
  transition: all 0.3s ease;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(102, 126, 234, 0.5);
}

.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-xs);
}

.history-timestamp {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.history-nsfw-badge {
  background: linear-gradient(135deg, #f5576c 0%, #ff6b6b 100%);
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.history-prompt {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: var(--spacing-sm);
}

.history-actions {
  display: flex;
  gap: var(--spacing-xs);
}

.history-action-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: var(--border-radius-sm);
  padding: 6px 12px;
  color: var(--text-primary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.history-action-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.modal-footer {
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ===== MAIN CONTENT GRID ===== */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-lg);
  align-items: start;
}

/* ===== SECTION TITLES ===== */
.section-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: var(--spacing-md);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.section-title .icon {
  font-size: 1.5rem;
}

/* ===== OPTION GROUPS ===== */
.option-group {
  margin-bottom: var(--spacing-lg);
}

.option-label {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.875rem;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--spacing-sm);
}

.option-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  padding: var(--spacing-sm) var(--spacing-md);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.option-btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: var(--primary-gradient);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
  z-index: -1;
}

.option-btn:hover {
  border-color: rgba(102, 126, 234, 0.5);
  color: var(--text-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.option-btn:hover::before {
  width: 300px;
  height: 300px;
}

.option-btn.active {
  background: var(--primary-gradient);
  border-color: transparent;
  color: var(--text-primary);
  box-shadow: 0 4px 16px var(--glow-purple);
}

.option-btn.active::before {
  width: 300px;
  height: 300px;
}

/* ===== RIGHT PANEL ===== */
.sticky-card {
  position: sticky;
  top: var(--spacing-md);
}

.selection-preview {
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--border-radius);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.preview-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
  color: var(--text-secondary);
}

.selection-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
}

.tag {
  display: inline-block;
  background: var(--primary-gradient);
  color: var(--text-primary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  animation: tagAppear 0.3s ease;
}

@keyframes tagAppear {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ===== PROMPT OUTPUT ===== */
.prompt-output {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius);
  padding: var(--spacing-md);
  min-height: 200px;
  margin-bottom: var(--spacing-md);
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text-primary);
  position: relative;
  overflow-y: auto;
  max-height: 400px;
}

.placeholder-text {
  color: var(--text-muted);
  text-align: center;
  padding: var(--spacing-lg);
  font-style: italic;
}

/* ===== BUTTONS ===== */
.action-buttons {
  display: flex;
  gap: var(--spacing-sm);
}

.btn {
  flex: 1;
  padding: var(--spacing-sm) var(--spacing-lg);
  border: none;
  border-radius: var(--border-radius-sm);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  position: relative;
  overflow: hidden;
}

.btn-icon {
  font-size: 1.25rem;
}

.btn-primary {
  background: var(--primary-gradient);
  color: var(--text-primary);
  box-shadow: 0 4px 16px var(--glow-purple);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px var(--glow-purple);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

/* ===== SUCCESS MESSAGE ===== */
.success-message {
  background: var(--success);
  color: white;
  padding: var(--spacing-sm);
  border-radius: var(--border-radius-sm);
  text-align: center;
  margin-top: var(--spacing-sm);
  font-weight: 600;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  pointer-events: none;
}

.success-message.show {
  opacity: 1;
  transform: translateY(0);
}

/* ===== FOOTER ===== */
.footer {
  text-align: center;
  padding: var(--spacing-lg) 0;
  margin-top: var(--spacing-xl);
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ===== SCROLLBAR STYLING ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--primary-gradient);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--secondary-gradient);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1200px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .sticky-card {
    position: static;
  }

  .logo-text {
    font-size: 2.5rem;
  }
}

@media (max-width: 768px) {
  .container {
    padding: var(--spacing-sm);
  }

  .logo-text {
    font-size: 2rem;
  }

  .subtitle {
    font-size: 1rem;
  }

  .button-grid {
    grid-template-columns: 1fr;
  }

  .action-buttons {
    flex-direction: column;
  }

  .section-title {
    font-size: 1.5rem;
  }
}

/* ===== ANIMATIONS ===== */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
}

.loading {
  animation: pulse 1.5s ease-in-out infinite;
}
