/* BUTTONS */
.ai-btn { background: #16253f; border: 1px solid #1e3a5f; color: #cbd5e1; padding: 6px 12px; border-radius: 7px; font-size: 12px; cursor: pointer; }
.ai-btn:hover { background: #1e3a5f; }
.ai-btn-primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.ai-btn-primary:hover { background: #1d4ed8; }

/* TOPBAR */
.topbar { display: flex !important; align-items: center !important; padding: 14px 24px !important; gap: 8px; }
.topbar-right { display: flex !important; align-items: center !important; gap: 8px; margin-left: auto; }

/* Hide hamburger on PC */
#history-toggle { display: none; }

/* LAYOUT */
.ai-layout { display: flex; height: calc(100vh - 53px); overflow: hidden; }

/* HISTORY PANEL */
.ai-history { width: 200px; background: #0b1729; border-right: 1px solid #16253f; display: flex; flex-direction: column; flex-shrink: 0; }
.history-header { padding: 10px 12px; border-bottom: 1px solid #16253f; }
.history-title { font-size: 12px; font-weight: 600; color: #fff; }
.history-close { display: none; background: none; border: none; color: #7d8ca3; font-size: 16px; cursor: pointer; }
.history-close:hover { color: #fff; }
.subject-filter { background: #16253f; border: 1px solid #1e3a5f; border-radius: 6px; padding: 4px 7px; color: #cbd5e1; font-size: 10px; outline: none; width: 100%; margin-top: 6px; }
.subject-filter option { background: #0b1729; }
.history-list { flex: 1; overflow-y: auto; padding: 6px; }
.history-item { padding: 8px 10px; border-radius: 7px; margin-bottom: 4px; cursor: pointer; border: 1px solid transparent; position: relative; }
.history-item:hover { background: #16253f; }
.history-item.active { background: #16253f; border-color: #2563eb44; }
.h-title { font-size: 11px; color: #cbd5e1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 20px; }
.h-meta { font-size: 9px; color: #7d8ca3; margin-top: 2px; }
.h-del { position: absolute; right: 6px; top: 8px; background: none; border: none; color: #7d8ca3; cursor: pointer; font-size: 11px; opacity: 0; }
.history-item:hover .h-del { opacity: 1; }
.h-del:hover { color: #ef4444; }
.no-chats { font-size: 11px; color: #7d8ca3; text-align: center; padding: 20px 10px; line-height: 1.6; }

/* OVERLAY — phone only */
.history-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 997; }

/* CHAT AREA */
.ai-chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-topbar { background: #0b1729; border-bottom: 1px solid #16253f; padding: 8px 14px; display: flex; align-items: center; justify-content: space-between; }
.chat-subject-row { display: flex; align-items: center; gap: 8px; }
.subject-select { background: #16253f; border: 1px solid #1e3a5f; border-radius: 6px; padding: 4px 8px; color: #7eb3f7; font-size: 11px; outline: none; cursor: pointer; }
.subject-select option { background: #0b1729; }
.query-counter { font-size: 10px; color: #7d8ca3; }
.query-counter.warning { color: #f59e0b; }
.query-counter.maxed { color: #ef4444; }

/* MESSAGES */
.chat-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; gap: 8px; max-width: 80%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-av { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.msg-av.ai { background: #16253f; }
.msg-av.user { background: #2563eb; color: #fff; font-size: 10px; font-weight: 700; }
.bubble { border-radius: 10px; padding: 9px 12px; font-size: 12px; color: #cbd5e1; line-height: 1.6; }
.bubble.ai { background: #0b1729; border: 1px solid #16253f; }
.bubble.user { background: #1e3a6e; border: 1px solid #2563eb44; color: #e2e8f0; }
.msg-time { font-size: 9px; color: #7d8ca3; margin-top: 3px; }
.msg.user .msg-time { text-align: right; }

/* TYPING */
.typing-wrap { display: flex; gap: 4px; align-items: center; padding: 4px 0; }
.typing-dot { width: 6px; height: 6px; border-radius: 50%; background: #7d8ca3; animation: tdot 1s infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes tdot { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-4px)} }

/* EMPTY STATE */
.empty-chat { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; padding: 30px 20px; text-align: center; }
.empty-icon { font-size: 36px; margin-bottom: 10px; }
.empty-title { font-size: 15px; font-weight: 600; color: #fff; margin-bottom: 6px; }
.empty-sub { font-size: 11px; color: #7d8ca3; margin-bottom: 20px; max-width: 260px; line-height: 1.5; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; max-width: 320px; }
.qa-btn { background: #0b1729; border: 1px solid #16253f; border-radius: 8px; padding: 10px 8px; font-size: 11px; color: #cbd5e1; cursor: pointer; text-align: left; }
.qa-btn:hover { border-color: #2563eb; color: #7eb3f7; }

/* SUGGESTIONS */
.suggestions-row { padding: 6px 14px; display: flex; gap: 6px; flex-wrap: wrap; border-top: 1px solid #16253f; }
.suggest-chip { font-size: 10px; padding: 4px 10px; border-radius: 12px; border: 1px solid #16253f; color: #7d8ca3; background: none; cursor: pointer; }
.suggest-chip:hover { border-color: #2563eb; color: #7eb3f7; }

/* INPUT */
.chat-input-wrap { padding: 10px 14px; border-top: 1px solid #16253f; display: flex; gap: 8px; align-items: flex-end; background: #07111f; }
.chat-input { flex: 1; background: #16253f; border: 1px solid #1e3a5f; border-radius: 10px; padding: 8px 12px; color: #cbd5e1; font-size: 12px; resize: none; outline: none; font-family: sans-serif; max-height: 120px; }
.chat-input:focus { border-color: #2563eb; }
.send-btn { width: 36px; height: 36px; border-radius: 8px; background: #2563eb; border: none; color: #fff; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.send-btn:hover { background: #1d4ed8; }
.send-btn:disabled { background: #16253f; color: #7d8ca3; cursor: not-allowed; }

/* RIGHT TOOLS */
.ai-tools { width: 180px; background: #0b1729; border-left: 1px solid #16253f; padding: 12px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; flex-shrink: 0; }
.tools-title { font-size: 10px; color: #7d8ca3; font-weight: 600; letter-spacing: 0.5px; margin-bottom: 2px; }
.tool-chip { background: #07111f; border: 1px solid #16253f; border-radius: 7px; padding: 7px 9px; font-size: 10px; color: #cbd5e1; cursor: pointer; text-align: left; width: 100%; }
.tool-chip:hover { border-color: #2563eb; color: #7eb3f7; }
.usage-card { background: #07111f; border: 1px solid #16253f; border-radius: 8px; padding: 10px; text-align: center; }
.usage-num { font-size: 20px; font-weight: 700; color: #f59e0b; }
.usage-lbl { font-size: 9px; color: #7d8ca3; margin-top: 2px; }
.usage-bar-wrap { background: #16253f; border-radius: 10px; height: 4px; margin-top: 8px; overflow: hidden; }
.usage-bar { height: 100%; border-radius: 10px; background: #f59e0b; transition: width 0.3s; }

/* MAXED BANNER */
.maxed-banner { background: #3d1a0f; border: 1px solid #7f1d1d; border-radius: 8px; padding: 10px 14px; margin: 0 14px 10px; font-size: 11px; color: #fca5a5; text-align: center; }

/* ─── PHONE ─────────────────────────────────── */
@media (max-width: 767px) {
  /* show hamburger, hide tools */
  #history-toggle { display: block; }
  .ai-tools { display: none; }

  /* history slides in from left */
  .ai-history {
    position: fixed;
    top: 0;
    left: -100%;
    height: 100vh;
    width: 75%;
    max-width: 280px;
    z-index: 998;
    transition: left 0.3s ease;
    border-right: 1px solid #16253f;
  }

  .ai-history.open { left: 0; }

  /* show close button inside panel */
  .history-close { display: block; }

  /* overlay shows when panel open */
  .history-overlay.open { display: block; }

  /* chat takes full width */
  .ai-layout { height: calc(100vh - 56px); }
  .ai-chat { width: 100%; }
}