/* ============================================================
   RAF v7 — Chat, Notifications page, WebRTC call modal, PWA install
   ============================================================ */

.input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--neutral-200);
  border-radius: var(--radius);
  font: inherit;
  color: var(--neutral-900);
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus { outline: none; border-color: var(--brand-bronze); box-shadow: 0 0 0 3px rgba(143,121,97,.12); }
select.input { cursor: pointer; }

/* ---------- PWA install button ---------- */
.install-btn { gap: 8px; }
.install-btn i { color: var(--brand-bronze); }
@media (max-width: 640px) { .install-btn .install-btn-label { display: none; } }

/* ============================================================ NOTIFICATIONS PAGE */
.notif-page { padding: 0; overflow: hidden; }
.notif-page-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  flex-wrap: wrap; padding: 18px 20px; border-bottom: 1px solid var(--neutral-100);
  background: linear-gradient(180deg, rgba(143,121,97,.05), transparent);
}
.notif-page-toolbar .filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.notif-page-toolbar .filters .input { width: auto; }
.notif-page-list { min-height: 320px; }
.notif-row {
  display: flex; align-items: flex-start; gap: 14px; padding: 16px 20px;
  border-bottom: 1px solid var(--neutral-100); cursor: pointer;
  transition: background-color .15s ease; position: relative;
}
.notif-row:hover { background: var(--neutral-100); }
.notif-row.unread { background: rgba(143,121,97,.06); }
.notif-row.unread::before { content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 3px; background: var(--brand-bronze); }
.notif-row-icon {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(143,121,97,.12); color: var(--brand-bronze); font-size: 16px;
}
.notif-row-main { flex: 1; min-width: 0; }
.notif-row-head { display: flex; align-items: center; gap: 8px; }
.notif-row-title { font-weight: 600; font-size: 14px; color: var(--neutral-900); }
.notif-unread-dot { width: 8px; height: 8px; border-radius: 50%; background: #ef4444; flex-shrink: 0; }
.notif-row-msg { font-size: 13px; color: var(--neutral-600); margin-top: 3px; white-space: pre-wrap; word-break: break-word; }
.notif-row-meta { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.notif-row-time { font-size: 11px; color: var(--neutral-500); }
.notif-row-go { color: var(--neutral-300); align-self: center; }
.notif-row:hover .notif-row-go { color: var(--brand-bronze); }
.notif-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600;
  color: var(--chip, #64748b); background: color-mix(in srgb, var(--chip, #64748b) 12%, transparent);
}
.notif-pager {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-top: 1px solid var(--neutral-100);
}
.pager-info { font-size: 13px; color: var(--neutral-600); }
.notif-pager .btn:disabled { opacity: .4; cursor: not-allowed; }
.notif-viewall {
  display: block; text-align: center; padding: 12px; font-size: 13px; font-weight: 600;
  color: var(--brand-bronze); border-top: 1px solid var(--neutral-100);
  position: sticky; bottom: 0; background: #fff; text-decoration: none;
}
.notif-viewall:hover { background: var(--neutral-100); }

/* ============================================================ CHAT (WhatsApp style) */
.chat-app {
  display: grid; grid-template-columns: 320px 1fr;
  height: calc(100vh - 132px); min-height: 480px;
  border: 1px solid var(--neutral-200); border-radius: var(--radius-lg);
  overflow: hidden; background: #fff; box-shadow: var(--shadow);
}
.chat-sidebar { border-inline-end: 1px solid var(--neutral-200); display: flex; flex-direction: column; min-width: 0; }
.chat-sidebar-head { padding: 16px; border-bottom: 1px solid var(--neutral-100); }
.chat-sidebar-head h3 { margin: 0 0 12px; font-size: 17px; }
.chat-search .input { width: 100%; padding: 9px 12px; }
.chat-contacts { flex: 1; overflow-y: auto; }
.chat-contact {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: start;
  padding: 12px 14px; background: none; border: none; border-bottom: 1px solid var(--neutral-100);
  cursor: pointer; transition: background-color .12s ease; font: inherit;
}
.chat-contact:hover { background: var(--neutral-100); }
.chat-contact.active { background: rgba(143,121,97,.10); }
.chat-avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; position: relative;
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--brand-gold), var(--brand-bronze));
}
.chat-avatar.lg { width: 40px; height: 40px; font-size: 15px; }
.chat-online-dot {
  position: absolute; bottom: 0; inset-inline-end: 0; width: 12px; height: 12px;
  border-radius: 50%; background: #22c55e; border: 2px solid #fff;
}
.chat-contact-body { flex: 1; min-width: 0; }
.chat-contact-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-contact-name { font-weight: 600; font-size: 14px; color: var(--neutral-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-contact-time { font-size: 11px; color: var(--neutral-500); flex-shrink: 0; }
.chat-contact-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 3px; }
.chat-contact-preview { font-size: 12.5px; color: var(--neutral-600); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.chat-unread {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; flex-shrink: 0;
  background: #22c55e; color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.chat-empty-sm { padding: 30px 16px; text-align: center; color: var(--neutral-500); font-size: 13px; }

.chat-main { display: flex; flex-direction: column; min-width: 0; background: #f6f3ee; }
.chat-conv { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: var(--neutral-500); padding: 40px; height: 100%;
}
.chat-empty i { font-size: 56px; color: var(--neutral-300); margin-bottom: 16px; }
.chat-empty h4 { margin: 0 0 6px; color: var(--neutral-700); }
.chat-empty p { margin: 0; font-size: 13px; max-width: 320px; }

.chat-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px; background: #fff; border-bottom: 1px solid var(--neutral-200); flex-shrink: 0;
}
.chat-head-peer { display: flex; align-items: center; gap: 12px; }
.chat-head-name { font-weight: 600; font-size: 15px; }
.chat-head-status { font-size: 12px; color: var(--neutral-500); }
.chat-head-actions { display: flex; gap: 6px; }
.chat-call { width: 42px; height: 42px; border-radius: 50%; color: var(--brand-bronze); font-size: 16px; }
.chat-call:hover { background: rgba(143,121,97,.12); }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 8px;
  background-image: radial-gradient(rgba(143,121,97,.05) 1px, transparent 1px); background-size: 22px 22px;
}
.chat-bubble-row { display: flex; }
.chat-bubble-row.mine { justify-content: flex-end; }
.chat-bubble-row.theirs { justify-content: flex-start; }
.chat-bubble {
  max-width: min(76%, 520px); padding: 9px 13px; border-radius: 14px; position: relative;
  box-shadow: var(--shadow-sm); font-size: 14px; line-height: 1.55; word-break: break-word;
}
.chat-bubble.mine { background: #dcf3e4; border-bottom-right-radius: 4px; color: #10331f; }
.chat-bubble.theirs { background: #fff; border-bottom-left-radius: 4px; color: var(--neutral-900); }
.chat-bubble-text { white-space: pre-wrap; }
.chat-bubble-time { font-size: 10.5px; color: rgba(0,0,0,.42); margin-top: 4px; text-align: end; }
.chat-img { max-width: 240px; max-height: 260px; border-radius: 10px; display: block; margin-bottom: 4px; }
.chat-file {
  display: inline-flex; align-items: center; gap: 10px; padding: 9px 12px; margin-bottom: 4px;
  background: rgba(0,0,0,.05); border: none; border-radius: 10px; cursor: pointer; font: inherit;
  color: var(--brand-bronze-700); font-weight: 600;
}
.chat-file:hover { background: rgba(0,0,0,.09); }

.chat-composer {
  display: flex; align-items: center; gap: 8px; padding: 12px 16px;
  background: #fff; border-top: 1px solid var(--neutral-200); flex-shrink: 0;
}
.chat-input { flex: 1; padding: 11px 16px; border: 1.5px solid var(--neutral-200); border-radius: 999px; font: inherit; }
.chat-input:focus { outline: none; border-color: var(--brand-bronze); }
.chat-attach { width: 44px; height: 44px; border-radius: 50%; color: var(--neutral-600); font-size: 17px; }
.chat-send { width: 46px; height: 46px; border-radius: 50%; padding: 0; }

@media (max-width: 820px) {
  .chat-app { grid-template-columns: 1fr; }
  .chat-app.has-active .chat-sidebar { display: none; }
}

/* ============================================================ WEBRTC CALL MODAL */
.call-backdrop {
  position: fixed; inset: 0; z-index: 500; background: rgba(15,23,42,.82);
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(6px);
  animation: callFade .2s ease;
}
@keyframes callFade { from { opacity: 0; } to { opacity: 1; } }
.call-window {
  width: min(92vw, 760px); background: #0f172a; border-radius: 20px; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.5); color: #fff; display: flex; flex-direction: column;
}
.call-video-wrap { position: relative; background: #0b1220; aspect-ratio: 16/10; overflow: hidden; }
.call-remote { width: 100%; height: 100%; object-fit: cover; background: #0b1220; }
.call-remote.audio-only { opacity: 0; }
.call-peer-avatar {
  position: absolute; inset: 0; margin: auto; width: 120px; height: 120px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 48px; font-weight: 700;
  background: linear-gradient(135deg, var(--brand-gold), var(--brand-bronze)); color: #fff;
}
.call-window.is-video .call-peer-avatar { display: none; }
.call-local {
  position: absolute; bottom: 14px; inset-inline-end: 14px; width: 150px; height: 100px;
  object-fit: cover; border-radius: 12px; border: 2px solid rgba(255,255,255,.6); background: #000; z-index: 2;
}
.call-window.is-audio .call-local { display: none; }
.call-info { text-align: center; padding: 18px 16px 6px; }
.call-peer-name { font-size: 20px; font-weight: 700; }
.call-status { font-size: 14px; color: #94a3b8; margin-top: 4px; }
.call-controls { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 20px; }
.call-ctrl {
  width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.14); color: #fff; font-size: 20px; transition: transform .12s ease, background-color .15s ease;
}
.call-ctrl:hover { transform: scale(1.06); background: rgba(255,255,255,.24); }
.call-ctrl.active { background: #ef4444; }
.call-end { background: #ef4444; }
.call-end:hover { background: #dc2626; }
.call-accept { background: #22c55e; }
.call-accept:hover { background: #16a34a; }

.call-incoming { width: min(90vw, 380px); background: #0f172a; border-radius: 20px; padding: 34px 24px 26px; text-align: center; color: #fff; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.call-incoming-avatar {
  width: 92px; height: 92px; border-radius: 50%; margin: 0 auto 18px; font-size: 34px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand-gold), var(--brand-bronze));
  animation: ring 1.4s ease-in-out infinite;
}
@keyframes ring { 0%,100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(34,197,94,.5); } 50% { transform: scale(1.05); box-shadow: 0 0 0 16px rgba(34,197,94,0); } }
.call-incoming-title { font-size: 19px; font-weight: 700; }
.call-incoming-sub { font-size: 14px; color: #94a3b8; margin-top: 4px; }
.call-incoming-actions { display: flex; justify-content: center; gap: 40px; margin-top: 26px; }
