/* ---- chat.php ---- */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{font-family:'PT Sans',sans-serif;background:#f4f4f6;color:#1a1a2e;display:flex;flex-direction:column}

/* ── top bar ── */
.chat-topbar{
  display:flex;align-items:center;justify-content:space-between;
  background:#1a1a2e;color:#fff;padding:10px 20px;
  min-height:54px;flex-shrink:0;
}
.topbar-logo{font-family:'PT Serif',serif;font-size:18px;font-weight:700;color:#fff;text-decoration:none;}
.topbar-logo span{color:#c0364e}
.topbar-user{display:flex;align-items:center;gap:12px;font-size:13px;color:rgba(255,255,255,.65)}
.topbar-user a{color:rgba(255,255,255,.65);text-decoration:none;border-bottom:1px dashed rgba(255,255,255,.3)}
.topbar-user a:hover{color:#fff}

/* ── layout ── */
.chat-wrap{display:flex;flex:1;overflow:hidden}

/* ── sidebar ── */
.chat-sidebar{
  width:280px;flex-shrink:0;background:#fff;border-right:1px solid #e8e8ef;
  display:flex;flex-direction:column;overflow-y:auto;
}
.sidebar-section{padding:20px 16px;border-bottom:1px solid #f0f0f5}
.sidebar-label{font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:1.2px;color:#aaa;margin-bottom:10px}

/* quota card */
.quota-card{background:#fafafa;border:1px solid #eee;border-radius:10px;padding:14px 16px}
.quota-plan{display:flex;align-items:center;gap:8px;margin-bottom:10px}
.quota-plan-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0;background:<?= $planColor ?>}
.quota-plan-name{font-size:13px;font-weight:700;color:#1a1a2e}
.quota-nums{display:flex;justify-content:space-between;align-items:baseline;margin-bottom:6px}
.quota-remaining{font-family:'PT Serif',serif;font-size:26px;font-weight:700;color:<?= $planColor ?>}
.quota-total{font-size:12px;color:#888}
.quota-bar{height:5px;background:#eee;border-radius:3px;overflow:hidden;margin-bottom:8px}
.quota-bar-fill{height:100%;border-radius:3px;background:<?= $planColor ?>;width:<?= $pct ?>%;transition:width .4s}
.quota-period{font-size:11px;color:#aaa;line-height:1.4}

/* plan upgrade */
.upgrade-btn{display:block;text-align:center;background:#c0364e;color:#fff;border-radius:8px;padding:10px 16px;font-size:13px;font-weight:700;text-decoration:none;margin-top:12px;transition:background .15s}
.upgrade-btn:hover{background:#a02040}

/* trial notice */
.trial-notice{background:#fef3c7;border:1px solid #fde68a;border-radius:8px;padding:10px 12px;margin-top:12px}
.trial-notice p{font-size:12px;color:#92400e;line-height:1.5}

/* history links */
.hist-btn{width:100%;text-align:left;background:none;border:none;padding:7px 10px;border-radius:6px;font-size:13px;font-family:'PT Sans',sans-serif;color:#555;cursor:pointer;display:flex;align-items:center;gap:8px;transition:background .12s}
.hist-btn:hover{background:#f5f5fa}
.hist-btn svg{flex-shrink:0;opacity:.45}

/* ── main chat ── */
.chat-main{flex:1;display:flex;flex-direction:column;overflow:hidden;background:#f4f4f6}
.chat-messages{flex:1;overflow-y:auto;padding:24px 20px;display:flex;flex-direction:column;gap:12px}

/* messages */
.msg{display:flex;align-items:flex-end;gap:8px;max-width:72%;animation:fadeUp .22s ease}
@keyframes fadeUp{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
.msg.user{align-self:flex-end;flex-direction:row-reverse}
.msg.assistant{align-self:flex-start}
.msg-avatar{width:30px;height:30px;border-radius:50%;flex-shrink:0;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700}
.msg.user .msg-avatar{background:#c0364e;color:#fff}
.msg.assistant .msg-avatar{background:#1a1a2e;color:#fff}
.msg-bubble{padding:11px 15px;border-radius:16px;font-size:14px;line-height:1.6;word-break:break-word;white-space:pre-wrap}
.msg.user .msg-bubble{background:#c0364e;color:#fff;border-bottom-right-radius:4px}
.msg.assistant .msg-bubble{background:#fff;color:#1a1a2e;border-bottom-left-radius:4px;box-shadow:0 1px 4px rgba(0,0,0,.07)}

/* typing */
.typing{align-self:flex-start;display:flex;align-items:center;gap:5px;padding:12px 16px;background:#fff;border-radius:16px;border-bottom-left-radius:4px;box-shadow:0 1px 4px rgba(0,0,0,.07);display:none}
.typing-dot{width:7px;height:7px;border-radius:50%;background:#c0364e;animation:bounce .9s infinite}
.typing-dot:nth-child(2){animation-delay:.15s}
.typing-dot:nth-child(3){animation-delay:.3s}
@keyframes bounce{0%,80%,100%{transform:translateY(0)}40%{transform:translateY(-6px)}}

/* empty state */
.chat-empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:40px 20px;color:#aaa}
.chat-empty-icon{font-size:48px;margin-bottom:16px;opacity:.5}
.chat-empty h3{font-size:17px;color:#555;margin-bottom:8px}
.chat-empty p{font-size:13px;line-height:1.6;max-width:320px}

/* quota exceeded overlay */
.quota-exceeded{background:#fff5f7;border:1px solid #fecdd3;border-radius:12px;padding:20px;margin:20px;text-align:center}
.quota-exceeded h3{font-size:16px;color:#c0364e;margin-bottom:8px}
.quota-exceeded p{font-size:13px;color:#666;margin-bottom:16px;line-height:1.6}
.quota-exceeded .btns{display:flex;gap:10px;justify-content:center;flex-wrap:wrap}
.qe-btn-primary{background:#c0364e;color:#fff;padding:10px 20px;border-radius:8px;font-size:13px;font-weight:700;text-decoration:none}
.qe-btn-secondary{background:#fff;color:#c0364e;border:2px solid #c0364e;padding:8px 18px;border-radius:8px;font-size:13px;font-weight:700;text-decoration:none}

/* ── input area ── */
.chat-input-wrap{padding:12px 20px;background:#fff;border-top:1px solid #e8e8ef;flex-shrink:0}
.chat-input-inner{display:flex;align-items:center;gap:10px;background:#f4f4f6;border-radius:12px;padding:6px 6px 6px 16px}
#chatInput{flex:1;border:none;background:none;font-size:14px;font-family:'PT Sans',sans-serif;color:#1a1a2e;outline:none;line-height:1.5;max-height:120px;resize:none;min-height:36px;padding:4px 0}
#chatInput::placeholder{color:#aaa}
#chatSend{background:#c0364e;color:#fff;border:none;border-radius:8px;width:40px;height:40px;display:flex;align-items:center;justify-content:center;cursor:pointer;flex-shrink:0;transition:background .15s}
#chatSend:hover:not(:disabled){background:#a02040}
#chatSend:disabled{background:#e0a0a8;cursor:not-allowed}
.input-footer{display:flex;justify-content:space-between;align-items:center;margin-top:8px;padding:0 4px}
.input-footer-note{font-size:11px;color:#bbb}
.quota-inline{font-size:11px;font-weight:700}

/* ── mobile ── */
@media(max-width:680px){
  .chat-sidebar{display:none}
  .chat-topbar{padding:8px 14px}
  .topbar-user{gap:8px}
  .chat-messages{padding:16px 12px}
  .msg{max-width:90%}
  .chat-input-wrap{padding:8px 12px}
}
