/* ============================================================================
   Nemlai - Shared Styles
   Theme: Catppuccin Mocha
   ============================================================================ */

/* Font Import */

/* CSS Variables - Catppuccin Mocha Palette */
:root {
  --ctp-base: #1e1e2e;
  --ctp-mantle: #181825;
  --ctp-crust: #11111b;
  --ctp-surface0: #313244;
  --ctp-surface1: #45475a;
  --ctp-surface2: #585b70;
  --ctp-overlay0: #6c7086;
  --ctp-overlay1: #7f849c;
  --ctp-overlay2: #9399b2;
  --ctp-text: #cdd6f4;
  --ctp-subtext0: #a6adc8;
  --ctp-subtext1: #bac2de;
  --ctp-green: #a6e3a1;
  --ctp-blue: #89b4fa;
  --ctp-red: #f38ba8;
  --ctp-yellow: #f9e2af;
  --ctp-mauve: #cba6f7;
  --ctp-peach: #fab387;
  --ctp-lavender: #b4befe;
  --ctp-teal: #94e2d5;
  --ctp-sapphire: #74c7ec;

  /* RGB component variants for rgba() opacity usage */
  --ctp-base-rgb: 30, 30, 46;
  --ctp-mantle-rgb: 24, 24, 37;
  --ctp-crust-rgb: 17, 17, 27;
  --ctp-surface0-rgb: 49, 50, 68;
  --ctp-mauve-rgb: 203, 166, 247;
  --ctp-lavender-rgb: 180, 190, 254;
  --ctp-green-rgb: 166, 227, 161;
  --ctp-red-rgb: 243, 139, 168;
  --ctp-yellow-rgb: 249, 226, 175;
  --ctp-blue-rgb: 137, 180, 250;
  --ctp-teal-rgb: 148, 226, 213;
  --ctp-peach-rgb: 250, 179, 135;
  --ctp-sapphire-rgb: 116, 199, 236;

  --ctp-accent: var(--ctp-mauve);
  --ctp-accent-rgb: var(--ctp-mauve-rgb);

  --font-h1: clamp(1.5rem, 1.25rem + 1.25vw, 2rem);
  --font-h2: clamp(1.125rem, 1rem + 0.625vw, 1.375rem);
  --font-body: clamp(0.875rem, 0.8125rem + 0.3125vw, 0.9375rem);
  --font-small: clamp(0.75rem, 0.6875rem + 0.3125vw, 0.8125rem);
}

/* ============================================================================
   Theme Flavors — Catppuccin
   ============================================================================ */

[data-theme="mocha"] {
  --ctp-base: #1e1e2e;    --ctp-base-rgb: 30, 30, 46;
  --ctp-mantle: #181825;   --ctp-mantle-rgb: 24, 24, 37;
  --ctp-crust: #11111b;    --ctp-crust-rgb: 17, 17, 27;
  --ctp-surface0: #313244; --ctp-surface0-rgb: 49, 50, 68;
  --ctp-surface1: #45475a;
  --ctp-surface2: #585b70;
  --ctp-overlay0: #6c7086;
  --ctp-overlay1: #7f849c;
  --ctp-overlay2: #9399b2;
  --ctp-text: #cdd6f4;
  --ctp-subtext0: #a6adc8;
  --ctp-subtext1: #bac2de;
  --ctp-green: #a6e3a1;    --ctp-green-rgb: 166, 227, 161;
  --ctp-blue: #89b4fa;     --ctp-blue-rgb: 137, 180, 250;
  --ctp-red: #f38ba8;      --ctp-red-rgb: 243, 139, 168;
  --ctp-yellow: #f9e2af;   --ctp-yellow-rgb: 249, 226, 175;
  --ctp-mauve: #cba6f7;    --ctp-mauve-rgb: 203, 166, 247;
  --ctp-peach: #fab387;    --ctp-peach-rgb: 250, 179, 135;
  --ctp-lavender: #b4befe; --ctp-lavender-rgb: 180, 190, 254;
  --ctp-teal: #94e2d5;     --ctp-teal-rgb: 148, 226, 213;
  --ctp-sapphire: #74c7ec; --ctp-sapphire-rgb: 116, 199, 236;
  --ctp-accent: #cba6f7;   --ctp-accent-rgb: 203, 166, 247;
}

[data-theme="macchiato"] {
  --ctp-base: #24273a;     --ctp-base-rgb: 36, 39, 58;
  --ctp-mantle: #1e2030;   --ctp-mantle-rgb: 30, 32, 48;
  --ctp-crust: #181926;    --ctp-crust-rgb: 24, 25, 38;
  --ctp-surface0: #363a4f; --ctp-surface0-rgb: 54, 58, 79;
  --ctp-surface1: #494d64;
  --ctp-surface2: #5b6078;
  --ctp-overlay0: #6e738d;
  --ctp-overlay1: #8087a2;
  --ctp-overlay2: #939ab7;
  --ctp-text: #cad3f5;
  --ctp-subtext0: #a5adcb;
  --ctp-subtext1: #b8c0e0;
  --ctp-green: #a6da95;    --ctp-green-rgb: 166, 218, 149;
  --ctp-blue: #8aadf4;     --ctp-blue-rgb: 138, 173, 244;
  --ctp-red: #ed8796;      --ctp-red-rgb: 237, 135, 150;
  --ctp-yellow: #eed49f;   --ctp-yellow-rgb: 238, 212, 159;
  --ctp-mauve: #c6a0f6;    --ctp-mauve-rgb: 198, 160, 246;
  --ctp-peach: #f5a97f;    --ctp-peach-rgb: 245, 169, 127;
  --ctp-lavender: #b7bdf8; --ctp-lavender-rgb: 183, 189, 248;
  --ctp-teal: #8bd5ca;     --ctp-teal-rgb: 139, 213, 202;
  --ctp-sapphire: #7dc4e4; --ctp-sapphire-rgb: 125, 196, 228;
  --ctp-accent: #c6a0f6;   --ctp-accent-rgb: 198, 160, 246;
}

[data-theme="frappe"] {
  --ctp-base: #303446;     --ctp-base-rgb: 48, 52, 70;
  --ctp-mantle: #292c3c;   --ctp-mantle-rgb: 41, 44, 60;
  --ctp-crust: #232634;    --ctp-crust-rgb: 35, 38, 52;
  --ctp-surface0: #414559; --ctp-surface0-rgb: 65, 69, 89;
  --ctp-surface1: #51576d;
  --ctp-surface2: #626880;
  --ctp-overlay0: #737994;
  --ctp-overlay1: #838ba7;
  --ctp-overlay2: #949cbb;
  --ctp-text: #c6d0f5;
  --ctp-subtext0: #a5adce;
  --ctp-subtext1: #b5bfe2;
  --ctp-green: #a6d189;    --ctp-green-rgb: 166, 209, 137;
  --ctp-blue: #8caaee;     --ctp-blue-rgb: 140, 170, 238;
  --ctp-red: #e78284;      --ctp-red-rgb: 231, 130, 132;
  --ctp-yellow: #e5c890;   --ctp-yellow-rgb: 229, 200, 144;
  --ctp-mauve: #ca9ee6;    --ctp-mauve-rgb: 202, 158, 230;
  --ctp-peach: #ef9f76;    --ctp-peach-rgb: 239, 159, 118;
  --ctp-lavender: #babbf1; --ctp-lavender-rgb: 186, 187, 241;
  --ctp-teal: #81c8be;     --ctp-teal-rgb: 129, 200, 190;
  --ctp-sapphire: #85c1dc; --ctp-sapphire-rgb: 133, 193, 220;
  --ctp-accent: #ca9ee6;   --ctp-accent-rgb: 202, 158, 230;
}

[data-theme="latte"] {
  --ctp-base: #eff1f5;     --ctp-base-rgb: 239, 241, 245;
  --ctp-mantle: #e6e9ef;   --ctp-mantle-rgb: 230, 233, 239;
  --ctp-crust: #dce0e8;    --ctp-crust-rgb: 220, 224, 232;
  --ctp-surface0: #ccd0da; --ctp-surface0-rgb: 204, 208, 218;
  --ctp-surface1: #bcc0cc;
  --ctp-surface2: #acb0be;
  --ctp-overlay0: #9ca0b0;
  --ctp-overlay1: #8c8fa1;
  --ctp-overlay2: #7c7f93;
  --ctp-text: #4c4f69;
  --ctp-subtext0: #6c6f85;
  --ctp-subtext1: #5c5f77;
  --ctp-green: #40a02b;    --ctp-green-rgb: 64, 160, 43;
  --ctp-blue: #1e66f5;     --ctp-blue-rgb: 30, 102, 245;
  --ctp-red: #d20f39;      --ctp-red-rgb: 210, 15, 57;
  --ctp-yellow: #df8e1d;   --ctp-yellow-rgb: 223, 142, 29;
  --ctp-mauve: #ea76cb;    --ctp-mauve-rgb: 234, 118, 203;
  --ctp-peach: #fe640b;    --ctp-peach-rgb: 254, 100, 11;
  --ctp-lavender: #dd7878; --ctp-lavender-rgb: 221, 120, 120;
  --ctp-teal: #179299;     --ctp-teal-rgb: 23, 146, 153;
  --ctp-sapphire: #209fb5; --ctp-sapphire-rgb: 32, 159, 181;
  --ctp-accent: #ea76cb;   --ctp-accent-rgb: 234, 118, 203;
}

/* Reset & Base */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--ctp-base);
  color: var(--ctp-text);
  min-height: 100vh;
}

/* ============================================================================
   Header / Navigation
   ============================================================================ */

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--ctp-mantle);
  border-bottom: 1px solid var(--ctp-surface1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ctp-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.125rem;
}

.logo-text {
  color: var(--ctp-accent);
  font-weight: 700;
}

.logo-icon {
  display: none;
  color: var(--ctp-accent);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1;
}

@media (max-width: 600px) {
  .logo-text { display: none; }
  .logo-icon { display: block; }
}

.nav {
  display: flex;
  gap: 8px;
}

.nav a, .nav button {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.875rem;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.nav a {
  color: var(--ctp-subtext0);
  background: transparent;
}

.nav a:hover {
  color: var(--ctp-text);
  background: var(--ctp-surface0);
}

.nav button {
  color: var(--ctp-subtext0);
  background: transparent;
  border: 1px solid var(--ctp-surface1);
}

.nav button:hover {
  color: var(--ctp-text);
  background: var(--ctp-surface0);
}

/* Mobile nav tightening */
@media (max-width: 480px) {
  .header {
    padding: 0 12px;
  }
  
  .nav {
    gap: 4px;
  }
  
  .nav a,
  .nav button {
    padding: 7px 10px;
    font-size: 0.8125rem;
    line-height: 1.2;
    white-space: nowrap;
  }
}

/* ============================================================================
   Hamburger Menu — Mobile Dropdown
   ============================================================================ */

.nav-menu-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--ctp-surface1);
  color: var(--ctp-subtext0);
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}

.hamburger-btn:hover {
  color: var(--ctp-text);
  background: var(--ctp-surface0);
}

.hamburger-btn svg {
  width: 18px;
  height: 18px;
}

/* Desktop: menu items display inline */
.nav-menu {
  display: flex;
  gap: 8px;
}

/* Inherit nav item styling */
.nav-menu a,
.nav-menu button {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.875rem;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.nav-menu a {
  color: var(--ctp-subtext0);
  background: transparent;
}

.nav-menu a:hover {
  color: var(--ctp-text);
  background: var(--ctp-surface0);
}

.nav-menu button {
  color: var(--ctp-subtext0);
  background: transparent;
  border: 1px solid var(--ctp-surface1);
}

.nav-menu button:hover {
  color: var(--ctp-text);
  background: var(--ctp-surface0);
}

/* Mobile: hamburger visible, menu becomes dropdown */
@media (max-width: 600px) {
  .hamburger-btn {
    display: flex;
  }

  .nav-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--ctp-mantle);
    border: 1px solid var(--ctp-surface1);
    border-radius: 8px;
    padding: 4px;
    min-width: 170px;
    z-index: 200;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    flex-direction: column;
    gap: 0;
  }

  .nav-menu.open {
    display: flex;
  }

  .nav-menu a,
  .nav-menu button {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.875rem;
    text-align: left;
    width: 100%;
    border: none;
    white-space: nowrap;
  }
}

/* ============================================================================
   Hyper Mode Navigation Link
   ============================================================================ */

.hyper-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.hyper-link.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.hyper-link.locked:hover {
  background: transparent;
}

.hyper-link.unlocked {
  opacity: 1;
  background: linear-gradient(135deg, rgba(var(--ctp-accent-rgb), 0.1), rgba(var(--ctp-lavender-rgb), 0.1));
  border: 1px solid var(--ctp-accent);
}

.hyper-link.unlocked:hover {
  background: linear-gradient(135deg, rgba(var(--ctp-accent-rgb), 0.2), rgba(var(--ctp-lavender-rgb), 0.2));
}

/* Tooltip for locked state */
.hyper-link.locked::after {
  content: attr(title);
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  background: var(--ctp-surface0);
  color: var(--ctp-text);
  font-size: 0.75rem;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 1000;
  border: 1px solid var(--ctp-surface1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  max-width: 250px;
  white-space: normal;
  text-align: center;
}

.hyper-link.locked:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(8px);
}

.nav-beta-badge {
  font-size: 0.55em;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ctp-peach);
  margin-left: 3px;
  vertical-align: super;
  line-height: 1;
  pointer-events: none;
}

/* ============================================================================
   Hyper Mode Item List
   ============================================================================ */

.hyper-item-list {
  background: var(--ctp-surface0);
  border-radius: 12px;
  overflow: hidden;
}

.hyper-item {
  display: flex;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ctp-surface1);
  gap: 12px;
  transition: background 0.15s;
  position: relative;
}

.hyper-item:hover {
  background: rgba(var(--ctp-surface0-rgb), 0.3);
}

.hyper-item:last-child {
  border-bottom: none;
}

.hyper-item-image-col {
  width: 56px;
  min-width: 56px;
  align-self: stretch;
  border-radius: 6px;
  overflow: hidden;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hyper-item-image-col img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.hyper-item-image-col.hyper-item-image-placeholder {
  background: linear-gradient(135deg, var(--ctp-surface0) 0%, var(--ctp-surface1) 100%);
  opacity: 0.3;
}

.hyper-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hyper-item-row-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.hyper-item-info {
  flex: 1;
  min-width: 0;
}

.hyper-item-name {
  font-weight: 500;
  color: var(--ctp-text);
}

.hyper-item-meta {
  font-size: 0.8125rem;
  color: var(--ctp-subtext0);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  align-items: center;
  margin-top: 2px;
}

.substitute-label {
  font-size: 0.8125rem;
  color: var(--ctp-subtext0);
  margin-top: 1px;
}

.hyper-item-price {
  font-weight: 600;
  color: var(--ctp-text);
  text-align: right;
  white-space: nowrap;
  flex-shrink: 0;
}

.hyper-item-row-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hyper-item-bottom-left {
  font-size: 0.8125rem;
  color: var(--ctp-subtext0);
}

.hyper-item-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

/* Quantity controls */
.qty-control {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--ctp-mantle);
  border-radius: 6px;
  padding: 4px;
}

.qty-control button {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--ctp-surface1);
  color: var(--ctp-text);
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.qty-control button:hover {
  background: var(--ctp-surface2);
}

.qty-control button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.qty-control span {
  min-width: 28px;
  text-align: center;
  font-weight: 600;
}

.remove-item-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--ctp-overlay0);
  cursor: pointer;
  border-radius: 6px;
  font-size: 1rem;
  transition: all 0.2s;
}

.remove-item-btn:hover {
  background: rgba(var(--ctp-red-rgb), 0.1);
  color: var(--ctp-red);
}

/* Sparkle indicator for new items */
.sparkle-badge {
  animation: sparkle-pulse 2s ease-in-out infinite;
  will-change: opacity, transform;
}

@keyframes sparkle-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.1); }
}

.hyper-item.new-item {
  background: linear-gradient(135deg, rgba(var(--ctp-accent-rgb), 0.05), rgba(var(--ctp-lavender-rgb), 0.05));
}

/* Low stock / unavailable indicators */
.stock-warning {
  font-size: 0.6875rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(var(--ctp-yellow-rgb), 0.2);
  color: var(--ctp-yellow);
}

.stock-unavailable {
  font-size: 0.6875rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(var(--ctp-red-rgb), 0.2);
  color: var(--ctp-red);
}

/* ============================================================================
   Hyper Mode Page Components
   ============================================================================ */

.hyper-size-selector {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.size-option {
  flex: 1;
  padding: 16px;
  background: var(--ctp-mantle);
  border: 2px solid var(--ctp-overlay0);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.size-option:hover {
  border-color: var(--ctp-accent);
  background: var(--ctp-surface0);
}

.size-option.selected {
  border-color: var(--ctp-accent);
  background: linear-gradient(135deg, rgba(var(--ctp-accent-rgb), 0.1), rgba(var(--ctp-lavender-rgb), 0.1));
}

.size-option input {
  display: none;
}

.size-label {
  font-weight: 600;
  color: var(--ctp-text);
  margin-bottom: 4px;
}

.size-price {
  font-size: 0.875rem;
  color: var(--ctp-subtext0);
}

/* Add items section */
.add-items-section {
  background: var(--ctp-surface0);
  border-radius: 12px;
  padding: 16px;
  margin-top: 20px;
}

.add-items-row {
  display: flex;
  gap: 12px;
}

.add-items-row input {
  flex: 1;
  margin-bottom: 0;
}

.add-items-row button {
  white-space: nowrap;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--ctp-surface0);
  color: var(--ctp-text);
  padding: 12px 24px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--ctp-surface1);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  border-color: var(--ctp-green);
}

/* Hyper action buttons */
.hyper-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.hyper-actions .btn {
  flex: 1;
}

.item-badges {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.item-badges:empty {
  display: none;
}

@media (max-width: 600px) {
  .hyper-item-list {
    margin: 0 -2.5rem;
    border-radius: 0;
  }

  .hyper-item {
    padding: 10px 1rem;
  }

  .hyper-item-image-col {
    width: 64px;
    min-width: 64px;
  }
}

@media (max-width: 480px) {
  .hyper-size-selector {
    flex-direction: column;
  }
  
  .hyper-actions {
    flex-direction: column-reverse;
  }
}

@media (min-width: 768px) {
  .result-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1.5rem;
    align-items: start;
  }
  
  .result-sidebar {
    position: sticky;
    top: 72px;
    align-self: start;
  }
}

@media (min-width: 1024px) {
  .result-layout {
    grid-template-columns: 1fr 320px;
    gap: 2rem;
  }
}

/* ============================================================================
   Forms
   ============================================================================ */

label {
  display: block;
  margin-bottom: 4px;
  color: var(--ctp-subtext1);
  font-size: 0.875rem;
}

input, select {
  width: 100%;
  padding: 10px;
  margin-bottom: 16px;
  border: 1px solid var(--ctp-surface1);
  border-radius: 4px;
  background: var(--ctp-surface0);
  color: var(--ctp-text);
  font-size: 0.875rem;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--ctp-green);
}

input:focus-visible, select:focus-visible {
  box-shadow: 0 0 0 3px rgba(var(--ctp-green-rgb), 0.4);
}

/* Password field with toggle */
.password-field {
  position: relative;
  margin-bottom: 16px;
}

.password-field input {
  padding-right: 44px;
  margin-bottom: 0;
}

.password-toggle {
  position: absolute;
  right: 12px;
  top: 10px;
  background: none;
  border: none;
  color: var(--ctp-overlay0);
  cursor: pointer;
  padding: 4px;
  font-size: 1.125rem;
  line-height: 1;
}

.password-toggle:hover {
  color: var(--ctp-accent);
}

/* Checkbox rows */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.checkbox-row input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--ctp-green);
}

.checkbox-row label {
  margin: 0;
  cursor: pointer;
}

/* Form rows */
.row {
  display: flex;
  gap: 12px;
}

.row > div {
  flex: 1;
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn {
  display: block;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  text-align: center;
}

.btn-primary {
  background: linear-gradient(135deg, var(--ctp-green) 0%, var(--ctp-teal) 100%);
  color: var(--ctp-crust);
  box-shadow: 0 2px 12px rgba(var(--ctp-green-rgb), 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(var(--ctp-green-rgb), 0.4);
}

.btn-secondary {
  background: var(--ctp-surface0);
  color: var(--ctp-text);
  border: 1px solid var(--ctp-surface1);
}

.btn-secondary:hover {
  background: var(--ctp-surface1);
  border-color: var(--ctp-surface2);
}

.btn-purple {
  background: linear-gradient(135deg, var(--ctp-accent) 0%, var(--ctp-lavender) 100%);
  color: var(--ctp-crust);
  box-shadow: 0 2px 12px rgba(var(--ctp-accent-rgb), 0.3);
}

.btn-purple:hover {
  box-shadow: 0 4px 16px rgba(var(--ctp-accent-rgb), 0.4);
}

button.submit {
  width: 100%;
  padding: 14px;
  background: var(--ctp-green);
  color: var(--ctp-crust);
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
}

button.submit:hover {
  filter: brightness(1.1);
}

button.submit:disabled {
  background: var(--ctp-surface2);
  cursor: wait;
}

/* ============================================================================
   Status States
   ============================================================================ */

.pending { border-left: 3px solid var(--ctp-yellow); }
.running { border-left: 3px solid var(--ctp-blue); }
.completed { border-left: 3px solid var(--ctp-green); }
.failed { border-left: 3px solid var(--ctp-red); }

.warn { color: var(--ctp-yellow); }
.ok { color: var(--ctp-green); }
.err { color: var(--ctp-red); }

/* ============================================================================
   Spinner & Progress
   ============================================================================ */

.spinner-container {
  display: none;
  text-align: center;
  padding: 30px 0;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--ctp-surface1);
  border-top: 4px solid var(--ctp-green);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
  will-change: transform;
}

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

.spinner-text {
  color: var(--ctp-subtext0);
  font-size: 0.875rem;
}

.spinner-step {
  color: var(--ctp-green);
  font-size: 1rem;
  font-weight: bold;
  margin-top: 8px;
}

/* Progress bar */
.progress-container {
  background: var(--ctp-surface0);
  border-radius: 4px;
  overflow: hidden;
  height: 6px;
  margin: 16px 0;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--ctp-green), var(--ctp-teal));
  width: 0%;
  transition: width 0.5s ease;
  animation: shimmer 2s infinite;
  will-change: width;
}

@keyframes shimmer {
  0% { opacity: 1; }
  50% { opacity: 0.7; }
  100% { opacity: 1; }
}

/* ============================================================================
   Modals
   ============================================================================ */

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(var(--ctp-crust-rgb), 0.9);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal {
  background: var(--ctp-base);
  border: 1px solid var(--ctp-surface1);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
  margin: 20px;
}

.modal h2 {
  color: var(--ctp-accent);
  margin-bottom: 24px;
  font-size: 1.5rem;
}

.modal label {
  display: block;
  margin-bottom: 6px;
  color: var(--ctp-subtext0);
  font-size: 0.875rem;
}

.modal input {
  width: 100%;
  padding: 14px;
  margin-bottom: 20px;
  border: 1px solid var(--ctp-surface1);
  border-radius: 8px;
  background: var(--ctp-surface0);
  color: var(--ctp-text);
  font-size: 1rem;
  font-family: inherit;
}

.modal input:focus {
  outline: none;
  border-color: var(--ctp-green);
}

.modal input:focus-visible {
  box-shadow: 0 0 0 3px rgba(var(--ctp-green-rgb), 0.4);
}

.modal-buttons {
  display: flex;
  gap: 12px;
}

.modal-buttons .btn {
  flex: 1;
  padding: 14px;
}

/* ============================================================================
   Utility Classes
   ============================================================================ */

.subtitle {
  color: var(--ctp-subtext0);
  margin-bottom: 24px;
}

.note {
  font-size: 0.75rem;
  color: var(--ctp-subtext0);
  margin-bottom: 16px;
}

.note a {
  color: var(--ctp-blue);
}

a {
  color: var(--ctp-blue);
}

/* Household badge */
.household-badge {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(var(--ctp-green-rgb), 0.1);
  border: 1px solid rgba(var(--ctp-green-rgb), 0.3);
  border-radius: 20px;
  font-size: 0.8125rem;
  color: var(--ctp-green);
  margin-bottom: 24px;
}

/* Info box */
.info-box {
  background: var(--ctp-surface0);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
  border-left: 4px solid var(--ctp-accent);
}

.info-box h4 {
  color: var(--ctp-accent);
  margin-bottom: 8px;
}

.info-box p {
  font-size: 0.875rem;
  color: var(--ctp-subtext1);
  line-height: 1.5;
}

/* Success box */
.success-box {
  background: rgba(var(--ctp-green-rgb), 0.1);
  border: 1px solid var(--ctp-green);
  padding: 16px;
  border-radius: 4px;
  margin-top: 20px;
  display: none;
}

.success-box h3 {
  color: var(--ctp-green);
  margin: 0 0 12px 0;
}

.success-box a {
  display: inline-block;
  margin-top: 12px;
  padding: 10px 20px;
  background: var(--ctp-green);
  color: var(--ctp-crust);
  text-decoration: none;
  border-radius: 4px;
  font-weight: bold;
}

/* Error message */
.error-msg {
  color: var(--ctp-red);
  font-size: 0.875rem;
  margin-bottom: 16px;
  display: none;
}

/* Error box */
.error-box {
  display: none;
  background: var(--ctp-surface0);
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
  border-left: 4px solid var(--ctp-red);
}

.error-box p {
  color: var(--ctp-red);
  font-size: 0.875rem;
}

/* Password match indicator */
.password-mismatch {
  border-color: var(--ctp-red) !important;
}

.match-indicator {
  font-size: 0.75rem;
  margin-top: 4px;
  margin-bottom: 16px;
}

.match-indicator.match { color: var(--ctp-green); }
.match-indicator.no-match { color: var(--ctp-red); }

/* Status display */
#status {
  margin-top: 20px;
  padding: 12px;
  background: var(--ctp-surface0);
  border-radius: 4px;
  font-size: 0.8125rem;
  white-space: pre-wrap;
  display: none;
  max-height: 500px;
  overflow-y: auto;
}

/* Logs display */
#logs {
  margin-top: 20px;
  padding: 12px;
  background: var(--ctp-surface0);
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: monospace;
  white-space: pre-wrap;
  max-height: 400px;
  overflow-y: auto;
  display: none;
}

/* Section divider */
.section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--ctp-surface1);
}

/* ============================================================================
   Inline Form Validation
   ============================================================================ */

.field-group {
  position: relative;
  margin-bottom: 1rem;
}

.field-group label {
  display: block;
  margin-bottom: 0.5rem;
}

.field-group input {
  margin-bottom: 0;
}

.field-group.invalid input {
  border-color: var(--ctp-red) !important;
  box-shadow: 0 0 0 3px rgba(var(--ctp-red-rgb), 0.25);
  animation: shake 0.3s ease;
}

.field-group .field-error {
  display: none;
  color: var(--ctp-red);
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.field-group.invalid .field-error {
  display: block;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ============================================================================
   Theme Toggle
   ============================================================================ */

.theme-toggle {
  position: relative;
  margin-left: 4px;
}

.theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: transparent;
  color: var(--ctp-subtext0);
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--ctp-surface1);
  padding: 0;
}

.theme-btn:hover {
  color: var(--ctp-text);
  background: var(--ctp-surface0);
}

.theme-btn svg {
  width: 18px;
  height: 18px;
}

.theme-btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(var(--ctp-lavender-rgb), 0.4);
}

.theme-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #1e1e2e;
  border: 1px solid #313244;
  border-radius: 8px;
  padding: 4px;
  min-width: 160px;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.theme-menu.open {
  display: block;
}

.theme-menu button {
  all: unset;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.8125rem;
  color: #cdd6f4;
  cursor: pointer;
  box-sizing: border-box;
}

.theme-menu button:hover {
  background: #313244;
}

.theme-menu button:focus-visible {
  box-shadow: 0 0 0 2px rgba(180, 190, 254, 0.4);
}

.theme-menu button.active {
  color: #f5c2e7;
  font-weight: 600;
}

.theme-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--ctp-surface2);
  flex-shrink: 0;
}

/* ============================================================================
   Shared Primitives — Audit Remediation
   ============================================================================ */

/* Accessible button reset — for converting div/span onclick to <button> */
.btn-reset {
  all: unset;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  font: inherit;
  color: inherit;
}

.btn-reset:focus-visible {
  box-shadow: 0 0 0 3px rgba(var(--ctp-lavender-rgb), 0.4);
  border-radius: 4px;
}

/* Product attribute badges — replacing emoji indicators */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1;
  vertical-align: middle;
}

.badge-search {
  background: rgba(var(--ctp-sapphire-rgb), 0.15);
  color: var(--ctp-sapphire);
}

.badge-substitute {
  background: rgba(var(--ctp-peach-rgb), 0.15);
  color: var(--ctp-peach);
  padding: 3px 5px;
}

.badge-eco {
  background: none;
  padding: 2px;
}

.badge-eco img {
  display: block;
}

.badge-substitute svg {
  display: block;
}

/* Status indicators — replacing emoji ✅ ❌ ⚠️ */
.status-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  line-height: 1;
  text-align: center;
  font-weight: 700;
  vertical-align: middle;
}

.status-success { color: var(--ctp-green); }
.status-success::before { content: "\2713"; }

.status-error { color: var(--ctp-red); }
.status-error::before { content: "\2717"; }

.status-warning { color: var(--ctp-yellow); }
.status-warning::before { content: "\26A0"; }
