/* ============================================
   SL Protein Calculator — Scoped Styles
   All classes prefixed with .sl-protein-
   ============================================ */

:root {
  --slp-primary: #1a7a4c;
  --slp-primary-dark: #145e3a;
  --slp-primary-light: #e8f5ee;
  --slp-accent: #f59e0b;
  --slp-accent-light: #fef3c7;
  --slp-danger: #dc2626;
  --slp-danger-light: #fef2f2;
  --slp-text: #1f2937;
  --slp-text-light: #6b7280;
  --slp-bg: #f8fafc;
  --slp-card: #ffffff;
  --slp-border: #e5e7eb;
  --slp-radius: 12px;
  --slp-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --slp-shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
  --slp-font: 'Segoe UI', 'Noto Sans Sinhala', 'Iskoola Pota', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Reset & Base */
.sl-protein-wrapper {
  font-family: var(--slp-font);
  color: var(--slp-text);
  line-height: 1.6;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  box-sizing: border-box;
}

.sl-protein-wrapper *, .sl-protein-wrapper *::before, .sl-protein-wrapper *::after {
  box-sizing: border-box;
}

/* Header */
.sl-protein-header {
  text-align: center;
  margin-bottom: 24px;
}

.sl-protein-lang-toggle {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.sl-protein-lang-label {
  font-size: 14px;
  color: var(--slp-text-light);
}

.sl-protein-lang-btn {
  padding: 6px 16px;
  border: 2px solid var(--slp-border);
  background: var(--slp-card);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--slp-font);
  transition: all 0.2s;
  color: var(--slp-text);
}

.sl-protein-lang-btn:first-of-type {
  border-radius: 6px 0 0 6px;
  border-right: 1px solid var(--slp-border);
}

.sl-protein-lang-btn:last-of-type {
  border-radius: 0 6px 6px 0;
  border-left: 1px solid var(--slp-border);
}

.sl-protein-lang-btn.active {
  background: var(--slp-primary);
  color: #fff;
  border-color: var(--slp-primary);
}

.sl-protein-title {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--slp-primary-dark);
}

.sl-protein-subtitle {
  font-size: 15px;
  color: var(--slp-text-light);
  margin: 0 0 4px;
}

.sl-protein-powered {
  font-size: 12px;
  color: var(--slp-text-light);
  opacity: 0.8;
}

/* Cards */
.sl-protein-card {
  background: var(--slp-card);
  border-radius: var(--slp-radius);
  box-shadow: var(--slp-shadow);
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--slp-border);
}

.sl-protein-card-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--slp-text);
}

/* Form Elements */
.sl-protein-form-group {
  margin-bottom: 16px;
}

.sl-protein-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--slp-text);
}

.sl-protein-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--slp-border);
  border-radius: 8px;
  font-size: 16px;
  font-family: var(--slp-font);
  transition: border-color 0.2s;
  background: var(--slp-card);
  color: var(--slp-text);
}

.sl-protein-input:focus {
  outline: none;
  border-color: var(--slp-primary);
  box-shadow: 0 0 0 3px rgba(26, 122, 76, 0.15);
}

.sl-protein-input.error {
  border-color: var(--slp-danger);
}

.sl-protein-error-msg {
  color: var(--slp-danger);
  font-size: 13px;
  margin-top: 4px;
  display: none;
}

.sl-protein-error-msg.show {
  display: block;
}

.sl-protein-select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--slp-border);
  border-radius: 8px;
  font-size: 16px;
  font-family: var(--slp-font);
  background: var(--slp-card);
  color: var(--slp-text);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' fill='none' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.sl-protein-select:focus {
  outline: none;
  border-color: var(--slp-primary);
  box-shadow: 0 0 0 3px rgba(26, 122, 76, 0.15);
}

/* Inline groups */
.sl-protein-row {
  display: flex;
  gap: 12px;
}

.sl-protein-row .sl-protein-form-group {
  flex: 1;
}

/* Radio cards for gender */
.sl-protein-radio-group {
  display: flex;
  gap: 8px;
}

.sl-protein-radio-card {
  flex: 1;
  position: relative;
}

.sl-protein-radio-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.sl-protein-radio-card label {
  display: block;
  padding: 12px 16px;
  border: 2px solid var(--slp-border);
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  transition: all 0.2s;
}

.sl-protein-radio-card input[type="radio"]:checked + label {
  border-color: var(--slp-primary);
  background: var(--slp-primary-light);
  color: var(--slp-primary-dark);
}

.sl-protein-radio-card input[type="radio"]:focus-visible + label {
  box-shadow: 0 0 0 3px rgba(26, 122, 76, 0.15);
}

/* Advanced toggle */
.sl-protein-advanced-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--slp-primary);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--slp-font);
  font-weight: 500;
  padding: 8px 0;
  margin-bottom: 8px;
}

.sl-protein-advanced-toggle .arrow {
  transition: transform 0.2s;
  display: inline-block;
  font-size: 10px;
  width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  flex-shrink: 0;
}

.sl-protein-advanced-toggle.open .arrow {
  transform: rotate(90deg);
}

.sl-protein-advanced-section {
  display: none;
  padding-top: 4px;
}

.sl-protein-advanced-section.show {
  display: block;
}

.sl-protein-helper {
  font-size: 12px;
  color: var(--slp-text-light);
  margin-top: 4px;
}

/* Buttons */
.sl-protein-btn {
  display: block;
  width: 100%;
  padding: 16px 24px;
  border: none;
  border-radius: 10px;
  font-size: 17px;
  font-weight: 600;
  font-family: var(--slp-font);
  cursor: pointer;
  transition: all 0.2s;
  min-height: 48px;
}

.sl-protein-btn-primary {
  background: var(--slp-primary);
  color: #fff;
}

.sl-protein-btn-primary:hover {
  background: var(--slp-primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--slp-shadow-lg);
}

.sl-protein-btn-primary:active {
  transform: translateY(0);
}

.sl-protein-btn-secondary {
  background: transparent;
  color: var(--slp-text-light);
  border: 2px solid var(--slp-border);
  font-size: 14px;
  padding: 10px 16px;
}

.sl-protein-btn-secondary:hover {
  border-color: var(--slp-text-light);
}

.sl-protein-btn-row {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.sl-protein-btn-row .sl-protein-btn {
  flex: 1;
}

/* ====== RESULTS ====== */
.sl-protein-results {
  display: none;
}

.sl-protein-results.show {
  display: block;
  animation: slpFadeIn 0.4s ease;
}

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

/* Big number display */
.sl-protein-big-result {
  text-align: center;
  padding: 32px 24px;
  background: linear-gradient(135deg, var(--slp-primary), var(--slp-primary-dark));
  border-radius: var(--slp-radius);
  color: #fff;
  margin-bottom: 20px;
}

.sl-protein-big-result .sl-protein-result-label {
  font-size: 14px;
  opacity: 0.9;
  margin-bottom: 4px;
}

.sl-protein-big-number {
  font-size: 64px;
  font-weight: 700;
  line-height: 1.1;
}

.sl-protein-big-unit {
  font-size: 22px;
  font-weight: 400;
  opacity: 0.85;
}

.sl-protein-range-text {
  font-size: 15px;
  opacity: 0.85;
  margin-top: 8px;
}

.sl-protein-per-meal-text {
  font-size: 14px;
  opacity: 0.8;
  margin-top: 12px;
  line-height: 1.4;
}

.sl-protein-notes {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.sl-protein-note-tag {
  display: inline-block;
  padding: 4px 10px;
  background: rgba(255,255,255,0.2);
  border-radius: 20px;
  font-size: 12px;
}

/* Meter */
.sl-protein-meter-wrap {
  margin-bottom: 20px;
}

.sl-protein-meter {
  height: 28px;
  border-radius: 14px;
  background: #e5e7eb;
  overflow: hidden;
  position: relative;
  margin: 12px 0 8px;
}

.sl-protein-meter-fill {
  height: 100%;
  border-radius: 14px;
  transition: width 1.5s ease;
  width: 0;
  position: relative;
}

.sl-protein-meter-zones {
  display: flex;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.sl-protein-meter-zone {
  height: 100%;
  opacity: 0.3;
}

.sl-protein-meter-zone.zone-low { background: #ef4444; flex: 0.8; }
.sl-protein-meter-zone.zone-adequate { background: #eab308; flex: 0.4; }
.sl-protein-meter-zone.zone-optimal { background: #22c55e; flex: 0.8; }
.sl-protein-meter-zone.zone-high { background: #3b82f6; flex: 0.4; }
.sl-protein-meter-zone.zone-excessive { background: #f97316; flex: 0.6; }

.sl-protein-meter-needle {
  position: absolute;
  top: -4px;
  width: 4px;
  height: 36px;
  background: var(--slp-text);
  border-radius: 2px;
  transition: left 1.5s ease;
  z-index: 2;
  left: 0;
}

.sl-protein-meter-labels {
  display: flex;
  font-size: 11px;
  color: var(--slp-text-light);
}

.sl-protein-meter-labels span {
  text-align: center;
}

.sl-protein-meter-labels span:nth-child(1) { flex: 0.8; }
.sl-protein-meter-labels span:nth-child(2) { flex: 0.4; }
.sl-protein-meter-labels span:nth-child(3) { flex: 0.8; }
.sl-protein-meter-labels span:nth-child(4) { flex: 0.4; }
.sl-protein-meter-labels span:nth-child(5) { flex: 0.6; }

.sl-protein-meter-value {
  text-align: center;
  font-size: 13px;
  color: var(--slp-text-light);
  margin-top: 4px;
}

/* Gap analysis */
.sl-protein-gap-card {
  border-left: 4px solid var(--slp-accent);
}

.sl-protein-gap-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--slp-border);
}

.sl-protein-gap-stat:last-of-type {
  border-bottom: none;
}

.sl-protein-gap-stat-label {
  font-size: 14px;
  color: var(--slp-text-light);
}

.sl-protein-gap-stat-value {
  font-size: 20px;
  font-weight: 700;
}

.sl-protein-gap-stat-value.highlight {
  color: var(--slp-primary);
}

.sl-protein-gap-stat-value.gap-value {
  color: var(--slp-danger);
}

.sl-protein-gap-severity {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
}

.sl-protein-gap-severity.low { background: #dcfce7; color: #166534; }
.sl-protein-gap-severity.moderate { background: var(--slp-accent-light); color: #92400e; }
.sl-protein-gap-severity.high { background: #fef2f2; color: #991b1b; }
.sl-protein-gap-severity.veryHigh { background: #fef2f2; color: #7f1d1d; }

.sl-protein-gap-warning {
  margin-top: 12px;
  font-size: 13px;
  color: var(--slp-text-light);
  font-style: italic;
}

.sl-protein-gap-source {
  font-size: 12px;
  color: var(--slp-text-light);
  opacity: 0.7;
  margin-top: 4px;
}

/* Food table */
.sl-protein-food-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.sl-protein-food-table th {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 2px solid var(--slp-border);
  font-weight: 600;
  font-size: 13px;
  color: var(--slp-text-light);
}

.sl-protein-food-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--slp-border);
}

.sl-protein-food-table tr:last-child td {
  border-bottom: none;
}

.sl-protein-food-category {
  font-weight: 600;
  color: var(--slp-primary);
  padding: 12px 8px 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Meal plan */
.sl-protein-meal-plan {
  margin-top: 20px;
}

.sl-protein-meal-group {
  margin-bottom: 16px;
}

.sl-protein-meal-label {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 6px;
  color: var(--slp-primary-dark);
}

.sl-protein-meal-items {
  padding-left: 16px;
}

.sl-protein-meal-item {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 14px;
}

.sl-protein-meal-item-protein {
  font-weight: 600;
  color: var(--slp-primary);
  white-space: nowrap;
  margin-left: 8px;
}

.sl-protein-meal-subtotal {
  text-align: right;
  font-size: 13px;
  color: var(--slp-text-light);
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed var(--slp-border);
}

.sl-protein-meal-total {
  display: flex;
  justify-content: space-between;
  padding: 14px 0;
  margin-top: 8px;
  border-top: 2px solid var(--slp-primary);
  font-weight: 700;
  font-size: 16px;
}

.sl-protein-meal-total-value {
  color: var(--slp-primary);
}

.sl-protein-target-badge {
  display: inline-block;
  background: var(--slp-primary-light);
  color: var(--slp-primary-dark);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 8px;
}

/* Plan tabs */
.sl-protein-plan-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 4px;
}

.sl-protein-plan-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--slp-font);
  font-weight: 500;
  color: var(--slp-text-light);
  transition: all 0.2s;
}

.sl-protein-plan-tab.active {
  background: var(--slp-card);
  color: var(--slp-text);
  box-shadow: var(--slp-shadow);
}

/* Budget table */
.sl-protein-budget-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 16px;
}

.sl-protein-budget-table th {
  text-align: left;
  padding: 8px;
  border-bottom: 2px solid var(--slp-border);
  font-size: 13px;
  font-weight: 600;
  color: var(--slp-text-light);
}

.sl-protein-budget-table td {
  padding: 8px;
  border-bottom: 1px solid var(--slp-border);
}

.sl-protein-budget-rank {
  font-weight: 700;
  color: var(--slp-primary);
}

/* Science section */
.sl-protein-science-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
}

.sl-protein-science-list li {
  padding: 6px 0;
  font-size: 14px;
  padding-left: 20px;
  position: relative;
}

.sl-protein-science-list li::before {
  content: "\2713";
  position: absolute;
  left: 0;
  color: var(--slp-primary);
  font-weight: 700;
}

/* Share */
.sl-protein-share-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sl-protein-share-btn {
  flex: 1;
  min-width: 120px;
  padding: 12px 16px;
  border: 2px solid var(--slp-border);
  background: var(--slp-card);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--slp-font);
  font-weight: 500;
  text-align: center;
  transition: all 0.2s;
  color: var(--slp-text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.sl-protein-share-btn:hover {
  border-color: var(--slp-primary);
  color: var(--slp-primary);
}

.sl-protein-share-btn.whatsapp:hover {
  border-color: #25d366;
  color: #25d366;
}

.sl-protein-share-btn.facebook:hover {
  border-color: #1877f2;
  color: #1877f2;
}

.sl-protein-share-btn.copied {
  border-color: var(--slp-primary);
  background: var(--slp-primary-light);
  color: var(--slp-primary-dark);
}

/* Collapsible sections */
.sl-protein-collapsible {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sl-protein-collapsible::after {
  content: "\25BC";
  font-size: 12px;
  color: var(--slp-text-light);
  transition: transform 0.2s;
}

.sl-protein-collapsible.collapsed::after {
  transform: rotate(-90deg);
}

.sl-protein-collapsible-content {
  overflow: hidden;
  max-height: 2000px;
  transition: max-height 0.3s ease;
}

.sl-protein-collapsible-content.collapsed {
  max-height: 0;
}

/* FAQ */
.sl-protein-faq-item {
  border-bottom: 1px solid var(--slp-border);
  padding: 12px 0;
}

.sl-protein-faq-item:last-child {
  border-bottom: none;
}

.sl-protein-faq-q {
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.sl-protein-faq-q::after {
  content: "+";
  font-size: 20px;
  color: var(--slp-text-light);
  flex-shrink: 0;
  transition: transform 0.2s;
}

.sl-protein-faq-q.open::after {
  content: "\2212";
}

.sl-protein-faq-a {
  display: none;
  padding-top: 8px;
  font-size: 14px;
  color: var(--slp-text-light);
  line-height: 1.6;
}

.sl-protein-faq-a.show {
  display: block;
}

/* Disclaimer */
.sl-protein-disclaimer {
  font-size: 12px;
  color: var(--slp-text-light);
  line-height: 1.5;
  padding: 16px;
  background: #f9fafb;
  border-radius: 8px;
  margin-top: 20px;
  border: 1px solid var(--slp-border);
}

/* References */
.sl-protein-references {
  margin-top: 16px;
}

.sl-protein-references ol {
  padding-left: 20px;
  margin: 8px 0 0;
}

.sl-protein-references li {
  font-size: 12px;
  color: var(--slp-text-light);
  padding: 3px 0;
  line-height: 1.4;
}

/* ====== MOBILE ====== */
@media (max-width: 768px) {
  .sl-protein-wrapper {
    padding: 12px;
  }

  .sl-protein-title {
    font-size: 22px;
  }

  .sl-protein-big-number {
    font-size: 52px;
  }

  .sl-protein-card {
    padding: 16px;
  }

  .sl-protein-row {
    flex-direction: column;
    gap: 0;
  }

  .sl-protein-radio-group {
    flex-direction: row;
  }

  .sl-protein-share-buttons {
    flex-direction: column;
  }

  .sl-protein-share-btn {
    min-width: auto;
  }

  .sl-protein-plan-tabs {
    flex-wrap: wrap;
  }
}

/* Sticky calculate button on mobile */
@media (max-width: 600px) {
  .sl-protein-sticky-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: var(--slp-card);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 100;
    display: none;
  }

  .sl-protein-sticky-bar.show {
    display: block;
  }

  .sl-protein-results.show ~ .sl-protein-sticky-bar {
    display: none;
  }

  .sl-protein-wrapper {
    padding-bottom: 80px;
  }
}

@media (min-width: 601px) {
  .sl-protein-sticky-bar {
    display: none !important;
  }
}

/* Print styles */
@media print {
  .sl-protein-share-buttons,
  .sl-protein-lang-toggle,
  .sl-protein-btn-row,
  .sl-protein-sticky-bar {
    display: none !important;
  }
}
