/* Page Specific Overrides */
body {
  background: var(--bg-base);
  overflow-x: hidden;
}

/* Subtle warm ambient background glows */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 10% 20%, rgba(200, 145, 42, 0.04) 0%, transparent 50%),
    radial-gradient(circle at 90% 80%, rgba(200, 145, 42, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.app-body {
  position: relative;
  z-index: 1;
  min-height: calc(100vh - 72px);
}

.left-panel {
  height: calc(100vh - 72px);
  z-index: 5;
}
/*  Hide the "Find Utility" search panel —
    four items don't need a search box */
.left-panel .panel-section:first-child {
  display: block;
}

/* Toolbox Navigation Item Styles */
.toolbox-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.toolbox-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  background: rgba(22, 20, 16, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.toolbox-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--da-accent);
  opacity: 0;
  transition: opacity 0.2s;
}

.toolbox-item:hover:not(.disabled) {
  background: var(--bg-raised);
  border-color: var(--da-accent-dim);
  transform: translateX(3px);
}

.toolbox-item.active {
  background: var(--bg-raised);
  border-color: var(--da-accent-dim);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.toolbox-item.active::before {
  opacity: 1;
}

.toolbox-item.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.toolbox-icon {
  font-size: 1.35rem;
  flex-shrink: 0;
  filter: saturate(0.85);
}

.toolbox-item:hover .toolbox-icon {
  filter: saturate(1.1);
}

.toolbox-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.toolbox-name {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.15rem;
}

.toolbox-item.active .toolbox-name {
  color: var(--da-accent);
}

.toolbox-desc {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

/* Main Workspace & Form Grid */
.toolbox-workspace {
  padding: 2rem;
  flex: 1;
  max-width: 1200px;
}

.tool-content {
  display: none;
  animation: fadeUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.tool-content.active {
  display: block;
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.75rem;
  align-items: start;
}


/* Panel Cards */
.panel-card {
  background: rgba(22, 20, 16, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(200, 145, 42, 0.15);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
  transition: border-color 0.3s;
}

.panel-card:hover {
  border-color: rgba(200, 145, 42, 0.25);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(30, 27, 22, 0.85);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.card-header .output-copy-btn {
  font-size: 0.65rem;
}

.card-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--da-accent);
  font-weight: bold;
}

.card-body {
  padding: 1.5rem;
}

/* Input Elements */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 1.25rem;
}

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

.form-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.form-input,
.form-select {
  width: 100%;
  background: rgba(14, 13, 11, 0.8);
  border: 1px solid var(--border-mid);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: 0.75rem;
  padding: 0.55rem 0.75rem;
  outline: none;
  box-sizing: border-box;
  transition: all 0.2s;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--da-accent);
  box-shadow: 0 0 0 2px var(--da-accent-glow);
}

.custom-override {
  border-style: dashed;
  font-size: 0.8rem;
  padding: 0.4rem 0.65rem;
  background: rgba(22, 20, 16, 0.4);
}

.custom-override:focus {
  border-style: solid;
}

.field-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.15rem;
  line-height: 1.3;
}

/* Live Preview Box & SVG Layout Styles */
.preview-canvas {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  background: #0d0b09;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.preview-bg-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  transition: all 0.3s ease;
}

/* Actions & Test Bench */
.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* Search bar overrides */
.search-input:focus {
  border-color: var(--da-accent);
}

#toolSearch {
  box-sizing: border-box;
}

/* Help button and modal */
#openHelpModalButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-overlay, #26221b);
  color: var(--da-accent, #c8912a);
  border: 1px solid var(--border-mid, #3a3428);
  cursor: pointer;
  vertical-align: middle;
  margin-left: 12px;
  transition: all 0.2s ease;
}

#openHelpModalButton:hover {
  background: var(--da-accent);
  color: var(--bg-base);
  border-color: var(--da-accent);
}
.version-info {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.9rem;
}

/* Smooth styles for active toast and status elements */
.copy-feedback {
  opacity: 0;
  transition: opacity 0.3s ease;
  color: #6aaf88;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}
.copy-feedback.show {
  opacity: 1;
}

/* ─────────────────────────────────────────────
Mobile Layout Restructure  1024px
───────────────────────────────────────────── */
@media (max-width: 1024px) {
  .tool-grid {
    grid-template-columns: 1fr;
  }
}

/* ─────────────────────────────────────────────
Mobile Layout Restructure  ≤ 768px
───────────────────────────────────────────── */
@media (max-width: 768px) {

  /* 1. Stack sidebar above workspace instead of side-by-side */
  .app-body {
    display: flex;
    flex-direction: column;
  }

  /* 2. Sidebar becomes a compact horizontal tab strip */
  .left-panel {
    height: auto;
    min-height: 0;
    width: 100%;
    /* full width of the column — correct for a strip */
    max-width: 100%;
    /* prevent any overflow */
    box-sizing: border-box;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    overflow: hidden;
    /* clip; inner .toolbox-list handles its own scroll */
    flex-shrink: 0;
    padding: 0;
    /* strip any panel padding so the list fills edge-to-edge */
  }


  /* 4. Kill the flex:1 / overflow-y:auto on the list panel-section
    (those are inline styles; we override via the container) */
  .left-panel .panel-section:last-child {
    flex: none !important;
    overflow: visible !important;
    padding: 0.5rem 0.75rem;
    border-bottom: none;
  }

  /* 5. Toolbox list → horizontal scrollable row */
  .toolbox-list {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 0.5rem;
    padding-bottom: 0.25rem;
    /* room for scrollbar on iOS */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Firefox */
  }

  .toolbox-list::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
  }

  /* 6. Each tab item: compact icon-only pill, no translateX hover */
  .toolbox-item {
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.6rem 0.85rem;
    min-width: 80px;
    white-space: nowrap;
    flex-shrink: 0;
    transform: none !important;
    /* suppress translateX hover shift */
  }

  /* 7. Show only the icon + short name; hide the description line */
  .toolbox-desc {
    display: none;
  }

  .toolbox-name {
    font-size: 0.6rem;
    letter-spacing: 0.05em;
    text-align: center;
    white-space: normal;
    /* allow wrapping inside the pill */
    line-height: 1.2;
  }

  /* 8. Active indicator: bottom bar instead of left bar */
  .toolbox-item::before {
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: auto;
    height: 3px;
  }

  /* 9. Workspace: full width, reduced padding */
  .toolbox-workspace {
    width: 100%;
    /* fill the column axis in flex-direction:column */
    box-sizing: border-box;
    padding: 1rem;
    max-width: 100%;
  }

  .card-body {
    padding: 1rem !important;
  }

  /* 10. tool-grid already collapses at 1024px; just tighten the gap */
  .tool-grid {
    gap: 1rem;
  }

  /* 11. Preview canvas: aspect-ratio instead of fixed min-height */
  .preview-canvas {
    min-height: unset;
    aspect-ratio: 16 / 7;
  }

  /* 12. Actions row: stack buttons full-width on very narrow screens */
  .actions-row {
    flex-direction: column;
  }

  .actions-row .btn {
    width: 100%;
    text-align: center;
  }

  /* 13. Prevent iOS zoom on input focus */
  .form-input,
  .form-select,
  .search-input,
  .output-text {
    font-size: 16px !important;
  }
  ::placeholder {
    font-size: 0.6rem;
  }

  #imageeditorTool .tool-grid {
    display: flex;
    flex-direction: column;
  }

  #imageeditorTool .control-panel {
    order: 1;
  }

  #imageeditorTool .preview-panel {
    order: 2;
  }

  #imageeditorTool #exportControlsPanel {
    order: 3;
    margin-top: 0 !important;
  }

  #sendToBuilderBtn,
  #copyOutputBtn,
  #formatLocallyBtn,
  #formatGeminiBtn,
  #copyTestResultBtn,
  #savePresetBtn {
    font-size: 0.6rem;
  }
  #presetSaveContainer,
  #presetListContainer {
    flex-direction: column;
    gap: 0.5rem;
  }

  /* 14. Presets list: let it expand naturally on mobile
     (no fixed max-height that fights the virtual keyboard) */
  #presetsListContainer {
    max-height: none;
  }
}
