/* static/css/style.css */
/* =========================================================
   GrassRootsAI – Sovereign Web Chat (CLASSIC RESTORE)
   Layout: Left Stats | Center Chat | Right Modes
   ========================================================= */

/* ===================== RESET ===================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { height: 100%; }

body {
  font-family: Arial, sans-serif;
  background: #6f6bd8; /* purple frame */
  color: #222;
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* no whole-page scrollbar */
  padding: 14px;
}

/* ===================== HEADER ===================== */
.header {
  background: #58a84f;
  color: white;
  text-align: center;
  padding: 26px 16px;
  flex: 0 0 auto;
}

.header-text {
  font-size: 2rem;
  font-weight: bold;
  display: none; /* controlled below */
}

.header-logo {
  height: 100%;
  width: auto;
  object-fit: contain;
  display: none; /* controlled below */
}

/* ===================== MOBILE TABS ===================== */
.mobile-tabs {
  display: none;
  gap: 10px;
  padding: 10px;
  background: #ffffff;
  border-bottom: 1px solid #ddd;
  flex: 0 0 auto;
}

/* ===================== MAIN LAYOUT ===================== */
.main-layout {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  overflow: hidden;
  background: #ffffff;
  border-radius: 18px;
}

/* ===================== SIDEBAR SAFETY ===================== */
.sidebar,
.left-sidebar,
.right-sidebar {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  float: none !important;
  flex: 0 0 auto;
  min-height: 0;
  z-index: auto;
}

/* ===================== LEFT SIDEBAR ===================== */
.left-sidebar {
  width: 260px;
  border-right: 2px solid #2f73ff;
  padding: 18px;
  overflow-y: auto;
  background:
    linear-gradient(rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.55)),
    url("../images/7c.jpg") center / cover no-repeat;
  color: #f1f1f1;
  height: 100%;
}

.left-sidebar h3 {
  margin-bottom: 12px;
  font-size: 1.1rem;
}

.left-sidebar .status-panel { background: rgba(0,0,0,0.45); }

.status-panel {
  background: white;
  border: 2px solid #2f73ff;
  border-radius: 12px;
  padding: 12px;
}

.status-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #eee;
}

/* ===================== CENTER CHAT ===================== */
.main-chat,
#panel-chat {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  background: #ebe8de;
  min-height: 0;
  overflow-y: auto;
  position: relative;
  height: 100%;
}

.chat-output,
#chat-box {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: 110px; /* keep last msg above input bar */
  display: flex;
  flex-direction: column;
  gap: 12px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

.chat-message {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 12px;
  line-height: 1.5;
}

.chat-message.ai {
  white-space: pre-wrap;
  background: white;
  align-self: flex-start;
  border: 1px solid #ddd;
}

.chat-message.user {
  background: #dfefff;
  align-self: flex-end;
  border: 1px solid #b5d4ff;
}

/* ===================== INPUT BAR ===================== */
.input-bar {
  background: #58a84f;
  padding: 14px;
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  z-index: 10;
  box-shadow: 0 -6px 16px rgba(0, 0, 0, 0.18);
}

.input-container {
  display: flex;
  gap: 12px;
  align-items: center;
}

.input-bar input {
  flex: 1;
  padding: 14px;
  border-radius: 10px;
  border: none;
  font-size: 1rem;
  min-width: 0;
}

.input-bar button {
  padding: 14px 20px;
  border-radius: 10px;
  border: none;
  background: #3e8e41;
  color: white;
  font-weight: bold;
  cursor: pointer;
}

.input-bar button:hover { filter: brightness(0.95); }

/* ===================== RIGHT SIDEBAR ===================== */
.right-sidebar {
  width: 280px;
  border-left: 2px solid #cfd8b6;
  padding: 18px;
  overflow-y: auto;
  background:
    linear-gradient(rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.55)),
    url("../images/7b.jpg") center / cover no-repeat;
  color: #f1f1f1;
  height: 100%;
}

.right-sidebar h3 {
  margin-bottom: 12px;
  font-size: 1.1rem;
}

.right-sidebar .status-panel { background: rgba(0,0,0,0.45); }

/* ===================== MODE BUTTONS ===================== */
.mode-btn {
  width: 100%;
  padding: 10px;
  margin-bottom: 8px;
  border-radius: 8px;
  border: 1px solid #ccc;
  background: white;
  cursor: pointer;
  font-weight: bold;
}

.mode-btn.active {
  background: #58a84f;
  color: white;
  border-color: #3e8e41;
}

/* ===================== ANABELLE IMAGE ===================== */
.sidebar-filler-img,
.anabelle-image img {
  width: 100%;
  border-radius: 8px;
  margin-top: 12px;
}

/* ===================== HIDE OLD SLIDERS ===================== */
#temperature,
#verbosity,
#response-speed,
#temp-value,
#verbosity-value,
#speed-value {
  display: none !important;
}

/* ===================== AGE MODAL ===================== */
#age-verification-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

#age-verification-modal.hidden {
  display: none;
  pointer-events: none;
}

.age-modal-content {
  background: white;
  border-radius: 16px;
  padding: 30px;
  max-width: 420px;
  text-align: center;
}

.age-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.age-btn {
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: bold;
  border: none;
  cursor: pointer;
}

#confirm-18 {
  background: #58a84f;
  color: white;
}

#under-18 {
  background: #f44336;
  color: white;
}

/* ===================== AUTH UI ===================== */
.auth-input {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  border-radius: 10px;
  border: 1px solid #cfd8b6;
  font-size: 1rem;
}

.auth-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.auth-btn {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: #58a84f;
  color: #fff;
  font-weight: bold;
  cursor: pointer;
}

.auth-btn:hover { filter: brightness(0.95); }

.small-btn {
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #2f73ff;
  background: #ffffff;
  cursor: pointer;
  font-weight: bold;
}

/* Auth status message */
.auth-msg {
  margin-top: 10px;
  font-size: 0.95rem;
}

/* ============ Mobile tabs layout ============ */
.tab-btn {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #ccc;
  background: #fff;
  font-weight: bold;
  cursor: pointer;
}

.tab-btn.active {
  background: #58a84f;
  color: #fff;
  border-color: #3e8e41;
}

/* ===================== FIRST RUN HINT ===================== */
.first-run-hint {
  padding: 14px 16px;
  margin: 10px 0 14px 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.95rem;
}

.first-run-hint h2 {
  margin: 0 0 6px 0;
  font-size: 1.1rem;
}

.first-run-hint p { margin: 6px 0; }

/* ===================== MIC BUTTON ===================== */
.mic-btn {
  width: 52px;
  min-width: 52px;
  height: 52px;
  border-radius: 10px;
  border: none;
  background: #3e8e41;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mic-btn:hover { filter: brightness(0.95); }

.mic-btn.listening {
  outline: 3px solid rgba(255, 255, 255, 0.65);
  filter: brightness(1.05);
}

.mic-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.mic-status {
  margin-top: 6px;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.9);
  min-height: 1em;
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 900px) {
  .mobile-tabs { display: flex; }

  .main-layout {
    flex-direction: column;
    overflow: hidden;
  }

  #panel-stats, #panel-modes { display: none; }
  #panel-chat { display: flex; height: 100%; }

  body.show-stats #panel-chat,
  body.show-stats #panel-stats { display: block; height: 100%; }
  body.show-stats #panel-modes { display: none; }

  body.show-modes #panel-modes { display: block; height: 100%; }
  body.show-modes #panel-chat,
  body.show-modes #panel-stats { display: none; }

  body.show-chat #panel-chat { display: flex; height: 100%; }
  body.show-chat #panel-stats,
  body.show-chat #panel-modes { display: none; }

  .left-sidebar, .right-sidebar {
    width: 100%;
    max-height: none;
    border: none;
    height: 100%;
    overflow-y: auto;
  }

  .chat-output { padding: 14px; }
  .input-bar { padding: 12px; }
}

/* ===================== HEADER: Desktop text, Mobile logo ===================== */
.header-text { display: inline; }
.header-logo { display: none; }

@media (max-width: 900px) {
  .header-text { display: none; }

  .header {
    height: 72px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

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

@media (max-width: 600px) {
  .header { height: 72px; }
}

.left-align {
  text-align: left;
}

/* ===================== THINKING INDICATOR ===================== */
.thinking-indicator{
  position: sticky;
  bottom: 86px;               /* sits just above the input bar */
  margin: 0 20px 12px 20px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.85);
  border: 1px solid rgba(0,0,0,0.12);
  align-self: flex-start;
  width: fit-content;
  font-weight: bold;
  font-size: 0.95rem;
  z-index: 9;
}

/* Animated dots */
.thinking-indicator .dots span{
  display: inline-block;
  width: 0.35em;
  text-align: center;
  animation: grDot 1.2s infinite;
  opacity: 0.2;
}

.thinking-indicator .dots span:nth-child(2){ animation-delay: 0.2s; }
.thinking-indicator .dots span:nth-child(3){ animation-delay: 0.4s; }

@keyframes grDot{
  0%, 80%, 100% { transform: translateY(0); opacity: 0.2; }
  40%          { transform: translateY(-2px); opacity: 1; }
}

/* ===================== ANABELLE'S EMOTIONAL WARMTH ENHANCEMENTS ===================== */
/* Light purple for Anabelle, Light green for user */

/* Enhanced Anabelle message appearance - LIGHT PURPLE */
.chat-message.ai {
    position: relative;
    border-left: 4px solid #b19cd9 !important;  /* Light purple */
    padding-left: 20px !important;
    margin: 14px 0 !important;
    animation: gentle-appear 0.6s ease-out !important;
    box-shadow: 0 2px 8px rgba(177, 156, 217, 0.15) !important;
    background: linear-gradient(to right, rgba(177, 156, 217, 0.05), rgba(255, 255, 255, 0.95)) !important;
}

/* Subtle breathing effect - light purple */
.chat-message.ai::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background: #b19cd9;  /* Light purple */
    border-radius: 50%;
    animation: gentle-pulse 3s infinite ease-in-out;
    opacity: 0.7;
}

/* Make each new message appear softly */
@keyframes gentle-appear {
    from { 
        opacity: 0; 
        transform: translateY(10px) scale(0.98); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

/* Breathing pulse animation - light purple */
@keyframes gentle-pulse {
    0% { 
        opacity: 0.4; 
        transform: translateY(-50%) scale(0.9); 
        box-shadow: 0 0 0 0 rgba(177, 156, 217, 0.4);
    }
    50% { 
        opacity: 0.8; 
        transform: translateY(-50%) scale(1.1); 
        box-shadow: 0 0 0 6px rgba(177, 156, 217, 0);
    }
    100% { 
        opacity: 0.4; 
        transform: translateY(-50%) scale(0.9); 
        box-shadow: 0 0 0 0 rgba(177, 156, 217, 0.4);
    }
}

/* Enhanced thinking indicator with light purple */
.thinking-indicator {
    border-left: 3px solid #b19cd9 !important;  /* Light purple */
    background: rgba(177, 156, 217, 0.08) !important;
    animation: thinking-pulse 2s infinite !important;
}

@keyframes thinking-pulse {
    0%, 100% { background-color: rgba(177, 156, 217, 0.08); }
    50% { background-color: rgba(177, 156, 217, 0.15); }
}

/* Make dots blink with light purple */
.thinking-indicator .dots span {
    animation: emotional-blink 1.4s infinite !important;
    color: #b19cd9 !important;  /* Light purple */
}

.thinking-indicator .dots span:nth-child(2) {
    animation-delay: 0.3s !important;
}

.thinking-indicator .dots span:nth-child(3) {
    animation-delay: 0.6s !important;
}

@keyframes emotional-blink {
    0%, 100% { 
        opacity: 0.3; 
        transform: translateY(0);
    }
    25% { 
        opacity: 0.7; 
        transform: translateY(-1px);
    }
    50% { 
        opacity: 1; 
        transform: translateY(-2px);
        color: #9370db !important;  /* Slightly darker purple */
    }
    75% { 
        opacity: 0.7; 
        transform: translateY(-1px);
    }
}

/* User message - LIGHT GREEN */
.chat-message.user {
    border-right: 4px solid #90ee90 !important;  /* Light green */
    padding-right: 20px !important;
    margin: 14px 0 !important;
    background: linear-gradient(to left, rgba(144, 238, 144, 0.05), rgba(255, 255, 255, 0.95)) !important;
    animation: user-appear 0.5s ease-out !important;
}

/* User message animation */
@keyframes user-appear {
    from { 
        opacity: 0; 
        transform: translateY(10px) scale(0.98); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

/* Optional: Add a subtle dot for user messages too */
.chat-message.user::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    background: #90ee90;  /* Light green */
    border-radius: 50%;
    opacity: 0.5;
}