/* ============================================
   CHAT PAGE — Ceron Matthew Calsena
   CMC Portfolio · 2026
============================================ */

:root {
  --yellow:  #ffd000;
  --orange:  #ff6a00;
  --orange2: #ff9a3c;
  --white:   #ffffff;
  --black:   #050505;
  --dark:    #0d0d0d;
  --card:    rgba(18,18,18,0.97);
  --border:  rgba(255,255,255,0.07);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--black);
  color: var(--white);
  font-family: 'Poppins', sans-serif;
  display: flex; flex-direction: column;
}

/* ── COSMOS ──────────────────────────────── */
#cosmos { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.star { position: absolute; border-radius: 50%; background: #fff; animation: twinkle var(--dur) ease-in-out infinite; animation-delay: var(--delay); opacity: 0; }
@keyframes twinkle { 0%,100%{opacity:0;transform:scale(.5);}50%{opacity:var(--op);transform:scale(1);} }
.nebula { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .05; animation: nebulaDrift 20s ease-in-out infinite alternate; }
@keyframes nebulaDrift { 0%{transform:translate(0,0) scale(1);}100%{transform:translate(40px,30px) scale(1.1);} }

/* ── TOP NAV ─────────────────────────────── */
.chat-topnav {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: rgba(8,8,8,.97);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.nav-col-btns { display: flex; flex-direction: column; gap: 5px; }
.nav-col-btn {
  display: flex; align-items: center; gap: 6px;
  color: rgba(255,255,255,.45); text-decoration: none;
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; transition: color .2s;
  font-family: 'Space Mono', monospace; white-space: nowrap;
}
.nav-col-btn:hover { color: var(--yellow); }
.chat-nav-title { text-align: center; }
.chat-nav-tag { display: block; font-family: 'Space Mono', monospace; font-size: 9px; letter-spacing: .2em; text-transform: uppercase; color: var(--orange2); margin-bottom: 3px; }
.chat-nav-heading { font-size: 16px; font-weight: 800; background: linear-gradient(135deg,var(--yellow),var(--orange)); -webkit-background-clip:text; -webkit-text-fill-color:transparent; background-clip:text; }
.owner-btn { background: rgba(255,208,0,.08); border: 1px solid rgba(255,208,0,.2); color: rgba(255,208,0,.6); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; padding: 6px 12px; border-radius: 20px; cursor: pointer; transition: all .2s; font-family: 'Space Mono', monospace; white-space: nowrap; }
.owner-btn:hover { background: rgba(255,208,0,.15); color: var(--yellow); }
.owner-btn.active { color: var(--yellow); border-color: rgba(255,208,0,.5); }

/* ── LAYOUT ──────────────────────────────── */
.chat-layout { position: relative; z-index: 5; display: flex; flex: 1; overflow: hidden; }

/* ── LEFT SIDEBAR ────────────────────────── */
.chat-sidebar { width: 280px; flex-shrink: 0; background: rgba(10,10,10,.97); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.sidebar-header { padding: 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.sidebar-title { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.3); margin-bottom: 10px; }
.sidebar-search { width: 100%; background: rgba(255,255,255,.05); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; color: var(--white); font-family: 'Poppins', sans-serif; font-size: 12px; outline: none; transition: border-color .2s; }
.sidebar-search:focus { border-color: rgba(255,208,0,.4); }
.sidebar-search::placeholder { color: rgba(255,255,255,.2); }
.convo-list { flex: 1; overflow-y: auto; padding: 6px; }
.convo-list::-webkit-scrollbar { width: 3px; }
.convo-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 3px; }

/* Conversation item */
.convo-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; cursor: pointer; transition: background .15s; position: relative; margin-bottom: 2px; border: 1px solid transparent; }
.convo-item:hover { background: rgba(255,255,255,.04); }
.convo-item.active { background: rgba(255,208,0,.06); border-color: rgba(255,208,0,.12); }
.convo-avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg,var(--orange),var(--yellow)); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 800; color: var(--black); flex-shrink: 0; }
.convo-info { flex: 1; min-width: 0; }
.convo-name { font-size: 13px; font-weight: 600; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-preview { font-size: 11px; color: rgba(255,255,255,.3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.convo-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.convo-time { font-size: 9px; color: rgba(255,255,255,.2); font-family: 'Space Mono', monospace; }
.convo-tag { font-size: 8px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 2px 6px; border-radius: 20px; }
.tag-new     { background: rgba(255,208,0,.15); color: var(--yellow); border: 1px solid rgba(255,208,0,.3); }
.tag-read    { background: rgba(255,255,255,.05); color: rgba(255,255,255,.3); border: 1px solid var(--border); }
.tag-replied { background: rgba(0,200,130,.1); color: #00c882; border: 1px solid rgba(0,200,130,.25); }
.tag-starred { background: rgba(255,106,0,.12); color: var(--orange2); border: 1px solid rgba(255,106,0,.3); }
.tag-closed  { background: rgba(255,68,68,.08); color: rgba(255,68,68,.6); border: 1px solid rgba(255,68,68,.2); }
.convo-unread-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--yellow); position: absolute; top: 10px; right: 10px; box-shadow: 0 0 6px rgba(255,208,0,.6); }

.sidebar-new-btn { margin: 10px; padding: 10px; width: calc(100% - 20px); background: linear-gradient(135deg,var(--orange),var(--yellow)); border: none; border-radius: 10px; color: var(--black); font-family: 'Poppins', sans-serif; font-size: 12px; font-weight: 700; cursor: pointer; transition: all .2s; flex-shrink: 0; }
.sidebar-new-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(255,106,0,.4); }

/* ── CHAT MAIN ───────────────────────────── */
.chat-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: rgba(255,255,255,.2); text-align: center; gap: 12px; }
.chat-empty-icon { font-size: 48px; opacity: .3; }
.chat-empty h3 { font-size: 16px; font-weight: 600; }
.chat-empty p { font-size: 12px; line-height: 1.8; max-width: 240px; }

/* Chat header */
.chat-header { padding: 12px 18px; background: rgba(10,10,10,.97); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; gap: 10px; }
.chat-header-info { display: flex; align-items: center; gap: 10px; }
.chat-header-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg,var(--orange),var(--yellow)); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; color: var(--black); flex-shrink: 0; }
.chat-header-name { font-size: 14px; font-weight: 700; }
.chat-header-sub { font-size: 11px; color: rgba(255,255,255,.3); margin-top: 1px; }
.chat-header-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chat-action-btn { background: rgba(255,255,255,.05); border: 1px solid var(--border); border-radius: 8px; color: rgba(255,255,255,.45); font-size: 11px; padding: 5px 10px; cursor: pointer; transition: all .2s; font-family: 'Poppins', sans-serif; font-weight: 600; }
.chat-action-btn:hover { background: rgba(255,255,255,.09); color: var(--white); }
.chat-action-btn.danger:hover { background: rgba(255,68,68,.12); color: #ff4444; border-color: rgba(255,68,68,.3); }
.tag-select { background: rgba(255,255,255,.05); border: 1px solid var(--border); border-radius: 8px; color: rgba(255,255,255,.6); font-size: 11px; padding: 5px 8px; cursor: pointer; outline: none; font-family: 'Poppins', sans-serif; -webkit-appearance: none; appearance: none; }
.tag-select option { background: #111; }

/* Messages */
.chat-messages { flex: 1; overflow-y: auto; padding: 16px 18px 8px; display: flex; flex-direction: column; gap: 10px; }
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 3px; }

/* Confidential overlay */
.chat-confidential { flex: 1; display: flex; align-items: center; justify-content: center; }
.chat-confidential-inner { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.confidential-icon { font-size: 44px; opacity: .35; }
.confidential-text { font-family: 'Space Mono', monospace; font-size: 13px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: rgba(255,255,255,.3); }
.confidential-sub { font-size: 12px; color: rgba(255,255,255,.2); max-width: 230px; line-height: 1.8; }

/* Message bubbles */
.msg-wrap { display: flex; align-items: flex-end; gap: 8px; animation: msgIn .2s ease; width: 100%; }
@keyframes msgIn { from{opacity:0;transform:translateY(8px);}to{opacity:1;transform:translateY(0);} }
.msg-wrap.own { flex-direction: row; justify-content: flex-end; }
.msg-avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg,var(--orange),var(--yellow)); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; color: var(--black); flex-shrink: 0; }
.msg-avatar.owner-av { background: linear-gradient(135deg,#222,#333); border: 1px solid rgba(255,208,0,.3); font-size: 12px; }
.msg-bubble { max-width: 60%; min-width: 60%; padding: 10px 14px; border-radius: 16px; font-size: 13px; line-height: 1.6; word-break: break-word; white-space: normal; }
.msg-wrap:not(.own) .msg-bubble { background: rgba(255,255,255,.07); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-wrap.own .msg-bubble { background: linear-gradient(135deg,rgba(255,106,0,.22),rgba(255,208,0,.12)); border: 1px solid rgba(255,208,0,.18); border-bottom-right-radius: 4px; }
.msg-bubble.auto-reply { background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.06); color: rgba(255,255,255,.35); font-style: italic; font-size: 12px; }
.msg-time { font-size: 9px; color: rgba(255,255,255,.18); margin-top: 3px; font-family: 'Space Mono', monospace; }
.msg-wrap.own .msg-time { text-align: right; }
.msg-system { text-align: center; font-size: 10px; color: rgba(255,255,255,.18); letter-spacing: .06em; text-transform: uppercase; font-family: 'Space Mono', monospace; padding: 4px 0; }

/* Input */
.chat-input-area { padding: 10px 14px; background: rgba(10,10,10,.97); border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: flex-end; flex-shrink: 0; }
.chat-input { flex: 1; background: rgba(255,255,255,.05); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; color: var(--white); font-family: 'Poppins', sans-serif; font-size: 13px; outline: none; resize: none; max-height: 120px; min-height: 42px; transition: border-color .2s; line-height: 1.5; }
.chat-input:focus { border-color: rgba(255,208,0,.4); }
.chat-input::placeholder { color: rgba(255,255,255,.18); }
.chat-send-btn { width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(135deg,var(--orange),var(--yellow)); border: none; color: var(--black); font-size: 16px; cursor: pointer; transition: all .2s; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.chat-send-btn:hover { transform: scale(1.05); box-shadow: 0 4px 16px rgba(255,106,0,.4); }
.chat-send-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* ── MODALS ──────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.85); backdrop-filter: blur(10px); display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; pointer-events: none; transition: opacity .3s; }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: #111; border: 1px solid rgba(255,208,0,.2); border-radius: 24px; padding: 28px; width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto; transform: translateY(30px) scale(.95); transition: transform .35s cubic-bezier(.34,1.56,.64,1); position: relative; }
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-close { position: absolute; top: 14px; right: 14px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); color: rgba(255,255,255,.5); font-size: 18px; cursor: pointer; transition: all .2s; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.modal-close:hover { background: rgba(255,255,255,.12); color: #fff; }
.modal-tag { font-family: 'Space Mono', monospace; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--orange2); margin-bottom: 8px; }
.modal-title { font-size: 20px; font-weight: 800; margin-bottom: 20px; }
.modal-title span { background: linear-gradient(135deg,var(--yellow),var(--orange)); -webkit-background-clip:text; -webkit-text-fill-color:transparent; background-clip:text; }
.mf { margin-bottom: 14px; }
.ml { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.4); margin-bottom: 5px; display: block; }
.ml .req { color: var(--orange2); }
.mi { width: 100%; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1); border-radius: 10px; padding: 10px 14px; color: var(--white); font-family: 'Poppins', sans-serif; font-size: 13px; outline: none; transition: border-color .2s; -webkit-appearance: none; }
.mi:focus { border-color: rgba(255,208,0,.5); }
.mi.err { border-color: #ff4444 !important; }
.modal-submit { width: 100%; margin-top: 12px; padding: 13px; background: linear-gradient(135deg,var(--orange),var(--yellow)); border: none; border-radius: 12px; color: var(--black); font-family: 'Poppins', sans-serif; font-size: 14px; font-weight: 700; cursor: pointer; transition: all .2s; }
.modal-submit:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(255,106,0,.4); }
.modal-submit:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.pin-err { color: #ff4444; font-size: 12px; text-align: center; margin-top: 8px; display: none; }

/* Visitor return banner */
.visitor-return-banner { background: rgba(255,208,0,.07); border: 1px solid rgba(255,208,0,.18); border-radius: 10px; padding: 12px 14px; margin: 8px; display: none; flex-direction: column; gap: 8px; flex-shrink: 0; }
.visitor-return-banner.show { display: flex; }
.vrb-label { font-size: 10px; color: var(--orange2); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.vrb-name { font-size: 13px; font-weight: 700; }
.vrb-btn { background: linear-gradient(135deg,var(--orange),var(--yellow)); border: none; border-radius: 8px; color: var(--black); font-size: 12px; font-weight: 700; padding: 8px; cursor: pointer; width: 100%; font-family: 'Poppins', sans-serif; }

/* ── BLURRED RIGHT PANEL (visitor viewing another's convo) ── */
.chat-main--blurred .chat-header,
.chat-main--blurred .chat-input-area {
  filter: blur(4px);
  pointer-events: none;
  user-select: none;
  opacity: 0.4;
}

.chat-main--blurred #chatMessagesWrap {
  position: relative;
}

.chat-main--blurred #chatMessagesWrap::after {
  content: '🔒  This conversation is private';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 208, 0, 0.7);
  background: rgba(5, 5, 5, 0.88);
  border: 1px solid rgba(255, 208, 0, 0.25);
  border-radius: 12px;
  padding: 12px 22px;
  z-index: 10;
  white-space: nowrap;
  pointer-events: none;
}

.chat-main--blurred .chat-messages {
  filter: blur(7px);
  pointer-events: none;
  user-select: none;
}

.chat-main { position: relative; }

@media (max-width: 700px) { .chat-sidebar { width: 200px; } .msg-bubble { max-width: 100%; min-width: 100%; } }
@media (max-width: 480px) { .chat-sidebar { display: none; } }