@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Outfit:wght@700;900&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ==========================================================================
   Design Tokens & Themes
   ========================================================================== */
:root {
  /* Default: Dark Theme */
  --bg: #10121a;
  --panel: #171a26;
  --panel-2: #1d2133;
  --border: #2a2f45;
  --text: #d9dbe8;
  --muted: #8b8fa3;
  
  --mono: 'JetBrains Mono', 'Fira Code', ui-monospace, 'SFMono-Regular', Consolas, monospace;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  
  --accent: #5eead4;
  --accent-dim: #2f4a47;
  --err: #f87171;
  --warn: #fbbf24;
  --success: #34d399;
}

body.light-theme {
  /* Light Theme Overrides */
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-2: #f1f5f9;
  --border: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  
  --accent: #0ea5e9;
  --accent-dim: #e0f2fe;
  --err: #ef4444;
  --warn: #f59e0b;
  --success: #10b981;
}

/* ==========================================================================
   Base Styles & Resets
   ========================================================================== */
* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden;
  transition: background 0.15s, color 0.15s;
}

/* ==========================================================================
   Header & Logo Brand Styling
   ========================================================================== */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.logo-img {
  height: 24px;
  width: auto;
  display: block;
}

.logo-text-wrapper {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
}

.logo-title {
  font-family: 'Outfit', var(--sans);
  font-weight: 900;
  font-size: 14px;
  line-height: 0.9;
  color: var(--text);
  letter-spacing: -0.01em;
  transition: color 0.15s;
}

.logo-highlight {
  background: linear-gradient(90deg, #3b82f6, #818cf8, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: #818cf8;
}

.logo-subtext {
  font-family: 'Outfit', var(--sans);
  font-size: 4px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.17em;
  margin-top: 2px;
  text-transform: uppercase;
  line-height: 1;
}

.logo-divider {
  color: var(--border);
  font-weight: 300;
  font-size: 18px;
  user-select: none;
  transition: color 0.15s;
}

.tool-title {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  letter-spacing: 0.02em;
  transition: color 0.15s;
}

/* ==========================================================================
   Toolbar Component
   ========================================================================== */
.toolbar {
  display: flex;
  gap: 8px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  align-items: center;
  transition: background 0.15s, border-color 0.15s;
}

button, select {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button.primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

button.primary:hover {
  background: var(--accent);
  color: var(--bg);
}

.spacer {
  flex: 1;
}

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

/* Icon visibility overrides for themes */
body.light-theme .sun-icon { display: none !important; }
body.light-theme .moon-icon { display: block !important; }
body:not(.light-theme) .sun-icon { display: block !important; }
body:not(.light-theme) .moon-icon { display: none !important; }

/* ==========================================================================
   Main Grid Layout
   ========================================================================== */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  min-height: 0;
  transition: background 0.15s;
}

@media (max-width: 860px) {
  main {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
}

/* ==========================================================================
   Editor Panels & Fallbacks
   ========================================================================== */
.pane {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  transition: background 0.15s;
}

.pane-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  user-select: none;
  transition: border-color 0.15s, color 0.15s;
}

.editor-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

textarea {
  flex: 1;
  background: transparent;
  color: var(--text);
  border: none;
  resize: none;
  padding: 16px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  outline: none;
  transition: color 0.15s;
}

.monaco-container {
  flex: 1;
  width: 100%;
  height: 100%;
}

/* ==========================================================================
   Loading Skeleton & Spinners
   ========================================================================== */
.editor-loader {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 5;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  gap: 12px;
  user-select: none;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ==========================================================================
   Footer Status Bar
   ========================================================================== */
footer {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 20px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
}

.status {
  display: flex;
  align-items: center;
  gap: 7px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.15s, box-shadow 0.15s;
}

.dot.ok {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.dot.bad {
  background: var(--err);
  box-shadow: 0 0 6px var(--err);
}

.status-text.ok {
  color: var(--success);
}

.status-text.bad {
  color: var(--err);
}

/* ==========================================================================
   Toast Notification Popups
   ========================================================================== */
.toast {
  position: fixed;
  bottom: 48px;
  right: 20px;
  background: var(--panel-2);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 8px 14px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s, background 0.15s, border-color 0.15s, color 0.15s;
  pointer-events: none;
  z-index: 99;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   Drag and Drop Hover States
   ========================================================================== */
.pane.drag-over::after {
  content: 'Drop your CSS file here';
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  bottom: 10px;
  border: 2px dashed var(--accent);
  border-radius: 8px;
  background: rgba(94, 234, 212, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 14px;
  z-index: 10;
  pointer-events: none;
}

body.light-theme .pane.drag-over::after {
  background: rgba(14, 165, 233, 0.05);
}

/* ==========================================================================
   Tool Switcher Selector Styles
   ========================================================================== */
.tool-selector-container {
  position: relative;
  display: inline-block;
}

.tool-selector-btn {
  background: transparent;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 4px;
  transition: background 0.15s;
}

.tool-selector-btn:hover {
  background: var(--panel-2);
}

.tool-selector-btn .tool-title {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  letter-spacing: 0.02em;
}

.tool-selector-btn .chevron-icon {
  color: var(--muted);
  transition: transform 0.2s ease;
}

.tool-selector-container.open .chevron-icon {
  transform: rotate(180deg);
}

.tool-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
  z-index: 100;
  width: 290px;
  padding: 6px;
  flex-direction: column;
  gap: 2px;
}

.tool-dropdown-menu.show {
  display: flex;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s, color 0.15s;
}

.dropdown-item:hover {
  background: var(--panel-2);
}

.dropdown-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  pointer-events: none;
}

.dropdown-item.coming-soon {
  opacity: 0.55;
  cursor: not-allowed;
}

.item-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--panel-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--muted);
  flex-shrink: 0;
}

.font-code {
  font-family: var(--mono);
}

.dropdown-item.active .item-icon {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(94, 234, 212, 0.05);
}

body.light-theme .dropdown-item.active .item-icon {
  background: rgba(14, 165, 233, 0.05);
}

.item-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.item-name {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
}

.item-desc {
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.3;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   Auto-Process Toolbar Toggle
   ========================================================================== */
.toolbar-checkbox-label {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  padding: 6px 10px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.toolbar-checkbox-label:hover {
  background: var(--panel-2);
  color: var(--text);
}

.toolbar-checkbox-label input {
  cursor: pointer;
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  margin: 0;
}
