/* ── AskAncients Advise Page CSS ──
   Styles specific to the advise/index page.
*/

/* ── Input section ── */
.input-section {
  margin-bottom: 30px;
}

.input-section label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

textarea {
  width: 100%;
  min-height: 120px;
  padding: 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.3s;
}

/* Parchment textarea on advise page */
.page-advise textarea {
  background: rgba(255, 250, 240, 0.6);
  border-color: rgba(200, 190, 170, 0.4);
}
.page-advise textarea:focus {
  border-color: #667eea;
}

/* ── Draft restored hint ── */
.draft-hint {
  font-size: 12px;
  color: rgba(61, 50, 37, 0.5);
  margin-top: 6px;
  opacity: 0;
  transition: opacity 0.4s;
  height: 0;
  overflow: hidden;
}

.draft-hint.visible {
  opacity: 1;
  height: auto;
}

textarea:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.button-group {
  display: flex;
  gap: 12px;
  margin-bottom: 30px;
}

button {
  flex: 1;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-primary {
  background: linear-gradient(135deg, #b8860b 0%, #8b6914 100%);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(184, 134, 11, 0.3);
}

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

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

.btn-secondary:hover {
  background: #e0e0e0;
}

/* Parchment buttons on advise page */
.page-advise .btn-secondary {
  background: rgba(255, 250, 240, 0.5);
  border: 1px solid rgba(160, 140, 110, 0.2);
}
.page-advise .btn-secondary:hover {
  background: rgba(255, 250, 240, 0.7);
}

/* ── Examples ── */
.examples {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.example-btn {
  padding: 10px 12px;
  background: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  color: #555;
}

.example-btn:hover {
  background: #f0f0f0;
  border-color: #667eea;
  color: #333;
}

/* Parchment example buttons */
.page-advise .example-btn {
  background: transparent;
  border-color: rgba(160, 140, 110, 0.2);
}
.page-advise .example-btn:hover {
  background: rgba(255, 250, 240, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-color: #667eea;
}

.example-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #999;
  margin-bottom: 8px;
  font-weight: 600;
}

/* ── Response section ── */
.response-section {
  display: none;
  margin-top: 30px;
  padding-top: 30px;
  border-top: 2px solid #e0e0e0;
}

/* Parchment border */
.page-advise .response-section {
  border-top-color: rgba(160, 140, 110, 0.25);
}

.response-section.active {
  display: block;
}

.response-header {
  margin-bottom: 20px;
}

.response-header h2 {
  font-size: 18px;
  color: #667eea;
  margin-bottom: 8px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.response-body {
  font-size: 15px;
  line-height: 1.8;
  color: #444;
}

.response-body.plain-text {
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ── Loading ── */
.loading {
  display: none;
  text-align: center;
  padding: 30px;
  color: #667eea;
}

.loading.active {
  display: block;
}

.inline-loading {
  display: none;
  text-align: center;
  padding: 30px;
  color: #667eea;
}

.inline-loading.active {
  display: block;
}

.loading-fact {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding: 14px 20px;
  background: #fafafe;
  border-radius: 10px;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  text-align: left;
  opacity: 0;
  transition: opacity 0.4s ease;
}

/* Parchment loading fact */
.page-advise .loading-fact {
  background: rgba(255, 250, 240, 0.4);
  border: 1px solid rgba(160, 140, 110, 0.15);
}

.loading-fact.visible {
  opacity: 1;
}

.loading-fact .fact-monogram {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: white;
  font-family: Georgia, 'Times New Roman', serif;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.loading-fact .fact-content {
  flex: 1;
  min-width: 0;
}

.loading-fact .fact-philosopher {
  font-size: 12px;
  font-weight: 600;
  color: #667eea;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
}

.loading-fact .fact-text {
  font-size: 13px;
  line-height: 1.5;
  color: #555;
}

.spinner {
  border: 3px solid rgba(160, 140, 110, 0.15);
  border-top: 3px solid #667eea;
  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); }
}

/* ── Error & nudge ── */
.error {
  display: none;
  padding: 16px;
  background: #fee;
  border: 1px solid #fcc;
  border-radius: 8px;
  color: #c00;
  margin-bottom: 20px;
  font-size: 14px;
}

.error.active {
  display: block;
}

.error strong {
  display: block;
  margin-bottom: 4px;
  font-size: 15px;
}

.error-retry-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 20px;
  background: #c00;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.error-retry-btn:hover {
  background: #a00;
  transform: translateY(-1px);
}

.nudge {
  display: none;
  padding: 14px 16px;
  background: #f0f0ff;
  border: 1px solid #d0d0ee;
  border-radius: 8px;
  color: #555;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.5;
}

/* Parchment nudge */
.page-advise .nudge {
  background: rgba(255, 250, 240, 0.5);
  border-color: rgba(160, 140, 110, 0.25);
}

.nudge.active {
  display: block;
}

/* ── Challenge summary & exploration invite ── */
.challenge-summary {
  font-size: 15px;
  line-height: 1.7;
  color: #555;
  margin-bottom: 25px;
  padding: 16px 20px;
  background: #fafafe;
  border-left: 3px solid #667eea;
  border-radius: 0 8px 8px 0;
}

/* Parchment challenge summary */
.page-advise .challenge-summary {
  background: rgba(255, 250, 240, 0.4);
}

.exploration-invite {
  font-size: 14px;
  line-height: 1.6;
  color: #777;
  font-style: italic;
}

/* ── Follow-up section ── */
.follow-up-section {
  display: none;
  margin-top: 25px;
  padding-top: 25px;
  border-top: 1px solid #e0e0e0;
}

/* Parchment border */
.page-advise .follow-up-section {
  border-top-color: rgba(160, 140, 110, 0.2);
}

.follow-up-section.active {
  display: block;
}

.follow-up-section label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.follow-up-section textarea {
  min-height: 80px;
  margin-bottom: 12px;
}

.follow-up-btn {
  display: inline-block;
  flex: none;
  padding: 10px 24px;
  background: linear-gradient(135deg, #b8860b 0%, #8b6914 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.follow-up-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

/* Parchment: warm gold follow-up button */
.page-advise .follow-up-btn {
  background: linear-gradient(135deg, #b8860b 0%, #8b6914 100%);
}
.page-advise .follow-up-btn:hover:not(:disabled) {
  box-shadow: 0 10px 20px rgba(184, 134, 11, 0.3);
}

.follow-up-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.follow-up-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.new-question-btn {
  display: inline-block;
  flex: none;
  padding: 10px 20px;
  background: #f0f0f0;
  color: #555;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.new-question-btn:hover {
  background: #e0e0e0;
  color: #333;
}

/* Parchment new question button */
.page-advise .new-question-btn {
  background: rgba(255, 250, 240, 0.5);
  border: 1px solid rgba(160, 140, 110, 0.2);
}
.page-advise .new-question-btn:hover {
  background: rgba(255, 250, 240, 0.7);
}

/* ── Exchange counter ── */
.exchange-counter {
  font-size: 12px;
  color: #999;
  margin-bottom: 15px;
}

/* ── Session limit ── */
.session-limit {
  display: none;
  padding: 20px;
  background: linear-gradient(135deg, #f0f0ff 0%, #faf0ff 100%);
  border: 1px solid #d0d0ee;
  border-radius: 8px;
  text-align: center;
  margin-top: 25px;
}

/* Parchment session limit */
.page-advise .session-limit {
  background: rgba(255, 250, 240, 0.5);
  border-color: rgba(160, 140, 110, 0.25);
}

.session-limit.active {
  display: block;
}

.session-limit p {
  font-size: 14px;
  color: #555;
  line-height: 1.6;
  margin-bottom: 15px;
}

.new-session-btn {
  display: inline-block;
  flex: none;
  padding: 10px 24px;
  background: #f0f0f0;
  color: #333;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.new-session-btn:hover {
  background: #e0e0e0;
}

/* Parchment new session button */
.page-advise .new-session-btn {
  background: rgba(255, 250, 240, 0.5);
  border: 1px solid rgba(160, 140, 110, 0.2);
}
.page-advise .new-session-btn:hover {
  background: rgba(255, 250, 240, 0.7);
}

.session-feedback-prompt {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  font-size: 13px;
  color: #888;
}

/* ── Conversation history ── */
.conversation-history {
  margin-bottom: 20px;
}

.conversation-entry {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #eee;
}

/* Parchment conversation borders */
.page-advise .conversation-entry {
  border-bottom-color: rgba(160, 140, 110, 0.15);
}

.conversation-entry:last-child {
  border-bottom: none;
}

.conversation-entry .user-question {
  font-size: 13px;
  color: #667eea;
  font-weight: 600;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.conversation-entry .user-question-text {
  font-size: 14px;
  color: #666;
  margin-bottom: 12px;
  font-style: italic;
}

.conversation-entry .response-text {
  font-size: 15px;
  line-height: 1.8;
  color: #444;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ── Usage Status ── */
.usage-status {
  display: none;
  font-size: 12px;
  color: rgba(61, 50, 37, 0.6);
  margin-bottom: 16px;
  padding: 8px 12px;
  background: rgba(255, 250, 240, 0.3);
  border: 1px solid rgba(160, 140, 110, 0.15);
  border-radius: 8px;
}

.usage-status.active {
  display: block;
}

.usage-admin-badge {
  display: inline-block;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  color: #b8860b;
  background: rgba(184, 134, 11, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 6px;
}

/* ── Limit Reached Overlay ── */
.usage-limit-reached {
  display: none;
  margin-bottom: 20px;
}

.usage-limit-reached.active {
  display: block;
}

.limit-reached-content {
  text-align: center;
  padding: 28px 24px;
  background: rgba(255, 250, 240, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(160, 140, 110, 0.25);
  border-radius: 12px;
}

.limit-reached-icon {
  font-size: 32px;
  margin-bottom: 10px;
}

.limit-reached-title {
  font-size: 16px;
  font-weight: 600;
  color: #3d3225;
  margin-bottom: 6px;
}

.limit-reached-message {
  font-size: 14px;
  color: rgba(61, 50, 37, 0.7);
  margin-bottom: 12px;
}

.limit-reached-countdown {
  font-size: 13px;
  font-weight: 600;
  color: #b8860b;
  margin-bottom: 16px;
}

.limit-reached-upgrade {
  font-size: 12px;
  color: rgba(61, 50, 37, 0.5);
  line-height: 1.5;
}

/* ── Sage Picker Lock ── */
.sage-picker-lock {
  display: none;
  text-align: center;
  padding: 14px;
  margin-top: 10px;
  background: rgba(255, 250, 240, 0.4);
  border: 1px dashed rgba(160, 140, 110, 0.3);
  border-radius: 8px;
}

.sage-picker-lock.active {
  display: block;
}

.sage-lock-icon {
  font-size: 18px;
  margin-bottom: 4px;
}

.sage-lock-text {
  font-size: 12px;
  color: rgba(61, 50, 37, 0.55);
}

/* Locked grid — dim and disable interaction */
.sage-picker-grid.locked {
  opacity: 0.4;
  pointer-events: none;
}

/* ── Sage Picker ── */
.sage-picker {
  margin-bottom: 24px;
}

.sage-picker-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.sage-picker-label {
  font-size: 13px;
  font-weight: 600;
  color: #6b5a3e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sage-picker-link {
  font-size: 12px;
  color: #8b7355;
  text-decoration: none;
  transition: color 0.2s;
}
.sage-picker-link:hover {
  color: #6b5a3e;
}

.sage-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sage-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 5px;
  background: transparent;
  border: 1px solid rgba(160, 140, 110, 0.2);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.25s ease;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary, #5e6470);
  font-family: inherit;
  text-transform: none;
  letter-spacing: 0;
  flex: none;
}

.sage-chip:hover {
  background: rgba(255, 250, 240, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-color: rgba(160, 140, 110, 0.35);
  transform: translateY(-1px);
}

.sage-chip.selected {
  background: rgba(184, 134, 11, 0.1);
  border-color: rgba(184, 134, 11, 0.4);
  color: #6b5a3e;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(184, 134, 11, 0.12);
}

.sage-chip-portrait {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: white;
  font-family: Georgia, 'Times New Roman', serif;
  object-fit: cover;
}

.sage-chip-name {
  white-space: nowrap;
}

/* ── Selected sage info bar ── */
.sage-picker-selected {
  display: none;
  margin-top: 12px;
  padding: 12px 16px;
  background: rgba(255, 250, 240, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(184, 134, 11, 0.25);
  border-radius: 10px;
  align-items: center;
  justify-content: space-between;
}

.sage-picker-selected.active {
  display: flex;
}

.sage-selected-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sage-selected-portrait {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: white;
  font-family: Georgia, 'Times New Roman', serif;
  object-fit: cover;
}

.sage-selected-info strong {
  font-size: 14px;
  color: #3d3225;
  display: block;
}

.sage-selected-school {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #667eea;
  background: rgba(102, 126, 234, 0.08);
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 8px;
  font-weight: 600;
  vertical-align: middle;
}

.sage-selected-bio {
  font-size: 12px;
  color: rgba(61, 50, 37, 0.6);
  margin-top: 2px;
}

.sage-deselect-btn {
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  background: none;
  border: 1px solid rgba(160, 140, 110, 0.2);
  border-radius: 50%;
  font-size: 16px;
  color: rgba(61, 50, 37, 0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  text-transform: none;
  letter-spacing: 0;
}

.sage-deselect-btn:hover {
  background: rgba(0, 0, 0, 0.04);
  color: rgba(61, 50, 37, 0.8);
}

/* ── Sage card deeper context styling ── */
.sage-deeper-context {
  font-style: italic;
  color: rgba(61, 50, 37, 0.7);
}

/* ── Sage card — slightly stronger tint than 3-perspective cards ── */
.sage-card {
  border-left-width: 4px;
}

/* ── Mobile responsive: advise-specific ── */
@media (max-width: 600px) {
  .button-group {
    flex-direction: column;
  }

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

  .sage-picker-header {
    flex-direction: column;
    gap: 4px;
  }

  .sage-picker-grid {
    gap: 6px;
  }

  .sage-chip {
    padding: 4px 8px 4px 4px;
    font-size: 11px;
  }

  .sage-chip-portrait {
    width: 22px;
    height: 22px;
    font-size: 9px;
  }

  .sage-picker-selected {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }

  .sage-deselect-btn {
    align-self: flex-end;
  }
}

/* ── Guest cap CTA (shown to guests when they hit the 1/day limit) ── */
.limit-reached-guest-cta {
  display: none;
  margin: 16px 0 4px;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.limit-reached-guest-cta.active {
  display: flex;
}

.limit-guest-signup-btn {
  display: inline-block;
  padding: 11px 22px;
  border-radius: 8px;
  background: linear-gradient(135deg, #b8860b 0%, #8b6914 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.15s;
}

.limit-guest-signup-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.limit-guest-sub {
  font-size: 12.5px;
  color: rgba(61, 50, 37, 0.55);
  line-height: 1.4;
}
