/* ===== CSS RESET & BASE ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

body {
  color: var(--text-primary);
  background: var(--bg-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  min-height: 100vh;
  line-height: 1.6;
  padding: 1rem !important;
}

/* ===== CSS VARIABLES FOR THEMES ===== */
:root {
  /* Light theme (default) */
  --bg-primary: #e0e5ec;
  --text-primary: #2d3748;
  --text-secondary: #4a5568;
  --card-bg: #e0e5ec;
  --shadow-light: #ffffff;
  --shadow-dark: #bebebe;
  --border-color: #d1d9e6;
  --accent-color: #2563eb;
  --accent-hover: #1d4ed8;
  --input-bg: #e0e5ec;
  --scrollbar-track: #e0e5ec;
  --scrollbar-thumb: #bebebe;
  --scrollbar-thumb-hover: #a0a0a0;
  --overlay-bg: rgba(0,0,0,0.8);
  --quality-bg: #e5e7eb;
  --json-bg: #f8fafc;
  --json-border: #e2e8f0;
  --info-bg: #f8fafc;
  --history-bg: #f1f5f9;
}

[data-theme="dark"] {
  /* Dark theme */
  --bg-primary: #1a202c;
  --text-primary: #f7fafc;
  --text-secondary: #e2e8f0;
  --card-bg: #2d3748;
  --shadow-light: #4a5568;
  --shadow-dark: #1a202c;
  --border-color: #4a5568;
  --accent-color: #3b82f6;
  --accent-hover: #60a5fa;
  --input-bg: #2d3748;
  --scrollbar-track: #2d3748;
  --scrollbar-thumb: #4a5568;
  --scrollbar-thumb-hover: #718096;
  --overlay-bg: rgba(0,0,0,0.9);
  --quality-bg: #4a5568;
  --json-bg: #2d3748;
  --json-border: #4a5568;
  --info-bg: #2d3748;
  --history-bg: #374151;
}

/* ===== LAYOUT & CONTAINER ===== */
.neuromorphic-bg {
  background: var(--bg-primary);
}

.min-h-screen {
  min-height: 100vh;
}

.max-w-7xl {
  max-width: 1200px;
  margin: 0 auto;
}

.mt-16 {
  margin-top: 4rem;
}

/* ===== HEADER STYLES - FIXED ===== */
.header-container {
  margin: 0 auto 2rem auto;
  border-radius: 0 0 20px 20px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background-color: var(--bg-primary);
  min-height: 350px;
  width: 100%;
  max-width: 1200px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.header-image {
  width: 100%;
  max-width: 1200px;
  height: auto;
  max-height: 400px;
  object-fit: contain;
  display: block;
}

/* ===== THEME TOGGLE - FIXED POSITION ===== */
.theme-toggle-fixed {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
}

.theme-toggle-fixed .neuromorphic-btn {
  width: 45px;
  height: 45px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: all 0.2s ease;
  box-shadow: 4px 4px 10px var(--shadow-dark), -4px -4px 10px var(--shadow-light);
}

.theme-toggle-fixed .neuromorphic-btn i {
  font-size: 1.1rem;
}

.theme-toggle-fixed .neuromorphic-btn:hover {
  transform: scale(1.08);
  box-shadow: 2px 2px 6px var(--shadow-dark), -2px -2px 6px var(--shadow-light);
}

.theme-toggle-fixed .neuromorphic-btn:active {
  transform: scale(0.95);
  box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
}

/* ===== NEUROMORPHIC COMPONENTS ===== */
.neuromorphic-card {
  background: var(--card-bg);
  border-radius: 20px;
  box-shadow: 20px 20px 60px var(--shadow-dark), -20px -20px 60px var(--shadow-light);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.neuromorphic-card-inset {
  background: var(--card-bg);
  border-radius: 20px;
  box-shadow: inset 5px 5px 10px var(--shadow-dark), inset -5px -5px 10px var(--shadow-light);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 1.5rem;
}

.neuromorphic-btn {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  outline: none;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.neuromorphic-btn:hover {
  box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
  transform: translateY(-1px);
}

.neuromorphic-btn:active {
  box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
  transform: translateY(0);
}

.neuromorphic-btn.active {
  box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
  background: var(--border-color);
}

.neuromorphic-input {
  background: var(--input-bg);
  border-radius: 12px;
  box-shadow: inset 5px 5px 10px var(--shadow-dark), inset -5px -5px 10px var(--shadow-light);
  border: none;
  outline: none;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  width: 100%;
  font-family: inherit;
}

.neuromorphic-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

.neuromorphic-input:focus {
  box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light), 0 0 0 2px var(--accent-color);
}

/* ===== TABS SYSTEM ===== */
.tabs-container {
  display: flex;
  justify-content: center;
  margin-bottom: 2rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.tab-button {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  border-radius: 12px;
  transition: all 0.3s ease;
  width: 60px;
  height: 60px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  cursor: pointer;
}

.tab-button.active {
  box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
  background: var(--border-color);
}

.tab-button i {
  font-size: 1.5rem;
  color: var(--accent-color);
  transition: all 0.3s ease;
}

.tab-button.active i {
  color: var(--accent-hover);
}

.tab-button:hover i {
  transform: scale(1.1);
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease-out;
}

.tab-content.active {
  display: block;
}

/* ===== GRID SYSTEM ===== */
.grid {
  display: grid;
  gap: 1.5rem;
}

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

.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

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

.lg\:grid-cols-3 {
  grid-template-columns: 2fr 1fr;
}

.xl\:grid-cols-3 {
  grid-template-columns: 2fr 1fr;
}

.gap-6 {
  gap: 1.5rem;
}

.space-y-6 > * + * {
  margin-top: 1.5rem;
}

/* ===== FORM ELEMENTS ===== */
textarea.neuromorphic-input {
  min-height: 120px;
  resize: vertical;
  font-family: inherit;
}

select.neuromorphic-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
  cursor: pointer;
}

input[type="checkbox"] {
  accent-color: var(--accent-color);
  width: 18px;
  height: 18px;
  cursor: pointer;
}

input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border-color);
  outline: none;
  -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-color);
  cursor: pointer;
}

/* ===== TYPOGRAPHY ===== */
.text-4xl {
  font-size: 2.25rem;
  line-height: 2.5rem;
  font-weight: 700;
}

.text-xl {
  font-size: 1.25rem;
  line-height: 1.75rem;
  font-weight: 600;
}

.text-lg {
  font-size: 1.125rem;
  line-height: 1.75rem;
  font-weight: 600;
}

.text-blue-700 {
  color: var(--accent-color);
  font-weight: 600;
}

.text-blue-600 {
  color: var(--accent-color);
}

.text-gray-500 {
  color: var(--text-secondary);
}

.text-gray-600 {
  color: var(--text-secondary);
}

.text-gray-700 {
  color: var(--text-primary);
}

.text-gray-800 {
  color: var(--text-primary);
}

/* ===== NOTIFICATION SYSTEM ===== */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #4ade80;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transform: translateX(150%);
  transition: transform 0.3s ease;
  z-index: 1000;
  font-weight: 500;
}

.notification.show {
  transform: translateX(0);
}

.notification.error {
  background: #f87171;
}

.toast {
  position: fixed;
  top: 80px;
  right: 20px;
  background: #4ade80;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transform: translateX(150%);
  transition: transform 0.3s ease;
  z-index: 1000;
  font-weight: 500;
}

.toast.show {
  transform: translateX(0);
}

.toast.error {
  background: #ef4444;
}

.toast.warning {
  background: #f59e0b;
}

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

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

@keyframes slideIn {
  from { 
    opacity: 0; 
    transform: translateX(-20px); 
  }
  to { 
    opacity: 1; 
    transform: translateX(0); 
  }
}

.slide-in {
  animation: slideIn 0.3s ease-out;
}

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

.loading-spinner {
  animation: spin 1s linear infinite;
}

/* ===== QUALITY INDICATORS ===== */
.quality-indicator {
  height: 8px;
  border-radius: 4px;
  background: var(--quality-bg);
  overflow: hidden;
  margin-top: 4px;
}

.quality-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.quality-high { 
  background: linear-gradient(90deg, #10b981, #34d399); 
}

.quality-medium { 
  background: linear-gradient(90deg, #f59e0b, #fbbf24); 
}

.quality-low { 
  background: linear-gradient(90deg, #ef4444, #f87171); 
}

/* ===== IMAGE PREVIEW ===== */
.image-preview-container {
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  position: relative;
}

#generatedImage {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  display: block;
}

#loadingSpinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* ===== CUSTOM SCROLLBAR ===== */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

.custom-scrollbar {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* ===== FULLSCREEN OVERLAY ===== */
.fullscreen-overlay {
  background: var(--overlay-bg);
  backdrop-filter: blur(5px);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== ANALYSIS TABS ===== */
.analysis-tab-button {
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: var(--text-primary);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  font-size: 0.875rem;
}

.analysis-tab-button.active {
  background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-hover) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  border-color: transparent;
}

[data-theme="dark"] .analysis-tab-button.active {
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* ===== JSON DISPLAY ===== */
.json-display {
  font-family: 'Courier New', monospace;
  background: var(--json-bg);
  border-radius: 8px;
  padding: 16px;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  border: 1px solid var(--json-border);
  color: var(--text-primary);
  font-size: 0.875rem;
}

/* ===== MODEL BADGE ===== */
.model-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-hover) 100%);
  color: white;
  font-weight: 600;
  display: inline-block;
}

/* ===== DROP ZONE ===== */
.drop-zone {
  border: 2px dashed var(--border-color);
  transition: all 0.3s ease;
  background: var(--card-bg);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
}

.drop-zone.dragover {
  border-color: var(--accent-color);
  background: rgba(37, 99, 235, 0.05);
}

[data-theme="dark"] .drop-zone.dragover {
  background: rgba(59, 130, 246, 0.1);
}

/* ===== CHAT STYLES ===== */
.user-message {
  background: linear-gradient(145deg, var(--border-color), var(--shadow-light));
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.bot-message {
  background: linear-gradient(145deg, var(--shadow-light), var(--border-color));
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.message {
  animation: fadeIn 0.3s ease-out;
}

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

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

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

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

.justify-between {
  justify-content: space-between;
}

.justify-end {
  justify-content: flex-end;
}

.w-full {
  width: 100%;
}

.h-full {
  height: 100%;
}

.h-auto {
  height: auto;
}

.max-w-full {
  max-width: 100%;
}

.max-h-64 {
  max-height: 16rem;
}

.overflow-y-auto {
  overflow-y: auto;
}

.overflow-hidden {
  overflow: hidden;
}

.rounded-lg {
  border-radius: 12px;
}

.rounded-full {
  border-radius: 9999px;
}

.border {
  border-width: 1px;
}

.border-2 {
  border-width: 2px;
}

.p-2 {
  padding: 0.5rem;
}

.p-3 {
  padding: 0.75rem;
}

.p-4 {
  padding: 1rem;
}

.p-6 {
  padding: 1.5rem;
}

.px-3 {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

.px-4 {
  padding-left: 1rem;
  padding-right: 1rem;
}

.py-1 {
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}

.py-2 {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.py-4 {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.py-8 {
  padding-top: 2rem;
  padding-bottom: 2rem;
}

.m-0 {
  margin: 0;
}

.mb-2 {
  margin-bottom: 0.5rem;
}

.mb-3 {
  margin-bottom: 0.75rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.mt-1 {
  margin-top: 0.25rem;
}

.mt-2 {
  margin-top: 0.5rem;
}

.mt-3 {
  margin-top: 0.75rem;
}

.mt-4 {
  margin-top: 1rem;
}

.mt-12 {
  margin-top: 3rem;
}

.mr-1 {
  margin-right: 0.25rem;
}

.mr-2 {
  margin-right: 0.5rem;
}

.ml-auto {
  margin-left: auto;
}

.mr-auto {
  margin-right: auto;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-3 {
  gap: 0.75rem;
}

.gap-4 {
  gap: 1rem;
}

.space-y-2 > * + * {
  margin-top: 0.5rem;
}

.space-y-3 > * + * {
  margin-top: 0.75rem;
}

.space-y-4 > * + * {
  margin-top: 1rem;
}

.opacity-50 {
  opacity: 0.5;
}

.opacity-70 {
  opacity: 0.7;
}

.leading-relaxed {
  line-height: 1.625;
}

.font-medium {
  font-weight: 500;
}

.font-semibold {
  font-weight: 600;
}

.font-bold {
  font-weight: 700;
}

.text-sm {
  font-size: 0.875rem;
}

.text-xs {
  font-size: 0.75rem;
}

.block {
  display: block;
}

.inline-block {
  display: inline-block;
}

.flex-1 {
  flex: 1 1 0%;
}

.flex-grow {
  flex-grow: 1;
}

.flex-shrink-0 {
  flex-shrink: 0;
}

.cursor-pointer {
  cursor: pointer;
}

.resize-none {
  resize: none;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  body {
    padding: 0.5rem !important;
  }
  
  .header-container {
    min-height: 250px;
    border-radius: 0 0 15px 15px;
    margin-bottom: 1.5rem;
  }
  
  .header-image {
    max-height: 300px;
  }
  
  .theme-toggle-fixed {
    top: 15px;
    right: 15px;
  }
  
  .theme-toggle-fixed .neuromorphic-btn {
    width: 40px;
    height: 40px;
  }
  
  .neuromorphic-card {
    padding: 1rem;
    margin-bottom: 1rem;
  }
  
  .lg\:grid-cols-3,
  .xl\:grid-cols-3 {
    grid-template-columns: 1fr;
  }
  
  .grid-cols-2 {
    grid-template-columns: 1fr;
  }
  
  .grid-cols-3 {
    grid-template-columns: 1fr;
  }
  
  .tabs-container {
    gap: 0.5rem;
  }
  
  .tab-button {
    width: 50px;
    height: 50px;
  }
  
  .max-w-7xl {
    padding: 0 0.5rem !important;
  }
  
  .text-4xl {
    font-size: 1.875rem;
  }
  
  .mt-16 {
    margin-top: 3rem;
  }
}

@media (max-width: 480px) {
  .header-container {
    min-height: 200px;
  }
  
  .header-image {
    max-height: 250px;
  }
  
  .tabs-container {
    gap: 0.25rem;
  }
  
  .tab-button {
    width: 45px;
    height: 45px;
    padding: 0.75rem;
  }
  
  .tab-button i {
    font-size: 1.25rem;
  }
  
  .analysis-tab-button {
    padding: 8px 12px;
    font-size: 0.75rem;
  }
  
  .theme-toggle-fixed {
    top: 10px;
    right: 10px;
  }
  
  .theme-toggle-fixed .neuromorphic-btn {
    width: 35px;
    height: 35px;
  }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== FOCUS VISIBLE ===== */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* ===== PRINT STYLES ===== */
@media print {
  .theme-toggle-fixed,
  .tabs-container,
  .neuromorphic-btn {
    display: none !important;
  }
  
  .neuromorphic-card {
    box-shadow: none !important;
    border: 1px solid #000 !important;
  }
  }
