:root {
  --primary-color: #007bff;
  --primary-hover: #0056b3;
  --secondary-color: #6c757d;
  --bg-color: #ffffff;
  --surface-color: #f8f9fa;
  --border-color: #dee2e6;
  --text-color: #212529;
  --label-color: #495057;
  --success-color: #28a745;
  --warning-color: #ffc107;
  --danger-color: #dc3545;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  --border-radius: 8px;
  --box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.water-deficit-calculator {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  padding: 2rem;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  max-width: 700px;
  margin: 2rem auto;
  color: var(--text-color);
}

/* --- Form & Inputs --- */
#deficitForm fieldset {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  background-color: #fff;
}

#deficitForm legend {
  font-weight: 600;
  color: var(--primary-color);
  padding: 0 0.5rem;
  margin-left: 1rem;
  font-size: 1.1rem;
}

.form-row {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.form-row .form-group {
  flex: 1 1 200px;
}

.form-group {
  margin-bottom: 1.25rem;
}
.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: flex;
  align-items: center;
  font-weight: 500;
  color: var(--label-color);
  margin-bottom: 0.5rem;
}

.input-group {
  display: flex;
  align-items: center;
}

.input-group input, .input-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  background-color: #fff;
}
.input-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

.input-group select {
  border-left: none;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  background-color: var(--surface-color);
  width: auto;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 16px 12px;
}

.input-group input[type="number"] {
  border-right: none;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

.input-group .unit-text {
  padding: 0.75rem;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-left: none;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  color: var(--label-color);
  white-space: nowrap;
}

.radio-group {
  display: flex;
  gap: 1rem;
  align-items: center;
}
.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 0.75rem 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
    background-color: #fff;
}
.radio-label:hover {
    background-color: var(--surface-color);
    border-color: #adb5bd;
}
.radio-label:has(input:checked) {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}
.radio-label:has(input:checked):hover {
    background-color: var(--primary-hover);
}
.radio-label input {
    display: none;
}

.actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.calculate-btn, .reset-btn {
  flex-grow: 1;
  padding: 0.85rem 1.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}
.calculate-btn {
  background-color: var(--primary-color);
  color: white;
}
.calculate-btn:hover {
  background-color: var(--primary-hover);
}
.reset-btn {
  background-color: var(--surface-color);
  color: var(--secondary-color);
  border: 1px solid var(--border-color);
}
.reset-btn:hover {
  background-color: #e2e6ea;
}
.calculate-btn:active, .reset-btn:active {
  transform: translateY(1px);
}

/* --- Results Section --- */
.results-section {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px dashed var(--border-color);
  animation: fadeIn 0.5s ease-in-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.results-section h3 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--primary-color);
  font-size: 1.5rem;
}

.results-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  justify-content: space-around;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background-color: var(--surface-color);
  border-radius: var(--border-radius);
}

.result-main, .severity-indicator {
  flex: 1 1 250px;
  text-align: center;
}

.result-label {
  display: block;
  font-size: 1rem;
  color: var(--label-color);
  margin-bottom: 0.5rem;
}

.result-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

.bar-container {
  width: 100%;
  background-color: #e9ecef;
  border-radius: 20px;
  height: 25px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.bar {
  height: 100%;
  border-radius: 20px;
  transition: width 0.5s ease-out, background-color 0.5s ease-out;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
}

.results-details ul {
  list-style: none;
  padding: 1.5rem;
  margin: 0;
  background-color: var(--surface-color);
  border-radius: var(--border-radius);
}

.results-details li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
}
.results-details li:last-child {
  border-bottom: none;
}
.results-details strong {
  color: var(--text-color);
}

.results-insights {
  margin-top: 2rem;
}
.results-insights h4, .results-details h4 {
    margin-bottom: 1rem;
    color: var(--text-color);
}

.warning-box {
  background-color: #fff3cd;
  border-left: 5px solid var(--warning-color);
  padding: 1rem 1.5rem;
  margin: 1rem 0;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}
.disclaimer {
  font-size: 0.85rem;
  color: var(--secondary-color);
  text-align: center;
  margin-top: 2rem;
}
.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 1rem;
    border: 1px solid #f5c6cb;
    border-radius: var(--border-radius);
    margin-top: 1rem;
    text-align: center;
    font-weight: 500;
}

/* --- Utilities --- */
.hidden {
  display: none;
}

/* --- Tooltip --- */
.tooltip-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: var(--secondary-color);
  color: white;
  text-align: center;
  font-size: 13px;
  line-height: 18px;
  font-weight: 700;
  cursor: help;
  position: relative;
  margin-left: 8px;
  flex-shrink: 0;
}
.tooltip-icon::before, .tooltip-icon::after {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 10;
}
.tooltip-icon::before {
  content: attr(data-tooltip);
  background-color: var(--text-color);
  color: white;
  padding: 0.75rem;
  border-radius: var(--border-radius);
  width: 240px;
  bottom: 150%;
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.4;
}
.tooltip-icon::after {
  content: '';
  border: 6px solid transparent;
  border-top-color: var(--text-color);
  bottom: calc(150% - 6px);
  width: 0;
  height: 0;
}
.tooltip-icon:hover::before, .tooltip-icon:hover::after {
  opacity: 1;
}

/* --- Responsive Design --- */
@media (max-width: 600px) {
  .water-deficit-calculator {
    padding: 1rem;
    box-shadow: none;
  }
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  .actions {
    flex-direction: column;
  }
  .results-summary {
    flex-direction: column;
    gap: 1.5rem;
  }
  .result-value {
    font-size: 2rem;
  }
}



html, body {
  max-width: 100%;
  overflow-x: hidden;
}
