/* =================================================================
   Platform-Out Frontend Styles
   Migrated from Streamlit to pure CSS
   ================================================================= */

/* Base & Reset */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: #FBFBFD !important;
  color: #1a1a1a !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
}

/* Page Container */
.block-container {
  padding-top: 24px;
  padding-bottom: 48px;
  min-height: 100vh;
  max-width: 1200px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

/* Loading Spinner */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
}

.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #67bed9;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
}

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

/* Section Loading Spinner */
.section-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.section-loading .spinner {
  width: 40px;
  height: 40px;
  margin-bottom: 12px;
}

.section-loading p {
  color: #666;
  font-size: 14px;
  margin: 0;
}

/* Error Container */
.error-container {
  max-width: 600px;
  margin: 100px auto;
  padding: 40px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  text-align: center;
}

/* Buttons */
.button {
  appearance: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  line-height: 1;
  padding: 12px 16px;
  font-size: 14px;
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease, color 120ms ease;
  display: inline-block;
  text-decoration: none;
}

.button:hover {
  text-decoration: none;
}

.button--primary {
  background-color: #67bed9;
  color: #ffffff;
  box-shadow:
    0 1px 1px rgba(0,0,0,0.05),
    0 4px 12px rgba(103, 190, 217, 0.25);
}

.button--primary:hover {
  background-color: #5aacca;
}

.button--primary:active {
  background-color: #4d9ab8;
}

/* Frames (sections) */
.frame {
  width: 100%;
  padding: 24px 0;
  border-top: 1px solid #eeeeee;
}

.frame:first-of-type {
  border-top: none;
}

.frame__title {
  margin: 0 0 16px 0;
  font-size: 20px;
  font-weight: 700;
  color: #1a1a1a;
}

/* Cards Layout */
.cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
}

.card {
  width: auto;
  background: #ffffff;
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow:
    0 1px 1px rgba(0,0,0,0.04),
    0 6px 18px rgba(0,0,0,0.06);
}

.card__number {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  flex-shrink: 0;
}

/* Chatbot Window */
.chatbot-window {
  max-width: 800px;
  margin: 0 auto 24px auto;
  background: #ffffff;
  border-radius: 12px;
  box-shadow:
    0 1px 1px rgba(0,0,0,0.04),
    0 6px 18px rgba(0,0,0,0.06);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: height 0.3s ease;
  position: relative;
  min-height: 200px;
}

.chat-messages {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-message-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.chat-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
  word-wrap: break-word;
}

.chat-bubble--ai {
  align-self: flex-start;
  background-color: #f0f7f9;
  color: #1a1a1a;
  border-bottom-left-radius: 2px;
  margin-left: 30px; /* Space for avatar */
}

.chat-bubble--ai::before {
  content: "";
  display: block;
  width: 40px;
  height: 40px;
  position: absolute;
  left: -25px;
  top: -15px;
  background-image: url('/images/aiava.png');
  background-size: cover;
  background-position: center;
  border-radius: 50%;
  background-color: #f0f7f9;
  z-index: 1;
}

/* Thinking Dots Animation */
.thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 20px;
}

.thinking-dots span {
  width: 4px;
  height: 4px;
  background-color: #67bed9;
  border-radius: 50%;
  display: inline-block;
  animation: thinking-dots 1.4s infinite ease-in-out both;
}

.thinking-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.thinking-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes thinking-dots {
  0%, 80%, 100% { 
    transform: scale(0);
    opacity: 0.3;
  } 
  40% { 
    transform: scale(1.0);
    opacity: 1;
  }
}

/* Typewriter Cursor */
.typewriter-cursor::after {
  content: "|";
  animation: cursor-blink 0.7s infinite;
  margin-left: 2px;
  color: #67bed9;
  font-weight: bold;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

.chat-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-left: 30px; /* Align with AI bubble */
  align-items: flex-start;
  transition: opacity 0.3s ease;
}

.chat-buttons.hidden {
  opacity: 0;
  pointer-events: none;
}

.chat-button {
  appearance: none;
  border: 1px solid #67bed9;
  border-radius: 18px;
  background-color: #ffffff;
  color: #67bed9;
  cursor: pointer;
  font-weight: 500;
  line-height: 1.2;
  padding: 8px 16px;
  font-size: 13px;
  transition: all 0.3s ease;
  width: auto;
  max-width: 100%;
  text-align: left;
  position: relative;
  top: 0;
}

.chat-button.selected {
  background-color: #67bed9;
  color: #ffffff;
  border-color: #67bed9;
  cursor: default;
}

.chat-button.hidden {
  display: none;
}

.chat-button:hover:not(.selected) {
  background-color: #f0f7f9;
  border-color: #5aacca;
  color: #5aacca;
}

.chat-button:active:not(.selected) {
  transform: translateY(1px);
}

.chat-bubble h3, .chat-bubble h4 {
  margin: 8px 0 4px 0;
  line-height: 1.2;
}

.chat-bubble h3 {
  font-size: 1.1em;
}

.chat-bubble h4 {
  font-size: 1em;
}

.chat-bubble p {
  margin: 4px 0 8px 0;
}

.chat-bubble ul {
  margin: 4px 0 8px 20px;
  padding: 0;
}

.chat-bubble li {
  margin-bottom: 4px;
}

.text-highlight {
  background-color: #17dcad;
  padding: 0 4px;
  border-radius: 4px;
  font-weight: 600;
  color: #ffffff;
}

/* Chat Clinic Cards Grid (inside chat bubble) */
.chat-clinic-cards-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

/* Chat Clinic Card */
.chat-clinic-card {
  background: #ffffff;
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.chat-clinic-card__specialty {
  font-weight: 700;
  font-size: 13px;
  color: #1a1a1a;
}

.chat-clinic-card__header {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
}

.chat-clinic-card__name {
  font-size: 11px;
  color: #666666;
  font-weight: 400;
  line-height: 1.3;
}

.chat-clinic-card__price {
  font-size: 12px;
  font-weight: 600;
  color: #1a1a1a;
  margin-top: 2px;
}

.chat-clinic-card__btn {
  margin-top: 8px;
  align-self: flex-start;
  font-size: 12px;
  padding: 8px 14px;
}

/* Recommendation Text Box */
.recommendation-text {
  max-width: 800px;
  margin: 0 auto 16px auto;
  background: #ffffff;
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow:
    0 1px 1px rgba(0,0,0,0.04),
    0 6px 18px rgba(0,0,0,0.06);
  font-weight: 600;
  color: #1a1a1a;
  text-align: center;
}

.recommendation-text pre {
  margin: 0;
  text-align: left;
  white-space: pre-wrap;
  font-size: 0.9em;
  font-family: inherit;
}

/* App Logo */
.app-logo {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1000;
  max-width: 200px;
  max-height: 80px;
}

.app-logo img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.chat-button-label {
  display: block;
  cursor: pointer;
}

.chat-button-label .chat-button {
  pointer-events: none; /* Let the label handle the click */
}

/* Popup Overlay */
.popup-toggle {
  display: none;
}

.popup-overlay {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #F2F6FD;
  z-index: 1000;
  border-radius: 12px;
  padding: 20px;
}

/* Show popup when checkbox is checked */
.popup-toggle:checked ~ .popup-overlay {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.popup-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 28px;
  line-height: 1;
  transition: color 0.2s ease;
}

.popup-close:hover {
  color: #333;
}

/* Popup Form */
.popup-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 360px;
}

.popup-form-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.popup-form-row.checkbox {
  gap: 8px;
}

.popup-form label {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
  white-space: nowrap;
  min-width: 70px;
}

.popup-form-row.checkbox label {
  white-space: normal;
  min-width: auto;
}

.popup-form-row.checkbox label a {
  color: #67bed9;
  text-decoration: underline;
  cursor: pointer;
  transition: color 0.2s ease;
}

.popup-form-row.checkbox label a:hover {
  color: #5aacca;
  text-decoration: underline;
}

.popup-form-row.checkbox label a:visited {
  color: #67bed9;
}

.popup-form input[type="text"],
.popup-form input[type="tel"] {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  color: #1a1a1a;
  background: #ffffff;
  transition: border-color 0.2s ease;
}

.popup-form input[type="text"]:focus,
.popup-form input[type="tel"]:focus {
  outline: none;
  border-color: #67bed9;
}

.popup-form input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #67bed9;
}

.popup-form-submit {
  display: flex;
  justify-content: center;
  margin-top: 4px;
}

/* Disabled button state */
#callSubmitBtn {
  background-color: #cccccc;
  color: #666666;
  cursor: not-allowed;
  box-shadow: none;
  pointer-events: none;
  padding: 10px 20px;
  font-size: 13px;
}

#callSubmitBtn:hover {
  background-color: #cccccc;
}

/* Enable button when consent is checked */
#consent:checked ~ .popup-form-rows #callSubmitBtn,
.popup-form:has(#consent:checked) #callSubmitBtn {
  background-color: #67bed9;
  color: #ffffff;
  cursor: pointer;
  box-shadow:
    0 1px 1px rgba(0,0,0,0.05),
    0 4px 12px rgba(103, 190, 217, 0.25);
  pointer-events: auto;
}

.popup-form:has(#consent:checked) #callSubmitBtn:hover {
  background-color: #5aacca;
}

.popup-form:has(#consent:checked) #callSubmitBtn:active {
  background-color: #4d9ab8;
}

/* Make partners section relatively positioned */
#frame-partners {
  position: relative;
}

/* =================================================================
   Authorization Form Styles
   ================================================================= */

.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background-color: #FBFBFD;
}

.auth-content {
  width: 100%;
  max-width: 500px;
  background: #ffffff;
  border-radius: 12px;
  padding: 40px;
  box-shadow:
    0 1px 1px rgba(0,0,0,0.04),
    0 6px 18px rgba(0,0,0,0.06);
}

.auth-title {
  margin: 0 0 32px 0;
  font-size: 24px;
  font-weight: 700;
  color: #1a1a1a;
  text-align: center;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.auth-error {
  padding: 12px 16px;
  background-color: #fee;
  border: 1px solid #fcc;
  border-radius: 8px;
  color: #c33;
  font-size: 14px;
  margin-bottom: 8px;
}

.auth-form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-label {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 4px;
}

.auth-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  color: #1a1a1a;
  background: #ffffff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
}

.auth-input:focus {
  outline: none;
  border-color: #67bed9;
  box-shadow: 0 0 0 3px rgba(103, 190, 217, 0.1);
}

.auth-input:hover {
  border-color: #bbb;
}

.auth-hint {
  margin: 4px 0 0 0;
  font-size: 12px;
  color: #666;
  line-height: 1.4;
}

.auth-form-submit {
  margin-top: 8px;
  display: flex;
  justify-content: center;
}

.auth-form-submit .button {
  width: 100%;
  padding: 14px 24px;
  font-size: 16px;
}

/* Responsive adjustments for auth form */
@media (max-width: 600px) {
  .auth-container {
    padding: 20px 14px;
    align-items: flex-start;
    padding-top: max(20px, env(safe-area-inset-top));
  }

  .auth-content {
    padding: 28px 18px;
    border-radius: 10px;
  }

  .auth-title {
    font-size: 20px;
    margin-bottom: 24px;
  }

  .auth-form {
    gap: 20px;
  }

  .auth-input {
    min-height: 48px;
    padding: 14px 16px;
    font-size: 16px;
  }

  .auth-form-submit .button {
    min-height: 48px;
  }
}
