/* ═══════════════════════════════════════════════════
   Concordia – Renderer Styles
   Brand: Indigo / Montserrat  (see branding/branding.md)
═══════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── Dark theme (default) ──────────────────────── */
:root {
  --bg:                #0f0d2a;
  --surface0:          #1e1b4b;   /* Indigo 900 */
  --surface1:          #2e2a6a;
  --surface2:          #3730a3;   /* Indigo 700 */
  --overlay0:          #4f46e5;   /* Indigo 600 */
  --text:              #e0e7ff;   /* Indigo 100 */
  --subtext0:          #a5b4fc;   /* Indigo 300 */
  --subtext1:          #c7d2fe;   /* Indigo 200 */
  --primary:           #4f46e5;   /* Indigo 600 */
  --primary-hover:     #4338ca;   /* Indigo 700 */
  --primary-text:      #818cf8;   /* Indigo 400 */
  --red:               #f87171;
  --radius:            8px;
  --sidebar-w:         230px;
  --msg-hover:         rgba(255,255,255,0.04);
  --logo-filter:       brightness(0) invert(1);
  --server-sidebar-bg: #09081a;
  --pill-color:        #ffffff;
}

/* ─── Light theme ───────────────────────────────── */
body.light {
  --bg:                #ffffff;
  --surface0:          #f3f4f6;   /* Gray 100 */
  --surface1:          #e5e7eb;   /* Gray 200 */
  --surface2:          #d1d5db;   /* Gray 300 */
  --overlay0:          #9ca3af;   /* Gray 400 */
  --text:              #111827;   /* Gray 900 */
  --subtext0:          #6b7280;   /* Gray 500 */
  --subtext1:          #374151;   /* Gray 700 */
  --primary:           #4f46e5;
  --primary-hover:     #4338ca;
  --primary-text:      #4f46e5;
  --red:               #ef4444;
  --msg-hover:         rgba(0,0,0,0.04);
  --logo-filter:       none;
  --server-sidebar-bg: #e0e7ff;
  --pill-color:        #4f46e5;
}

html, body {
  height: 100%;
  font-family: 'Montserrat', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  overflow: hidden;
}

/* ─── Utilities ─────────────────────────────────── */
.hidden { display: none !important; }
.screen { width: 100vw; height: 100vh; }

/* ─── Auth ──────────────────────────────────────── */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top, #1e1b4b 0%, #0f0d2a 65%);
}
body.light #auth-screen {
  background: linear-gradient(135deg, #e0e7ff 0%, #f3f4f6 100%);
}

.auth-card {
  background: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: calc(var(--radius) * 1.5);
  padding: 2.5rem 2rem;
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  box-shadow: 0 8px 40px rgba(0,0,0,0.35);
}
body.light .auth-card {
  box-shadow: 0 4px 24px rgba(79,70,229,0.10);
}

.auth-logo {
  display: block;
  width: 220px;
  margin: 0 auto 0.1rem;
  filter: var(--logo-filter);
}

.tagline {
  text-align: center;
  color: var(--subtext0);
  font-size: 0.8rem;
  margin-top: -0.5rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tab-row {
  display: flex;
  gap: 0.5rem;
}

.tab {
  flex: 1;
  padding: 0.5rem;
  background: var(--surface1);
  border: none;
  border-radius: var(--radius);
  color: var(--subtext1);
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
  transition: background 0.15s;
}

.tab.active {
  background: var(--primary);
  color: #fff;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ─── Splash screen ─────────────────────────────── */
#splash-screen {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: radial-gradient(ellipse at top, #1e1b4b 0%, #0f0d2a 65%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
body.light #splash-screen {
  background: linear-gradient(135deg, #e0e7ff 0%, #f3f4f6 100%);
}
#splash-screen.fade-out { opacity: 0; }

.splash-logo {
  width: 260px;
  opacity: 0;
  animation: splash-logo-in 0.7s 0.15s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  filter: var(--logo-filter);
}
.splash-tagline {
  opacity: 0;
  animation: splash-logo-in 0.6s 0.6s ease forwards;
  color: var(--subtext0);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
@keyframes splash-logo-in {
  from { opacity: 0; transform: translateY(14px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0)   scale(1);   }
}

/* ─── Inputs ────────────────────────────────────── */
input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: var(--surface1);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.18);
}

/* ─── Buttons ───────────────────────────────────── */
.btn-primary {
  padding: 0.6rem 1.2rem;
  background: var(--primary);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  padding: 0.6rem 1.2rem;
  background: var(--surface1);
  border: none;
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--surface2); }

.danger-btn {
  padding: 0.35rem 0.75rem;
  background: transparent;
  border: 1px solid var(--red);
  border-radius: var(--radius);
  color: var(--red);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.danger-btn:hover { background: var(--red); color: #fff; }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--subtext0);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.icon-btn:hover { color: var(--text); background: var(--surface1); }

.error-msg {
  color: var(--red);
  font-size: 0.8rem;
  min-height: 1rem;
}

/* ─── Chat layout ───────────────────────────────── */
#chat-screen {
  display: flex;
}

/* Left panel: wraps server sidebar + channel sidebar + user banner */
#left-panel {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

#left-sidebars {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ─── Server sidebar ────────────────────────────── */
#server-sidebar {
  width: 72px;
  flex-shrink: 0;
  background: var(--server-sidebar-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 8px;
}

#server-list-icons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  width: 100%;
  padding: 0 0 8px;
  scrollbar-width: none;
}
#server-list-icons::-webkit-scrollbar { display: none; }

.server-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 56px;
  flex-shrink: 0;
}

/* Pill indicator on the left edge */
.server-icon-wrap::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  background: var(--pill-color);
  border-radius: 0 4px 4px 0;
  transition: height 0.15s ease, opacity 0.15s ease;
  height: 0;
  opacity: 0;
}
.server-icon-wrap:hover::before   { height: 20px; opacity: 1; }
.server-icon-wrap.active::before  { height: 40px; opacity: 1; }

.server-icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface0);
  border: none;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-radius 0.2s ease, background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
  overflow: hidden;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1;
}
.server-icon-btn:hover {
  border-radius: 30%;
  background: var(--primary);
  color: #fff;
}
.server-icon-btn.active {
  border-radius: 30%;
  background: var(--primary);
  color: #fff;
}
.server-icon-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.server-list-divider {
  width: 32px;
  height: 2px;
  background: rgba(255,255,255,0.08);
  border-radius: 1px;
  margin: 4px 0;
  flex-shrink: 0;
}
body.light .server-list-divider { background: rgba(0,0,0,0.1); }

.add-server-btn {
  background: var(--surface0);
  color: var(--primary-text);
  font-size: 1.5rem;
  font-weight: 300;
  line-height: 1;
}
.add-server-btn:hover {
  background: var(--primary);
  color: #fff;
  border-radius: 30%;
}

/* ─── Channel sidebar ────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface0);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--surface1);
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--surface1);
  gap: 0.25rem;
}

.channels-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--subtext0);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  border-top: 1px solid var(--surface1);
  gap: 0.25rem;
  flex-shrink: 0;
  background: var(--surface0);
}

#channel-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 0.5rem 0;
}

.channel-section-label {
  padding: 0.6rem 0.75rem 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--subtext0);
}

#channel-list li {
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  border-radius: 6px;
  margin: 1px 0.35rem;
  color: var(--subtext1);
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
#channel-list li::before { content: '# '; color: var(--overlay0); opacity: 0.7; }
#channel-list li:hover  { background: var(--surface1); color: var(--text); }
#channel-list li.active { background: var(--primary); color: #fff; font-weight: 700; }
#channel-list li.active::before { color: rgba(255,255,255,0.7); opacity: 1; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
  flex: 1;
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
  overflow: hidden;
}
.sidebar-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#current-user-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* Main pane */
#chat-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#no-channel-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--subtext0);
  gap: 0.5rem;
}
#no-channel-placeholder p {
  font-size: 1rem;
  font-weight: 600;
}

#channel-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#channel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--surface1);
  background: var(--bg);
  flex-shrink: 0;
}

#channel-name-label {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}
#channel-name-label::before { content: '# '; color: var(--primary-text); }

/* Messages */
#message-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  scroll-behavior: smooth;
}

.load-more-btn {
  align-self: center;
  background: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: var(--radius);
  color: var(--subtext0);
  padding: 0.4rem 1rem;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  font-weight: 600;
  margin-bottom: 0.5rem;
  transition: background 0.15s;
}
.load-more-btn:hover { background: var(--surface1); }

.message {
  display: flex;
  gap: 0.6rem;
  padding: 0.2rem 0;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  margin-top: 2px;
  text-transform: uppercase;
}

.message-body {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1;
  min-width: 0;
}

.message-meta {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.message-author {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--primary-text);
}
.message-time {
  font-size: 0.72rem;
  color: var(--overlay0);
}
.message-content {
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
  border-radius: 3px;
  padding: 1px 4px;
  margin: 0 -4px;
  transition: background 0.1s;
}
.message-content:hover {
  background: var(--msg-hover);
}
.message-body > .message-content + .message-content {
  margin-top: 3px;
}

/* Typing bar */
#typing-bar {
  min-height: 1.4rem;
  padding: 0 1rem;
  font-size: 0.8rem;
  color: var(--subtext0);
  font-style: italic;
  flex-shrink: 0;
}

/* Message input */
#message-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--surface1);
  flex-shrink: 0;
}

#message-input { flex: 1; }

.send-btn { flex-shrink: 0; }

/* ─── Modals (shared overlay) ───────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: calc(var(--radius) * 1.5);
  padding: 1.5rem;
  width: 380px;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 { font-size: 1.05rem; font-weight: 700; }

.modal form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* ─── Settings modal ────────────────────────────── */
.settings-modal { width: 420px; }

.settings-section h3 {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--subtext0);
  margin-bottom: 0.75rem;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--surface1);
  gap: 1rem;
}
.setting-row:last-child { border-bottom: none; }

.setting-row input[type="text"] {
  width: 160px;
  flex-shrink: 0;
}

.setting-label { font-weight: 600; font-size: 0.9rem; }
.setting-desc  { font-size: 0.78rem; color: var(--subtext0); margin-top: 2px; }
.setting-label-group { display: flex; flex-direction: column; }

/* Toggle switch */
.toggle-btn {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface2);
  border: none;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}
.toggle-btn[aria-checked="true"] { background: var(--primary); }
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  pointer-events: none;
}
.toggle-btn[aria-checked="true"] .toggle-thumb { transform: translateX(20px); }

/* ─── Scrollbar ─────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--overlay0); }
