/* Connections web — IRC terminal aesthetic, matching the iOS palette */

:root {
  --bg:           #060810;
  --sidebar-bg:   #080C18;
  --userlist-bg:  #0D1220;
  --input-bg:     #0F1524;
  --selected:     #1A2540;
  --border:       #1E2D4A;
  --timestamp:    #445577;
  --system:       #7A8BA8;
  --text:         #D8DDE8;
  --section:      #334466;
  --titlebar:     #0E1830;
  --titletext:    #A0B4CC;
  --connected:    #2ECC71;
  --blue:         #60AAFF;
  --activename:   #A0C8FF;
  --dimname:      #7A96B8;
  --gold:         #C8A050;
  --purple:       #B080E0;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  font-size: 13px;
}

.hidden { display: none !important; }
.spacer { flex: 1; }

button {
  background: none;
  border: none;
  color: var(--blue);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
button:hover { filter: brightness(1.3); }

input {
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 4px;
  outline: none;
}
input:focus { border-color: var(--blue); }

/* ============ Auth ============ */
#auth-screen {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-box {
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.auth-logo {
  color: var(--connected);
  text-align: center;
  margin-bottom: 14px;
  font-size: 13px;
}
.auth-tabs { display: flex; gap: 6px; }
.auth-tab {
  flex: 1;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--dimname);
}
.auth-tab.active { background: var(--selected); color: var(--activename); }
#auth-form { display: flex; flex-direction: column; gap: 8px; }
#auth-submit {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--selected);
  color: var(--blue);
  font-weight: bold;
}
#auth-error { color: #FF6060; font-size: 11px; min-height: 14px; }
#auth-info { color: var(--connected); font-size: 11px; }

/* ============ Layout ============ */
#app-screen {
  display: flex;
  height: 100%;
}

#sidebar {
  width: 200px;
  min-width: 200px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

#chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#members-panel {
  width: 170px;
  min-width: 170px;
  background: var(--userlist-bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

/* ============ Panels ============ */
.panel-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--titlebar);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}
.panel-title {
  font-weight: bold;
  font-size: 11px;
  color: var(--titletext);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.panel-footer {
  margin-top: auto;
  padding: 7px 10px;
  background: var(--titlebar);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--timestamp);
  position: sticky;
  bottom: 0;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: red; flex: none; }
.dot.on { background: var(--connected); }

.section-header {
  display: flex;
  align-items: center;
  padding: 12px 10px 4px;
  font-size: 9px;
  font-weight: bold;
  color: var(--section);
  letter-spacing: 1px;
}

/* ============ Channel rows ============ */
.channel-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  cursor: pointer;
  color: var(--dimname);
  font-size: 12px;
  white-space: nowrap;
}
.channel-row:hover { background: rgba(26, 37, 64, .5); }
.channel-row.active { background: var(--selected); color: var(--activename); font-weight: bold; }
.channel-row.unread { color: white; }
.channel-row .icon { width: 12px; text-align: center; flex: none; font-size: 10px; }
.channel-row .icon.lock { color: var(--gold); }
.channel-row .icon.dm { color: var(--purple); font-weight: bold; }
.channel-row .name { overflow: hidden; text-overflow: ellipsis; }
.channel-row .badge {
  background: red;
  color: white;
  font-size: 9px;
  font-weight: bold;
  border-radius: 8px;
  padding: 1px 6px;
  margin-left: auto;
}
.channel-row .muted-icon { margin-left: auto; color: var(--timestamp); font-size: 10px; }
.channel-row .badge + .muted-icon, .channel-row .muted-icon + .badge { margin-left: 4px; }

/* ============ Friends ============ */
.friend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.friend-row:hover { background: rgba(26, 37, 64, .5); }
.friend-row .status { width: 6px; height: 6px; border-radius: 50%; background: var(--timestamp); flex: none; }
.friend-row .status.on { background: var(--connected); }
.friend-row .pend { color: var(--timestamp); font-size: 9px; margin-left: auto; }
.friend-row .req-btn { font-size: 13px; padding: 0 2px; }
.friend-row .req-btn.accept { color: var(--connected); }
.friend-row .req-btn.decline { color: #FF6060; }
.friend-row .q { color: var(--gold); }
.friends-empty { padding: 4px 10px; font-size: 10px; color: var(--timestamp); }

/* ============ Topic bar ============ */
#topic-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: #0A1020;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: #7A9BBF;
}
#topic-bar .hash { color: var(--timestamp); font-weight: bold; }
#topic-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#btn-mute.muted { filter: grayscale(1) brightness(.6); }
#btn-members { display: none; }

/* ============ Messages ============ */
#message-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}
.msg {
  padding: 1px 0;
  line-height: 1.45;
  word-wrap: break-word;
  cursor: pointer;
}
.msg:hover { background: rgba(26, 37, 64, .35); }
.msg .ts { color: var(--timestamp); font-size: 11px; }
.msg .brak { color: var(--timestamp); font-weight: bold; }
.msg .nick { font-weight: bold; }
.msg .body { color: var(--text); }
.msg.system { color: var(--system); font-style: italic; font-size: 12px; cursor: default; }
.msg.system:hover { background: none; }
.msg.action { font-style: italic; }
.msg.reply { margin-left: 18px; border-left: 2px solid #2A4A70; padding-left: 8px; }

.thread-toggle {
  color: var(--blue);
  font-size: 11px;
  font-weight: 600;
  margin-left: 18px;
  padding: 1px 0;
  cursor: pointer;
  user-select: none;
}
.thread-toggle:hover { text-decoration: underline; }

/* ============ Reply strip & input ============ */
#reply-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: #0A1224;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--system);
}
.reply-arrow { color: var(--blue); font-weight: bold; }
#reply-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#input-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  background: var(--input-bg);
  border-top: 1px solid var(--border);
}
#input-bar .prompt { color: #3A6090; font-weight: bold; }
#message-input {
  flex: 1;
  background: none;
  border: none;
  padding: 4px;
}
#input-bar button {
  border: 1px solid #2A4A70;
  background: #0D1A30;
  border-radius: 4px;
  padding: 5px 12px;
  font-weight: 600;
}

/* ============ Members ============ */
#member-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.member-section {
  padding: 8px 8px 2px;
  font-size: 9px;
  font-weight: bold;
  letter-spacing: 1px;
  color: var(--section);
}
.member-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  font-size: 12px;
}
.member-row .status { width: 6px; height: 6px; border-radius: 50%; background: var(--timestamp); flex: none; }
.member-row .status.on { background: var(--connected); }
.member-row.offline { color: var(--timestamp); }

/* ============ Modal ============ */
#modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
#modal {
  width: 340px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#modal h3 {
  font-size: 12px;
  color: var(--titletext);
  letter-spacing: 1px;
}
#modal .modal-row { display: flex; gap: 8px; align-items: center; }
#modal .modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
#modal .modal-actions button {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 12px;
}
#modal .primary { background: var(--selected); }
#modal label { font-size: 11px; color: var(--dimname); display: flex; align-items: center; gap: 6px; }
#modal input[type="text"] { width: 100%; }
#modal .invite-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(30, 45, 74, .4);
}
#modal .invite-row button {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 11px;
}
#modal .note { font-size: 11px; color: var(--timestamp); }

/* ============ Responsive ============ */
@media (max-width: 800px) {
  #members-panel { display: none; }
  #members-panel.open {
    display: flex;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 5;
    box-shadow: -4px 0 20px rgba(0, 0, 0, .5);
  }
  #btn-members { display: block; }
}
@media (max-width: 600px) {
  #sidebar { width: 150px; min-width: 150px; }
}
