/* ═══════════════════════════════════════════
   PIXELCRAFT — IMAGE EDITOR & RESIZER
   Zero-bloat Vanilla CSS Design System
   ═══════════════════════════════════════════ */

:root {
  /* Color Palette (Dark Slate/Indigo) */
  --bg-main: #030712;        /* slate-950 */
  --bg-surface: #090d16;     /* dark slate */
  --bg-card: #0f172a;        /* slate-900 */
  
  --border-color: #1e293b;   /* slate-800 */
  --border-focus: #4f46e5;   /* indigo-600 */
  
  --text-primary: #f8fafc;   /* slate-50 */
  --text-secondary: #94a3b8; /* slate-400 */
  --text-muted: #475569;     /* slate-600 */
  
  --accent-color: #6366f1;   /* indigo-500 */
  --accent-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.15);
  
  --success-color: #10b981;  /* emerald-500 */
  --success-hover: #059669;

  --family-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--family-sans);
  line-height: 1.5;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Background aesthetic glow */
.bg-glow {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 600px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.05) 0%, rgba(3, 7, 18, 0) 70%);
  z-index: -1;
  pointer-events: none;
}

/* Helper Utilities */
.hidden {
  display: none !important;
}

.flex { display: flex; }
.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.flex-1 { flex: 1; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.w-full { width: 100%; }

/* ═══════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════ */
/* ─── Persistent Micro Navbar ─── */
.navbar {
  border-bottom: 1px solid var(--border-color);
  background: rgba(3, 7, 18, 0.85);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  z-index: 50;
  position: sticky;
  top: 0;
  height: 48px;
  display: flex;
  align-items: center;
}

.navbar-container {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.brand-icon-wrapper {
  color: var(--accent-color);
  display: flex;
  align-items: center;
  transition: color 0.2s ease;
}

.brand-link:hover .brand-icon-wrapper {
  color: var(--accent-hover);
}

.brand-text {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  transition: color 0.2s ease;
}

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

.brand-link:hover .brand-text {
  color: #fff;
}

.tool-pill-wrapper {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.tool-pill-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .tool-pill-label {
    display: none;
  }
}

.tool-pill-nav {
  display: flex;
  align-items: center;
}

.tool-pill-active {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.25rem 0.625rem;
  border-radius: 0.375rem;
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent-color);
  border: 1px solid rgba(99, 102, 241, 0.2);
  text-decoration: none;
}

.right-cluster {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.portal-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s ease;
}

.portal-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.github-link {
  display: flex;
  align-items: center;
  padding: 0.375rem;
  border-radius: 0.375rem;
  color: var(--text-muted);
  transition: all 0.2s ease;
  text-decoration: none;
}

.github-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

/* ═══════════════════════════════════════════
   WORKSPACE (Fixed height split layout)
   ═══════════════════════════════════════════ */
.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
  position: relative;
}

/* ─── UPLOAD LANDING AREA ─── */
.upload-landing-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  gap: 2rem;
}

/* Landing Page Promo Slot */
.landing-promo {
  width: 100%;
  max-width: 728px;
  display: flex;
  justify-content: center;
}

.landing-promo .promo-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
}

.landing-promo .promo-text {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.landing-promo .promo-banner-container {
  width: 100%;
  height: 90px;
  background: rgba(255, 255, 255, 0.01);
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s ease;
}

.landing-promo .promo-banner-container:hover {
  border-color: rgba(99, 102, 241, 0.2);
}

.landing-promo .promo-placeholder {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.2);
}

@media (max-width: 768px) {
  .landing-promo .promo-banner-container {
    height: 60px;
  }
}


.upload-box {
  width: 100%;
  max-width: 580px;
  border: 2px dashed var(--border-color);
  background: var(--bg-surface);
  border-radius: 1.25rem;
  padding: 3.5rem 2.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.upload-box:hover, .upload-box.dragover {
  border-color: var(--accent-color);
  background: rgba(99, 102, 241, 0.02);
  transform: scale(1.01);
}

.upload-icon {
  width: 72px;
  height: 72px;
  border-radius: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-color);
  margin-bottom: 0.5rem;
}

.upload-box h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.upload-box p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.hidden-file-input {
  display: none;
}

/* ─── EDITOR INTERFACE ─── */
.editor-interface {
  display: flex;
  flex: 1;
  width: 100%;
  overflow: hidden;
}

/* ─── SIDEBAR ─── */
.sidebar {
  width: 320px;
  border-right: 1px solid var(--border-color);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  height: 100%;
}

.feature-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.2);
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-family: var(--family-sans);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.75rem 0.25rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}

.tab-btn.active {
  color: var(--accent-color);
  border-bottom-color: var(--accent-color);
  background: rgba(99, 102, 241, 0.04);
}

.sidebar-panels {
  padding: 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.panel {
  display: none;
  flex-direction: column;
  gap: 1.25rem;
}

.panel.active {
  display: flex;
}

.panel h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.panel-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Forms & Inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.65rem 0.85rem;
  border-radius: 0.5rem;
  font-family: var(--family-sans);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-input:focus {
  border-color: var(--border-focus);
}

.form-select {
  width: 100%;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.65rem 0.85rem;
  border-radius: 0.5rem;
  font-family: var(--family-sans);
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
}

.checkbox-label, .radio-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input, .radio-label input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-color);
  cursor: pointer;
}

/* Range Sliders */
.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-header output {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-color);
  font-family: monospace;
}

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

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-color);
  transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--family-sans);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-color);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  border-color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.02);
}

.btn-success {
  background: var(--success-color);
  color: white;
}

.btn-success:hover {
  background: var(--success-hover);
}

.btn-full {
  width: 100%;
}

/* ─── SPONSOR / PROMO SLOTS (ADBLOCK SAFE) ─── */
.sidebar-promo {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  padding: 1.25rem;
  background: rgba(0, 0, 0, 0.15);
}

.promo-inner {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.promo-text {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.promo-box-container {
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  height: 250px;
  background: rgba(255, 255, 255, 0.01);
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.promo-box-container:hover {
  border-color: rgba(99, 102, 241, 0.2);
}

.promo-placeholder {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.2);
  text-align: center;
}

/* ─── CENTER EDITOR VIEWPORT ─── */
.editor-viewport {
  flex: 1;
  background: #02040a;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  overflow: auto;
  position: relative;
}

.canvas-wrapper {
  position: relative;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  overflow: hidden;
}

#editor-canvas {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 180px);
  object-fit: contain;
  background-image: linear-gradient(45deg, #111 25%, transparent 25%), 
                    linear-gradient(-45deg, #111 25%, transparent 25%), 
                    linear-gradient(45deg, transparent 75%, #111 75%), 
                    linear-gradient(-45deg, transparent 75%, #111 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* Interactive Crop Box Overlay */
#crop-overlay {
  position: absolute;
  border: 2px dashed #ffffff;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.65);
  cursor: move;
  pointer-events: auto;
}

.crop-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--accent-color);
  border: 2px solid white;
  border-radius: 50%;
}

.crop-handle.nw { top: -6px; left: -6px; cursor: nwse-resize; }
.crop-handle.ne { top: -6px; right: -6px; cursor: nesw-resize; }
.crop-handle.sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.crop-handle.se { bottom: -6px; right: -6px; cursor: nwse-resize; }

.crop-grid-line {
  position: absolute;
  background: rgba(255, 255, 255, 0.3);
}

.crop-grid-line.h1 { top: 33.33%; left: 0; right: 0; height: 1px; }
.crop-grid-line.h2 { top: 66.66%; left: 0; right: 0; height: 1px; }
.crop-grid-line.v1 { left: 33.33%; top: 0; bottom: 0; width: 1px; }
.crop-grid-line.v2 { left: 66.66%; top: 0; bottom: 0; width: 1px; }


/* ═══════════════════════════════════════════
   METADATA BAR (BOTTOM)
   ═══════════════════════════════════════════ */
.metadata-bar {
  background: rgba(9, 13, 22, 0.95);
  border-top: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  padding: 0.75rem 0;
  z-index: 10;
}

.metadata-bar .container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
}

.stats-table {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.75rem;
}

.stats-row {
  display: grid;
  grid-template-columns: 80px 100px 90px 60px;
  color: var(--text-secondary);
}

.stats-row.header-row {
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.15rem;
}

.stats-row.highlight {
  color: var(--accent-color);
  font-weight: 600;
}

.stats-row .label {
  font-weight: 500;
}

/* Bottom Sponsor Banner Bar */
.bottom-sponsor-container {
  width: 100%;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 0.5rem 0;
  display: flex;
  justify-content: center;
}

.sponsor-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.sponsor-notice-text {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sponsor-banner-placeholder {
  width: 100%;
  max-width: 728px;
  height: 90px;
  background: rgba(255, 255, 255, 0.01);
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s ease;
}

.sponsor-banner-placeholder:hover {
  border-color: rgba(99, 102, 241, 0.2);
}

.sponsor-banner-placeholder span {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.2);
}


/* ═══════════════════════════════════════════
   RESPONSIVE DESIGN
   ═══════════════════════════════════════════ */
@media (max-width: 992px) {
  body {
    overflow-y: auto;
    height: auto;
  }
  
  .workspace {
    flex-direction: column;
    overflow: visible;
  }
  
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    overflow-y: visible;
    height: auto;
  }

  .editor-interface {
    flex-direction: column;
    overflow: visible;
  }

  .editor-viewport {
    height: 500px;
    overflow: auto;
  }

  .metadata-bar {
    position: sticky;
    bottom: 0;
  }

  .metadata-bar .container {
    flex-direction: column;
    align-items: flex-start;
  }

  .action-ctas {
    width: 100%;
    justify-content: flex-end;
    margin-top: 0.5rem;
  }

  .sponsor-banner-placeholder {
    width: 100%;
    max-width: 728px;
    height: 60px;
  }
}
