/* ============================================================
   HEADER + ACCOUNT PANEL (V4 GREY) — Resizing-friendly version
   Only header, dropdowns, and big account panel.
   No chat, no sidebar, no footer.
   ============================================================ */

/* ------------------------------------------------------------
   ANIMATIONS
   ------------------------------------------------------------ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------------
   HEADER BAR
   ------------------------------------------------------------ */
.chat-header {
  background: #ffffff;
  padding: 12px 24px;
  height: 56px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  z-index: 20;
}

.chat-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: #111;
}

.chat-subtitle {
  font-size: 12px;
  color: #6b7280;
}

.chat-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

/* Plan Badge */
.chat-plan-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #e8f0ff;
  color: #2b6cb0;
  border: 1px solid #cbd5f5;
}

/* 3-dot button */
.chat-header-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid #ccc;
  color: #444;
  font-size: 20px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-header-icon:hover {
  background: #f0f0f0;
  border-color: #999;
}

/* Avatar Circle */
.chat-header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #075e37;
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid #0a5a33;
  cursor: pointer;
}

/* ------------------------------------------------------------
   3-DOT MENU DROPDOWN
   ------------------------------------------------------------ */
.chat-header-menu {
  display: none;
  position: absolute;
  top: 48px;
  right: 8px;
  background: white;
  border-radius: 10px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
  min-width: 200px;
  z-index: 9999;
  border: 1px solid #e2e8f0;
  overflow: hidden;
}

.chat-header-menu.open {
  display: block;
  animation: fadeIn 0.2s ease-out;
}

.chat-header-menu a,
.chat-header-menu button {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  text-align: left;
  font-size: 14px;
  color: #333;
  text-decoration: none;
  cursor: pointer;
}

.chat-header-menu a:hover,
.chat-header-menu button:hover {
  background: #f7f9fb;
}

/* ------------------------------------------------------------
   AVATAR DROPDOWN (MINI)
   ------------------------------------------------------------ */
#avatarMenu {
  display: none;
  position: absolute;
  top: 48px;
  right: 0;
  width: 260px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  z-index: 10000;
  padding: 12px 0;
  border: 1px solid #e2e8f0;
  animation: fadeIn 0.2s ease-out;
}

#avatarMenu.show {
  display: block;
}

/* Header section (name/email) */
#avatarMenu .avatar-menu-section {
  padding: 8px 16px 12px;
  border-bottom: 1px solid #eee;
}

#avatarMenuName {
  font-weight: 700;
  font-size: 15px;
  color: #111;
}

#avatarMenuEmail {
  font-size: 13px;
  color: #666;
  margin-top: 2px;
}

/* Optional divider (kept for compatibility if your HTML uses it) */
#avatarMenu .avatar-menu-divider {
  height: 1px;
  background: #eee;
  margin: 8px 0;
}

/* Menu items */
.avatar-menu-item {
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  text-align: left;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  transition: background 0.15s;
}

.avatar-menu-item:hover {
  background: #f7f9fb;
}

.avatar-menu-item[data-action="upgrade"] {
  color: #0c8f54;
  font-weight: 600;
}

.avatar-menu-item[data-action="logout"] {
  color: #b91c1c;
}

/* Token Usage Meter (legacy + new) */
.token-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid #999;
}

.avatar-menu-token,
#avatarMenu .avatar-menu-token {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #555;
}

#tokenCircle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: conic-gradient(
    #10b981 0%,
    #facc15 70%,
    #ef4444 90%
  );
  background-size: 100% 100%;
  background-repeat: no-repeat;
  position: relative;
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

#tokenCircle::after {
  content: "";
  position: absolute;
  inset: 5px;
  background: white;
  border-radius: 50%;
}

#tokenPercent {
  font-weight: 700;
  min-width: 50px;
}

#avatarMenu .avatar-menu-token #tokenPercent {
  font-weight: 700;
  color: #222;
  min-width: 44px;
}

/* Plan badge + Language selector (inside #avatarMenu) */
#avatarMenuPlanLang #planBadge {
  display: inline-block;
  margin: 2px 0 10px 0;
}

#avatarMenu #planBadge {
  margin-left: 10px;
  white-space: nowrap;
}

#avatarMenuPlanLang .lang-switch {
  position: relative;
  margin-top: 6px;
}

/* Override .menu-btn so it doesn't inherit the giant header button style */
#avatarMenuPlanLang #lang-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  color: #111;
  background: #fff;
}

/* Language dropdown styling (white background + readable text) */
#avatarMenuPlanLang #lang-dropdown,
#avatarMenu #lang-dropdown {
  background: #fff !important;
  color: #111 !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15) !important;
}

/* Language dropdown buttons */
#avatarMenuPlanLang #lang-dropdown button,
#avatarMenu #lang-dropdown button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: #111 !important;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}

#avatarMenuPlanLang #lang-dropdown button:hover,
#avatarMenu #lang-dropdown button:hover {
  background: #f7f9fb !important;
}

/* ------------------------------------------------------------
   BIG ACCOUNT PANEL (GREY V4 — COMPACT, RESPONSIVE)
   ------------------------------------------------------------ */
.account-panel.hidden {
  display: none;
}

.account-panel {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Overlay */
.account-panel-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
}

/* Panel Body */
.account-panel-body {
  position: relative;
  width: min(900px, 96vw);
  height: min(620px, 92vh);
  background: white;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: row;
  box-shadow: 0 12px 40px rgba(0,0,0,0.20);
}

/* Close Button */
.account-panel-button {
  position: absolute;
  top: 10px;
  right: 16px;
  background: none;
  border: none;
  font-size: 30px;
  cursor: pointer;
  color: #444;
  z-index: 300;
}

/* Sidebar */
.account-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #f4f5f7;
  border-right: 1px solid #e5e7eb;
  padding: 20px 0;
  overflow-y: auto;
}

.account-sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-item {
  padding: 12px 22px;
  background: none;
  border: none;
  text-align: left;
  font-size: 15px;
  color: #333;
  cursor: pointer;
  transition: background 0.15s ease;
}

.sidebar-item:hover {
  background: #e8e9eb;
}

/* Active tab with 4px green bar */
.sidebar-item.active {
  font-weight: 600;
  background: white;
  position: relative;
  color: #0c5734;
}

.sidebar-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 4px;
  background: #0c8f54;
  border-radius: 0 4px 4px 0;
}

/* ------------------------------------------------------------
   PANEL CONTENT AREA
   ------------------------------------------------------------ */
.account-panel-content {
  flex: 1;
  overflow-y: auto;
  background: white;
  padding: 36px 42px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* Headings */
.account-panel-content h3 {
  margin: 0 0 24px;
  font-size: 20px;
  font-weight: 700;
  color: #111;
}

.account-panel-content h4 {
  margin: 0 0 18px;
  font-size: 18px;
  font-weight: 700;
  color: #111;
}

.account-panel-content h5 {
  margin: 24px 0 12px;
  font-size: 16px;
  font-weight: 600;
  color: #222;
}

.account-panel-content p,
.account-panel-content .hint {
  font-size: 13px;
  color: #555;
}

/* ------------------------------------------------------------
   FORMS INSIDE THE PANEL
   ------------------------------------------------------------ */
.account-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

.account-panel-content label {
  font-size: 14px;
  font-weight: 600;
  color: #222;
  display: block;
  margin-bottom: 4px;
}

.account-panel-content input[type="text"],
.account-panel-content input[type="email"],
.account-panel-content input[type="password"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
  box-sizing: border-box;
}

/* If inputs are inside .form-row, spacing is handled by the row */
.account-panel-content .form-row input[type="text"],
.account-panel-content .form-row input[type="email"],
.account-panel-content .form-row input[type="password"] {
  margin-bottom: 0;
}

/* If an input is not inside .form-row, keep a safe default spacing */
.account-panel-content input[type="text"]:not(.no-margin),
.account-panel-content input[type="email"]:not(.no-margin),
.account-panel-content input[type="password"]:not(.no-margin) {
  margin-bottom: 14px;
}

/* Make inputs visually grouped */
.account-panel-content input {
  height: 40px;
}

.account-panel-content input:focus {
  border-color: #0c8f54;
}

/* Buttons grouped at the bottom */
.account-panel-content .actions {
  margin-top: 28px;
}

/* ------------------------------------------------------------
   BUTTONS
   ------------------------------------------------------------ */
.btn-primary,
.btn-upgrade {
  padding: 8px 14px;
  font-size: 14px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  background: #0c8f54;
  color: white;
}

.btn-primary:hover,
.btn-upgrade:hover {
  background: #0a6f41;
}

.btn-danger {
  padding: 8px 14px;
  font-size: 14px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: #b91c1c;
  color: white;
}

.btn-danger:hover {
  background: #991b1b;
}

/* Messages */
.form-msg {
  margin-top: 10px;
  min-height: 24px;
  font-size: 14px;
}

.error {
  color: #b91c1c;
  font-weight: 600;
  text-align: center;
  padding: 20px;
}

.loading {
  text-align: center;
  padding: 40px;
  color: #666;
  font-size: 15px;
}

/* ------------------------------------------------------------
   TOOLTIP
   ------------------------------------------------------------ */
.tooltip-container {
  position: relative;
  display: inline-block;
  width: 100%;
}

.tooltip-text {
  visibility: hidden;
  width: 280px;
  background: #333;
  color: white;
  text-align: center;
  border-radius: 6px;
  padding: 8px 12px;
  position: absolute;
  z-index: 1000;
  bottom: 120%;
  left: 50%;
  margin-left: -140px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.3s;
}

.tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border: 5px solid transparent;
  border-top-color: #333;
}

.tooltip-container:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* ------------------------------------------------------------
   PASSWORD POPOVER + PASSWORD INPUTS
   ------------------------------------------------------------ */
.pwd-popover {
  display: none;
  position: absolute;
  background: white;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
  margin-top: 4px;
  list-style: none;
}

.pwd-popover li {
  margin: 6px 0;
}

.pwd-popover li.ok { color: green; }
.pwd-popover li.bad { color: #d00; }

/* Password field with eye icon inside */
.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap input {
  width: 100%;
  height: 44px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  font-size: 14px;
  padding-left: 12px;
  padding-right: 44px;
  box-sizing: border-box;
}

.password-wrap input:focus {
  border-color: #0c8f54;
  outline: none;
}

/* Eye button INSIDE the input, aligned to the right */
.password-wrap .icon-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  font-size: 18px;
  opacity: 0.6;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}

.password-wrap .icon-btn:hover {
  opacity: 1;
}

/* Legacy toggle button (kept for compatibility if used elsewhere) */
.toggle-password {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #666;
  padding: 4px;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.toggle-password:hover {
  background: #f0f0f0;
  color: #000;
}

.toggle-password:active {
  background: #e0e0e0;
}

/* Optional: use real SVG eye */
.toggle-password::after {
  content: "";
  width: 20px;
  height: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='currentColor'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M15 12a3 3 0 11-6 0 3 3 0 016 0z' /%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z' /%3E%3C/svg%3E") center/contain no-repeat;
  display: block;
}

.toggle-password.show::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='currentColor'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21' /%3E%3C/svg%3E");
}
