/* ==========================================================================
   Textile & Box Rate Calculator - Responsive Architecture
   Flawless spacing across Mobile (320px+), Tablet, and Desktop (1080p/4K)
   Zero Overlapping · Clean Typography · Touch Targets (44px+)
   ========================================================================== */

:root {
  /* Color Tokens - Modern Light */
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-card-hover: #fcfdfe;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-subtle: #e2e8f0;
  --border-hover: #cbd5e1;

  /* Brand Accents */
  --indigo-50: #eef2ff;
  --indigo-100: #e0e7ff;
  --indigo-500: #6366f1;
  --indigo-600: #4f46e5;
  --indigo-700: #4338ca;

  /* Component Identity Accents */
  --shirting-accent: #0284c7;
  --shirting-bg: #f0f9ff;
  --shirting-border: #bae6fd;
  
  --suiting-accent: #7c3aed;
  --suiting-bg: #f5f3ff;
  --suiting-border: #ddd6fe;

  --box-accent: #d97706;
  --box-bg: #fffbeb;
  --box-border: #fde68a;

  --gift-accent: #e11d48;
  --gift-bg: #fff1f2;
  --gift-border: #fecdd3;

  --emerald-600: #059669;
  --emerald-500: #10b981;
  --emerald-50: #ecfdf5;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 10px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 20px -3px rgba(15, 23, 42, 0.08);

  /* Radii */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Typography */
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', system-ui, -apple-system, sans-serif;
}

/* Reset & Box-Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  box-sizing: border-box;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-body);
  line-height: 1.4;
  overflow-x: hidden;
  overflow-y: auto; /* Natural, smooth scrolling so nothing ever collides */
  -webkit-font-smoothing: antialiased;
}

/* Ambient glow */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
}

.glow-1 {
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, #e0e7ff 0%, #c7d2fe 100%);
  top: -80px;
  left: -80px;
}

.glow-2 {
  width: 360px;
  height: 360px;
  background: radial-gradient(circle, #dcfce7 0%, #bbf7d0 100%);
  bottom: -60px;
  right: -80px;
}

/* App Wrapper: Sits comfortably with natural padding */
.app-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 12px 14px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Header Bar */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: #ffffff;
  border: 1.2px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.app-title {
  font-family: var(--font-heading);
  font-size: clamp(0.98rem, 2.5vw, 1.35rem);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pro-tag {
  font-family: var(--font-heading);
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--indigo-700);
  background: var(--indigo-50);
  border: 1px solid var(--indigo-100);
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.app-tagline {
  font-size: clamp(0.68rem, 1.5vw, 0.78rem);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.live-indicator-pill {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--emerald-600);
  background: var(--emerald-50);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-full);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background-color: var(--emerald-500);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
  animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.7; }
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--bg-card-subtle);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* Dashboard Layout */
.dashboard-layout {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Selectors Area */
.selectors-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Panel Card */
.panel-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.2s ease;
}

.panel-card:hover {
  border-color: var(--border-hover);
}

.card-shirting:focus-within { border-color: var(--shirting-accent); box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.12); }
.card-suiting:focus-within  { border-color: var(--suiting-accent);  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.12); }
.card-box:focus-within      { border-color: var(--box-accent);      box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.12); }
.card-gift:focus-within     { border-color: var(--gift-accent);     box-shadow: 0 0 0 2px rgba(225, 29, 72, 0.12); }

/* Panel Header */
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.68rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.num-shirting { background: var(--shirting-bg); color: var(--shirting-accent); border: 1px solid var(--shirting-border); }
.num-suiting  { background: var(--suiting-bg);  color: var(--suiting-accent);  border: 1px solid var(--suiting-border); }
.num-box      { background: var(--box-bg);      color: var(--box-accent);      border: 1px solid var(--box-border); }
.num-gift     { background: var(--gift-bg);     color: var(--gift-accent);     border: 1px solid var(--gift-border); }

.panel-name {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Badges */
.badge {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-shirting { background: var(--shirting-bg); color: var(--shirting-accent); border: 1px solid var(--shirting-border); }
.badge-suiting  { background: var(--suiting-bg);  color: var(--suiting-accent);  border: 1px solid var(--suiting-border); }
.badge-box      { background: var(--box-bg);      color: var(--box-accent);      border: 1px solid var(--box-border); }
.badge-gift     { background: var(--gift-bg);     color: var(--gift-accent);     border: 1px solid var(--gift-border); }

/* Dedicated Filter Row for Shirting (Never collides with title!) */
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.filter-row::-webkit-scrollbar { display: none; }

.filter-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.mini-chips {
  display: flex;
  gap: 5px;
  flex-wrap: nowrap;
}

.m-chip {
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.m-chip:hover {
  background: #ffffff;
  color: var(--indigo-600);
}

.m-chip.active {
  background: var(--indigo-600);
  border-color: var(--indigo-600);
  color: #ffffff;
}

/* Select Container & Modern Custom Arrow */
.select-container {
  position: relative;
  width: 100%;
}

.compact-select {
  width: 100%;
  height: 44px; /* Touch target >= 44px */
  appearance: none;
  -webkit-appearance: none;
  background-color: #ffffff;
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0 34px 0 12px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.compact-select:hover {
  border-color: var(--border-hover);
}

.compact-select optgroup {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--indigo-700);
  background: #f8fafc;
}

.compact-select option {
  font-family: var(--font-body);
  font-weight: 500;
  padding: 8px;
}

.custom-arrow {
  position: absolute;
  right: 14px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-secondary);
  border-bottom: 2px solid var(--text-secondary);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

/* Result Strip */
.result-strip {
  background: var(--bg-card-subtle);
  border-radius: var(--radius-xs);
  padding: 7px 10px;
  min-height: 34px;
  display: flex;
  align-items: center;
  font-size: 0.82rem;
  border: 1px solid transparent;
  transition: all 0.25s ease;
}

.result-strip.strip-active-shirting { background: var(--shirting-bg); border-color: var(--shirting-border); }
.result-strip.strip-active-suiting  { background: var(--suiting-bg);  border-color: var(--suiting-border); }
.result-strip.strip-active-box      { background: var(--box-bg);      border-color: var(--box-border); }
.result-strip.strip-active-gift     { background: var(--gift-bg);     border-color: var(--gift-border); }

.strip-empty {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-style: italic;
}

.strip-filled {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap; /* Wraps gracefully on 320px narrow screens */
}

.strip-filled.hidden {
  display: none;
}

.strip-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 65%;
}

.strip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.strip-name {
  font-weight: 600;
  color: var(--text-primary);
  text-transform: capitalize;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.strip-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.strip-formula {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-family: var(--font-heading);
  background: #ffffff;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.strip-total {
  font-family: var(--font-heading);
  font-weight: 800;
  color: var(--emerald-600);
  font-size: 0.9rem;
  font-feature-settings: 'tnum' 1;
  white-space: nowrap;
}

/* Summary Column & Receipt Card */
.summary-column {
  width: 100%;
}

.summary-card {
  background: #ffffff;
  border: 1.5px solid #e0e7ff;
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.summary-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.summary-title-group {
  display: flex;
  flex-direction: column;
}

.summary-kicker {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--emerald-600);
}

.summary-heading {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.status-pill {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--indigo-700);
  background: var(--indigo-50);
  border: 1px solid var(--indigo-100);
  padding: 3px 9px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

/* Component Breakdown Grid (2x2 grid fits cleanly on any screen >= 320px) */
.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.b-tile {
  background: var(--bg-card-subtle);
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: all 0.2s ease;
}

.tile-shirting:hover { background: var(--shirting-bg); border-color: var(--shirting-border); }
.tile-suiting:hover  { background: var(--suiting-bg);  border-color: var(--suiting-border); }
.tile-box:hover      { background: var(--box-bg);      border-color: var(--box-border); }
.tile-gift:hover     { background: var(--gift-bg);     border-color: var(--gift-border); }

.b-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.b-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.d-shirting { background: var(--shirting-accent); }
.d-suiting  { background: var(--suiting-accent); }
.d-box      { background: var(--box-accent); }
.d-gift     { background: var(--gift-accent); }

.b-val {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-primary);
  font-feature-settings: 'tnum' 1;
  margin-top: 2px;
}

/* Subtotal Bar */
.subtotal-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: var(--radius-xs);
  border: 1px dashed var(--border-subtle);
}

.subtotal-left {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

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

.subtotal-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.subtotal-amount {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--indigo-700);
  font-feature-settings: 'tnum' 1;
}

/* Hero Final Rate Box */
.hero-total-box {
  background: linear-gradient(135deg, #047857 0%, #065f46 100%);
  border-radius: var(--radius-sm);
  padding: 16px;
  color: #ffffff;
  text-align: center;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.28);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  gap: 2px;
}

.hero-bg-orb {
  position: absolute;
  top: -30px;
  right: -30px;
  width: 90px;
  height: 90px;
  background: radial-gradient(circle, rgba(255,255,255,0.18) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.hero-top-meta {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.68rem;
  color: #a7f3d0;
  margin-bottom: 4px;
}

.hero-secure-tag {
  font-weight: 600;
}

.hero-calc-status {
  font-size: 0.65rem;
  opacity: 0.9;
}

.hero-total-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #d1fae5;
}

.hero-total-number {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  font-weight: 800;
  line-height: 1.1;
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  font-feature-settings: 'tnum' 1;
}

.hero-footer-note {
  font-size: 0.68rem;
  color: #a7f3d0;
  margin-top: 4px;
}

/* Actions */
.action-row {
  display: flex;
  gap: 8px;
}

.btn-copy {
  flex: 1;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 700;
  color: #ffffff;
  background: var(--indigo-600);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
  transition: all 0.2s ease;
}

.btn-copy:hover:not(:disabled) {
  background: var(--indigo-700);
}

.btn-copy:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-share {
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 16px;
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  background: #ffffff;
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-share:hover {
  background: var(--bg-card-subtle);
  border-color: var(--border-hover);
}

/* Toast */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-30px);
  background: #0f172a;
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: var(--radius-full);
  box-shadow: 0 10px 20px rgba(0,0,0,0.15);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 999;
}

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

/* Animations */
@keyframes numberPop {
  0% { transform: scale(0.96); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.pop-animate {
  animation: numberPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   DESKTOP & TABLET ENHANCEMENTS (>= 900px)
   Balanced 2-Column Dashboard with Sticky Calculation Studio
   ========================================================================== */

@media (min-width: 900px) {
  .app-wrapper {
    padding: 20px 24px 40px;
    gap: 20px;
  }

  .live-indicator-pill {
    display: inline-flex;
  }

  .dashboard-layout {
    display: grid;
    grid-template-columns: 1.18fr 0.82fr;
    gap: 24px;
    align-items: start;
  }

  .selectors-column {
    gap: 14px;
  }

  .summary-column {
    position: sticky;
    top: 20px;
  }

  .summary-card {
    padding: 20px;
    gap: 16px;
  }

  .breakdown-grid {
    gap: 10px;
  }

  .b-tile {
    padding: 10px 12px;
  }

  .b-val {
    font-size: 1.1rem;
  }

  .hero-total-box {
    padding: 20px;
  }

  .hero-total-number {
    font-size: 2.6rem;
  }

  .btn-copy, .btn-share {
    height: 46px;
  }
}

/* Ultra-Wide Monitors (>= 1280px) */
@media (min-width: 1280px) {
  .app-wrapper {
    max-width: 1240px;
  }
  
  .dashboard-layout {
    grid-template-columns: 1.25fr 0.75fr;
    gap: 32px;
  }
}
