@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
  /* Botanical color system based on SMGP logo */
  --primary-hue: 157;
  --primary: hsl(var(--primary-hue), 100%, 26.5%);
  --primary-hover: hsl(var(--primary-hue), 100%, 20%);
  --primary-soft: hsl(var(--primary-hue), 30%, 96%);
  --primary-glow: rgba(0, 135, 83, 0.15);
  
  --secondary: hsl(140, 20%, 93%);
  --accent: hsl(157, 90%, 15%);
  
  --bg-gradient-start: hsl(160, 20%, 97%);
  --bg-gradient-end: hsl(210, 20%, 98%);
  
  --text-main: hsl(215, 28%, 17%);
  --text-muted: hsl(215, 16%, 47%);
  --text-light: hsl(215, 16%, 60%);
  
  --border: hsl(214, 30%, 90%);
  --border-focus: hsl(var(--primary-hue), 60%, 50%);
  
  --surface: #ffffff;
  --surface-glass: rgba(255, 255, 255, 0.85);
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 8px 16px -2px rgba(0, 0, 0, 0.04), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
  --shadow-lg: 0 20px 25px -5px rgba(0, 135, 83, 0.04), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  
  --font-title: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;
}

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

body {
  font-family: var(--font-body);
  background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
  padding: 20px 10px;
  -webkit-font-smoothing: antialiased;
}

@media(min-width: 768px) {
  body {
    padding: 40px 20px;
  }
}

.container {
  max-width: 800px;
  margin: 0 auto;
}

/* Header */
header {
  background: var(--surface-glass);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 30px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  text-align: center;
  animation: fadeInDown 0.6s ease;
}

@media(min-width: 576px) {
  header {
    flex-direction: row;
    text-align: left;
    padding: 25px 30px;
  }
}

.logo-container img {
  height: 70px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.05));
}

@media(min-width: 576px) {
  .logo-container img {
    height: 90px;
  }
}

.header-text h1 {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--accent);
  margin-bottom: 4px;
}

.header-text p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Progress Tracker */
.progress-container {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 15px 20px;
  margin-bottom: 25px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.progress-bar-wrapper {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), hsl(var(--primary-hue), 100%, 35%));
  border-radius: 3px;
  transition: width 0.4s ease;
}

.progress-steps {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.progress-step-item.active {
  color: var(--primary);
}

/* Questionnaire Cards */
.card-section {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 25px 20px;
  margin-bottom: 25px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

@media(min-width: 768px) {
  .card-section {
    padding: 35px;
  }
}

.card-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--primary);
  opacity: 0.8;
}

.card-section h2 {
  font-family: var(--font-title);
  font-size: 1.25rem;
  color: var(--accent);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--primary-soft);
  padding-bottom: 10px;
}

.card-section h2 span.section-number {
  background: var(--primary-soft);
  color: var(--primary);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
}

/* Form Groups */
.form-group {
  margin-bottom: 22px;
}

.form-group:last-child {
  margin-bottom: 0;
}

label.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
  margin-bottom: 8px;
}

label.form-label span.required {
  color: var(--error);
  margin-left: 3px;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: -4px;
  margin-bottom: 8px;
}

/* Form Inputs */
input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-main);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
  outline: none;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

input[readonly] {
  background: var(--primary-soft);
  color: var(--accent);
  font-weight: 600;
  border-color: var(--border);
  cursor: not-allowed;
}

/* Radio & Checkbox Cards */
.radio-group-vertical,
.checkbox-group-vertical {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.custom-option {
  position: relative;
}

.custom-option input[type="radio"],
.custom-option input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.custom-option-label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.95rem;
  transition: var(--transition-fast);
  background: var(--surface);
}

.custom-option-label:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.custom-option input:checked + .custom-option-label {
  border-color: var(--primary);
  background: var(--primary-soft);
  font-weight: 500;
  box-shadow: 0 2px 4px rgba(0,135,83,0.05);
}

/* Custom indicator design */
.custom-option-label::before {
  content: '';
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--text-light);
  background: var(--surface);
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.custom-option input[type="radio"] + .custom-option-label::before {
  border-radius: 50%;
}

.custom-option input[type="checkbox"] + .custom-option-label::before {
  border-radius: 4px;
}

.custom-option input[type="radio"]:checked + .custom-option-label::before {
  border-color: var(--primary);
  background: radial-gradient(circle, var(--primary) 40%, var(--surface) 45%);
}

.custom-option input[type="checkbox"]:checked + .custom-option-label::before {
  border-color: var(--primary);
  background: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white' width='18px' height='18px'%3E%3Cpath d='M0 0h24v24H0V0z' fill='none'/%3E%3Cpath d='M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z'/%3E%3C/svg%3E");
  background-size: contain;
  background-position: center;
}

/* Horizontal Radio Groups */
.radio-group-horizontal {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media(min-width: 576px) {
  .radio-group-horizontal {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  }
}

/* 0-10 NRS Numeric Rating Scale */
.nrs-scale-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.nrs-scale {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  overflow-x: auto;
  padding: 5px 2px;
}

.nrs-item {
  flex: 1;
  min-width: 32px;
  aspect-ratio: 1;
}

.nrs-item input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.nrs-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: 50%;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  background: var(--surface);
  transition: var(--transition-fast);
}

.nrs-item:hover .nrs-label {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  transform: scale(1.1);
}

.nrs-item input:checked + .nrs-label {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 4px 10px var(--primary-glow);
  transform: scale(1.15);
}

.nrs-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  padding: 0 4px;
}

/* Expanding/Collapsible Field logic */
.expanding-container {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.4s cubic-bezier(0, 1, 0, 1), opacity 0.3s ease;
  background: var(--bg-gradient-start);
  border-radius: var(--radius-md);
  margin-top: 0;
}

.expanding-container.show {
  max-height: 2000px; /* arbitrary high value for smooth overflow auto */
  opacity: 1;
  padding: 18px;
  margin-top: 15px;
  border: 1px dashed var(--primary);
  transition: max-height 0.8s cubic-bezier(1, 0, 1, 0), opacity 0.4s ease;
}

/* Autocomplete/Searchable Dropdown styling */
.searchable-select-wrapper {
  position: relative;
}

.search-input-icon {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  width: 100%;
  max-height: 250px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: none;
  animation: fadeIn 0.2s ease;
}

.autocomplete-dropdown.show {
  display: block;
}

.autocomplete-option {
  padding: 10px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition-fast);
  border-bottom: 1px solid var(--primary-soft);
}

.autocomplete-option:last-child {
  border-bottom: none;
}

.autocomplete-option:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.autocomplete-group-header {
  background: var(--bg-gradient-start);
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.selected-tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.selected-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid hsl(var(--primary-hue), 40%, 85%);
  animation: zoomIn 0.2s ease;
}

.selected-tag-remove {
  cursor: pointer;
  font-weight: bold;
  font-size: 1.1rem;
  line-height: 1;
}

.selected-tag-remove:hover {
  color: var(--primary-hover);
}

/* Buttons */
.btn-container {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  margin-top: 30px;
}

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 14px 28px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-gradient-start);
  border-color: var(--text-light);
}

.btn-outline-primary {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  padding: 8px 16px;
  font-size: 0.85rem;
  border-radius: var(--radius-md);
}

.btn-outline-primary:hover {
  background: var(--primary-soft);
}

/* Dynamic List Items (e.g. Symptoms) */
.dynamic-item-card {
  background: var(--bg-gradient-start);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px;
  margin-bottom: 12px;
  position: relative;
  animation: slideIn 0.3s ease;
}

.dynamic-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--primary);
  text-transform: uppercase;
}

.dynamic-item-remove {
  background: none;
  border: none;
  color: var(--error);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.dynamic-item-remove:hover {
  text-decoration: underline;
}

/* Alert Boxes */
.alert {
  padding: 15px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 25px;
  font-weight: 500;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: fadeIn 0.4s ease;
}

.alert-danger {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.alert-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #86efac;
}

/* Grid Layout Helper */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
}

@media(min-width: 576px) {
  .form-grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
}

@media(min-width: 768px) {
  .form-grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Index / Landing Page Portal styling */
.portal-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 25px;
  margin-top: 20px;
}

@media(min-width: 768px) {
  .portal-container {
    grid-template-columns: 1fr 1fr;
  }
}

.portal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 30px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  text-align: center;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  min-height: 300px;
}

.portal-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.portal-card-icon {
  font-size: 3rem;
  margin-bottom: 15px;
  color: var(--primary);
  background: var(--primary-soft);
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.portal-card h2 {
  font-family: var(--font-title);
  color: var(--accent);
  margin-bottom: 12px;
}

.portal-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 25px;
  max-width: 280px;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes zoomIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

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