@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600&family=Manrope:wght@400;500;600;700&display=swap');

:root {
  --bg-deep: #17141f;
  --bg-panel: #201c2c;
  --bg-raised: #292339;
  --line: #37304a;
  --text-main: #f1ecf5;
  --text-dim: #a89cc0;
  --accent: #e0a56b;
  --accent-soft: rgba(224, 165, 107, 0.16);
  --accent-strong: #f0b878;
  --online: #7fd99b;
  --danger: #e0705f;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Manrope', sans-serif;
  background: var(--bg-deep);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ===== AUTH SCREEN ===== */
#auth-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(224,165,107,0.10), transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(127,111,180,0.14), transparent 50%),
    var(--bg-deep);
}

.auth-card {
  width: 380px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 36px 32px;
}

.brand { text-align: center; margin-bottom: 24px; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 22px;
  margin-bottom: 10px;
}
.brand h1 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 28px;
  margin: 4px 0 2px;
  letter-spacing: 0.3px;
}
.tagline { color: var(--text-dim); font-size: 13px; margin: 0; }

.tabs { display: flex; gap: 6px; background: var(--bg-raised); padding: 4px; border-radius: 10px; margin-bottom: 20px; }
.tab-btn {
  flex: 1; padding: 8px 0; border: none; background: transparent; color: var(--text-dim);
  font-family: 'Manrope', sans-serif; font-weight: 600; font-size: 13px; border-radius: 8px; cursor: pointer;
}
.tab-btn.active { background: var(--accent); color: #211a13; }

.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--text-main);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-family: 'Manrope', sans-serif;
}
.auth-form input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.auth-form button[type="submit"] {
  margin-top: 6px;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #211a13;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.auth-form button[type="submit"]:hover { background: var(--accent-strong); }
.form-error { color: var(--danger); font-size: 12.5px; min-height: 16px; margin: 2px 0 0; }

/* ===== APP SCREEN ===== */
#app-screen { display: flex; height: 100vh; }

.sidebar {
  width: 280px;
  background: var(--bg-panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 16px 12px;
}
.brand-mini { display: flex; align-items: center; gap: 8px; font-family: 'Fraunces', serif; font-weight: 600; font-size: 17px; }
.brand-mini .brand-mark { width: 26px; height: 26px; font-size: 13px; margin: 0; }
.header-actions { display: flex; gap: 6px; }
#invite-btn {
  background: var(--accent-soft); color: var(--accent-strong); border: none;
  padding: 6px 10px; border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer;
}
#admin-btn {
  background: var(--bg-raised); border: 1px solid var(--line); color: var(--text-main);
  padding: 6px 10px; border-radius: 8px; font-size: 13px; cursor: pointer;
}

.me-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  font-size: 13px; color: var(--text-dim);
}
#me-username { flex: 1; color: var(--text-main); font-weight: 600; }
#logout-btn { background: transparent; border: none; color: var(--text-dim); cursor: pointer; font-size: 16px; }

.avatar-dot {
  width: 9px; height: 9px; border-radius: 50%; background: #5c5470; display: inline-block; flex-shrink: 0;
}
.avatar-dot.online { background: var(--online); }

.contact-list { flex: 1; overflow-y: auto; padding: 8px; }
.contact-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px; border-radius: 10px; cursor: pointer; margin-bottom: 2px;
}
.contact-item:hover { background: var(--bg-raised); }
.contact-item.active { background: var(--accent-soft); }
.contact-item .name { font-weight: 600; font-size: 14px; }

.chat-area { flex: 1; display: flex; flex-direction: column; background: var(--bg-deep); }
.empty-state { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-dim); font-size: 14px; }

.chat-panel { flex: 1; display: flex; flex-direction: column; }
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--line);
}
.chat-header-user { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.call-buttons { display: flex; gap: 8px; }
.call-buttons button {
  background: var(--bg-raised); border: 1px solid var(--line); color: var(--text-main);
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer; font-size: 15px;
}
.call-buttons button:hover { background: var(--accent-soft); }

.messages { flex: 1; overflow-y: auto; padding: 20px 22px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 60%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.4; }
.msg.mine { align-self: flex-end; background: var(--accent); color: #211a13; border-bottom-right-radius: 4px; }
.msg.theirs { align-self: flex-start; background: var(--bg-raised); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg img { max-width: 220px; border-radius: 10px; display: block; margin-top: 4px; }
.msg .ts { display: block; font-size: 10px; opacity: 0.6; margin-top: 4px; }

.message-form { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); }
.photo-btn {
  cursor: pointer; font-size: 18px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--bg-raised);
}
#message-input {
  flex: 1; background: var(--bg-raised); border: 1px solid var(--line); color: var(--text-main);
  padding: 11px 14px; border-radius: 20px; font-size: 14px; font-family: 'Manrope', sans-serif;
}
#message-input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.message-form button[type="submit"] {
  background: var(--accent); color: #211a13; border: none; padding: 10px 18px; border-radius: 20px; font-weight: 700; cursor: pointer;
}

/* ===== CALL OVERLAY ===== */
.call-overlay {
  position: fixed; inset: 0; background: rgba(10, 8, 16, 0.92);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.call-box { text-align: center; }
#call-status { color: var(--text-dim); margin-bottom: 14px; font-size: 14px; }
.video-wrap { position: relative; width: 640px; max-width: 90vw; aspect-ratio: 4/3; background: #000; border-radius: var(--radius); overflow: hidden; }
#remote-video { width: 100%; height: 100%; object-fit: cover; }
#local-video { position: absolute; bottom: 14px; right: 14px; width: 130px; border-radius: 10px; border: 2px solid var(--accent); background: #000; }
.call-controls { display: flex; justify-content: center; gap: 14px; margin-top: 18px; }
.call-controls button {
  width: 52px; height: 52px; border-radius: 50%; border: none; font-size: 18px; cursor: pointer;
  background: var(--bg-raised); color: var(--text-main);
}
.call-controls .hangup { width: auto; border-radius: 26px; padding: 0 22px; background: var(--danger); color: white; font-weight: 700; font-size: 14px; }

/* ===== MODAL ===== */
.modal { position: fixed; inset: 0; background: rgba(10,8,16,0.8); display: flex; align-items: center; justify-content: center; z-index: 60; }
.modal-box { background: var(--bg-panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; width: 340px; text-align: center; }
.modal-box h3 { font-family: 'Fraunces', serif; margin-top: 0; }
.modal-box p { color: var(--text-dim); font-size: 13px; }
.invite-code {
  background: var(--bg-raised); border: 1px dashed var(--accent); color: var(--accent-strong);
  padding: 12px; border-radius: 10px; font-weight: 700; letter-spacing: 1px; margin: 14px 0; word-break: break-all;
}
.modal-box button {
  background: var(--accent); border: none; color: #211a13; padding: 10px 20px; border-radius: 10px; font-weight: 700; cursor: pointer;
}

/* ===== ADMIN MODAL ===== */
.admin-box { width: 640px; max-width: 92vw; text-align: left; }
.admin-tabs { margin-bottom: 14px; }
.admin-body { display: flex; gap: 12px; height: 360px; margin: 14px 0; }
.admin-conv-list { width: 240px; overflow-y: auto; border-right: 1px solid var(--line); padding-right: 8px; }
.admin-conv-item { padding: 10px; border-radius: 8px; cursor: pointer; margin-bottom: 4px; font-size: 13px; }
.admin-conv-item:hover { background: var(--bg-raised); }
.admin-conv-item.active { background: var(--accent-soft); }
.admin-conv-meta { display: block; color: var(--text-dim); font-size: 11px; margin-top: 2px; }
.admin-conv-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.admin-placeholder { color: var(--text-dim); font-size: 13px; }
.admin-msg { background: var(--bg-raised); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.admin-msg-from { display: block; font-weight: 700; color: var(--accent-strong); font-size: 11px; margin-bottom: 3px; }
.admin-msg img { max-width: 180px; border-radius: 8px; display: block; margin-top: 4px; }
.admin-recordings-list { max-height: 380px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.admin-recording-item { background: var(--bg-raised); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 13px; }
.admin-recording-meta { margin-bottom: 8px; }
.admin-recording-item video { max-width: 100%; border-radius: 8px; }
.admin-recording-item audio { width: 100%; }
.admin-invites-list { max-height: 380px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.admin-invite-item { background: var(--bg-raised); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.admin-invite-used { color: var(--text-dim); font-size: 12px; margin-top: 4px; }

/* ===== CALL RECORDING NOTICE ===== */
.record-notice { color: var(--accent-strong); font-size: 12px; margin: 6px 0 0; }

@media (max-width: 720px) {
  .sidebar { width: 100%; position: absolute; z-index: 10; height: 100vh; }
  #app-screen { position: relative; }
}
