/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f5f5;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
.app-header {
  background-color: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 1rem 0;
  margin-bottom: 2rem;
}

.app-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.app-header h2 {
  margin: 0;
}

.app-header h2 a {
  color: #2563eb;
  font-size: 1.5rem;
  text-decoration: none;
}

.app-header h2 a:hover {
  color: #1d4ed8;
}

.main-nav {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.main-nav a {
  color: #374151;
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 0;
  border-bottom: 2px solid transparent;
}

.main-nav a:hover {
  color: #2563eb;
  border-bottom-color: #2563eb;
}

.user-nav {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.user-nav span {
  color: #666;
}

/* Main content */
main.container {
  padding: 0 1rem 2rem;
}

/* Page header */
.page-header,
.header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.page-header h1,
.header-actions h1 {
  font-size: 2rem;
  color: #1f2937;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background-color: #2563eb;
  color: white;
}

.btn-primary:hover {
  background-color: #1d4ed8;
}

.btn-secondary {
  background-color: #6b7280;
  color: white;
}

.btn-secondary:hover {
  background-color: #4b5563;
}

.btn-danger {
  background-color: #dc2626;
  color: white;
}

.btn-danger:hover {
  background-color: #b91c1c;
}

.btn-logout {
  background-color: #f3f4f6;
  color: #374151;
}

.btn-logout:hover {
  background-color: #e5e7eb;
}

/* Forms */
.form-container {
  background-color: #fff;
  padding: 2rem;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  max-width: 600px;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #374151;
}

.form-control {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  font-size: 1rem;
  line-height: 1.5;
}

.form-control:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea.form-control {
  resize: vertical;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Login */
.login-container {
  max-width: 400px;
  margin: 4rem auto;
  background-color: #fff;
  padding: 2rem;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.login-container h1 {
  text-align: center;
  margin-bottom: 2rem;
  color: #1f2937;
}

/* Cards */
.card {
  background-color: #fff;
  border-radius: 0.5rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.2s;
}

.card:hover {
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.card h3 {
  color: #1f2937;
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.card h3 a {
  color: inherit;
  text-decoration: none;
}

.card h3 a:hover {
  color: #2563eb;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e5e7eb;
}

.card-details {
  margin-bottom: 1rem;
}

.card-details p {
  margin-bottom: 0.5rem;
  color: #4b5563;
}

.card-details strong {
  color: #1f2937;
}

.card-actions {
  display: flex;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
}

/* Patients grid */
.patients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

/* Appointments list */
.appointments-list {
  display: grid;
  gap: 1rem;
}

.appointment-card {
  background-color: #fff;
  border-radius: 0.5rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.2s;
}

.appointment-card:hover {
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.appointment-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e5e7eb;
}

.appointment-header h3 {
  color: #1f2937;
  font-size: 1.25rem;
}

.appointment-date {
  color: #6b7280;
  font-size: 0.875rem;
}

.appointment-body {
  margin-bottom: 1rem;
}

.appointment-detail {
  margin-bottom: 0.5rem;
  color: #4b5563;
}

.appointment-detail strong {
  color: #1f2937;
  margin-right: 0.5rem;
}

.appointment-actions {
  display: flex;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  background-color: #fff;
  border-radius: 0.5rem;
}

.empty-state p {
  margin-bottom: 1.5rem;
  color: #6b7280;
  font-size: 1.125rem;
}

/* Alerts */
.alert {
  padding: 1rem;
  border-radius: 0.375rem;
  margin-bottom: 1.5rem;
}

.alert-notice {
  background-color: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
}

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

.alert h3 {
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.alert ul {
  margin-left: 1.5rem;
}

/* Error messages */
.error-messages {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
  padding: 1rem;
  border-radius: 0.375rem;
  margin-bottom: 1.5rem;
}

.error-messages h2 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.error-messages ul {
  margin-left: 1.5rem;
}

/* Form styles */
.form {
  background-color: #fff;
  padding: 2rem;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  max-width: 600px;
}

.help-text {
  color: #6b7280;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* Actions */
.actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1.5rem;
}

/* Patient detail */
.patient-detail {
  background-color: #fff;
  padding: 2rem;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 2rem;
}

.patient-detail h1 {
  margin-bottom: 1.5rem;
  color: #1f2937;
}

.patient-info p {
  margin-bottom: 0.75rem;
  color: #4b5563;
}

.patient-info strong {
  color: #1f2937;
}

.patient-info .notes {
  background-color: #f9fafb;
  padding: 1rem;
  border-radius: 0.375rem;
  white-space: pre-wrap;
}

/* Appointment item */
.appointment-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background-color: #f9fafb;
  border-radius: 0.375rem;
  margin-bottom: 0.5rem;
}

/* Select styling */
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
}

/* Calendar Navigation */
.calendar-nav {
  background-color: #fff;
  padding: 1rem;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 1.5rem;
}

.calendar-nav-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.date-navigation {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn-nav {
  padding: 0.5rem 0.75rem;
  font-size: 1.25rem;
  line-height: 1;
}

.current-period-wrapper {
  position: relative;
  cursor: pointer;
}

.current-period {
  font-size: 1.25rem;
  color: #1f2937;
  margin: 0;
  text-align: center;
}

.date-picker-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* Week label - hide mobile version on desktop */
.week-label-mobile {
  display: none;
}

.view-switcher {
  display: flex;
  gap: 0.25rem;
}

.view-switcher .btn {
  padding: 0.5rem 1rem;
}

.calendar-actions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
}

/* Day View */
.day-view {
  background-color: #fff;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.day-appointments {
  padding: 1rem;
}

.day-appointment-slot {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #e5e7eb;
}

.day-appointment-slot:last-child {
  border-bottom: none;
}

.appointment-time {
  font-weight: 600;
  color: #2563eb;
  min-width: 60px;
  padding-top: 1.5rem;
}

.appointment-content {
  flex: 1;
}

.appointment-content .card {
  margin: 0;
}

/* Week View */
.week-view {
  background-color: #fff;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.week-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background-color: #f3f4f6;
  border-bottom: 1px solid #e5e7eb;
}

.week-header-day {
  padding: 0.75rem 0.5rem;
  text-align: center;
}

.week-header-day--today {
  background-color: #dbeafe;
}

.week-header-day .day-name {
  display: block;
  font-size: 0.75rem;
  color: #6b7280;
  text-transform: uppercase;
}

.week-header-day .day-number {
  display: block;
  font-size: 1.25rem;
  font-weight: 600;
  color: #1f2937;
}

.week-header-day--today .day-number {
  color: #2563eb;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  min-height: 400px;
}

.week-day {
  border-right: 1px solid #e5e7eb;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  position: relative;
}

.week-day:last-child {
  border-right: none;
}

.week-day--today {
  background-color: #f0f9ff;
}

.week-day-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-appointment-link {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: #f3f4f6;
  color: #9ca3af;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 1.25rem;
  transition: all 0.2s;
}

.add-appointment-link:hover {
  background-color: #2563eb;
  color: white;
}

.week-day-link {
  position: absolute;
  bottom: 0.25rem;
  right: 0.25rem;
  font-size: 0.625rem;
  color: #9ca3af;
  text-decoration: none;
}

.week-day-link:hover {
  color: #2563eb;
}

/* Compact Appointment (for week view) */
.appointment-compact {
  display: block;
  background-color: #dbeafe;
  border-left: 3px solid #2563eb;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  text-decoration: none;
  font-size: 0.75rem;
  transition: background-color 0.2s;
}

.appointment-compact:hover {
  background-color: #bfdbfe;
}

.appointment-compact-time {
  display: block;
  font-weight: 600;
  color: #1e40af;
}

.appointment-compact-name {
  display: block;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Month View */
.month-view {
  background-color: #fff;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.month-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background-color: #f3f4f6;
  border-bottom: 1px solid #e5e7eb;
}

.month-header-day {
  padding: 0.75rem 0.5rem;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.month-day {
  min-height: 100px;
  border-right: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
  position: relative;
}

.month-day:nth-child(7n) {
  border-right: none;
}

.month-day-link {
  display: block;
  height: 100%;
  padding: 0.5rem;
  text-decoration: none;
  color: inherit;
  transition: background-color 0.2s;
}

.month-day-link:hover {
  background-color: #f9fafb;
}

.month-day-number {
  display: inline-block;
  width: 24px;
  height: 24px;
  line-height: 24px;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  border-radius: 50%;
}

.month-day--today .month-day-number {
  background-color: #2563eb;
  color: white;
}

.month-day--other-month {
  background-color: #f9fafb;
}

.month-day--other-month .month-day-number {
  color: #9ca3af;
}

.month-day--weekend {
  background-color: #fef3c7;
}

.month-day--other-month.month-day--weekend {
  background-color: #fef9e7;
}

.month-day-appointments {
  margin-top: 0.25rem;
}

.appointment-dot {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  padding: 0.125rem 0.25rem;
  margin-bottom: 0.125rem;
  background-color: #dbeafe;
  border-radius: 0.25rem;
  font-size: 0.625rem;
}

.appointment-dot-time {
  font-weight: 600;
  color: #1e40af;
}

.appointment-dot-name {
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appointment-more {
  font-size: 0.625rem;
  color: #6b7280;
  padding: 0.125rem 0.25rem;
}

/* Responsive */
@media (max-width: 768px) {
  .page-header,
  .header-actions {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .app-header .container {
    flex-direction: column;
    gap: 1rem;
  }

  .main-nav {
    order: 2;
    width: 100%;
    justify-content: center;
  }

  .user-nav {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .appointment-header,
  .card-header {
    flex-direction: column;
    gap: 0.5rem;
  }

  .form-actions,
  .card-actions,
  .actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    text-align: center;
  }

  .patients-grid {
    grid-template-columns: 1fr;
  }

  /* Week view: 3 days on mobile */
  .week-header,
  .week-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .week-header-day:not(.mobile-visible),
  .week-day:not(.mobile-visible) {
    display: none;
  }

  /* Week label switching for mobile */
  .week-label-desktop {
    display: none;
  }

  .week-label-mobile {
    display: inline;
  }

  /* Compact month view for mobile - fit all 7 days */
  .month-header-day {
    padding: 0.25rem;
    font-size: 0.6rem;
  }

  .month-day {
    min-height: 60px;
  }

  .month-day-link {
    padding: 0.25rem;
  }

  .month-day-number {
    font-size: 0.7rem;
  }

  .appointment-dot {
    font-size: 0.5rem;
    padding: 0.1rem;
  }

  .appointment-dot-time,
  .appointment-dot-name {
    display: none;
  }
}

/* Intake Form Styles */
.intake-form-container {
  max-width: 900px;
  margin: 0 auto;
}

.intake-form-container h1 {
  margin-bottom: 2rem;
  color: #1f2937;
}

.intake-form {
  background-color: #fff;
  padding: 2rem;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  max-width: 100%;
}

.form-section {
  margin-bottom: 2rem;
  padding: 1.5rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  background-color: #fafafa;
}

.form-section legend {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1f2937;
  padding: 0 0.5rem;
  background-color: #fafafa;
}

.form-section h4 {
  margin: 1rem 0 0.5rem;
  font-size: 0.95rem;
  color: #374151;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.substance-row {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
}

.checkbox-group label {
  margin-bottom: 0;
}

.form-static {
  padding: 0.5rem 0.75rem;
  background-color: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  color: #374151;
}

/* Intake Form Detail View */
.intake-form-detail {
  max-width: 900px;
  margin: 0 auto;
}

.intake-form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.intake-form-header h1 {
  color: #1f2937;
  margin: 0;
}

.intake-form-header .actions {
  margin: 0;
}

.intake-section {
  background-color: #fff;
  padding: 1.5rem;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 1.5rem;
}

.intake-section h2 {
  font-size: 1.125rem;
  color: #1f2937;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e5e7eb;
}

.detail-list {
  display: grid;
  gap: 0.75rem;
}

.detail-list dt {
  font-weight: 600;
  color: #374151;
  font-size: 0.875rem;
}

.detail-list dd {
  margin: 0;
  color: #1f2937;
  padding-left: 0;
}

.detail-list dd p {
  margin: 0;
}

.bottom-actions {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e5e7eb;
}

/* Intake Form Section on Patient Page */
.intake-form-section {
  background-color: #fff;
  padding: 1.5rem;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 2rem;
}

.intake-form-section h2 {
  font-size: 1.25rem;
  color: #1f2937;
  margin-bottom: 1rem;
}

.intake-form-section p {
  color: #6b7280;
  margin-bottom: 1rem;
}

.intake-form-section .actions {
  margin-top: 1rem;
}

@media (max-width: 768px) {
  .intake-form-container,
  .intake-form-detail {
    padding: 0 1rem;
  }

  .intake-form {
    padding: 1rem;
  }

  .form-section {
    padding: 1rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .intake-form-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .intake-form-header .actions {
    width: 100%;
  }
}
