:root {
  --primary-color: #ff8fa3;
  --secondary-color: #ffb3c6;
  --accent-color: #ff4d6d;
  --bg-color-dark: #121212;
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --text-main: #f8f9fa;
  --text-muted: #adb5bd;
  --success-color: #38b000;
  --error-color: #e63946;
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-color-dark);
  color: var(--text-main);
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 40px 20px;
}

/* Background animated elements */
.background-elements {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  overflow: hidden;
  background: radial-gradient(circle at center, #1a1a2e 0%, #121212 100%);
}

.glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: float 10s infinite ease-in-out alternate;
}

.glow-1 {
  width: 400px;
  height: 400px;
  background: #ff8fa3;
  top: -100px;
  left: -100px;
}

.glow-2 {
  width: 500px;
  height: 500px;
  background: #ffb3c6;
  bottom: -150px;
  right: -100px;
  animation-delay: -5s;
}

.glow-3 {
  width: 300px;
  height: 300px;
  background: #8338ec;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: pulse-glow 8s infinite alternate;
}

@keyframes float {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(50px) scale(1.1); }
}

@keyframes pulse-glow {
  0% { opacity: 0.2; transform: translate(-50%, -50%) scale(0.8); }
  100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1.2); }
}

.text-center { text-align: center; }
.hidden { display: none !important; }

.container {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  gap: 30px;
  z-index: 1;
}

.header {
  margin-bottom: 20px;
  animation: fade-in-down 0.8s ease-out;
}

.title {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 15px;
  letter-spacing: -0.5px;
}

.gradient-text {
  background: linear-gradient(135deg, var(--primary-color), #ffc8dd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 300;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Glassmorphism Panel */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 40px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: var(--transition);
  animation: fade-in-up 0.8s ease-out 0.2s both;
}

.glass-panel:hover {
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Form Styles */
.input-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.input-group {
  position: relative;
  display: flex;
  align-items: stretch;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  overflow: hidden;
  transition: var(--transition);
}

.input-group:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(255, 143, 163, 0.3);
}

.input-icon {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--primary-color);
  font-size: 1.2rem;
  pointer-events: none;
}

.glass-input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 20px 20px 20px 50px;
  color: #fff;
  font-size: 1.1rem;
  font-family: inherit;
  outline: none;
}

.glass-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
  color: white;
  border: none;
  padding: 0 30px;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: linear-gradient(135deg, rgba(255,255,255,0.2), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.btn-primary:hover::before {
  opacity: 1;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(255, 77, 109, 0.4);
}

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

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid var(--glass-border);
  padding: 15px 20px;
  border-radius: 16px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}

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

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

.btn-remove {
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  border: none;
  padding: 0 20px;
  cursor: pointer;
  font-size: 1.2rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-remove:hover {
  color: #ff4d6d;
}

.btn-remove.hidden {
  display: none;
}

/* Suggestion Tags */
.suggestions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-left: 5px;
}

.suggestions span {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.tag {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--secondary-color);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
  backdrop-filter: blur(4px);
}

.tag:hover {
  background: rgba(255, 143, 163, 0.15);
  border-color: var(--primary-color);
  color: white;
  transform: translateY(-2px);
}

/* Loading & Error States */
.state-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 0 10px;
  animation: fade-in 0.5s ease-out;
}

.spinner-container {
  margin-bottom: 25px;
}

.heartbeat-loader {
  width: 50px;
  height: 50px;
  background-color: var(--primary-color);
  transform: rotate(45deg);
  animation: heartbeat 1.2s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
  box-shadow: 0 0 20px rgba(255, 143, 163, 0.8);
}

.heartbeat-loader:before,
.heartbeat-loader:after {
  content: "";
  position: absolute;
  width: 50px;
  height: 50px;
  background-color: var(--primary-color);
  border-radius: 50%;
}

.heartbeat-loader:before { left: -25px; top: 0; }
.heartbeat-loader:after { left: 0; top: -25px; }

@keyframes heartbeat {
  0% { transform: rotate(45deg) scale(0.8); }
  5% { transform: rotate(45deg) scale(0.9); }
  10% { transform: rotate(45deg) scale(0.8); }
  15% { transform: rotate(45deg) scale(1.1); box-shadow: 0 0 30px var(--primary-color); }
  50% { transform: rotate(45deg) scale(0.8); box-shadow: 0 0 10px var(--primary-color); }
  100% { transform: rotate(45deg) scale(0.8); }
}

.loading-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
  background: linear-gradient(90deg, #fff, #ffb3c6, #fff);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shine 3s linear infinite;
}

.loading-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 20px;
}

.highlight {
  color: var(--primary-color);
  font-weight: 600;
}

.progress-bar {
  width: 100%;
  max-width: 400px;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  position: absolute;
  top: 0; left: 0; height: 100%;
  width: 30%;
  background: linear-gradient(90deg, var(--accent-color), var(--primary-color), var(--secondary-color));
  border-radius: 10px;
  animation: progress 20s ease-out forwards;
}

@keyframes progress {
  0% { width: 0%; }
  30% { width: 40%; }
  60% { width: 70%; }
  90% { width: 85%; }
  100% { width: 95%; } /* Will jump to 100 on complete */
}

@keyframes shine {
  to { background-position: 200% center; }
}

.error-icon {
  font-size: 3rem;
  color: var(--error-color);
  margin-bottom: 15px;
  filter: drop-shadow(0 0 10px rgba(230, 57, 70, 0.5));
}

.error-title { color: #fff; margin-bottom: 10px; }
.error-text { color: var(--text-muted); text-align: center; max-width: 400px; }

/* Image Grid Section */
.results-section {
  width: 100%;
  animation: fade-in-up 0.8s ease-out;
}

.section-title {
  font-size: 2rem;
  margin-bottom: 30px;
  display: flex;
  align-items: center;
  gap: 15px;
}

.heart-icon { color: var(--accent-color); font-size: 1.5rem; }

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 25px;
  width: 100%;
}

.image-card {
  position: relative;
  background: rgba(255,255,255,0.03);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.05);
  box-shadow: 0 10px 20px rgba(0,0,0,0.3);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.image-card:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: 0 20px 40px rgba(0,0,0,0.5), 0 0 20px rgba(255, 143, 163, 0.3);
  border-color: rgba(255, 143, 163, 0.5);
  z-index: 10;
}

.image-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
  display: block;
}

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

.image-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  padding: 20px;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

.image-card:hover .image-overlay {
  transform: translateY(0);
}

.image-img-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 9/16;
  overflow: hidden;
}

.btn-download {
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(10px);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 8px 16px;
  border-radius: 20px;
  text-decoration: none;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}

.btn-download:hover {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

/* Prompt Display */
.prompt-box {
  padding: 15px;
  background: rgba(0, 0, 0, 0.4);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.85rem;
  color: var(--text-muted);
  position: relative;
  display: flex;
  flex-direction: column;
}

.prompt-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 10px;
  line-height: 1.4;
}

.copy-btn {
  align-self: flex-end;
  background: transparent;
  border: 1px solid var(--text-muted);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
}

.copy-btn:hover {
  color: var(--primary-color);
  border-color: var(--primary-color);
}

/* Nav Tabs */
.nav-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 0;
  justify-content: center;
  width: 100%;
}

.tab-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  padding: 10px 20px;
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  transition: var(--transition);
}

.tab-btn.active {
  background: rgba(255, 143, 163, 0.2);
  color: white;
  border-color: var(--primary-color);
}

.tab-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.1);
}

/* History block */
.history-block {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 25px;
  margin-bottom: 30px;
}
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding-bottom: 10px;
}
.history-topic { font-size: 1.2rem; font-weight: 600; color: var(--secondary-color); }
.history-time { font-size: 0.9rem; color: var(--text-muted); }

/* Modal styles (Fullscreen viewing) */
.modal {
  display: none;
  position: fixed;
  z-index: 100;
  padding-top: 50px;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.9);
  backdrop-filter: blur(10px);
}

.modal-content {
  margin: auto;
  display: block;
  max-width: 90%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 0 50px rgba(0,0,0,0.5);
  animation: zoom 0.3s;
}

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

.close-btn {
  position: absolute;
  top: 15px;
  right: 35px;
  color: #f1f1f1;
  font-size: 40px;
  font-weight: bold;
  transition: 0.3s;
  cursor: pointer;
}

.close-btn:hover,
.close-btn:focus {
  color: var(--primary-color);
  text-decoration: none;
}

.footer {
  margin-top: 50px;
  color: var(--text-muted);
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  opacity: 0.6;
}

/* Animations */
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in-down {
  from { opacity: 0; transform: translateY(-30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Responsive */
@media (max-width: 768px) {
  body { padding: 15px 10px; }
  .title { font-size: 1.8rem; margin-bottom: 10px; }
  .subtitle { font-size: 0.9rem; }
  
  .glass-panel { padding: 20px 15px; border-radius: 20px; }
  
  .input-group { border-radius: 12px; }
  .input-icon { left: 15px; font-size: 1.1rem; } 
  .glass-input { 
    font-size: 1rem; 
    padding: 15px 15px 15px 45px; 
  }
  .btn-primary { 
    padding: 15px; 
    border-radius: 12px; 
    justify-content: center;
    width: 100%;
  }
  
  .suggestions { justify-content: flex-start; gap: 8px; padding-left: 0; margin-top: 5px; }
  .tag { padding: 8px 12px; font-size: 0.85rem; }
  
  .nav-tabs { gap: 8px; flex-wrap: wrap; }
  .tab-btn { padding: 10px 15px; font-size: 0.95rem; flex: 1; text-align: center; }
  
  .image-grid {
    grid-template-columns: repeat(2, 1fr); /* Two columns for mobile viewing */
    gap: 15px;
  }
  
  .image-overlay { transform: translateY(0); padding: 15px; }
  
  .section-title { font-size: 1.3rem; margin-bottom: 20px; }
  
  .prompt-box { padding: 12px; font-size: 0.85rem; }
  .history-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .history-block { padding: 15px; }
  
  .loading-title { font-size: 1.3rem; }
  .loading-subtitle { font-size: 0.85rem; }
}
