/* style.css – Self-Compass AI Coach UI (Enhanced UX Version - Clean)
   Calm → Clarity → Connection
   -----------------------------------------------------------
   Enhancements:
   - Fade-in animations for bubbles
   - Better focus states
   - Link hover effects
   - User bubble gradient
   - Hover transform on bubbles
   - Timestamp fade (hover to reveal)
   - Character counter styling
   - Improved scrollbar
   - No unused "typing dots" code
*/

:root{
  --bg:#FAFBFC;
  --panel:#FFFFFF;
  --ink:#1D3557;
  --muted:#5C6F82;
  --line:#E6ECF2;
  --user:#2F4288;
  --user-ink:#FFFFFF;
  --bot:#F5F5F5;
  --bot-ink:#1D3557;

  --cta:#FFB178;
  --cta-ink:#1C2E7A;
  --cta-hov:#D67B4C;

  --radius:16px;
  --shadow:0 4px 12px rgba(29,53,87,.08);

  --bubble-width-desktop:86%;
  --bubble-width-mobile:92%;
}

/* Base */
#scapp, #scapp *{ box-sizing:border-box; }
html,body{ height:100%; margin:0; }
#scapp{
  height:100dvh;
  color:var(--ink);
  background:transparent;
  font:16px/1.55 "Open Sans",system-ui,-apple-system,Segoe UI,Roboto,Arial;
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}

/* Layout */
#scapp .container{
  height:100%;
  display:grid;
  grid-template-rows:auto minmax(0,1fr) auto;
  max-width:980px;
  margin:0 auto;
  padding:24px;
  gap:14px;
}

/* Header */
#scapp .header{
  display:flex; 
  align-items:center; 
  justify-content:flex-start;
  padding:16px 24px; 
  border:1px solid var(--line);
  border-radius:var(--radius); 
  background:var(--panel); 
  box-shadow:var(--shadow);
}
#scapp .brand{ 
  display:flex; 
  gap:12px; 
  align-items:center; 
  min-width:0; 
}
#scapp .logo{ 
  width:36px; 
  height:36px; 
  border-radius:10px; 
  display:grid; 
  place-items:center; 
  overflow:hidden; 
  border:1px solid #D7D7D7; 
  background:#fff; 
  flex:0 0 auto; 
}
#scapp .logo img{ 
  width:100%; 
  height:100%; 
  object-fit:contain; 
  display:block; 
}
#scapp .ttl{ 
  font-weight:700; 
  letter-spacing:.3px; 
  white-space:nowrap; 
}
#scapp .sub{ 
  font-weight:300; 
  font-size:12px; 
  color:var(--muted); 
  white-space:nowrap; 
  overflow:hidden; 
  text-overflow:ellipsis; 
}

/* Log (scrollable panel) */
#scapp .log{
  position:relative;
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:var(--radius);
  padding:16px 18px;
  box-shadow:var(--shadow);
  overflow-y:auto; 
  height:100%; 
  min-height:0;
}
@media (min-height:700px){ 
  #scapp .log{ min-height:220px; } 
}

/* Fade-in animation for messages */
@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#scapp .row{ 
  display:flex; 
  gap:10px; 
  margin:14px 8px; 
  animation: fadeSlideIn 0.3s ease-out;
}
#scapp .row.you{ justify-content:flex-end; }

/* Bubbles */
#scapp .bubble{
  position:relative;
  max-width:var(--bubble-width-desktop);
  padding:16px 20px;
  line-height:1.55;
  transition: transform 0.15s ease;
}
@media (max-width:640px){
  #scapp .bubble{ max-width:var(--bubble-width-mobile); }
}

/* Subtle hover lift */
#scapp .bubble:hover {
  transform: translateY(-1px);
}

#scapp .you .bubble{
  background: linear-gradient(135deg, var(--user) 0%, #3d5299 100%);
  color:var(--user-ink);
  border-radius:19px 19px 6px 19px;
}
#scapp .you .bubble .meta{ color:#CCC !important; }

#scapp .bot .bubble{
  background:var(--bot); 
  color:var(--bot-ink);
  border-radius:19px 19px 19px 6px;
  border:1px solid #E0E0E0;
  box-shadow:0 1px 3px rgba(0,0,0,.03);
}

#scapp .name{ 
  font-size:12px; 
  color:var(--muted) !important; 
  margin:0 0 6px 2px; 
}

/* Timestamp fade - hover to reveal */
#scapp .meta{ 
  font-size:11px; 
  color:var(--muted); 
  margin-top:8px; 
  opacity: 0.5;
  transition: opacity 0.2s ease;
}
#scapp .bubble:hover .meta {
  opacity: 1;
}

/* Link styling with hover effect */
#scapp .bubble a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(0,0,0,0.3);
  transition: text-decoration-color 0.15s ease;
}
#scapp .bubble a:hover {
  text-decoration-color: rgba(0,0,0,0.8);
  text-decoration-thickness: 2px;
}

/* Composer Wrapper - contains form + helpers */
#scapp .composer-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Composer Form - Clean 3-column grid */
#scapp .composer{
  display:grid; 
  grid-template-columns:1fr auto auto;
  gap:10px; 
  align-items:flex-end;
}

#scapp textarea{
  width:100%; 
  min-height:48px; 
  max-height:40dvh; 
  resize:none;
  background:#F5F5F5; 
  color:var(--ink);
  border:1px solid var(--line); 
  border-radius:12px;
  padding:12px 14px; 
  transition:border-color .2s ease, box-shadow .2s ease;
}
#scapp textarea::placeholder{ 
  font-style:italic; 
  font-weight:300; 
  font-size:15px; 
  color:#6B7280; 
  letter-spacing:.1px; 
}

/* Better focus state */
#scapp textarea:focus{ 
  outline:none; 
  border-color:var(--user); 
  box-shadow:0 0 0 3px rgba(47,66,136,.12);
}

/* Character counter - above form */
#scapp #charcount {
  display: none;
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  padding: 0 4px 2px;
}

/* Keyboard hint - below form */
#scapp .keyboard-hint {
  font-size: 11px;
  color: var(--muted);
  text-align: left;
  padding: 2px 4px 0;
}

/* Buttons */
#scapp .send{
  background:var(--cta); 
  color:var(--cta-ink);
  font-weight:700; 
  padding:12px 16px; 
  border:1px solid rgba(0,0,0,.06);
  border-radius:10px; 
  cursor:pointer; 
  height:41px; 
  font-size:15px;
  box-shadow:0 1px 3px rgba(0,0,0,.08);
  transition: all 0.15s ease;
}
#scapp .send:hover{ 
  background:var(--cta-hov); 
  color:#fff; 
  text-shadow:0 1px 0 rgba(0,0,0,.15);
  transform: translateY(-1px);
}

/* Better focus state for buttons */
#scapp .send:focus-visible {
  outline: 2px solid var(--user);
  outline-offset: 2px;
}

#scapp .send:disabled{ 
  opacity:.5;
  cursor:not-allowed;
  transform: none;
}

#scapp .stop{
  display:none;
  background:#EEF3F8; 
  color:var(--ink);
  font-weight:700; 
  font-size:15px; 
  height:41px; 
  padding:12px 14px;
  border:1px solid #D8E0EA; 
  border-radius:10px; 
  cursor:pointer;
  box-shadow:0 1px 3px rgba(0,0,0,.06);
  transition:background-color .15s ease, border-color .15s ease, transform .05s ease;
}
#scapp .stop:hover{ 
  background:#E7EEF6; 
  border-color:#C9D3E0; 
}
#scapp .stop:active{ 
  transform:translateY(.5px); 
}

/* Better focus for stop button */
#scapp .stop:focus-visible {
  outline: 2px solid var(--user);
  outline-offset: 2px;
}

/* Copy – subtle but visible, matching Jump to latest style */
#scapp .bubble .copy{
  position:absolute; 
  top:8px; 
  right:10px;
  opacity:0; 
  visibility:hidden; 
  transform:translateY(-2px);
  transition:opacity .15s ease, transform .15s ease, visibility .15s;
  appearance:none; 
  background:#FFFFFF;           /* White background - visible */
  color:var(--muted);          /* Muted gray text */
  font-size:11px;              /* Small but readable */
  font-weight:400;             /* Normal weight */
  line-height:1;
  padding:4px 10px; 
  border:1px solid #E0E6ED;    /* Subtle gray border */
  border-radius:999px;
  box-shadow:0 1px 3px rgba(0,0,0,.04);  /* Very subtle shadow */
  cursor:pointer;
}
#scapp .bubble:hover .copy,
#scapp .bubble .copy:focus-visible{
  opacity:1; 
  visibility:visible; 
  transform:translateY(0);
}

/* Hover state - subtle highlight */
#scapp .bubble .copy:hover {
  background:#F8F9FA;          /* Slightly darker */
  color:var(--ink);            /* Darker text */
  border-color:#D0D7DE;        /* Slightly darker border */
  box-shadow:0 2px 4px rgba(0,0,0,.08);
}

/* Better focus for copy button */
#scapp .bubble .copy:focus-visible {
  outline:1px solid var(--muted);
  outline-offset:1px;
}

/* Jump to latest - Subtle but visible, matching the screenshot */
#scapp #jump {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: none;
  background: #FFFFFF;           /* White background - visible */
  color: var(--muted);           /* Muted gray text */
  font-weight: 400;              /* Normal weight */
  font-size: 11px;
  line-height: 1;
  padding: 5px 10px;
  border: 1px solid #E0E6ED;     /* Subtle gray border */
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);  /* Very subtle shadow */
  cursor: pointer;
  transition: all .18s ease-in-out;
  z-index: 10;
}

#scapp #jump:hover,
#scapp #jump:focus-visible {
  background: #F8F9FA;           /* Slightly darker on hover */
  color: var(--ink);             /* Darker text */
  border-color: #D0D7DE;         /* Slightly darker border */
  box-shadow: 0 2px 4px rgba(0,0,0,.08);
}

/* Better focus state for jump button */
#scapp #jump:focus-visible {
  outline: 1px solid var(--muted);
  outline-offset: 2px;
}

/* Mobile: slightly smaller, same position */
@media (max-width: 640px) {
  #scapp #jump { 
    font-size: 10px;
    padding: 4px 8px;
    bottom: 12px;
    right: 12px;
  }
}

/* Footer */
#scapp footer{ 
  font-size:12px; 
  color:var(--muted); 
  text-align:center; 
  margin-top:4px; 
}
#scapp .sep{ 
  height:1px; 
  background:var(--line); 
  margin:2px 0 4px; 
}

/* Thinking animation - gentle pulse effect */
@keyframes thinkingPulse {
  0%, 100% { 
    opacity: 0.4; 
  }
  50% { 
    opacity: 1; 
  }
}

#scapp .thinking-text {
  animation: thinkingPulse 1.5s ease-in-out infinite;
  color: var(--muted);
  font-style: italic;
}

/* Improved scrollbar styling */
#scapp .log::-webkit-scrollbar{ 
  width:10px; 
}
#scapp .log::-webkit-scrollbar-track{ 
  background:#f5f5f5; 
  border-radius:10px; 
}
#scapp .log::-webkit-scrollbar-thumb{ 
  background:#d0d0d0; 
  border-radius:10px; 
  transition: background 0.2s ease; 
}
#scapp .log::-webkit-scrollbar-thumb:hover{ 
  background:#b0b0b0; 
}
