/* ==========================================================================
   BADGEWORKS - HANDCRAFTED DESIGN SYSTEM & STYLES
   ========================================================================== */

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

:root {
  /* Catppuccin Mocha surfaces */
  --bg-dark: #1e1e2e;            /* base */
  --bg-panel: #181825;           /* mantle */
  --bg-card: #313244;            /* surface0 */
  --bg-input: #11111b;           /* crust */
  --border-color: rgba(205, 214, 244, 0.13);
  --border-hover: rgba(205, 214, 244, 0.3);

  /* Catppuccin Mocha accents */
  --accent: #89b4fa;             /* blue */
  --accent-sapphire: #74c7ec;
  --accent-green: #a6e3a1;
  --accent-red: #f38ba8;

  --text-primary: #cdd6f4;       /* text */
  --text-secondary: #a6adc8;     /* subtext1 */
  --text-tertiary: #7f849c;      /* overlay1 */

  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 6px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  background-image:
    radial-gradient(circle at 50% -10%, rgba(137, 180, 250, 0.04) 0%, transparent 45%);
  background-attachment: fixed;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(24, 24, 37, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 1.5rem;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.brand-logo svg {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

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

/* Presets Bar */
.presets-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-input);
  padding: 3px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.presets-label {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-right: 4px;
  font-weight: 600;
}

.preset-pill {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.775rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-pill:hover {
  background: rgba(205, 214, 244, 0.07);
  color: var(--text-primary);
}

.action-btn {
  background: rgba(137, 180, 250, 0.12);
  border: 1px solid rgba(137, 180, 250, 0.28);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  font-size: 0.775rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.action-btn:hover {
  background: rgba(137, 180, 250, 0.2);
  border-color: var(--accent);
}

.presets-divider {
  color: var(--border-color);
  margin: 0 0.25rem;
}

/* Main Layout */
.app-main {
  max-width: 1400px;
  margin: 1.5rem auto;
  padding: 0 1.25rem;
}

.studio-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.5rem;
  align-items: start;
}

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

  .preview-panel {
    order: -1;
    position: sticky;
    top: 0.5rem;
    z-index: 100;
  }
}

/* Panels */
.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: sticky;
  top: 1.5rem;
  z-index: 10;
}

.panel-section {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

.section-title {
  font-size: 0.825rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

/* Style Option Cards */
.style-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.5rem;
}

.style-option {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-align: left;
  transition: all 0.15s ease;
}

.style-option:hover {
  border-color: var(--border-hover);
  background: rgba(205, 214, 244, 0.04);
}

.style-option.active {
  border-color: var(--accent);
  background: rgba(137, 180, 250, 0.1);
}

.style-option-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.style-title {
  font-size: 0.825rem;
  font-weight: 700;
  color: var(--text-primary);
}

.style-badge {
  font-size: 0.65rem;
  font-weight: 700;
  background: var(--bg-card);
  padding: 1px 4px;
  border-radius: 4px;
  color: var(--text-secondary);
}

.style-sub {
  font-size: 0.675rem;
  color: var(--text-tertiary);
}

/* Form Fields & Inputs */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.grid-3col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 600px) {
  .grid-2col, .grid-3col, .grid-4col {
    grid-template-columns: 1fr;
  }
}

.grid-4col {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.input-text {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  transition: all 0.15s ease;
}

.input-text:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(137, 180, 250, 0.15);
}

.textarea-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  min-height: 70px;
  resize: vertical;
}

/* Segmented Control Bar */
.segmented-control {
  display: flex;
  background: var(--bg-input);
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 0.5rem;
}

.seg-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

/* Dropzone for File Upload (PNG/SVG) */
.dropzone {
  border: 2px dashed var(--border-color);
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 1.25rem 1rem;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
  transition: all 0.15s ease;
}

.dropzone:hover {
  border-color: var(--accent);
  background: rgba(137, 180, 250, 0.04);
  color: var(--text-primary);
}

.upload-hint {
  font-size: 0.7rem;
  color: var(--text-tertiary);
}

.upload-preview-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  margin-top: 0.5rem;
}

.upload-thumb {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  object-fit: contain;
  background: #fff;
  padding: 2px;
}

.upload-filename {
  flex: 1;
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remove-upload-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
}

.remove-upload-btn:hover {
  color: var(--accent-red);
}

/* Color Picker Wrappers */
.color-picker-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 3px 8px 3px 3px;
}

.color-picker-wrap input[type="color"] {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.color-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.range-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  margin-top: 4px;
}

.slider-num {
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
  font-weight: 600;
}

.checkbox-field label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 1rem;
}

/* Stage & Preview Card */
.stage-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: sticky;
  top: 80px;
}

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

.stage-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
}

.dimension-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.725rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(137, 180, 250, 0.1);
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid rgba(137, 180, 250, 0.22);
}

.badge-stage {
  background: #11111b;
  border: 1px dashed rgba(205, 214, 244, 0.18);
  border-radius: var(--radius-md);
  padding: 3.5rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  background-image:
    linear-gradient(45deg, #181825 25%, transparent 25%),
    linear-gradient(-45deg, #181825 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #181825 75%),
    linear-gradient(-45deg, transparent 75%, #181825 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

/* Export Buttons */
.export-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.btn {
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.825rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
  border: none;
}

.btn-primary {
  background: var(--accent);
  color: #11111b;
}

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

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

.btn-secondary:hover {
  border-color: var(--border-hover);
  background: rgba(205, 214, 244, 0.06);
}

.btn-accent {
  background: var(--accent-green);
  color: #1e1e2e;
  width: 100%;
}

.btn-accent:hover {
  background: #8ee79c;
}

.btn-github {
  background: #313244;
  color: var(--text-primary);
  border: 1px solid #45475a;
  width: 100%;
}

.btn-github:hover {
  background: #45475a;
}

/* Code Output Card */
.code-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.code-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-input);
}

.code-tabs {
  display: flex;
  gap: 0.25rem;
}

.code-tab {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
}

.code-tab.active {
  background: rgba(205, 214, 244, 0.08);
  color: var(--accent);
}

.copy-code-btn {
  background: rgba(137, 180, 250, 0.12);
  border: 1px solid rgba(137, 180, 250, 0.28);
  color: var(--accent);
  padding: 0.25rem 0.65rem;
  border-radius: 4px;
  font-size: 0.725rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.copy-code-btn:hover {
  background: var(--accent);
  color: #11111b;
}

.code-display {
  padding: 1rem;
  background: var(--bg-input);
  overflow-x: auto;
}

.code-display pre {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.775rem;
  color: #a6adc8;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--accent-green);
  color: #1e1e2e;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.825rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Footer */
.app-footer {
  border-top: 1px solid var(--border-color);
  padding: 1.5rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

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

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

.app-footer .fa-github {
  margin-right: 0.25rem;
}
