/* Global Styles & Variables */
:root {
  --color-text-primary: #1f2937;
  --color-text-secondary: #4b5563;
  --color-text-light: #6b7280;
  --color-bg-main: #f9fafb;
  --color-bg-card: #ffffff;
  --color-border: #d1d5db;
  --color-brand: #3b82f6; /* Brighter blue for a more modern feel */
  --color-brand-hover: #2563eb;
  --color-brand-light: #dbeafe;
  --color-brand-text: #1d4ed8;
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}

/* Base Container - No outer padding as requested */
.bf-calc {
  font-family: var(--font-sans);
  color: var(--color-text-primary);
  max-width: 1290px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

*, *::before, *::after {
  box-sizing: inherit;
}

/* Header */
.bf-calc-header {
  text-align: center;
  margin-bottom: 2rem;
}

.bf-calc-h2 {
  font-size: 1.875rem;
  line-height: 2.25rem;
  font-weight: 600;
  color: #111827;
}

.bf-calc-p {
  margin-top: 0.5rem;
  font-size: 1.125rem;
  line-height: 1.75rem;
  color: var(--color-text-secondary);
}

/* Main Layout */
.bf-calc-main {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

/* Card */
.bf-calc-card {
  background-color: var(--color-bg-card);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  height: 100%;
}

.bf-calc-card-content {
  padding: 1.5rem;
}

.bf-calc-h3 {
  font-size: 1.25rem;
  line-height: 1.75rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 1.5rem;
}

/* Form Styles */
.bf-calc-form-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.bf-calc-toggle-group {
  display: flex;
  gap: 0.5rem;
}

.bf-calc-toggle-button {
  width: 100%;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
  background-color: #e5e7eb;
  color: #374151;
}

.bf-calc-toggle-button:hover {
  background-color: #d1d5db;
}

.bf-calc-toggle-button.active {
  background-color: var(--color-brand);
  color: #ffffff;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.bf-calc-toggle-button.active:hover {
    background-color: var(--color-brand-hover);
}

.bf-calc-input-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.bf-calc-input-wrapper {
  display: flex;
  flex-direction: column;
}

.bf-calc-label {
  display: block;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.25rem;
}

.bf-calc-input {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background-color: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: 0.375rem;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.bf-calc-input:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

.bf-calc-help-text {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  line-height: 1rem;
  color: var(--color-text-light);
}

/* Results Display */
.bf-calc-results-placeholder {
  text-align: center;
  padding: 2.5rem 0;
  color: var(--color-text-light);
}

.bf-calc-results-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.bf-calc-results-summary {
  text-align: center;
}

.bf-calc-results-label {
  color: var(--color-text-secondary);
}

.bf-calc-results-value {
  font-size: 3rem;
  line-height: 1;
  font-weight: 700;
  color: var(--color-brand);
  margin: 0.5rem 0;
}

.bf-calc-results-category {
  font-size: 1.125rem;
  line-height: 1.75rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  display: inline-block;
  border-radius: 9999px;
  background-color: var(--color-brand-light);
  color: var(--color-brand-text);
}

/* Body Fat Chart */
.bf-chart-container {
    width: 100%;
}
.bf-chart-pointer-wrapper {
    position: relative;
    height: 3rem;
}
.bf-chart-pointer {
    position: absolute;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: left 0.5s ease-in-out;
    transform: translateX(-50%);
}
.bf-chart-pointer-label {
    background-color: #1f2937;
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
}
.bf-chart-pointer-arrow {
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #1f2937;
}
.bf-chart-bar {
    display: flex;
    height: 1rem;
    border-radius: 9999px;
    overflow: hidden;
}
.bf-chart-segment {
    height: 100%;
    transition: width 0.5s ease-in-out;
}
.bf-chart-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    margin-top: 0.5rem;
    padding: 0 0.25rem;
}
.bf-chart-labels span {
    text-align: center;
    flex-basis: 0;
    flex-grow: 1;
    white-space: nowrap;
}

/* Mass Breakdown Grid */
.bf-calc-mass-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  text-align: center;
  background-color: #f3f4f6;
  padding: 1rem;
  border-radius: 0.5rem;
}

.bf-calc-mass-label {
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--color-text-secondary);
}

.bf-calc-mass-value {
  font-size: 1.125rem;
  line-height: 1.75rem;
  font-weight: 600;
}

/* Action Buttons */
.bf-calc-actions {
  display: flex;
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e5e7eb;
}

.bf-calc-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
  position: relative;
}

.bf-calc-button:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.bf-calc-button-icon {
  height: 1.25rem;
  width: 1.25rem;
  margin-right: 0.5rem;
}

.bf-calc-button-primary {
  color: #ffffff;
  background-color: var(--color-brand);
  border: 1px solid transparent;
}

.bf-calc-button-primary:hover {
  background-color: var(--color-brand-hover);
}

.bf-calc-button-secondary {
  color: #374151;
  background-color: #ffffff;
  border: 1px solid var(--color-border);
}

.bf-calc-button-secondary:hover {
  background-color: #f9fafb;
}

/* Responsive Styles */
@media (min-width: 768px) {
  .bf-calc-input-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .bf-calc-main {
    grid-template-columns: repeat(5, 1fr);
  }
  .bf-calc-form-container {
    grid-column: span 3 / span 3;
  }
  .bf-calc-results-container {
    grid-column: span 2 / span 2;
  }
}

@media (min-width: 640px) {
    .bf-calc-h2 {
        font-size: 2.25rem;
        line-height: 2.5rem;
    }
}

/* Print Styles */
@media print {
  body > *:not(#printable-area) {
    display: none !important;
  }
  #printable-area {
    display: block !important;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
  }
  #printable-area > * {
    display: block !important;
    visibility: visible !important;
    box-shadow: none !important;
    border: 1px solid #ccc;
  }
  .bf-calc-actions {
    display: none !important;
  }
}