/**
 * Energy Assistant AI — Frontend Client Styles
 * Covers: embedded interface, floating widget, inline widget, dark + light themes
 *
 * @package EnergyAssistant
 */

/* ═══════════════════════════════════════════════════════════════
   CSS CUSTOM PROPERTIES (dark default — overridden by JS theme)
═══════════════════════════════════════════════════════════════ */
:root {
  --ea-accent:   #00C2FF;
  --ea-gold:     #FFB800;
  --ea-green:    #00E5A0;
  --ea-red:      #FF4C6A;
  --ea-amber:    #FFAA00;
  --ea-purple:   #9D5CFF;
  --ea-font:     'Syne', system-ui, sans-serif;
  --ea-mono:     'IBM Plex Mono', 'Courier New', monospace;
}

/* ═══════════════════════════════════════════════════════════════
   ANIMATIONS
═══════════════════════════════════════════════════════════════ */
@keyframes ea-spin {
  to { transform: rotate(360deg); }
}
@keyframes ea-fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0);    }
}
@keyframes ea-bubble-in {
  from { opacity: 0; transform: scale(.95) translateY(6px); }
  to   { opacity: 1; transform: scale(1)   translateY(0);   }
}
@keyframes ea-widget-open {
  from { opacity: 0; transform: scale(.92) translateY(12px); }
  to   { opacity: 1; transform: scale(1)   translateY(0);    }
}
@keyframes ea-dot-pulse {
  0%,80%,100% { transform: scale(.7); opacity: .4; }
  40%         { transform: scale(1);  opacity: 1;   }
}
@keyframes ea-glow {
  0%,100% { box-shadow: 0 0 10px rgba(0,194,255,.2); }
  50%     { box-shadow: 0 0 28px rgba(0,194,255,.45); }
}
@keyframes ea-skeleton {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}

/* ═══════════════════════════════════════════════════════════════
   BASE EMBED CONTAINER
═══════════════════════════════════════════════════════════════ */
.ea-embed,
.ea-inline-widget {
  font-family:  var(--ea-font);
  box-sizing:   border-box;
  border-radius: 14px;
  overflow:     hidden;
  animation:    ea-fade-up .4s ease both;
}

/* Full-width on mobile */
@media (max-width: 600px) {
  .ea-embed { border-radius: 8px; }
}

/* ═══════════════════════════════════════════════════════════════
   FLOATING WIDGET
═══════════════════════════════════════════════════════════════ */
.ea-floating {
  position: fixed;
  z-index:  9995;
  bottom:   0;
  right:    0;
}

/* Floating panel slide-in */
.ea-floating > div[style*="position:fixed"] {
  animation: ea-widget-open .25s cubic-bezier(.4,0,.2,1) both;
}

/* ═══════════════════════════════════════════════════════════════
   SCROLLBARS (chat area)
═══════════════════════════════════════════════════════════════ */
.ea-embed ::-webkit-scrollbar,
.ea-floating ::-webkit-scrollbar { width: 4px; }

.ea-embed ::-webkit-scrollbar-track,
.ea-floating ::-webkit-scrollbar-track { background: transparent; }

.ea-embed ::-webkit-scrollbar-thumb,
.ea-floating ::-webkit-scrollbar-thumb {
  background:    rgba(110,130,165,.35);
  border-radius: 4px;
}
.ea-embed ::-webkit-scrollbar-thumb:hover,
.ea-floating ::-webkit-scrollbar-thumb:hover {
  background: rgba(110,130,165,.6);
}

/* ═══════════════════════════════════════════════════════════════
   MESSAGE BUBBLES  (enhanced beyond inline styles)
═══════════════════════════════════════════════════════════════ */
.ea-bubble {
  animation: ea-bubble-in .22s ease both;
}

/* Typing indicator dots */
.ea-typing-dots {
  display:     inline-flex;
  gap:         5px;
  align-items: center;
  padding:     6px 0;
}
.ea-typing-dots span {
  width:        7px;
  height:       7px;
  border-radius: 50%;
  background:   var(--ea-accent);
  animation:    ea-dot-pulse 1.4s ease infinite;
}
.ea-typing-dots span:nth-child(2) { animation-delay: .2s; }
.ea-typing-dots span:nth-child(3) { animation-delay: .4s; }

/* ═══════════════════════════════════════════════════════════════
   ROLE SELECTOR DROPDOWN
═══════════════════════════════════════════════════════════════ */
.ea-role-dropdown {
  animation:     ea-fade-up .18s ease both;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Role card hover effect */
.ea-role-card:hover {
  border-color: var(--ea-accent) !important;
  transform:    translateY(-1px);
  transition:   all .15s;
}

/* ═══════════════════════════════════════════════════════════════
   AGENT GRID
═══════════════════════════════════════════════════════════════ */
.ea-agent-btn {
  transition: transform .12s, border-color .12s, background .12s;
}
.ea-agent-btn:hover {
  transform: translateY(-2px);
}
.ea-agent-btn:active {
  transform: translateY(0);
}

/* ═══════════════════════════════════════════════════════════════
   MODE TOGGLE
═══════════════════════════════════════════════════════════════ */
.ea-mode-btn {
  transition: background .15s, color .15s;
  user-select: none;
}

/* ═══════════════════════════════════════════════════════════════
   INPUT TEXTAREA — focus glow
═══════════════════════════════════════════════════════════════ */
.ea-embed textarea:focus,
.ea-floating textarea:focus {
  border-color: var(--ea-accent) !important;
  box-shadow:   0 0 0 3px rgba(0,194,255,.12) !important;
  outline:      none;
}
.ea-embed input:focus,
.ea-floating input:focus {
  border-color: var(--ea-accent) !important;
  box-shadow:   0 0 0 3px rgba(0,194,255,.12) !important;
  outline:      none;
}

/* ═══════════════════════════════════════════════════════════════
   TOOL SOURCE BADGES
═══════════════════════════════════════════════════════════════ */
.ea-source-ok {
  color:      var(--ea-green);
  background: rgba(0,229,160,.08);
  border:     1px solid rgba(0,229,160,.2);
}
.ea-source-fail {
  color:      var(--ea-red);
  background: rgba(255,76,106,.08);
  border:     1px solid rgba(255,76,106,.2);
}

/* ═══════════════════════════════════════════════════════════════
   CONFIDENCE BADGE
═══════════════════════════════════════════════════════════════ */
.ea-conf-high { color: var(--ea-green);  background: rgba(0,229,160,.10);  }
.ea-conf-mid  { color: var(--ea-gold);   background: rgba(255,184,0,.10);  }
.ea-conf-low  { color: var(--ea-red);    background: rgba(255,76,106,.10); }

/* ═══════════════════════════════════════════════════════════════
   SEND BUTTON — pulse when has content
═══════════════════════════════════════════════════════════════ */
.ea-send-active {
  animation: ea-glow 2.5s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════════════
   SESSION LIST
═══════════════════════════════════════════════════════════════ */
.ea-session-item {
  transition: background .12s, border-color .12s;
}
.ea-session-item:hover {
  border-color: var(--ea-accent) !important;
}

/* ═══════════════════════════════════════════════════════════════
   LOADING SKELETON
═══════════════════════════════════════════════════════════════ */
.ea-skeleton {
  background:      linear-gradient(90deg, #1a2235 25%, #1e2d47 50%, #1a2235 75%);
  background-size: 800px 100%;
  animation:       ea-skeleton 1.5s ease infinite;
  border-radius:   6px;
}

/* Light theme overrides for skeleton */
@media (prefers-color-scheme: light) {
  .ea-skeleton {
    background: linear-gradient(90deg, #e8ecf0 25%, #d5dde8 50%, #e8ecf0 75%);
    background-size: 800px 100%;
  }
}

/* ═══════════════════════════════════════════════════════════════
   LIGHT THEME FORM ELEMENTS
═══════════════════════════════════════════════════════════════ */
.ea-theme-light input,
.ea-theme-light textarea,
.ea-theme-light select {
  background:   #ffffff;
  border-color: #e2e8f0;
  color:        #1a202c;
}
.ea-theme-light input::placeholder,
.ea-theme-light textarea::placeholder {
  color: #a0aec0;
}

/* ═══════════════════════════════════════════════════════════════
   MARKDOWN-LIKE OUTPUT FORMATTING
   (used inside assistant response bubbles)
═══════════════════════════════════════════════════════════════ */
.ea-output h1, .ea-output h2, .ea-output h3 {
  font-family: var(--ea-font);
  font-weight: 700;
  margin:      12px 0 6px;
}
.ea-output h1 { font-size: 16px; }
.ea-output h2 { font-size: 14px; color: var(--ea-accent); }
.ea-output h3 { font-size: 13px; color: var(--ea-gold); }

.ea-output p  { margin: 6px 0; line-height: 1.65; }
.ea-output ul { padding-left: 18px; margin: 6px 0; }
.ea-output li { margin-bottom: 3px; }

.ea-output code {
  font-family:   var(--ea-mono);
  font-size:     12px;
  background:    rgba(0,194,255,.08);
  border:        1px solid rgba(0,194,255,.15);
  border-radius: 4px;
  padding:       1px 5px;
  color:         var(--ea-accent);
}

.ea-output pre {
  font-family:   var(--ea-mono);
  font-size:     12px;
  background:    #0d1626;
  border:        1px solid #1e2d47;
  border-radius: 8px;
  padding:       12px 14px;
  overflow-x:    auto;
  line-height:   1.6;
  margin:        8px 0;
}

.ea-output table {
  width:           100%;
  border-collapse: separate;
  border-spacing:  0;
  margin:          10px 0;
  font-size:       12px;
  font-family:     var(--ea-mono);
}
.ea-output th {
  background:    rgba(0,194,255,.08);
  border:        1px solid rgba(0,194,255,.15);
  color:         var(--ea-accent);
  padding:       7px 12px;
  text-align:    left;
  font-weight:   700;
  font-size:     11px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.ea-output td {
  border:    1px solid #1e2d47;
  padding:   7px 12px;
  color:     #e8edf5;
}
.ea-output tr:nth-child(even) td {
  background: rgba(255,255,255,.02);
}

.ea-output blockquote {
  border-left:   3px solid var(--ea-accent);
  margin:        8px 0;
  padding:       8px 12px;
  background:    rgba(0,194,255,.04);
  border-radius: 0 6px 6px 0;
  color:         #a0b0c8;
  font-style:    italic;
}

.ea-output strong { color: var(--ea-gold); font-weight: 700; }
.ea-output em     { color: #a0b0c8; }

.ea-output .ea-warning {
  background:    rgba(255,170,0,.10);
  border:        1px solid rgba(255,170,0,.25);
  border-radius: 6px;
  padding:       8px 12px;
  color:         var(--ea-amber);
  font-size:     11px;
  margin:        8px 0;
}
.ea-output .ea-verified {
  display:       inline-flex;
  align-items:   center;
  gap:           4px;
  font-size:     10px;
  color:         var(--ea-green);
  background:    rgba(0,229,160,.08);
  border:        1px solid rgba(0,229,160,.2);
  border-radius: 999px;
  padding:       2px 8px;
  font-family:   var(--ea-mono);
  font-weight:   700;
  letter-spacing: .05em;
}

/* ═══════════════════════════════════════════════════════════════
   BUDGET BAR
═══════════════════════════════════════════════════════════════ */
.ea-budget-bar {
  height:        3px;
  border-radius: 3px;
  overflow:      hidden;
  background:    rgba(255,255,255,.08);
}
.ea-budget-fill {
  height:        100%;
  border-radius: 3px;
  transition:    width .6s cubic-bezier(.4,0,.2,1);
}

/* ═══════════════════════════════════════════════════════════════
   FAB (Floating Action Button) — override WP theme interference
═══════════════════════════════════════════════════════════════ */
#ea-floating-widget button[aria-label="Energy Assistant"] {
  all:            unset;
  position:       fixed !important;
  width:          56px !important;
  height:         56px !important;
  border-radius:  50% !important;
  cursor:         pointer !important;
  display:        flex !important;
  align-items:    center !important;
  justify-content:center !important;
  font-size:      24px !important;
  z-index:        9998 !important;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE ADJUSTMENTS
═══════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .ea-embed {
    border-radius: 0;
    --ea-embed-height: 100svh;
  }
  /* Role selector panel full-width on mobile */
  .ea-role-dropdown {
    width: 95vw !important;
    left:  50% !important;
    transform: translateX(-50%) !important;
  }
  /* Hide session sidebar on small screens */
  .ea-session-sidebar { display: none !important; }
}

@media (max-width: 360px) {
  /* Tighten agent grid to 2 columns */
  .ea-agent-grid { grid-template-columns: 1fr 1fr !important; }
}

/* ═══════════════════════════════════════════════════════════════
   ACCESSIBILITY — focus rings
═══════════════════════════════════════════════════════════════ */
.ea-embed :focus-visible,
.ea-floating :focus-visible {
  outline: 2px solid var(--ea-accent);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   WP THEME RESETS (prevent theme styles bleeding in)
═══════════════════════════════════════════════════════════════ */
.ea-embed *,
.ea-floating *,
.ea-inline-widget * {
  box-sizing: border-box;
}
.ea-embed a,
.ea-floating a {
  color: var(--ea-accent);
  text-decoration: none;
}
.ea-embed button,
.ea-floating button {
  line-height: normal;
  letter-spacing: normal;
}
/* Override common WP theme button resets */
.ea-embed button:not([class]),
.ea-floating button:not([class]) {
  background: transparent;
  border: none;
  padding: 0;
}
