/* These styles are generated from project.scss. */

/* Alpine.js x-cloak directive - hides elements until Alpine initializes */
/* Only affects elements with x-cloak attribute, removed once Alpine loads */
[x-cloak] {
  display: none !important;
}

/* Ensure Alpine.js x-show works correctly after initialization */
/* x-show uses display: none dynamically, should not conflict with x-cloak */

.alert-debug {
  color: var(--color-gray-900);
  background-color: var(--color-white);
  border-color: var(--color-green-200);
}

.alert-error {
  color: var(--color-red-700);
  background-color: var(--color-red-50);
  border-color: var(--color-red-200);
}

/* Layout - uses design tokens from design-tokens.css */
html, body {
  height: 100%;
  margin: 0;
  background: var(--app-body-bg) !important;
}

.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* Sidebar: fixed to the left */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 220px;
  height: 100vh;
  background: var(--app-sidebar-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 24px;
  z-index: 100;
}

.sidebar-logo {
  text-align: center;
  margin-bottom: 40px;
}

.logo-img {
  /* constrain the width and preserve aspect‑ratio */
  max-width: 200px;
  width: 100%;
  height: auto;
  /* if you need spacing: */
  margin-right: 12px;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  align-items: center;
}

.sidebar-btn {
  background: var(--app-sidebar-btn-bg);
  color: var(--app-text-primary);
  border: none;
  border-radius: 20px;
  padding: 12px 32px;
  font-size: 1.2rem;
  margin-bottom: 8px;
  text-align: center;
  width: 80%;
  text-decoration: none;
  transition: background 0.2s;
}

.sidebar-btn:hover {
  background: var(--app-sidebar-btn-hover);
}

.sidebar-footer {
  margin-bottom: 24px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.sidebar-logout {
  background: var(--app-sidebar-logout-bg);
  color: var(--app-text-primary);
  border: none;
  border-radius: 20px;
  padding: 12px 32px;
  font-size: 1.2rem;
  text-align: center;
  width: 80%;
  text-decoration: none;
  transition: background 0.2s;
}

.sidebar-logout:hover {
  background: var(--app-sidebar-logout-hover);
  text-decoration: none;
}

/* Main content: add left and right margin to avoid overlap with fixed panels */
.main-content {
  flex: 1;
  margin-left: 220px; /* width of sidebar */
  margin-right: 340px; /* width of right-panel */
  min-height: 100vh;
  padding: 0 32px;
  display: flex;
  flex-direction: column;
  background-color: var(--app-body-bg);
}

.top-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 24px;
  margin-bottom: 24px;
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: var(--app-body-bg);
  padding: 10px 0;
}

.tab {
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--app-text-secondary);
  padding: 8px 32px;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: color 0.2s, border-bottom 0.2s;
}

.tab.active {
  color: var(--app-text-primary);
  border-bottom: 3px solid var(--app-text-primary);
  background: var(--app-card-bg);
}

.content-area {
  background: var(--app-content-bg);
  border-radius: 8px;
  padding: 24px 32px;
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: 1.2rem;
  color: var(--app-text-primary);
  max-width: 900px;
  width: 100%;
  margin: 0 auto 24px auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
  flex-grow: 1;
  overflow: visible; /* Ensure no inner scrollbars */
}

.journal-form {
  display: flex;
  flex-direction: column;
}

.journal-header {
  margin-bottom: 20px;
  padding: 15px 0;
  border-bottom: 2px solid var(--app-journal-header-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.journal-date-container {
  background-color: var(--app-journal-date-bg);
  border: 2px solid var(--app-journal-date-border);
  border-radius: 8px;
  padding: 10px 16px;
  width: 100%;
  max-width: 500px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  margin-bottom: 10px;
}

.journal-date-display {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--app-journal-date-text);
  padding: 4px 0;
  text-align: center;
  letter-spacing: 0.5px;
}

.journal-body {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  overflow: visible; /* Ensure no inner scrollbars */
}

.journal-textarea {
  width: 100%;
  border-radius: 8px;
  border: none;
  padding: 16px;
  font-size: 1.1rem;
  background: var(--app-journal-textarea-bg);
  color: var(--app-text-primary);
  box-sizing: border-box;
  min-height: 200px;
  resize: none;
  margin-bottom: 0;
  overflow: hidden; /* Hide scrollbar in textarea */
  outline: none;
}

.journal-footer {
  margin-top: 16px;
  text-align: left;
}

/* Right panel: fixed to the right */
.right-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 340px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 32px 24px 0 0;
  background: var(--app-body-bg); /* match main-content background */
  z-index: 100;
}

.feature-tabs {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
}

.feature-tab {
  background: var(--app-feature-tab-bg);
  color: var(--app-feature-tab-text);
  border-radius: 16px 0 0 16px;
  padding: 8px 28px 8px 18px;
  font-size: 1.08rem;
  font-family: inherit;
  font-weight: 500;
  margin-bottom: 8px;
  margin-right: 0;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  border: none;
  outline: none;
  transition: background 0.18s, color 0.18s, font-weight 0.18s;
  text-align: right;
  min-width: 120px;
  user-select: none;
}

.feature-tab:hover {
  background: var(--app-feature-tab-hover);
  color: var(--app-feature-tab-text-active);
}

.feature-tab.active {
  background: var(--app-feature-tab-active);
  color: var(--app-feature-tab-text-active);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
}

.chat-bubble-container {
  width: 100%;
  display: flex;
  justify-content: flex-end;
}

.chat-bubble {
  background: var(--app-chat-bubble-bg);
  border-radius: 24px;
  padding: 24px 32px;
  margin-bottom: 8px;
  margin-top: 0;
  max-width: 320px;
  display: none;
  align-items: flex-start;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  position: relative;
}

.chat-bubble.active {
  display: flex;
}

.chat-bubble-close {
  background: none;
  border: none;
  color: var(--color-gray-600);
  font-size: 1.5rem;
  font-weight: bold;
  position: absolute;
  top: 8px;
  right: 16px;
  cursor: pointer;
  z-index: 2;
  line-height: 1;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
  .right-panel {
    display: none;
  }
  .main-content {
    margin-right: 0;
  }
}

@media (max-width: 900px) {
  .sidebar {
    display: none;
  }
  .main-content {
    margin-left: 0;
    padding: 0 8px;
  }
}

/* ============================================================================
   THE PAST VIEW - Timeline Design
   ============================================================================ */

/* Remove paper background when past view is active */
.content-area.past-view-active {
  background: var(--color-gray-50);
  border-radius: 8px;
}

.past-view-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  background: transparent;
}

.past-view-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--app-text-heading);
  margin-bottom: 24px;
  padding-left: 2.5rem;  /* Align with timeline content */
}

/* Timeline container with vertical line */
.journal-entries-list {
  position: relative;
  padding-left: 2rem;
}

/* Vertical timeline line */
.journal-entries-list::before {
  content: '';
  position: absolute;
  left: 0.5rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--color-primary-500), var(--color-primary-200));
  border-radius: 1px;
}

/* Date header with timeline marker */
.journal-date-header {
  position: relative;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--app-text-heading);
  padding: 8px 0;
  margin-top: 24px;
  margin-bottom: 12px;
  border-bottom: none;
}

/* First date header needs less top margin */
.journal-date-header:first-child {
  margin-top: 0;
}

/* Timeline dot marker for date headers */
.journal-date-header::before {
  content: '';
  position: absolute;
  left: -1.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  background: var(--color-primary-500);
  border-radius: 50%;
  border: 2px solid var(--color-white);
  box-shadow: 0 0 0 2px var(--color-primary-200);
}

/* Individual entry card - timeline style */
.journal-entry-card {
  background: var(--app-card-bg);
  border: none;
  border-left: 3px solid var(--color-primary-200);
  border-radius: 0 8px 8px 0;
  padding: 16px 20px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.journal-entry-card:hover {
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
  border-left-color: var(--color-primary-400);
}

/* Time badge */
.entry-time-badge {
  display: inline-block;
  background: var(--app-entry-time-badge-bg);
  color: var(--color-white);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 12px;
}

/* Entry text */
.entry-text {
  color: var(--app-text-heading);
  font-size: 1rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Loading indicator */
.loading-indicator {
  text-align: center;
  padding: 40px 20px;
}

.loading-indicator .spinner {
  border: 4px solid var(--color-gray-100);
  border-top: 4px solid var(--app-entry-time-badge-bg);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto 15px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-indicator p {
  color: var(--app-text-muted);
  font-size: 0.95rem;
}

/* No entries message */
.no-entries-message {
  text-align: center;
  padding: 60px 20px;
}

.no-entries-message p {
  color: var(--app-text-muted);
  font-size: 1.1rem;
}

/* Scroll sentinel (invisible) */
#scroll-sentinel {
  height: 10px;
  visibility: hidden;
}

/* Responsive design for timeline */
@media (max-width: 768px) {
  .past-view-container {
    padding: 15px;
  }

  .past-view-title {
    font-size: 1.5rem;
    padding-left: 2rem;
  }

  .journal-entries-list {
    padding-left: 1.5rem;
  }

  .journal-entries-list::before {
    left: 0.35rem;
  }

  .journal-date-header::before {
    left: -1.35rem;
    width: 10px;
    height: 10px;
  }

  .journal-entry-card {
    padding: 12px 15px;
  }

  .journal-date-header {
    font-size: 1rem;
  }
}

/* ============================================================================
   reCAPTCHA Badge Positioning
   ============================================================================ */

/* Hide reCAPTCHA badge by default to prevent content overlap */
.grecaptcha-badge {
  visibility: hidden !important;
}

/* Show badge only on pages that use reCAPTCHA (login, signup, contact) */
body.has-recaptcha .grecaptcha-badge {
  visibility: visible !important;
  bottom: 20px !important;
  right: 20px !important;
}

/* Mobile adjustment - position above any fixed bottom navigation */
@media (max-width: 768px) {
  body.has-recaptcha .grecaptcha-badge {
    bottom: 70px !important;
  }
}

/* ============================================================================
   TOAST NOTIFICATIONS
   ============================================================================ */

.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
  width: 100%;
  pointer-events: none;
}

.toast-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  pointer-events: auto;
  animation: toast-enter 0.3s ease-out forwards;
}

.toast-item.toast-removing {
  animation: toast-exit 0.2s ease-in forwards;
}

/* Toast type variants */
.toast-success {
  background: var(--color-green-50, #f0fdf4);
  border: 1px solid var(--color-green-200, #bbf7d0);
  color: var(--color-green-800, #166534);
}

.toast-success .toast-icon {
  color: var(--color-green-600, #16a34a);
}

.toast-error {
  background: var(--color-red-50, #fef2f2);
  border: 1px solid var(--color-red-200, #fecaca);
  color: var(--color-red-800, #991b1b);
}

.toast-error .toast-icon {
  color: var(--color-red-600, #dc2626);
}

.toast-warning {
  background: var(--color-yellow-50, #fefce8);
  border: 1px solid var(--color-yellow-200, #fef08a);
  color: var(--color-yellow-800, #854d0e);
}

.toast-warning .toast-icon {
  color: var(--color-yellow-600, #ca8a04);
}

.toast-info {
  background: var(--color-blue-50, #eff6ff);
  border: 1px solid var(--color-blue-200, #bfdbfe);
  color: var(--color-blue-800, #1e40af);
}

.toast-info .toast-icon {
  color: var(--color-blue-600, #2563eb);
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.toast-message {
  flex: 1;
  font-size: 0.875rem;
  line-height: 1.4;
  font-weight: 500;
}

.toast-close {
  flex-shrink: 0;
  padding: 4px;
  margin: -4px -4px -4px 8px;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.toast-close:hover {
  opacity: 1;
}

.toast-close svg {
  width: 16px;
  height: 16px;
}

/* Toast animations */
@keyframes toast-enter {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-exit {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* Mobile toast positioning */
@media (max-width: 640px) {
  .toast-container {
    top: auto;
    bottom: 16px;
    left: 16px;
    right: 16px;
    max-width: none;
  }

  @keyframes toast-enter {
    from {
      opacity: 0;
      transform: translateY(100%);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes toast-exit {
    from {
      opacity: 1;
      transform: translateY(0);
    }
    to {
      opacity: 0;
      transform: translateY(100%);
    }
  }
}

/* ============================================================================
   LOADING SPINNER COMPONENT
   ============================================================================ */

.spinner {
  display: inline-block;
  border-radius: 50%;
  border-style: solid;
  animation: spinner-rotate 0.75s linear infinite;
}

/* Spinner sizes */
.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner-md {
  width: 24px;
  height: 24px;
  border-width: 3px;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

/* Spinner color variants */
.spinner-primary {
  border-color: var(--color-gray-200, #e5e7eb);
  border-top-color: var(--color-primary-600, #6366f1);
}

.spinner-white {
  border-color: rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
}

.spinner-current {
  border-color: currentColor;
  border-top-color: transparent;
  opacity: 0.3;
}

.spinner-current::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 50%;
  border-style: solid;
  border-width: inherit;
  border-color: transparent;
  border-top-color: currentColor;
  opacity: 1;
}

@keyframes spinner-rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Screen reader only text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ============================================================================
   BUTTON LOADING STATE
   ============================================================================ */

.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

.btn-loading .spinner {
  margin-right: 8px;
}
