@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

@keyframes spin { 100% { transform: rotate(360deg); } }
input[type="checkbox"]:checked + .slider { background-color: var(--accent) !important; }
input[type="checkbox"]:checked + .slider:before { transform: translateX(18px); }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 4px; bottom: 4px; background-color: white; transition: .4s; border-radius: 50%; }


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

:root {
  --bg-primary: #060a1a;
  --bg-secondary: #0c1130;
  --bg-card: rgba(15, 20, 55, 0.7);
  --bg-card-hover: rgba(20, 28, 70, 0.8);
  --border: rgba(0, 212, 255, 0.12);
  --border-hover: rgba(0, 212, 255, 0.3);
  --accent: #00d4ff;
  --accent-glow: rgba(0, 212, 255, 0.25);
  --accent-secondary: #7b61ff;
  --text-primary: #e8eaf6;
  --text-secondary: #8892b0;
  --text-muted: #5a6380;
  --success: #00e676;
  --warning: #ffab40;
  --danger: #ff5252;
  --radius: 14px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(0, 212, 255, 0.15);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(0, 212, 255, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(123, 97, 255, 0.05) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ===== HEADER ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: rgba(6, 10, 26, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
  color: var(--text-primary);
}

.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-size: 18px;
}

.logo span { color: var(--accent); }

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(0, 212, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
}

.status-dot {
  width: 8px; height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(0, 230, 118, 0.5); }
  50% { opacity: 0.8; box-shadow: 0 0 0 6px rgba(0, 230, 118, 0); }
}

/* ===== MAIN LAYOUT ===== */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px;
}

.main-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 28px;
  align-items: start;
}

/* ===== UPLOAD AREA ===== */
.upload-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.upload-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-card);
  overflow: hidden;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(0, 212, 255, 0.04);
  box-shadow: var(--shadow-glow);
}

.upload-zone.drag-over::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 212, 255, 0.06);
  animation: pulse-bg 1s infinite;
}

@keyframes pulse-bg {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.8; }
}

.upload-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.6;
}

.upload-text h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.upload-text p {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.upload-text .browse-link {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.upload-input { display: none; }

/* ===== SOURCE PANEL ===== */
.source-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  animation: fadeSlideUp 0.5s ease;
}

.source-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.source-header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
}

.btn-remove {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  transition: var(--transition);
}

.btn-remove:hover { background: rgba(255, 82, 82, 0.12); }

.source-preview {
  position: relative;
  padding: 14px;
}

.source-preview img {
  width: 100%;
  border-radius: var(--radius-sm);
  display: block;
}

.grid-overlay {
  position: absolute;
  inset: 14px;
  border-radius: var(--radius-sm);
  pointer-events: none;
  overflow: hidden;
}

.grid-overlay .grid-line-h,
.grid-overlay .grid-line-v {
  position: absolute;
  background: rgba(0, 212, 255, 0.35);
}

.grid-overlay .grid-line-h {
  left: 0; right: 0;
  height: 1px;
}

.grid-overlay .grid-line-v {
  top: 0; bottom: 0;
  width: 1px;
}

.source-info {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.source-info strong {
  color: var(--accent);
  font-weight: 600;
}

/* ===== GRID OPTIONS ===== */
.grid-options {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.grid-options h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.grid-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.grid-btn {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}

.grid-btn:hover { border-color: var(--accent); color: var(--accent); }

.grid-btn.active {
  background: rgba(0, 212, 255, 0.1);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--shadow-glow);
}

/* ===== RESULTS SECTION ===== */
.results-section {
  min-height: 400px;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.results-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

.results-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.btn-enhance-all {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  background: linear-gradient(135deg, var(--accent), #0090b0);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
  box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3);
}

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

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

/* ===== SPLIT GRID ===== */
.split-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
  animation: fadeSlideUp 0.5s ease both;
}

.panel-card:nth-child(1) { animation-delay: 0.05s; }
.panel-card:nth-child(2) { animation-delay: 0.1s; }
.panel-card:nth-child(3) { animation-delay: 0.15s; }
.panel-card:nth-child(4) { animation-delay: 0.2s; }
.panel-card:nth-child(5) { animation-delay: 0.25s; }
.panel-card:nth-child(6) { animation-delay: 0.3s; }
.panel-card:nth-child(7) { animation-delay: 0.35s; }
.panel-card:nth-child(8) { animation-delay: 0.4s; }
.panel-card:nth-child(9) { animation-delay: 0.45s; }

.panel-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-3px);
  box-shadow: var(--shadow), var(--shadow-glow);
}

.panel-image-wrapper {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--bg-secondary);
}

.panel-number {
  position: absolute;
  top: 10px; left: 10px;
  background: var(--accent);
  color: #000;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-xs);
  z-index: 2;
}

.panel-enhanced-badge {
  position: absolute;
  top: 10px; right: 10px;
  background: rgba(0, 230, 118, 0.2);
  color: var(--success);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  z-index: 2;
  display: none;
}

.panel-enhanced-badge.show { display: block; }

.panel-image-wrapper img,
.panel-image-wrapper canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.panel-card:hover .panel-image-wrapper img,
.panel-card:hover .panel-image-wrapper canvas {
  transform: scale(1.05);
}

.panel-preview-btn {
  position: absolute;
  bottom: 10px; right: 10px;
  width: 34px; height: 34px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #fff;
  font-size: 14px;
  transition: var(--transition);
  z-index: 2;
}

.panel-preview-btn:hover {
  background: rgba(0, 212, 255, 0.3);
  border-color: var(--accent);
}

/* Panel Actions */
.panel-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

.btn-action {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 6px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}

.btn-action:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0, 212, 255, 0.06);
}

.btn-action.btn-download {
  flex: 0 0 38px;
  padding: 8px;
}

.btn-action.btn-prompt {
  background: rgba(123, 97, 255, 0.08);
  border-color: rgba(123, 97, 255, 0.2);
  color: var(--accent-secondary);
}

.btn-action.btn-prompt:hover {
  background: rgba(123, 97, 255, 0.15);
  border-color: var(--accent-secondary);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 500px;
  text-align: center;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 72px;
  margin-bottom: 18px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.88rem;
  max-width: 340px;
}

/* ===== MODAL / LIGHTBOX ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: none;
  place-items: center;
  animation: fadeIn 0.25s ease;
}

.modal-overlay.active { display: grid; }

.modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  animation: scaleIn 0.3s ease;
}

.modal-content img,
.modal-content canvas {
  max-width: 100%;
  max-height: 85vh;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: -12px; right: -12px;
  width: 36px; height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: var(--transition);
}

.modal-close:hover { background: var(--danger); border-color: var(--danger); }

/* ===== PROMPT MODAL ===== */
.prompt-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: none;
  place-items: center;
  animation: fadeIn 0.25s ease;
}

.prompt-modal.active { display: grid; }

.prompt-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 560px;
  max-width: 92vw;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: scaleIn 0.3s ease;
}

.prompt-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.prompt-panel-header h3 {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.prompt-panel-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}

.prompt-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
}

.prompt-card:hover {
  border-color: var(--accent-secondary);
  background: var(--bg-card-hover);
}

.prompt-card .prompt-type {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-secondary);
  margin-bottom: 8px;
}

.prompt-card .prompt-text {
  font-size: 0.88rem;
  color: var(--text-primary);
  line-height: 1.6;
}

.prompt-card .copy-btn {
  position: absolute;
  top: 12px; right: 12px;
  background: rgba(123, 97, 255, 0.12);
  border: 1px solid rgba(123, 97, 255, 0.2);
  color: var(--accent-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}

.prompt-card .copy-btn:hover {
  background: var(--accent-secondary);
  color: #fff;
}

.prompt-card .copy-btn.copied {
  background: var(--success);
  border-color: var(--success);
  color: #000;
}

/* ===== ENHANCE MODAL ===== */
.enhance-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: none;
  place-items: center;
}

.enhance-modal.active { display: grid; }

.enhance-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 480px;
  max-width: 92vw;
  animation: scaleIn 0.3s ease;
}

.enhance-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.enhance-panel-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.enhance-panel-body { padding: 22px; }

.enhance-slider-group {
  margin-bottom: 18px;
}

.enhance-slider-group label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.enhance-slider-group label span { color: var(--accent); font-weight: 600; }

input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(0, 212, 255, 0.15);
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.4);
}

.enhance-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.btn-apply {
  flex: 1;
  padding: 12px;
  background: linear-gradient(135deg, var(--accent), #0090b0);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}

.btn-apply:hover { box-shadow: 0 4px 20px rgba(0, 212, 255, 0.35); }

.btn-cancel {
  padding: 12px 20px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}

.btn-cancel:hover { border-color: var(--text-secondary); color: var(--text-primary); }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 12px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
  box-shadow: var(--shadow);
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

/* ===== LOADING ===== */
.loading-shimmer {
  background: linear-gradient(90deg, var(--bg-card) 25%, rgba(0, 212, 255, 0.06) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(0, 212, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
@keyframes fadeSlideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .main-layout {
    grid-template-columns: 280px 1fr;
    gap: 20px;
  }
  .split-grid { gap: 14px; }
}

@media (max-width: 768px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
  .header { padding: 12px 16px; }
  .app-container { padding: 16px; }
  .split-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .split-grid { grid-template-columns: 1fr; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 212, 255, 0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 212, 255, 0.35); }
