* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: #f5f5f5;
  color: #333;
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.container.narrow {
  max-width: 700px;
}

/* Header */
header {
  background: #2563eb;
  color: white;
  padding: 20px;
  margin-bottom: 30px;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

header p {
  opacity: 0.9;
  font-size: 0.9rem;
}

/* Cards */
.card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 20px;
  margin-bottom: 20px;
}

.card h2 {
  font-size: 1.25rem;
  margin-bottom: 15px;
  color: #1f2937;
}

.card h3 {
  font-size: 1rem;
  margin-bottom: 10px;
  color: #374151;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-primary {
  background: #2563eb;
  color: white;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-secondary {
  background: #6b7280;
  color: white;
}

.btn-secondary:hover {
  background: #4b5563;
}

.btn-success {
  background: #10b981;
  color: white;
}

.btn-success:hover {
  background: #059669;
}

.btn-danger {
  background: #ef4444;
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Forms */
.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 5px;
  color: #374151;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="date"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9rem;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

.form-inline {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.form-inline .form-group {
  flex: 1;
  margin-bottom: 0;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
}

tr:hover {
  background: #f9fafb;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-active {
  background: #d1fae5;
  color: #065f46;
}

.badge-inactive {
  background: #fee2e2;
  color: #991b1b;
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 2px solid #e5e7eb;
  margin-bottom: 20px;
}

.tab {
  padding: 10px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: #6b7280;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.tab:hover {
  color: #2563eb;
}

.tab.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: white;
  border-radius: 8px;
  padding: 25px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 {
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* Number Rating */
.rating-wrapper {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.number-rating {
  display: flex;
  gap: 8px;
}

.number-rating input {
  display: none;
}

.number-rating label {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 44px;
  height: 44px;
  border: 2px solid #d1d5db;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  color: #6b7280;
  background: white;
  transition: all 0.2s;
  margin: 0;
  padding: 0;
  line-height: 44px;
}

.number-rating label:hover {
  border-color: #2563eb;
  color: #2563eb;
  background: #eff6ff;
}

.number-rating input:checked + label {
  background: #2563eb;
  color: white;
  border-color: #2563eb;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

/* N/A Option */
.na-option {
  display: flex;
  align-items: center;
  gap: 5px;
}

.na-option input {
  display: none;
}

.na-option label {
  cursor: pointer;
  padding: 6px 12px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 0.85rem;
  color: #6b7280;
  transition: all 0.2s;
}

.na-option label:hover {
  border-color: #9ca3af;
  background: #f9fafb;
}

.na-option input:checked + label {
  background: #6b7280;
  color: white;
  border-color: #6b7280;
}

/* Question Card */
.question-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
}

.question-card.dragging {
  opacity: 0.5;
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.question-header .drag-handle {
  cursor: grab;
  color: #9ca3af;
  padding: 0 5px;
}

.question-text {
  flex: 1;
  font-weight: 500;
}

.question-type {
  font-size: 0.8rem;
  color: #6b7280;
  background: #e5e7eb;
  padding: 2px 8px;
  border-radius: 4px;
}

.question-actions {
  display: flex;
  gap: 5px;
  margin-top: 10px;
}

/* Multiple Choice Options */
.options-list {
  margin-top: 10px;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.option-item input {
  flex: 1;
}

/* Checkbox list for provider selection */
.checkbox-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 10px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #f3f4f6;
}

.checkbox-item:last-child {
  border-bottom: none;
}

.checkbox-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

/* Survey Form (Patient) */
.survey-question {
  margin-bottom: 25px;
}

.survey-question label {
  display: block;
  font-weight: 500;
  margin-bottom: 10px;
  color: #1f2937;
}

.survey-question .required {
  color: #ef4444;
}

.multiple-choice-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.multiple-choice-options label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: normal;
  cursor: pointer;
  padding: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  transition: all 0.2s;
}

.multiple-choice-options label:hover {
  background: #f9fafb;
}

.multiple-choice-options input:checked + span {
  color: #2563eb;
  font-weight: 500;
}

/* Thank You Message */
.thank-you {
  text-align: center;
  padding: 60px 20px;
}

.thank-you h2 {
  color: #10b981;
  font-size: 2rem;
  margin-bottom: 15px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #6b7280;
}

.empty-state p {
  margin-bottom: 15px;
}

/* Alert Messages */
.alert {
  padding: 12px 15px;
  border-radius: 6px;
  margin-bottom: 15px;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

/* Loading Spinner */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Grid Layout */
.grid {
  display: grid;
  gap: 20px;
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 768px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .form-inline {
    flex-direction: column;
    align-items: stretch;
  }

  .form-inline .form-group {
    width: 100%;
  }
}

/* Provider ID Display */
.provider-id {
  font-family: monospace;
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* Provider Card (Patient Survey) */
.provider-card {
  border-left: 4px solid #2563eb;
}

.provider-card .provider-header {
  padding-bottom: 15px;
  border-bottom: 2px solid #2563eb;
  margin-bottom: 0;
  background: linear-gradient(to right, #eff6ff, transparent);
  margin: -20px -20px 0 -20px;
  padding: 20px;
  border-radius: 8px 8px 0 0;
}

.provider-card .default-rating {
  background: #f8fafc;
  padding: 20px;
  margin: 0 -20px;
  border-bottom: 1px solid #e5e7eb;
}

.provider-card .questions-section {
  background: #fff;
}

.provider-card .survey-question:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

/* Action Buttons Group */
.action-buttons {
  display: flex;
  gap: 5px;
}

/* Group Number Stepper */
.group-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  overflow: hidden;
}

.group-stepper .stepper-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: #f9fafb;
  color: #374151;
  font-size: 1.25rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.group-stepper .stepper-btn:hover {
  background: #e5e7eb;
}

.group-stepper .stepper-btn:active {
  background: #d1d5db;
}

.group-stepper input[type="number"] {
  width: 60px;
  height: 40px;
  border: none;
  border-left: 1px solid #d1d5db;
  border-right: 1px solid #d1d5db;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  color: #1f2937;
  background: white;
  -moz-appearance: textfield;
}

.group-stepper input[type="number"]::-webkit-outer-spin-button,
.group-stepper input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.group-stepper input[type="number"]:focus {
  outline: none;
  background: #eff6ff;
}

/* Program Type Buttons */
.program-type-buttons {
  display: flex;
  gap: 10px;
}

.program-type-buttons .program-btn {
  min-width: 80px;
  font-weight: 600;
}

.program-type-buttons .program-btn.btn-primary {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* FRP Location Dropdown */
#edit-survey-frp-location {
  width: 100%;
  padding: 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9rem;
  background: white;
}

#edit-survey-frp-location:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* CBI Location Dropdown */
#edit-survey-cbi-location {
  width: 100%;
  padding: 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9rem;
  background: white;
}

#edit-survey-cbi-location:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Response Stats */
.stat-box {
  background: #f0f4ff;
  border-radius: 8px;
  padding: 12px 18px;
  text-align: center;
  min-width: 100px;
}

.stat-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: #2563eb;
}

.stat-label {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 2px;
}

.stats-provider-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stats-provider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}

.stats-provider-name {
  min-width: 140px;
  color: #374151;
}

.stats-bar-container {
  flex: 1;
  height: 14px;
  background: #e5e7eb;
  border-radius: 7px;
  overflow: hidden;
}

.stats-bar {
  height: 100%;
  background: #2563eb;
  border-radius: 7px;
  min-width: 4px;
}

.stats-provider-count {
  min-width: 30px;
  text-align: right;
  font-weight: 600;
  color: #374151;
}
