/* ============================================================
   FamilyLink v2 — Premium CSS Additions
   Append this to assets/style.css  OR  <link> it after
   ============================================================ */

/* ── THEME SYSTEM ────────────────────────────────────────────── */

/* Accent: Coral (default) */
[data-accent="coral"]   { --primary:#FF6B6B;--primary-d:#E55555;--primary-l:#FFE0DC;--primary-xl:#FFF0EE;--accent:#FF9055;--accent-l:#FFE9DA; }
/* Accent: Lavender */
[data-accent="lavender"]{ --primary:#8B7CF6;--primary-d:#7163E6;--primary-l:#EDE9FF;--primary-xl:#F5F3FF;--accent:#C084FC;--accent-l:#F3E8FF; }
/* Accent: Mint */
[data-accent="mint"]    { --primary:#10B981;--primary-d:#059669;--primary-l:#D1FAE5;--primary-xl:#ECFDF5;--accent:#34D399;--accent-l:#D1FAE5; }
/* Accent: Ocean */
[data-accent="ocean"]   { --primary:#0EA5E9;--primary-d:#0284C7;--primary-l:#BAE6FD;--primary-xl:#F0F9FF;--accent:#38BDF8;--accent-l:#E0F2FE; }
/* Accent: Rose */
[data-accent="rose"]    { --primary:#F43F5E;--primary-d:#E11D48;--primary-l:#FFE4E6;--primary-xl:#FFF1F2;--accent:#FB7185;--accent-l:#FFE4E6; }
/* Accent: Amber */
[data-accent="amber"]   { --primary:#F59E0B;--primary-d:#D97706;--primary-l:#FEF3C7;--primary-xl:#FFFBEB;--accent:#FBBF24;--accent-l:#FEF9C3; }

/* ── DARK MODE ───────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:         #1A1210;
  --surface:    #241A17;
  --surface2:   #2E211D;
  --surface3:   #3A2924;
  --text:       #F5EDE8;
  --text-2:     #C4A89A;
  --text-3:     #8A6E64;
  --border:     #3D2820;
  --shadow:     rgba(0,0,0,.3);
  --shadow-lg:  rgba(0,0,0,.5);
}
[data-theme="dark"] .login-card,
[data-theme="dark"] .modal,
[data-theme="dark"] #incoming-banner,
[data-theme="dark"] .toast { box-shadow: 0 8px 60px rgba(0,0,0,.5); }
[data-theme="dark"] .msg-row:not(.mine) .bubble { background: var(--surface2); color: var(--text); }
[data-theme="dark"] .bubble-meta { color: var(--text-3); }
[data-theme="dark"] #chat-area { background: var(--bg); }
[data-theme="dark"] .input-group input,
[data-theme="dark"] #msg-input,
[data-theme="dark"] #search-input { color: var(--text); }
[data-theme="dark"] .call-card { background: var(--surface); }
[data-theme="dark"] .reaction-chip { background: var(--surface2); border-color: var(--border); color: var(--text-2); }
[data-theme="dark"] .reaction-chip.mine { background: var(--primary-xl); }

/* Dark mode transition */
*, *::before, *::after {
  transition-property: background-color, border-color, color, box-shadow;
  transition-duration: 0.25s;
  transition-timing-function: ease;
}
/* But NOT for animations that shouldn't be slowed */
.emoji-burst, .badge, .reaction-picker, .bubble,
.msg-row, .toast, .call-card, .incoming-banner { transition: none; }

/* ── FONT SIZE SYSTEM ────────────────────────────────────────── */
[data-font="small"]  { --fs-base: 0.85rem; }
[data-font="medium"] { --fs-base: 0.92rem; }
[data-font="large"]  { --fs-base: 1.02rem; }
.bubble { font-size: var(--fs-base, 0.92rem); }

/* ── DARK MODE TOGGLE BUTTON ─────────────────────────────────── */
.theme-toggle {
  width: 52px; height: 28px;
  background: var(--surface3);
  border-radius: 14px;
  border: none;
  cursor: pointer;
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}
.theme-toggle.dark { background: var(--primary); }
.theme-toggle::after {
  content: '';
  position: absolute;
  width: 22px; height: 22px;
  background: var(--surface);
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), background var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.theme-toggle.dark::after { transform: translateX(24px); }
.toggle-label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-3);
}

/* ── EMOJI REACTION PICKER ───────────────────────────────────── */
.reaction-picker {
  position: fixed;
  z-index: 500;
  background: var(--surface);
  border-radius: 40px;
  padding: 8px 12px;
  display: flex;
  gap: 4px;
  box-shadow: 0 8px 40px rgba(0,0,0,.2), 0 0 0 1px var(--border);
  animation: pickerIn .22s cubic-bezier(0.34,1.56,0.64,1);
  transform-origin: bottom center;
}
@keyframes pickerIn {
  from { opacity:0; transform:scale(.4) translateY(10px); }
  to   { opacity:1; transform:scale(1)  translateY(0); }
}
.rp-btn {
  width: 44px; height: 44px;
  background: transparent;
  border: none;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.18s cubic-bezier(0.34,1.56,0.64,1), background 0.15s;
  animation: rp-appear .25s both;
}
@keyframes rp-appear {
  from { opacity:0; transform:scale(0) translateY(6px); }
  to   { opacity:1; transform:scale(1) translateY(0); }
}
.rp-btn:hover { transform: scale(1.4) translateY(-4px); background: var(--surface2); }
.rp-btn.active { background: var(--primary-xl); }
.rp-btn.active::after { content:'✓'; position:absolute; font-size:.5rem; bottom:2px; right:2px; }

/* ── REACTION BAR (below bubble) ─────────────────────────────── */
.reaction-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  padding: 0 4px;
  animation: reactionBarIn .2s ease;
}
@keyframes reactionBarIn { from {opacity:0;transform:translateY(4px)} to {opacity:1;transform:none} }
.msg-row.mine .reaction-bar { justify-content: flex-end; }

.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 2px 8px 2px 5px;
  font-size: .8rem;
  cursor: pointer;
  transition: transform .15s, background .15s, border-color .15s;
  white-space: nowrap;
  box-shadow: 0 1px 4px var(--shadow);
}
.reaction-chip:hover { transform: scale(1.1); background: var(--surface2); }
.reaction-chip.mine  { background: var(--primary-xl); border-color: var(--primary-l); }
.rc-emoji { font-size: 1rem; line-height: 1; }
.rc-count { font-size: .72rem; font-weight: 700; color: var(--text-2); min-width: 10px; }

/* ── HOVER REACT BUTTON ──────────────────────────────────────── */
.msg-react-btn {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  width: 28px; height: 28px;
  font-size: .85rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity .15s, transform .2s;
  box-shadow: 0 2px 8px var(--shadow);
  z-index: 5;
}
.msg-row:not(.mine) .msg-react-btn { right: -36px; }
.msg-row.mine       .msg-react-btn { left: -36px; }
.msg-row:hover .msg-react-btn { opacity: 1; }
.msg-react-btn:hover { transform: translateY(-50%) scale(1.2); }

/* ── FLYING EMOJI BURST ──────────────────────────────────────── */
@keyframes emoji-burst {
  0%   { opacity:1; transform:translate(0,0) scale(1); }
  100% { opacity:0; transform:translate(var(--dx), var(--dy)) scale(1.4); }
}
.emoji-burst {
  animation: emoji-burst .7s ease-out forwards;
  user-select: none;
  pointer-events: none;
}

/* ── SWIPE TO REPLY ──────────────────────────────────────────── */
.msg-row {
  position: relative;
  touch-action: pan-y;
  will-change: transform;
}
.msg-row.swiping { transition: none !important; }
.swipe-reply-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%) scale(0);
  width: 32px; height: 32px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  opacity: 0;
  transition: transform .2s, opacity .2s;
  pointer-events: none;
  z-index: 2;
}
.msg-row:not(.mine) .swipe-reply-icon { right: -44px; }
.msg-row.mine       .swipe-reply-icon { left:  -44px; }
.msg-row.swipe-ready .swipe-reply-icon {
  transform: translateY(-50%) scale(1);
  opacity: 1;
}

/* ── E2E ENCRYPTION BADGE ────────────────────────────────────── */
.e2e-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--green-l);
  color: var(--green);
  font-size: .7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: .02em;
}
.e2e-badge.animating { animation: e2ePulse .5s ease; }
@keyframes e2ePulse {
  0%,100% { transform:scale(1); }
  50%     { transform:scale(1.08); }
}
.e2e-verify-btn {
  background: none;
  border: none;
  color: var(--green);
  font-size: .7rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.chat-peer-sub .e2e-badge { margin-left: 6px; }

/* ── FINGERPRINT MODAL ───────────────────────────────────────── */
.fingerprint-box {
  font-family: 'Courier New', monospace;
  font-size: .88rem;
  background: var(--surface2);
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  letter-spacing: .06em;
  line-height: 1.8;
  color: var(--text);
  word-break: break-all;
  margin: 1rem 0;
}
.fp-match  { color: var(--green);  font-weight: 700; }
.fp-nomatch{ color: var(--red);    font-weight: 700; }

/* ── SETTINGS PANEL ──────────────────────────────────────────── */
.settings-section { margin-bottom: 1.5rem; }
.settings-section h4 {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
  margin-bottom: .8rem;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem 0;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row label { font-size: .9rem; font-weight: 500; color: var(--text); }
.settings-row small { font-size: .75rem; color: var(--text-3); display:block; }

/* Accent color swatches */
.accent-swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: .5rem;
}
.swatch {
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform .15s, border-color .15s;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.swatch:hover { transform: scale(1.15); }
.swatch.active { border-color: var(--text); }

/* Font size selector */
.font-options { display:flex; gap:6px; margin-top:.4rem; }
.font-opt {
  padding: .4rem .85rem;
  background: var(--surface2);
  border: 2px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 600;
  transition: var(--transition);
}
.font-opt:hover  { background: var(--primary-l); }
.font-opt.active { border-color: var(--primary); background: var(--primary-xl); color: var(--primary); }

/* ── PREMIUM CHAT HEADER ENHANCEMENT ───────────────────────── */
.e2e-status-bar {
  background: var(--green-l);
  color: var(--green);
  text-align: center;
  font-size: .72rem;
  font-weight: 600;
  padding: 4px 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-bottom: 1px solid rgba(76,175,154,.15);
  animation: slideDown .3s ease;
}
@keyframes slideDown { from{height:0;opacity:0} to{height:auto;opacity:1} }

/* ── MESSAGE ENTER ANIMATIONS ───────────────────────────────── */
.msg-row { animation: msgIn .25s cubic-bezier(0.34,1.2,0.64,1) both; }
.msg-row.mine { animation-name: msgInMine; }
@keyframes msgIn     { from{opacity:0;transform:translateX(-12px) scale(.97)} to{opacity:1;transform:none} }
@keyframes msgInMine { from{opacity:0;transform:translateX( 12px) scale(.97)} to{opacity:1;transform:none} }

/* ── SEND BUTTON SEND ANIMATION ─────────────────────────────── */
.send-btn.sending {
  animation: sendPulse .4s ease;
}
@keyframes sendPulse {
  0%   { transform:scale(1);    }
  40%  { transform:scale(1.25); }
  100% { transform:scale(1);    }
}

/* ── SCROLLBAR FADE EFFECT ───────────────────────────────────── */
#messages-area {
  scrollbar-gutter: stable;
}

/* ── SIDEBAR SECTION LABEL ───────────────────────────────────── */
.sidebar-section-label {
  padding: .4rem 1.3rem .2rem;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
}

/* ── PREMIUM AVATAR RING (for online users) ─────────────────── */
.avatar-wrap .status-dot.online {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px rgba(76,175,154,.3);
}

/* ── UNREAD SEPARATOR ────────────────────────────────────────── */
.unread-sep {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin: .5rem 0;
}
.unread-sep::before, .unread-sep::after { content:''; flex:1; height:1px; background:var(--primary-l); }
.unread-sep span {
  background: var(--primary-l);
  color: var(--primary);
  font-size: .7rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 10px;
  white-space: nowrap;
}

/* ── NOTIFICATION PERMISSION BAR ─────────────────────────────── */
#notif-bar {
  background: var(--accent-l);
  padding: .6rem 1.2rem;
  display: flex;
  align-items: center;
  gap: .8rem;
  font-size: .82rem;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  animation: slideDown .3s ease;
}
#notif-bar button {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .35rem .9rem;
  font-family: var(--font);
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}
#notif-bar .nb-close {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  margin-left: auto;
}

/* ── IMAGE LIGHTBOX ──────────────────────────────────────────── */
#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.92);
  z-index: 600;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  cursor: zoom-out;
}
#lightbox.visible { display: flex; }
#lightbox img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 12px;
  animation: lightboxIn .3s ease;
}
@keyframes lightboxIn { from{opacity:0;transform:scale(.9)} to{opacity:1;transform:none} }
#lightbox .lb-close {
  position: absolute;
  top: 1rem; right: 1rem;
  background: rgba(255,255,255,.15);
  border: none;
  border-radius: 50%;
  width: 42px; height: 42px;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
#lightbox .lb-download {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 12px;
  color: #fff;
  font-size: .85rem;
  font-weight: 600;
  padding: .5rem 1.2rem;
  cursor: pointer;
  font-family: var(--font);
  text-decoration: none;
}
