/* === CSS Custom Properties (overridden by theme.js) === */
:root {
  --primary: #333;
  --accent: #666;
  --footer-color: #888;
  --font: "Source Sans Pro", sans-serif;
}

/* === Reset & Base === */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font), -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #333;
  background: #f5f5f5;
  min-height: 100vh;
}

/* === Shell Header === */
.shell-header {
  background: var(--primary);
  padding: 16px 24px;
}

.shell-header-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.shell-logo {
  height: 48px;
  width: auto;
}

.shell-title {
  color: #fff;
  font-size: 18px;
  font-weight: 600;
}

/* === Main Content === */
.shell-main {
  max-width: 720px;
  margin: 32px auto;
  padding: 0 16px;
}

.shell-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 32px;
}

.shell-center {
  text-align: center;
}

.shell-center h2 {
  margin-bottom: 12px;
  color: var(--primary);
}

/* === Spinner === */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #eee;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* === Utility === */
.hidden {
  display: none !important;
}

/* === Form Primitives (available to all profiles) === */

.form-section {
  margin-bottom: 32px;
}

.form-section h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 14px;
}

.form-group .hint {
  font-size: 13px;
  color: #666;
  margin-bottom: 4px;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 16px;
  font-family: inherit;
  transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

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

/* Radio and checkbox groups */
.radio-group,
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-group label,
.checkbox-group label {
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.radio-group input,
.checkbox-group input {
  width: auto;
  margin: 0;
}

/* Inline fields (e.g., value + unit side by side) */
.inline-fields {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline-fields input,
.inline-fields select {
  flex: 1;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  opacity: 0.9;
}

.btn-secondary {
  background: #eee;
  color: #333;
}

/* Navigation buttons */
.form-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #eee;
}

/* Progress bar */
.progress-bar {
  margin-bottom: 24px;
}

.progress-bar-label {
  font-size: 14px;
  color: #666;
  margin-bottom: 6px;
}

.progress-bar-track {
  height: 6px;
  background: #eee;
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
}

/* Validation */
input:invalid:not(:placeholder-shown),
select:invalid:not(:placeholder-shown) {
  border-color: #dc3545;
}

.validation-error {
  color: #dc3545;
  font-size: 13px;
  margin-top: 4px;
}

/* Medication / repeatable rows */
.repeatable-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-bottom: 8px;
}

.repeatable-row input,
.repeatable-row select {
  flex: 1;
}

.btn-remove {
  background: none;
  border: none;
  color: #dc3545;
  cursor: pointer;
  font-size: 18px;
  padding: 8px;
  line-height: 1;
}

.btn-add {
  background: none;
  border: 1px dashed #ccc;
  border-radius: 6px;
  padding: 8px 16px;
  color: #666;
  cursor: pointer;
  font-size: 14px;
  width: 100%;
  margin-top: 4px;
}

.btn-add:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Likert scale */
.likert-row {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.likert-row .likert-label {
  flex: 1;
  font-size: 14px;
}

.likert-row .likert-options {
  display: flex;
  gap: 12px;
}

.likert-row .likert-options label {
  font-size: 13px;
  text-align: center;
}

/* Conditional fields */
.conditional.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 600px) {
  .shell-main {
    margin: 16px auto;
  }

  .shell-card {
    padding: 20px 16px;
  }

  .likert-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .repeatable-row {
    flex-direction: column;
  }
}
