/**
 * Button Generator — UI Stylesheet
 * CertifID EMD Tools
 *
 * Sections:
 *   1. Design Tokens
 *   2. Reset & Base
 *   3. Control Panel (Sidebar)
 *   4. Panel Header & Scrollable
 *   5. Sections & Form Fields
 *   6. Color Picker
 *   7. Radio Groups (Ghost Glow)
 *   8. Custom Select (Icon Dropdown)
 *   9. Action Footer & Primary Button
 *  10. Main Content & Preview Area
 *  11. Browser Mockup
 *  12. Code Panel
 *  13. Toast Notification
 *  14. Demo Button (Preview)
 *  15. Responsive — Tablet (≤1024px)
 *  16. Responsive — Mobile (≤480px)
 */


/* ──────────────────────────────────────────────
   1. Design Tokens
   ────────────────────────────────────────────── */

:root {
  /* Brand HSL base */
  --brand-h: 216;
  --brand-s: 79%;
  --brand-l: 48%;

  /* Semantic colors */
  --c-primary:       hsl(var(--brand-h), var(--brand-s), var(--brand-l));
  --c-primary-hover: hsl(var(--brand-h), var(--brand-s), 40%);
  --c-primary-light: hsl(var(--brand-h), 50%, 72%);
  --c-primary-wash:  hsl(var(--brand-h), 50%, 96%);

  /* Reusable interaction colors */
  --c-focus-border:  hsl(var(--brand-h), 50%, 82%);
  --c-focus-ring:    hsl(var(--brand-h), var(--brand-s), 94%);
  --c-focus-ring-sm: hsl(var(--brand-h), var(--brand-s), 92%);

  /* Text hierarchy */
  --t-dark:   hsl(var(--brand-h), 28%, 16%);
  --t-medium: hsl(var(--brand-h), 7%, 34%);
  --t-light:  hsl(var(--brand-h), 7%, 46%);

  /* Surfaces & borders */
  --s-white:  #ffffff;
  --s-light:  hsl(var(--brand-h), 12%, 97%);
  --s-border: hsl(var(--brand-h), 10%, 91%);

  /* Toast (success) */
  --toast-bg:     hsl(145, 55%, 93%);
  --toast-text:   hsl(145, 50%, 30%);
  --toast-border: hsl(145, 40%, 82%);
  --toast-icon:   hsl(145, 50%, 36%);

  /* Code syntax highlighting */
  --hl-tag:  hsl(var(--brand-h), 10%, 55%);
  --hl-attr: hsl(var(--brand-h), 12%, 42%);
  --hl-val:  hsl(var(--brand-h), 18%, 32%);

  /* Typography */
  --font-heading: 'Thicccboi', system-ui, sans-serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'SF Mono', 'Fira Code', monospace;

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;

  /* Spacing (panel) */
  --panel-w:   360px;
  --panel-pad: 32px;

  /* Shadows */
  --shadow-panel:   8px 0 25px rgba(0, 0, 0, 0.05);
  --shadow-card:    0 8px 32px rgba(0, 0, 0, 0.06);
  --shadow-code:    0 4px 20px rgba(0, 0, 0, 0.06);
  --shadow-dropdown: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-toast:   0 4px 16px rgba(0, 0, 0, 0.08);

  /* Transitions */
  --ease-fast: 0.15s ease;
  --ease-base: 0.2s ease;

  /* Preview widths */
  --preview-w: 580px;
}


/* ──────────────────────────────────────────────
   2. Reset & Base
   ────────────────────────────────────────────── */

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

body {
  font-family: var(--font-body);
  background: var(--s-white);
  min-height: 100vh;
  display: flex;
  overflow: hidden;
}


/* ──────────────────────────────────────────────
   3. Control Panel (Sidebar)
   ────────────────────────────────────────────── */

.control-panel {
  width: var(--panel-w);
  height: 100vh;
  background: var(--s-white);
  border-right: 1px solid var(--s-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-panel);
}


/* ──────────────────────────────────────────────
   4. Panel Header & Scrollable
   ────────────────────────────────────────────── */

.panel-header {
  padding: 36px var(--panel-pad) var(--panel-pad);
  border-bottom: 1px solid var(--s-border);
  animation: builderSlideDown 0.12s ease-out;
  animation-fill-mode: backwards;
}

.panel-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
  color: var(--c-primary);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.panel-back-link:hover {
  color: var(--c-primary-hover);
}

.logo-mark {
  width: 32px;
  height: 32px;
  margin-bottom: 16px;
}

.logo-mark img {
  width: 100%;
  height: 100%;
}

.panel-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--t-dark);
  margin-bottom: 4px;
}

.panel-subtitle {
  font-size: 13px;
  color: var(--t-light);
  font-weight: 400;
  letter-spacing: -0.01em;
}

.panel-aux-links {
  margin-top: 14px;
}

.panel-aux-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--t-medium);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
}

.panel-aux-link:hover {
  color: var(--c-primary);
}

.panel-scrollable {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.panel-scrollable::-webkit-scrollbar {
  display: none;
}

.panel-content {
  padding: 0 var(--panel-pad) var(--panel-pad);
}


/* ──────────────────────────────────────────────
   5. Sections & Form Fields
   ────────────────────────────────────────────── */

.section {
  padding: 24px 0;
  border-bottom: 1px solid var(--s-border);
  animation: builderSlideDown 0.22s ease-out;
  animation-fill-mode: backwards;
}

.section:last-child {
  border-bottom: none;
}

.section:nth-child(1) { animation-delay: 0.10s; }
.section:nth-child(2) { animation-delay: 0.15s; }
.section:nth-child(3) { animation-delay: 0.20s; }
.section:nth-child(4) { animation-delay: 0.25s; }

.section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--t-light);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}

.form-field {
  margin-bottom: 16px;
}

.form-field:last-child {
  margin-bottom: 0;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--t-medium);
  margin-bottom: 8px;
}

.field-hint {
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--t-light);
}

.field-hint code {
  font-family: var(--font-mono);
  font-size: 11px;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--s-border);
  border-radius: var(--r-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--s-white);
  transition: border-color var(--ease-base), box-shadow var(--ease-base);
}

.form-input:hover {
  border-color: var(--c-primary-light);
}

.form-input:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-focus-ring-sm);
}

.form-input--mono {
  font-family: var(--font-mono);
  font-size: 13px;
}


/* ──────────────────────────────────────────────
   6. Color Picker
   ────────────────────────────────────────────── */

.color-input-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.color-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--s-border);
  border-radius: var(--r-sm);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all var(--ease-fast);
  flex-shrink: 0;
}

.color-button:hover {
  border-color: var(--c-primary);
  transform: scale(1.05);
}

.color-picker-input {
  position: absolute;
  width: 200%;
  height: 200%;
  top: -50%;
  left: -50%;
  cursor: pointer;
  border: none;
}


/* ──────────────────────────────────────────────
   7. Radio Groups (Ghost Glow)
   ────────────────────────────────────────────── */

.radio-group {
  display: flex;
  gap: 8px;
}

.radio-option {
  flex: 1;
  position: relative;
}

.radio-option input[type="radio"] {
  position: absolute;
  opacity: 0;
}

.radio-label {
  display: block;
  padding: 10px 8px;
  border: 1px solid var(--s-border);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  color: var(--t-medium);
  transition: border-color var(--ease-base), color var(--ease-base), box-shadow var(--ease-base);
}

.radio-option input[type="radio"]:checked + .radio-label {
  border-color: var(--c-focus-border);
  color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-focus-ring);
}

.radio-label:hover {
  border-color: var(--c-focus-border);
}

/* Radius visual previews */
.radius-preview-shape {
  width: 24px;
  height: 14px;
  background: var(--c-primary);
  margin: 0 auto 4px;
}

.radius-preview-shape.square  { border-radius: 0; }
.radius-preview-shape.rounded { border-radius: 4px; }
.radius-preview-shape.pill    { border-radius: 7px; }


/* ──────────────────────────────────────────────
   8. Custom Select (Icon Dropdown)
   ────────────────────────────────────────────── */

.custom-select {
  position: relative;
}

.custom-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--s-border);
  border-radius: var(--r-sm);
  background: var(--s-white);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--t-dark);
  cursor: pointer;
  transition: border-color var(--ease-base), box-shadow var(--ease-base);
}

.custom-select-trigger:hover {
  border-color: var(--c-focus-border);
}

.custom-select.open .custom-select-trigger {
  border-color: var(--c-focus-border);
  box-shadow: 0 0 0 3px var(--c-focus-ring);
}

.custom-select-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--c-primary-wash);
  color: var(--c-primary);
  font-size: 14px;
  flex-shrink: 0;
}

.custom-select-text {
  flex: 1;
  text-align: left;
}

.custom-select-arrow {
  font-size: 16px;
  color: var(--t-light);
  transition: transform var(--ease-base);
}

.custom-select.open .custom-select-arrow {
  transform: rotate(180deg);
}

.custom-select-options {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--s-white);
  border: 1px solid var(--s-border);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-dropdown);
  z-index: 200;
  padding: 4px;
  max-height: 280px;
  overflow-y: auto;
}

.custom-select-options::-webkit-scrollbar { width: 6px; }
.custom-select-options::-webkit-scrollbar-track { background: transparent; }
.custom-select-options::-webkit-scrollbar-thumb { background: var(--s-border); border-radius: 3px; }

.custom-select.open .custom-select-options {
  display: block;
}

.custom-select-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--t-medium);
  transition: background 0.12s;
}

.custom-select-option i:first-child {
  font-size: 16px;
  color: var(--t-light);
  width: 20px;
  text-align: center;
}

.custom-select-option span {
  flex: 1;
  text-align: left;
}

.custom-select-check {
  font-size: 16px;
  color: var(--c-primary);
  opacity: 0;
}

.custom-select-option.selected .custom-select-check {
  opacity: 1;
}

.custom-select-option.selected {
  color: var(--c-primary);
  background: var(--c-primary-wash);
}

.custom-select-option.selected i:first-child {
  color: var(--c-primary);
}

.custom-select-option:hover:not(.selected) {
  background: var(--s-light);
}


/* ──────────────────────────────────────────────
   9. Action Footer & Primary Button
   ────────────────────────────────────────────── */

.action-footer {
  padding: var(--panel-pad);
  border-top: 1px solid var(--s-border);
  flex-shrink: 0;
  animation: builderSlideDown 0.3s ease-out;
  animation-delay: 0.18s;
  animation-fill-mode: backwards;
}

.primary-button {
  width: 100%;
  padding: 13px 24px;
  background: var(--c-primary);
  color: white;
  border: none;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--ease-base), transform var(--ease-fast), box-shadow var(--ease-base);
}

.primary-button:hover {
  background: var(--c-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px hsl(var(--brand-h), var(--brand-s), 70%, 0.3);
}

.primary-button i {
  font-size: 18px;
}


/* ──────────────────────────────────────────────
   10. Main Content & Preview Area
   ────────────────────────────────────────────── */

.main-content {
  flex: 1;
  margin-left: var(--panel-w);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.preview-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--s-light);
  padding: 40px;
  animation: builderSlideDown 0.5s ease-out;
  animation-fill-mode: backwards;
}

.preview-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: var(--preview-w);
}

@keyframes builderSlideDown {
  0%   { opacity: 0; transform: translateY(-10px); }
  100% { opacity: 1; transform: translateY(0); }
}


/* ──────────────────────────────────────────────
   11. Browser Mockup
   ────────────────────────────────────────────── */

.browser-mockup {
  width: 100%;
  background: var(--s-white);
  border: 1px solid var(--s-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.browser-bar {
  height: 36px;
  background: var(--s-light);
  border-bottom: 1px solid var(--s-border);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 8px;
}

.browser-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--s-border);
}

.browser-url {
  flex: 1;
  margin-left: 8px;
  height: 22px;
  background: var(--s-white);
  border-radius: 4px;
  border: 1px solid var(--s-border);
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 11px;
  color: var(--t-light);
}

.browser-body {
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}


/* ──────────────────────────────────────────────
   12. Code Panel
   ────────────────────────────────────────────── */

.code-floating {
  width: 100%;
  background: var(--s-white);
  border: 1px solid var(--s-border);
  border-radius: var(--r-md);
  padding: 20px 24px;
  box-shadow: var(--shadow-code);
}

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

.code-floating-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--t-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.code-floating-title i {
  font-size: 15px;
}

.code-text-wrapper {
  position: relative;
  overflow: hidden;
}

.code-text-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 60px;
  pointer-events: none;
  background: linear-gradient(to right, transparent, var(--s-white));
}

.code-text {
  color: var(--t-dark);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  overflow: hidden;
  white-space: pre;
}

.code-text .hl-tag  { color: var(--hl-tag); }
.code-text .hl-attr { color: var(--hl-attr); }
.code-text .hl-val  { color: var(--hl-val); }

.copy-btn {
  padding: 5px 12px;
  border: 1px solid var(--s-border);
  border-radius: 6px;
  background: var(--s-light);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  color: var(--t-medium);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all var(--ease-fast);
}

.copy-btn:hover {
  border-color: var(--c-primary);
  color: var(--c-primary);
}


/* ──────────────────────────────────────────────
   13. Toast Notification
   ────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--toast-bg);
  color: var(--toast-text);
  padding: 12px 20px;
  border-radius: var(--r-sm);
  border: 1px solid var(--toast-border);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-toast);
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 9999;
}

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

.toast i {
  font-size: 17px;
  color: var(--toast-icon);
}


/* ──────────────────────────────────────────────
   14. Demo Button (Preview)
   ────────────────────────────────────────────── */

.demo-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 500;
  border: none;
  cursor: pointer;
  color: white;
  text-decoration: none;
  transition: all var(--ease-fast);
}

.demo-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.demo-button.size-medium { padding: 12px 24px; font-size: 15px; }
.demo-button.size-large  { padding: 16px 32px; font-size: 17px; }
.demo-button.size-xlarge { padding: 20px 40px; font-size: 19px; }
.demo-button i { font-size: 1.2em; }


/* ──────────────────────────────────────────────
   15. Responsive — Tablet (≤1024px)
   ────────────────────────────────────────────── */

@media (max-width: 1024px) {
  :root {
    --panel-w: 300px;
    --panel-pad: 24px;
    --preview-w: 100%;
  }

  .panel-header {
    padding: 28px var(--panel-pad) 24px;
  }

  .preview-area {
    padding: 24px;
  }

  .browser-body {
    min-height: 180px;
    padding: 32px 20px;
  }

  .code-floating {
    padding: 16px 20px;
  }
}


/* ──────────────────────────────────────────────
   16. Responsive — Mobile (≤480px)
   ────────────────────────────────────────────── */

@media (max-width: 480px) {
  body {
    flex-direction: column;
    overflow: auto;
  }

  .control-panel {
    position: relative;
    width: 100%;
    height: auto;
    max-height: none;
    box-shadow: none;
    border-right: none;
    border-bottom: 1px solid var(--s-border);
  }

  .panel-scrollable {
    overflow-y: visible;
  }

  .main-content {
    margin-left: 0;
    height: auto;
    min-height: 60vh;
  }

  .preview-area {
    padding: 20px 16px;
  }

  .browser-body {
    min-height: 140px;
    padding: 24px 16px;
  }

  .demo-button.size-xlarge {
    padding: 16px 28px;
    font-size: 17px;
  }

  .code-floating {
    padding: 14px 16px;
  }

  .action-footer {
    padding: 20px var(--panel-pad);
  }

  .toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    justify-content: center;
  }
}
