/**
 * Carton Packaging Calculator Stylesheet (calc.css)
 * Externalized for Strict Content Security Policy (CSP) compliance (eliminating 'unsafe-inline').
 * Responsive dark/light layout, input field styling, and calculated result display cards.
 */

:root {
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
  --card-bg: rgba(30, 41, 59, 0.75);
  --card-border: rgba(255, 255, 255, 0.12);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-calc: #06b6d4;
  --accent-calc-glow: rgba(6, 182, 212, 0.25);
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
}

/* Light Theme Variables (Solar Slate Glassmorphism) */
html[data-theme="light"] {
  --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 50%, #eef2f6 100%);
  --card-bg: rgba(255, 255, 255, 0.88);
  --card-border: rgba(148, 163, 184, 0.35);
  --text-main: #0f172a;
  --text-muted: #475569;
}

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

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
}

.nav-header {
  width: 100%;
  max-width: 680px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.75rem;
}

.brand-link {
  color: var(--text-main);
  text-decoration: none;
  font-size: 1.15rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: opacity 0.2s;
}

.brand-link:hover {
  opacity: 0.85;
}

.btn-back {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 0.45rem 0.95rem;
  border-radius: 9999px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
}

.btn-back:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

.card-container {
  width: 100%;
  max-width: 680px;
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 1.25rem;
  padding: 2rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
  position: relative;
  overflow: hidden;
}

.card-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #06b6d4, #10b981, #3b82f6);
}

.header-section {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.icon-box {
  width: 52px;
  height: 52px;
  border-radius: 0.85rem;
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  flex-shrink: 0;
}

.title-group h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #38bdf8, #34d399);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-wrap: balance;
}

.title-group p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #cbd5e1;
  margin-bottom: 0.45rem;
}

select, input[type="number"] {
  width: 100%;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.65rem;
  color: var(--text-main);
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: all 0.2s ease;
}

select:focus, input[type="number"]:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

input[type="number"]:user-valid {
  border-color: rgba(16, 185, 129, 0.4);
}

input[type="number"]:user-invalid {
  border-color: rgba(239, 68, 68, 0.6);
  background-color: rgba(239, 68, 68, 0.04);
}

select option {
  background: #1e293b;
  color: #f8fafc;
}

.custom-pack-group {
  display: none;
  margin-top: 0.5rem;
  animation: fadeIn 0.2s ease;
}

.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.chip-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  border-radius: 9999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.775rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-btn:hover {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.3);
}

.btn-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

.btn-calc {
  flex: 1;
  background: linear-gradient(135deg, #06b6d4, #0284c7);
  color: #ffffff;
  border: none;
  border-radius: 0.65rem;
  padding: 0.85rem 1.25rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 14px rgba(6, 182, 212, 0.35);
  transition: all 0.2s ease;
}

.btn-calc:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.45);
}

.btn-reset {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  border-radius: 0.65rem;
  padding: 0.85rem 1rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-reset:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
}

/* Result Presentation */
.result-section {
  display: none;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 0.95rem;
  padding: 1.35rem;
  margin-top: 1.25rem;
  animation: fadeIn 0.3s ease;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.result-caption {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.result-highlight {
  font-size: 1.35rem;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: -0.01em;
}

.btn-copy {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #38bdf8;
  padding: 0.3rem 0.65rem;
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 0.775rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-copy:hover {
  background: rgba(56, 189, 248, 0.25);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
}

.stat-box {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0.65rem;
  padding: 0.75rem 0.85rem;
  text-align: center;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-val {
  font-size: 1.15rem;
  font-weight: 600;
  color: #f8fafc;
}

.stat-val.highlight-cartons {
  color: #34d399;
}

.stat-val.highlight-pax {
  color: #fbbf24;
}

.footer-note {
  text-align: center;
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 1.5rem;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 600px) {
  .card-container {
    padding: 1.35rem;
  }
  .title-group h1 {
    font-size: 1.35rem;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* -------------------------------------------------------------
   Solar Slate Light Theme Overrides (Carton Calculator)
   ------------------------------------------------------------- */
html[data-theme="light"] .brand-link {
  color: #0f172a;
}

html[data-theme="light"] .btn-back {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(148, 163, 184, 0.35);
  color: #475569;
}

html[data-theme="light"] .btn-back:hover {
  background: #ffffff;
  color: #0f172a;
  border-color: rgba(148, 163, 184, 0.6);
}

html[data-theme="light"] .card-container {
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .icon-box {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .title-group h1 {
  color: #0f172a;
}

html[data-theme="light"] .form-group label {
  color: #334155;
}

html[data-theme="light"] .form-control {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}

html[data-theme="light"] .stat-card {
  background: rgba(241, 245, 249, 0.85);
  border-color: rgba(148, 163, 184, 0.35);
}

html[data-theme="light"] .highlight-box {
  background: rgba(6, 182, 212, 0.1);
  border-color: rgba(6, 182, 212, 0.3);
}

html[data-theme="light"] .footer-note {
  color: #64748b;
}

/* -------------------------------------------------------------
   Modern Web Guidance: Accessible Motion Reduction
   ------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .btn-calc,
  .chip-btn,
  .btn-back {
    transform: none !important;
  }
  .custom-pack-group {
    animation: none !important;
  }
}