:root {
  --primary-color: #333;
  --accent-color: #555;
  --text-color: #fff;
  --sidebar-bg: #f4f4f4;
  --button-bg: #e0e0e0;
  --button-active: #a0a0a0;
  --sidebar-width: 280px;
}

* {
  user-select: none;
  -webkit-user-select: none;
  /* Safari/Chrome */
  -moz-user-select: none;
  /* Firefox */
  -ms-user-select: none;
  /* Edge antiguo */
  -webkit-user-drag: none;
  user-drag: none;
}

img {
  -webkit-user-drag: none;
  user-drag: none;
  pointer-events: none;
}

body,
html {
  overflow-x: hidden;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

#app-container {
  overflow-x: hidden;
  display: flex;
  height: 100vh;
  width: 100%;
}

/* Sidebars */
.sidebar {
  background-color: var(--sidebar-bg);
  padding: clamp(8px, 1.2vh, 14px);
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1vh, 10px);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  z-index: 10;
  overflow-y: auto;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: #bbb transparent;
}

.sidebar::-webkit-scrollbar {
  width: 5px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background-color: #bbb;
  border-radius: 4px;
}

#right-sidebar {
  flex: 0 0 35%;
  max-width: 94%;
  min-width: 280px;
  /* evita colapsos raros */
}

/* Accordion Styles */
.config-accordion {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
}

.config-accordion summary {
  padding: clamp(8px, 1.2vh, 12px) clamp(10px, 1.5vw, 16px);
  font-size: clamp(0.88rem, 1.2vh, 1.05rem);
  font-weight: 600;
  color: #333;
  cursor: pointer;
  list-style: none;
  /* Hide default arrow */
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-transform: uppercase;
  letter-spacing: 1px;
  background-color: #f9f9f9;
  border-bottom: 1px solid transparent;
  transition: background-color 0.2s;
}

.config-accordion summary::-webkit-details-marker {
  display: none;
}

.config-accordion summary::after {
  content: '+';
  font-size: 1.3rem;
  font-weight: 300;
  color: #666;
  transition: transform 0.3s;
}

.config-accordion[open] summary {
  background-color: #fff;
  border-bottom: 1px solid #eee;
}

.config-accordion[open] summary::after {
  content: '-';
}

.accordion-content {
  padding: clamp(6px, 1vh, 12px);
}

.sidebar-section {
  margin-bottom: clamp(6px, 0.8vh, 10px);
  border-bottom: 1px solid #ddd;
  padding-bottom: 15px;
}

.sidebar-section.no-border {
  border-bottom: none;
}

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

h3 {
  margin: 0 0 15px;
  color: #333;
  text-align: center;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

h4 {
  margin: 10px 0;
  font-size: 0.85rem;
  color: #666;
  text-transform: uppercase;
  font-weight: 600;
  text-align: center;
}

/* Grid 2 Columns */
.grid-2-cols {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(4px, 0.6vh, 8px);
}

.grid-2-cols>* {
  flex: 0 0 calc(50% - 4px);
  max-width: calc(50% - 4px);
}

/* Grid 3 Columns */
.grid-3-cols {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(4px, 0.6vh, 6px);
}

.grid-3-cols>* {
  flex: 0 0 calc(50% - 6px);
  max-width: calc(50% - 6px);
}

@media (min-width: 740px) {
  .grid-3-cols>* {
    flex: 0 0 calc(33.333% - 6px);
    max-width: calc(33.333% - 6px);
  }
}

/* Grid 5 Columns */
.grid-5-cols {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(2px, 0.4vw, 5px);
  width: 100%;
}

.grid-5-cols>* {
  flex: 1 1 0;
  min-width: 0;
}

/* Buttons */
button.model-btn,
button.collection-btn {
  padding: clamp(2px, 0.4vh, 4px);
  border: none;
  border-radius: 4px;
  background-color: var(--button-bg);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(2px, 0.4vh, 4px);
  width: 100%;
  min-height: clamp(26px, 3.5vh, 32px);
  box-sizing: border-box;
}

button.model-btn img {
  width: 100%;
  height: clamp(36px, 5.5vh, 64px);
  border-radius: 4px;
  background-color: #EDEDED;
  object-fit: contain;
  transition: height 0.2s ease, transform 0.2s ease;
  flex-shrink: 0;
}

button.model-btn span {
  font-size: clamp(8.5px, 0.95vh, 11px);
  font-weight: 800;
  text-transform: uppercase;
  color: #222;
  transition: color 0.2s, font-size 0.2s;
  text-align: center;
  line-height: 1.15;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.2em;
  width: 100%;
  flex-grow: 1;
  padding: 0 2px;
  box-sizing: border-box;
}

button.collection-btn {
  font-size: clamp(8.5px, 1vh, 11.5px);
  font-weight: 700;
  text-transform: uppercase;
  color: #444;
  transition: all 0.2s;
  min-height: clamp(26px, 3.5vh, 34px);
  padding: clamp(3px, 0.5vh, 6px) 2px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

button.model-btn.active span,
button.collection-btn.active {
  color: #fff;
}

button.leg-btn,
.nav-btn,
.tab-btn {
  padding: 12px 10px;
  border: none;
  border-radius: 4px;
  background-color: var(--button-bg);
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
  text-align: center;
  text-decoration: none;
  color: #444;
  display: block;
  width: 100%;
  font-weight: 600;
}

button.leg-btn {
  padding: clamp(4px, 0.7vh, 8px) 4px;
  font-size: clamp(10px, 1.1vh, 12.5px);
  font-weight: 700;
  min-height: clamp(28px, 3.8vh, 36px);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.15;
  box-sizing: border-box;
}

button:hover,
.nav-btn:hover {
  background-color: #d8d8d8;
}

button.active,
.nav-btn.active {
  background-color: #333;
  color: white;
}

/* Tabs */
.tabs-header {
  display: flex;
  gap: 5px;
  margin-bottom: 5px;
}

.tab-btn {
  flex: 1;
  border-radius: 4px 4px 0 0;
}

.tab-content {
  display: none;
}

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

/* Custom Select */
.custom-select {
  width: 100%;
  padding: 10px;
  border-radius: 4px;
  border: 1px solid #ccc;
  background-color: white;
  font-size: 14px;
  cursor: pointer;
}

/* Color Grid */
.color-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(6px, 1vh, 10px);
}

.color-btn {
  position: relative;
  width: clamp(34px, 4.8vh, 48px);
  height: clamp(34px, 4.8vh, 48px);
  border-radius: 50%;
  border: 1px solid #dcdcdc;
  background-color: transparent;
  cursor: pointer;
  transition:
    border-color 0.3s ease,
    box-shadow 0.3s ease,
    width 0.2s ease,
    height 0.2s ease;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.color-btn:hover {
  border-color: #888;
}

.color-btn.active {
  border-color: #333;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.color-btn.active::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 18px;
  border: solid white;
  border-width: 0 3px 3px 0;
  transform: translate(-50%, -60%) rotate(45deg);
  filter: drop-shadow(0px 0px 4px rgba(0, 0, 0, 0.6));
}

/* Leg color picker — round buttons with label */
.leg-color-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(2px, 0.4vh, 4px);
  cursor: pointer;
  flex: 0 0 auto;
  min-width: clamp(34px, 4.8vh, 48px);
}

.leg-color-item .color-btn {
  width: clamp(34px, 4.8vh, 48px);
  height: clamp(34px, 4.8vh, 48px);
  border-radius: 50%;
  margin: 0 auto;
}

.leg-color-label {
  font-size: clamp(8.5px, 0.95vh, 10.5px);
  font-weight: 700;
  color: #333;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1.1;
  max-width: 85px;
  word-break: break-word;
}

/* Main Content */
#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: #eee;
  min-width: 0;
}

#canvas-container {
  flex: 1;
  width: 100%;
  background: radial-gradient(circle at center, #E0E0E2 0%, #E0E0E2 50%, #d4d4d6 100%);
  touch-action: none;
}

#canvas-container canvas {
  touch-action: none;
}


/* Volver Sutil */
.volver-sutil {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 1001;
  background: transparent;
  border: none;
  color: #333;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  padding: 10px;
  transition: opacity 0.3s ease;
}

.volver-sutil:hover {
  opacity: 0.7;
}

.dark-mode .volver-sutil {
  color: #fff;
}

@media (min-width: 740px) {
  .volver-sutil {
    font-size: 1.2rem;
    /* Adjusted from chairs' 1.8rem which felt too big for mesas */
    font-weight: 800;
  }
}

/* Stock Container */
#stock-container {
  position: sticky;
  bottom: 0;
  background: var(--sidebar-bg);
  z-index: 5;
  padding: 6px 0;
  margin-top: auto;
  flex-shrink: 0;
}

#stock-container .nav-btn {
  width: 100%;
  padding: clamp(8px, 1.1vh, 12px) 10px;
  font-size: clamp(13px, 1.3vh, 15px);
}

/* Responsive */
@media (max-width: 900px) {
  #app-container {
    flex-direction: column;
    overflow-y: auto;
  }

  .sidebar {
    width: 100%;
    height: auto;
    padding: 15px;
    box-shadow: none;
  }

  #main-content {
    height: 50vh;
    min-height: 380px;
    flex: none;
    order: 1;
  }

  #right-sidebar {
    order: 2;
    border-left: none;
    border-top: 1px solid #ddd;

    flex: none;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  /* Panel de medidas no visible en móvil */
  #dimensions-panel {
    display: none;
  }
}

/* Mobile tab-mode (< 900px) */
#mobile-tab-bar {
  display: none;
  /* hidden on desktop */
}

@media (max-width: 900px) {

  /* Hide the mobile tab bar above (it shows here) */
  #mobile-tab-bar {
    display: flex;
    gap: 0;
    background: #1a1a1a;
    border-radius: 14px;
    padding: 5px;
    margin-bottom: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .mobile-tab {
    flex: 1;
    padding: 8px 6px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #888;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    cursor: pointer;
    transition: all 0.25s ease;
  }

  .mobile-tab.active {
    background: #fff;
    color: #111;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }

  /* Hide the accordion summary (the clickable header) */
  .config-accordion>summary {
    display: none;
  }

  /* Hide ALL accordion content by default */
  .config-accordion {
    border: none;
    box-shadow: none;
    background: transparent;
    display: none;
  }

  /* Show only the active accordion */
  .config-accordion.mobile-active {
    display: block;
  }

  /* Make the accordion content always visible (no details open/close) */
  .config-accordion.mobile-active .accordion-content {
    display: block !important;
  }

  /* Sidebar adjustments for tab mode */
  #right-sidebar {
    gap: 0;
    padding: 10px 12px 16px;
    overflow-y: auto;
  }

  /* Stock button on mobile */
  #stock-container {
    margin-top: 12px;
    position: static;
    background: transparent;
  }
}

/* Loader */
#loader-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  display: none;
  pointer-events: none;
}

.loader {
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid #333;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Background Toggle Button */
.bg-toggle-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 1001;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background-color: white;
  color: #333;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
}

@media (min-width: 740px) {

  /* Background Toggle Button */
  .bg-toggle-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1001;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background-color: white;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
  }
}

.bg-toggle-btn:hover {
  transform: scale(1.1);
  background-color: #f0f0f0;
}

.bg-toggle-btn svg {
  width: 24px;
  height: 24px;
}

/* Dark mode updates */
.dark-mode #canvas-container {
  background: #575866 !important;
}

.dark-mode .bg-toggle-btn {
  background-color: #333;
  color: #fff;
}

/* Rotation Hint */
.rotation-hint {
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%) scale(0.5);
  pointer-events: none;
  opacity: 0.8;
  display: flex;
  justify-content: center;
  align-items: center;
}

@media (min-width: 740px) {
  .rotation-hint {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    opacity: 0.8;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}

/* Dimensions Panel */
#dimensions-panel {
  position: absolute;
  bottom: 20px;
  left: 20px;
  z-index: 100;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 200px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  pointer-events: none;
}

.dim-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 3px 0;
}

.dim-label {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  text-align: left;
  white-space: nowrap;
}

.dim-value {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  color: #222;
  text-align: right;
  white-space: nowrap;
}

/* Dark mode adaptation */
.dark-mode #dimensions-panel {
  background: rgba(30, 30, 35, 0.78);
  border-color: rgba(255, 255, 255, 0.1);
}

.dark-mode .dim-label {
  color: #bbb;
}

.dark-mode .dim-value {
  color: #fff;
}

/* Stock Popup Styles */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  backdrop-filter: blur(5px);
}

.popup-container {
  background-color: #fff;
  width: 98%;
  max-width: 1400px;
  max-height: 95vh;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  animation: popupFadeIn 0.3s ease-out;
}

@keyframes popupFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.close-btn {
  position: absolute;
  top: 15px;
  right: 20px;
  background: none;
  border: none;
  font-size: 30px;
  cursor: pointer;
  color: #333;
  z-index: 10;
}

.popup-content {
  display: flex;
  height: 100%;
}

.popup-left {
  flex: 1;
  background-color: #f9f9f9;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  border-right: 1px solid #eee;
}

.popup-left img {
  max-width: 100%;
  max-height: 520px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid #1a1a1a;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
}

.popup-right {
  flex: 1;
  padding: 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}

.popup-title {
  margin: 0;
  font-size: 1.8rem;
  color: #333;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 2px solid #333;
  padding-bottom: 10px;
}

.popup-item {
  background: #f4f4f4;
  padding: 15px;
  border-radius: 8px;
  border-left: 4px solid #333;
}

.popup-item-label {
  font-weight: 700;
  font-size: 0.8rem;
  color: #666;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.popup-item-value {
  font-size: 1.3rem;
  color: #222;
  font-weight: 600;
  word-break: break-word;
}

.popup-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.popup-field label {
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
}

.popup-field input {
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  outline: none;
}

.stock-status {
  text-align: center;
  font-weight: 800;
  font-size: 1.2rem;
  text-transform: uppercase;
  padding: 10px;
  border-radius: 6px;
}

.stock-status.available {
  color: #2e7d32;
  background-color: #e8f5e9;
}

.stock-status.unavailable {
  color: #c62828;
  background-color: #ffebee;
}

/* Responsive Popup */
@media (max-width: 900px) {
  .popup-container {
    width: 100%;
    max-width: 100%;
    max-height: 100dvh;
    border-radius: 16px 16px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .popup-content {
    flex-direction: column;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
  }

  .popup-left {
    border-right: none;
    border-bottom: 1px solid #eee;
    padding: 10px;
    flex: 0 0 auto;
  }

  .popup-left img {
    max-height: 180px;
  }

  .popup-right {
    padding: 16px;
    flex: 1 1 auto;
    overflow-y: auto;
    gap: 12px;
  }

  .popup-title {
    font-size: 1.2rem;
  }

  .popup-item {
    padding: 10px 12px;
  }

  .popup-item-value {
    font-size: 0.9rem;
  }

  .popup-field input {
    padding: 10px;
  }

  .stock-status {
    font-size: 0.95rem;
  }
}

/* Adaptación responsiva para dimensiones con altura de pantalla reducida (laptops y pantallas < 800px) */
@media (max-height: 800px) and (min-width: 901px) {
  .sidebar {
    padding: 6px 10px;
    gap: 6px;
  }

  .config-accordion summary {
    padding: 8px 12px;
    font-size: 0.88rem;
  }

  .accordion-content {
    padding: 6px 8px;
  }

  .sidebar-section {
    margin-bottom: 5px;
    padding-bottom: 6px;
  }

  .grid-3-cols {
    gap: 4px;
  }

  button.model-btn {
    padding: 2px;
    gap: 2px;
  }

  button.model-btn img {
    height: 42px;
  }

  button.model-btn span {
    font-size: 8.5px;
    min-height: 2em;
  }

  .color-btn,
  .leg-color-item .color-btn {
    width: 32px;
    height: 32px;
  }

  .leg-color-item {
    min-width: 32px;
  }

  .leg-color-label {
    font-size: 8px;
  }

  button.leg-btn {
    padding: 4px 3px;
    font-size: 10px;
    min-height: 26px;
  }

  button.collection-btn {
    min-height: 26px;
    font-size: 9px;
  }

  #stock-container .nav-btn {
    padding: 8px 10px;
    font-size: 13px;
  }
}

@media (max-height: 680px) and (min-width: 901px) {
  .sidebar {
    padding: 4px 8px;
    gap: 4px;
  }

  .config-accordion summary {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .accordion-content {
    padding: 4px 6px;
  }

  .grid-3-cols {
    gap: 3px;
  }

  button.model-btn img {
    height: 34px;
  }

  button.model-btn span {
    font-size: 8px;
    min-height: 1.8em;
  }

  .color-btn,
  .leg-color-item .color-btn {
    width: 26px;
    height: 26px;
  }

  .leg-color-item {
    min-width: 26px;
  }

  .leg-color-label {
    font-size: 7.5px;
  }

  button.leg-btn {
    padding: 3px 2px;
    font-size: 9.5px;
    min-height: 24px;
  }

  button.collection-btn {
    min-height: 24px;
    font-size: 8.5px;
  }
}

/* Selector de Idioma (Evita quedar cortado en la parte inferior) */
.lang-selector {
  position: fixed !important;
  bottom: 16px !important;
  top: auto !important;
  right: calc(35% + 15px) !important;
  z-index: 9999 !important;
  font-family: 'Inter', sans-serif;
}

@media (max-width: 900px) {
  .lang-selector {
    right: 15px !important;
    bottom: 15px !important;
    top: auto !important;
  }
}

#download-pdf-btn {
  width: 80%;
  margin: 0 auto;
  box-sizing: border-box;
}

/* Stock Query Button & Result Box */
.stock-query-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: -10px;
  width: 100%;
}

#stock-result-container {
  width: 100%;
}

.stock-query-btn {
  background: #b3e8b6 !important;
  color: #1f3d24 !important;
  border: none;
  border-radius: 4px;
  padding: 12px 10px;
  font-size: 16px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
  width: 80%;
  margin: 0 auto;
  box-sizing: border-box;
}

.stock-query-btn:hover {
  background: #9fe0a3 !important;
}

.stock-query-btn:active {
  transform: none;
}

.stock-query-btn.loading {
  pointer-events: none;
  opacity: 0.85;
  background: #a5dba9 !important;
}

.stock-btn-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(31, 61, 36, 0.25);
  border-top-color: #1f3d24;
  border-radius: 50%;
  animation: stockSpin 0.7s linear infinite;
  display: none;
}

.stock-query-btn.loading .stock-btn-spinner {
  display: inline-block;
}

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

/* Loading Card Indicator */
.stock-loading-card {
  margin-top: 10px;
  padding: 14px 18px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  color: #334155;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: stockCardFadeIn 0.25s ease-out;
}

.stock-inline-spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid #cbd5e1;
  border-top-color: #0f172a;
  border-radius: 50%;
  animation: stockSpin 0.75s linear infinite;
  flex-shrink: 0;
}

/* Stock Result Card */
.stock-result-card {
  margin-top: 10px;
  padding: 14px 16px;
  border-radius: 8px;
  animation: stockCardFadeIn 0.25s ease-out;
  transition: all 0.3s ease;
  font-family: 'Inter', sans-serif;
  text-align: left;
}

@keyframes stockCardFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.stock-result-card.success-high {
  background: #ecfdf5;
  border: 1.5px solid #10b981;
  color: #065f46;
}

.stock-result-card.success-limited {
  background: #f0fdfa;
  border: 1.5px solid #0d9488;
  color: #134e4a;
}

.stock-result-card.warning-low {
  background: #fffbeb;
  border: 1.5px solid #f59e0b;
  color: #92400e;
}

.stock-result-card.out-of-stock {
  background: #fff1f2;
  border: 1.5px solid #f43f5e;
  color: #881337;
}

.stock-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.stock-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stock-result-card.success-high .stock-badge {
  background: #10b981;
  color: #ffffff;
}

.stock-result-card.success-limited .stock-badge {
  background: #0d9488;
  color: #ffffff;
}

.stock-result-card.warning-low .stock-badge {
  background: #f59e0b;
  color: #ffffff;
}

.stock-result-card.out-of-stock .stock-badge {
  background: #f43f5e;
  color: #ffffff;
}

.stock-result-body {
  font-size: 0.88rem;
  line-height: 1.45;
  font-weight: 500;
}

.stock-phone-link {
  font-weight: 700;
  text-decoration: underline;
  color: inherit;
}

.stock-components-list {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.76rem;
  opacity: 0.9;
}

.stock-component-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stock-comp-name {
  font-weight: 500;
}

.stock-comp-qty {
  font-weight: 700;
}

/* Stock Retry Button in Error State */
.stock-retry-wrapper {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.stock-retry-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 18px;
  font-family: inherit;
  font-size: 0.83rem;
  font-weight: 600;
  color: #be123c;
  background: #ffffff;
  border: 1.5px solid #f43f5e;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(244, 63, 94, 0.12);
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  outline: none;
}

.stock-retry-btn:hover {
  background: #be123c;
  color: #ffffff;
  border-color: #be123c;
  box-shadow: 0 4px 12px rgba(190, 18, 60, 0.25);
  transform: translateY(-1px);
}

.stock-retry-btn:hover .stock-retry-icon {
  transform: rotate(180deg);
}

.stock-retry-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(190, 18, 60, 0.15);
}

.stock-retry-btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.35);
}

.stock-retry-icon {
  transition: transform 0.4s ease;
  flex-shrink: 0;
}

.stock-retry-btn.is-retrying {
  pointer-events: none;
  opacity: 0.85;
  background: #fff1f2;
}

.stock-retry-btn.is-retrying .stock-retry-icon {
  animation: stockSpin 0.7s linear infinite;
}

/* Mobile Responsive Adjustments for Stock Query */
@media (max-width: 768px) {
  #download-pdf-btn,
  .stock-query-btn {
    width: 92% !important;
    font-size: 15px;
    padding: 10px 8px;
  }

  .stock-query-actions {
    margin-top: -6px;
    width: 100%;
  }

  .stock-result-card {
    margin-top: 8px;
    padding: 12px 14px;
    border-radius: 6px;
    width: 100%;
    box-sizing: border-box;
  }

  .stock-result-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 6px;
  }

  .stock-badge {
    font-size: 0.72rem;
    padding: 3px 8px;
    line-height: 1.2;
  }

  .stock-result-body {
    font-size: 0.84rem;
    line-height: 1.42;
    word-break: break-word;
  }

  .stock-loading-card {
    margin-top: 8px;
    padding: 12px 14px;
    border-radius: 6px;
    font-size: 0.82rem;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
  }

  .stock-inline-spinner {
    width: 16px;
    height: 16px;
    border-width: 2px;
  }

  .stock-retry-wrapper {
    margin-top: 12px;
  }
}

@media (max-width: 480px) {
  #download-pdf-btn,
  .stock-query-btn {
    width: 100% !important;
    font-size: 14px;
    padding: 10px 6px;
  }

  .stock-result-card {
    padding: 10px 12px;
  }

  .stock-result-body {
    font-size: 0.8rem;
    line-height: 1.38;
  }

  .stock-badge {
    font-size: 0.68rem;
    padding: 2px 6px;
  }

  .stock-retry-wrapper {
    width: 100%;
  }

  .stock-retry-btn {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.85rem;
  }
}
