@import url('https://fonts.googleapis.com/css2?family=Abril+Fatface&display=swap');

/* ========== ROOT VARIABLES ========== */
:root {
  --bg-color: #ffffff;
  --shadow-light: #f0f0f0;
  --shadow-dark: #d0d0d0;
  --text-color: #000000;
  --border-radius: 20px;
  --highlight-color: #f5f5f5;
}

.dark-theme {
  --bg-color: #1a1a1a;
  --text-color: #ffffff;
  --shadow-dark: #0d0d0d;
  --shadow-light: #272727;
  --highlight-color: #2a2a2a;
}

/* ========== BASE STYLES ========== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 0;
  line-height: 1.6;
  background-color: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========== LAYOUT STRUCTURE ========== */
.app-header {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto 20px;
  padding: 20px 15px;
  background: var(--bg-color);
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-bottom: 1px solid #e0e0e0;
  border-radius: var(--border-radius);
}

.main-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 15px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}

/* Mobile Devices (nearly edge-to-edge) */
@media (max-width: 767px) {
  .app-header,
  .main-container {
    padding: 0 10px;
  }

  .app-header {
    padding: 20px 10px;
    margin-bottom: 15px;
  }

  .section-header,
  .neumorphic-card {
    border-radius: 12px;
  }
}

/* Extreme Mobile (true edge-to-edge) */
@media (max-width: 480px) {
  .app-header,
  .main-container {
    padding: 0 8px;
  }

  .neumorphic-card {
    border-radius: 10px;
  }
}

/* Tablet Devices */
@media (min-width: 768px) and (max-width: 1023px) {
  .app-header,
  .main-container {
    width: 98%;
    padding: 0 15px;
  }
}

/* Desktop Devices */
@media (min-width: 1024px) {
  .app-header,
  .main-container {
    width: 95%;
    padding: 0 20px;
  }
}

/* ========== HEADER STYLES ========== */
.header-content {
  max-width: 100%;
  margin: 0 auto;
}

.header-top {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.app-header h1 {
  margin: 0;
  font-family: 'Abril Fatface', cursive;
  font-size: clamp(2rem, 7vw, 3rem);
  color: var(--text-color);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  font-weight: 400;
  letter-spacing: 1.5px;
  line-height: 1.1;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.1);
}

.dark-theme .app-header h1 {
  text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
}

.header-subtitle {
  text-align: center;
  margin: 10px 0 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: clamp(1.1rem, 3.5vw, 1.3rem);
  color: #666;
  font-weight: 300;
  letter-spacing: 0.8px;
}

.dark-theme .header-subtitle {
  color: #aaa;
}

.theme-toggle {
  background: var(--bg-color);
  border: none;
  margin-top: 15px;
  margin-bottom: 10px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 3px 3px 6px var(--shadow-dark),
             -3px -3px 6px var(--shadow-light);
  color: var(--text-color);
  transition: all 0.3s ease;
}

.theme-toggle:hover {
  transform: scale(1.1);
}

/* ========== TOOL CONTAINERS ========== */
.tool-container {
  width: 100%;
  border-radius: var(--border-radius);
  margin-bottom: 20px;
  overflow: hidden;
}

/* ========== SECTION HEADER ========== */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-radius: var(--border-radius);
  background: var(--bg-color);
  box-shadow: 8px 8px 16px var(--shadow-dark),
             -8px -8px 16px var(--shadow-light);
  border: 1px solid #e0e0e0;
  width: 100%;
}

.section-header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--text-color);
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========== SECTION CONTENT ========== */
.section-content {
  padding: 22px;
  background: var(--bg-color);
  box-shadow: 8px 8px 16px var(--shadow-dark),
             -8px -8px 16px var(--shadow-light);
  border-radius: 0 0 var(--border-radius) var(--border-radius);
  border: 1px solid #e0e0e0;
  border-top: none;
  margin-top: -6px;
}

/* ========== CARD STYLES ========== */
.neumorphic-card {
  padding: clamp(16px, 5vw, 26px);
  border-radius: var(--border-radius);
  background: var(--bg-color);
  margin-bottom: 20px;
  width: 100%;
  min-height: 100px;
  overflow: visible;
  border: 1px solid #e0e0e0;
  box-shadow: 5px 5px 10px var(--shadow-dark),
             -5px -5px 10px var(--shadow-light);
}

/* ========== INPUT COMPONENTS ========== */
.textarea-container {
  position: relative;
  width: 100%;
  margin: 12px 0;
}

.clear-prompt-btn {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid #d0d0d0;
  background: var(--bg-color);
  color: var(--text-color);
  box-shadow: 3px 3px 6px var(--shadow-dark),
             -3px -3px 6px var(--shadow-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: all 0.2s ease;
}

.clear-prompt-btn:hover {
  transform: scale(1.1);
  box-shadow: 2px 2px 5px var(--shadow-dark),
             -2px -2px 5px var(--shadow-light);
}

.clear-prompt-btn:active {
  box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.1),
             inset -2px -2px 4px rgba(255, 255, 255, 0.1);
}

/* ========== RESULT DISPLAY ========== */
.result-display {
  max-height: 800px;
  overflow-y: auto;
  padding: 18px;
  margin-top: 12px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  background: var(--bg-color);
  border-radius: var(--border-radius);
  box-shadow: inset 5px 5px 10px var(--shadow-dark),
             inset -5px -5px 10px var(--shadow-light);
  border: 1px solid #e0e0e0;
}

/* ========== BUTTON STYLES ========== */
.neumorphic-btn {
  padding: 13px 26px;
  border: 1px solid #d0d0d0;
  border-radius: var(--border-radius);
  background: var(--bg-color);
  box-shadow: 5px 5px 10px var(--shadow-dark),
             -5px -5px 10px var(--shadow-light);
  color: var(--text-color);
  font-size: clamp(14px, 3.2vw, 16px);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 12px 0;
}

.neumorphic-btn:hover {
  background: var(--highlight-color);
  box-shadow: 3px 3px 7px var(--shadow-dark),
             -3px -3px 7px var(--shadow-light);
}

.neumorphic-btn:active {
  box-shadow: inset 3px 3px 6px var(--shadow-dark),
             inset -3px -3px 6px var(--shadow-light);
}

.btn-primary {
  background: var(--text-color);
  color: var(--bg-color);
  box-shadow: 5px 5px 10px var(--shadow-dark),
             -5px -5px 10px var(--shadow-light);
}

.btn-primary:hover {
  background: #333;
}

.neumorphic-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

/* ========== FORM ELEMENTS ========== */
.neumorphic-input,
.neumorphic-select,
.neumorphic-textarea {
  width: 100%;
  padding: clamp(13px, 3.2vw, 16px);
  border: 1px solid #e0e0e0;
  border-radius: var(--border-radius);
  background: var(--bg-color);
  box-shadow: inset 5px 5px 10px var(--shadow-dark),
             inset -5px -5px 10px var(--shadow-light);
  font-size: clamp(14px, 3.2vw, 16px);
  color: var(--text-color);
  margin: 12px 0;
}

.neumorphic-select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 16px;
}

.neumorphic-textarea {
  min-height: 130px;
  resize: vertical;
}

.neumorphic-input:focus,
.neumorphic-textarea:focus,
.neumorphic-select:focus {
  outline: none;
  box-shadow: inset 4px 4px 8px var(--shadow-dark),
             inset -4px -4px 8px var(--shadow-light);
}

/* ========== FILE INPUT ========== */
.neumorphic-file-input {
  width: 100%;
  padding: clamp(16px, 5vw, 22px);
  border-radius: var(--border-radius);
  background: var(--bg-color);
  box-shadow: 5px 5px 10px var(--shadow-dark),
             -5px -5px 10px var(--shadow-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
  margin: 12px 0;
  min-height: 130px;
  justify-content: center;
}

.neumorphic-file-input:hover {
  box-shadow: 3px 3px 7px var(--shadow-dark),
             -3px -3px 7px var(--shadow-light);
}

.file-input-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  color: #666;
  text-align: center;
}

.file-input-label i {
  font-size: clamp(26px, 6.5vw, 34px);
  margin-bottom: 12px;
}

.file-input-label span {
  font-size: clamp(14px, 3.2vw, 16px);
}

input[type="file"] {
  display: none;
}

/* ========== IMAGE PREVIEW ========== */
.image-preview {
  max-width: 100%;
  max-height: min(520px, 65vh);
  border-radius: var(--border-radius);
  box-shadow: 5px 5px 10px var(--shadow-dark),
             -5px -5px 10px var(--shadow-light);
  display: none;
  object-fit: contain;
  margin: 18px auto;
}

/* ========== HISTORY SECTION ========== */
.history-container {
  margin-top: 25px;
}

#historyList {
  max-height: 320px;
  overflow-y: auto;
  margin-top: 12px;
  padding-right: 6px;
}

.history-item {
  padding: 14px;
  margin-bottom: 12px;
  background: var(--bg-color);
  border-radius: var(--border-radius);
  box-shadow: inset 3px 3px 7px var(--shadow-dark),
             inset -3px -3px 7px var(--shadow-light);
  display: flex;
  flex-direction: column;
}

.history-prompt {
  font-weight: 600;
  margin-bottom: 10px;
}

.history-image {
  max-width: 100%;
  max-height: 160px;
  border-radius: var(--border-radius);
  margin-top: 12px;
  object-fit: contain;
  cursor: pointer;
}

/* ========== ADVANCED PANEL ========== */
.advanced-panel {
  margin-top: 25px;
  padding: 16px;
  border-radius: var(--border-radius);
  background: var(--bg-color);
  box-shadow: inset 5px 5px 10px var(--shadow-dark),
             inset -5px -5px 10px var(--shadow-light);
}

.advanced-toggle {
  display: flex;
  align-items: center;
  cursor: pointer;
  margin-bottom: 12px;
}

.advanced-content {
  display: none;
  padding-top: 12px;
}

.advanced-content.show {
  display: block;
}

/* ========== SPECIAL CONTROLS ========== */
.advanced-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.slider-container {
  width: 100%;
  margin: 16px 0;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.neumorphic-slider {
  width: 100%;
  -webkit-appearance: none;
  height: 10px;
  border-radius: 5px;
  background: var(--bg-color);
  box-shadow: inset 3px 3px 6px var(--shadow-dark),
             inset -3px -3px 6px var(--shadow-light);
  outline: none;
}

.neumorphic-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-color);
  cursor: pointer;
  box-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.style-presets,
.quality-presets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.style-preset,
.quality-preset {
  padding: 9px;
  border-radius: var(--border-radius);
  background: var(--bg-color);
  box-shadow: 3px 3px 6px var(--shadow-dark),
             -3px -3px 6px var(--shadow-light);
  text-align: center;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;
}

.style-preset:hover,
.quality-preset:hover {
  box-shadow: 2px 2px 5px var(--shadow-dark),
             -2px -2px 5px var(--shadow-light);
}

.style-preset.active,
.quality-preset.active {
  box-shadow: inset 2px 2px 4px var(--shadow-dark),
             inset -2px -2px 4px var(--shadow-light);
  background: var(--highlight-color);
}

/* ========== UTILITY CLASSES ========== */
#clearHistoryBtn, 
#clearPromptBtn {
  background-color: #db2525;
  color: #fff;
}

.loading {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 3px solid rgba(255,255,255,.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
.prompt-note {
    font-size: 0.8rem;
    color: #ff3333;
    margin-bottom: 8px;
    text-align: center;
    font-style: italic;
}

.dark-theme .prompt-note {
    color: #ff6666;
}

/* ========== SCROLLBAR ========== */
#historyList::-webkit-scrollbar {
  width: 7px;
}

#historyList::-webkit-scrollbar-thumb {
  background: #d0d0d0;
  border-radius: 4px;
}

/* ========== FOOTER STYLES ========== */
.app-footer {
  width: 100%;
  padding: 20px 0;
  text-align: center;
  margin-top: 30px;
  color: var(--text-color);
  font-size: 14px;
  border-top: 1px solid #e0e0e0;
}

.footer-content {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 20px;
}

.app-footer a {
  color: var(--text-color);
  text-decoration: none;
  font-weight: 600;
}

.app-footer a:hover {
  text-decoration: underline;
}

.dark-theme .app-footer {
  border-top: 1px solid #333;
}

/* ========== MEDIA QUERIES ========== */
@media (max-width: 768px) {
  :root {
    --border-radius: 16px;
  }
  
  .app-header {
    padding: 20px 10px;
    margin-bottom: 15px;
  }
  
  .app-header h1 {
    font-size: clamp(1.8rem, 8vw, 2.5rem);
    gap: 10px;
    letter-spacing: 1px;
  }
  
  .header-subtitle {
    font-size: clamp(1rem, 4vw, 1.2rem);
    margin-top: 8px;
  }
  
  .main-container {
    gap: 18px;
  }
  
  .section-header {
    padding: 12px 16px;
  }
  
  .section-header h2 {
    font-size: 1.1rem;
    gap: 10px;
  }
  
  .section-content {
    padding: 18px;
  }
  
  .neumorphic-btn {
    padding: 12px 20px;
    font-size: 14px;
  }
  
  .neumorphic-card {
    padding: 14px 16px;
  }
  
  .action-buttons {
    gap: 8px;
  }
  
  .advanced-grid {
    grid-template-columns: 1fr;
  }
  
  .style-presets,
  .quality-presets {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 10px;
  }
}

@media (min-width: 768px) {
  .neumorphic-btn {
    width: auto;
    min-width: 220px;
  }
  
  .neumorphic-file-input {
    min-height: 160px;
  }
  
  .section-content {
    padding: 25px;
  }
  
  .action-buttons {
    justify-content: flex-start;
  }
  
  .action-buttons .neumorphic-btn {
    flex: 0 1 auto;
  }
}

@media (min-width: 1200px) {
  .app-header h1 {
    font-size: 3.2rem;
  }
  
  .header-subtitle {
    font-size: 1.4rem;
  }
  
  .main-container {
    max-width: 1400px;
  }
}
/* ========== PROMPT BUTTON STYLES ========== */
.prompt-button-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
}

.enhance-prompt-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.enhance-tooltip {
    font-size: 0.8rem;
    color: #666;
    text-align: center;
}

.dark-theme .enhance-tooltip {
    color: #aaa;
}

#clearPromptBtn {
    width: 100%;
    margin: 0;
}

/* Responsive adjustments */
@media (min-width: 768px) {
    .prompt-button-container {
        flex-direction: row;
        align-items: flex-end;
    }
    
    .enhance-prompt-container {
        flex: 1;
    }
    
    #clearPromptBtn {
        width: auto;
        min-width: 120px;
    }
}

/* Add to main.css */
.image-loading-container {
  position: relative;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--highlight-color);
  border-radius: var(--border-radius);
  margin: 18px 0;
}

.image-loading-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: var(--text-color);
  animation: spin 1s ease-in-out infinite;
}

.error-message {
  color: #ff3333;
  text-align: center;
  padding: 20px;
  background: var(--highlight-color);
  border-radius: var(--border-radius);
}

.dark-theme .error-message {
  color: #ff6666;
}

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