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

/* GLOBAL STYLES */
:root {
  /* Default Colors: Dark Slate Glassmorphism */
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #020617 100%);
  --panel-bg: rgba(15, 23, 42, 0.45);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-blur: 20px;
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.4);
  
  --secondary: #10b981;
  --secondary-hover: #059669;
  
  --text-primary: #f8fafc;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;
  
  --danger: #ef4444;
  --danger-hover: #dc2626;
  
  --shadow-sm: 0 2px 8px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 12px 24px -4px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 40px -8px rgba(0, 0, 0, 0.5);
  
  --border-radius-sm: 8px;
  --border-radius-md: 14px;
  --border-radius-lg: 24px;
  
  --font-sans: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* THEME PRESETS */
[data-theme="emerald"] {
  --bg-gradient: linear-gradient(135deg, #022c22 0%, #064e3b 50%, #020617 100%);
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-glow: rgba(16, 185, 129, 0.4);
}

[data-theme="ocean"] {
  --bg-gradient: linear-gradient(135deg, #0c4a6e 0%, #0f172a 50%, #020617 100%);
  --primary: #0ea5e9;
  --primary-hover: #0284c7;
  --primary-glow: rgba(14, 165, 233, 0.4);
}

[data-theme="crimson"] {
  --bg-gradient: linear-gradient(135deg, #450a0a 0%, #1e1b4b 50%, #020617 100%);
  --primary: #f43f5e;
  --primary-hover: #e11d48;
  --primary-glow: rgba(244, 63, 94, 0.4);
}

[data-theme="purple"] {
  --bg-gradient: linear-gradient(135deg, #3b0764 0%, #0f172a 50%, #020617 100%);
  --primary: #a855f7;
  --primary-hover: #9333ea;
  --primary-glow: rgba(168, 85, 247, 0.4);
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* APP CONTAINER */
.generator-app {
  display: grid;
  grid-template-columns: 350px 1fr;
  min-height: 100vh;
  position: relative;
}

/* SIDEBAR CONFIGURATOR */
.config-sidebar {
  background: var(--panel-bg);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border-right: 1px solid var(--panel-border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100vh;
  overflow-y: auto;
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.brand-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 1.2rem;
  box-shadow: 0 0 15px var(--primary-glow);
}

.brand-title h1 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand-title span {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
}

/* MAIN PREVIEW AREA */
.main-viewport {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100vh;
  overflow-y: auto;
}

.viewport-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.viewport-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.25);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.viewport-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  font-family: var(--font-sans);
  transition: all var(--transition-fast);
}

.viewport-tab.active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

/* CONFIG ACCORDIONS */
.config-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.config-section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.config-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--border-radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* FORM ELEMENTS */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
}

.form-field input[type="text"],
.form-field select,
.form-field textarea {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: var(--border-radius-sm);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: all var(--transition-fast);
  outline: none;
}

.form-field input[type="text"]:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 8px var(--primary-glow);
}

.form-field textarea {
  resize: vertical;
  min-height: 80px;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: var(--border-radius-sm);
  font-size: 0.9rem;
  font-weight: 550;
  cursor: pointer;
  border: none;
  font-family: var(--font-sans);
  transition: all var(--transition-normal);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

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

.btn-success {
  background: var(--secondary);
  color: #fff;
}

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

.btn-block {
  width: 100%;
}

/* THEME CHIP SELECTION */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.theme-chip {
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.theme-chip.active {
  border-color: #fff;
  transform: scale(1.05);
}

.theme-chip-indigo { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.theme-chip-emerald { background: linear-gradient(135deg, #10b981, #059669); }
.theme-chip-ocean { background: linear-gradient(135deg, #0ea5e9, #0284c7); }
.theme-chip-purple { background: linear-gradient(135deg, #a855f7, #9333ea); }

/* CODE BOX */
.code-container {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--border-radius-md);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  overflow-x: auto;
  position: relative;
  max-height: 450px;
}

.code-container pre {
  margin: 0;
  color: #e2e8f0;
}

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

/* PREVIEW WORKSPACE */
.preview-window {
  flex: 1;
  background: var(--bg-gradient);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.preview-bar {
  background: rgba(0, 0, 0, 0.4);
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.dot-red { background: #ef4444; }
.dot-yellow { background: #f59e0b; }
.dot-green { background: #10b981; }

.preview-address-bar {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  padding: 4px 12px;
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.05);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.preview-body-container {
  flex: 1;
  position: relative;
  height: calc(100% - 37px);
}

.preview-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
}

/* DYNAMIC CONFIG FOR SHEETS */
.sheet-config-item {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.sheet-config-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

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

.sheet-config-title {
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  user-select: none;
}

.checkbox-row input {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
}

/* RESPONSIVE DESIGN */
@media (max-width: 1024px) {
  .generator-app {
    grid-template-columns: 1fr;
  }
  .config-sidebar {
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--panel-border);
  }
  .main-viewport {
    height: auto;
  }
  .preview-window {
    height: 600px;
  }
}

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

.toast {
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 250px;
}

.toast-success {
  border-left: 4px solid var(--secondary);
}

.toast-error {
  border-left: 4px solid var(--danger);
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
