/* ═══════════════════════════════════════════════════
   Skritka – App Layout
   ═══════════════════════════════════════════════════ */

/* ─── Desktop App Titlebar (Electron only) ─── */
.desktop-titlebar {
  display: none; /* hidden on web */
}

body.is-desktop .desktop-titlebar {
  display: flex;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  z-index: 99999;
  background: #1a1a2e;
  user-select: none;
}

/* Invisible overlay that makes the whole bar draggable */
.titlebar-drag-region {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  -webkit-app-region: drag;
  app-region: drag;
}

/* App icon + name (left side) */
.titlebar-appname {
  display: flex;
  align-items: center;
  gap: 7px;
  padding-left: 12px;
  font-size: 12px;
  font-weight: 600;
  color: #b5bac1;
  pointer-events: none;
  position: relative;
  z-index: 1;
}
.titlebar-icon { flex-shrink: 0; }

/* Window control buttons (right side) */
.titlebar-controls {
  display: flex;
  margin-left: auto;
  height: 100%;
  position: relative;
  z-index: 1;
  -webkit-app-region: no-drag;
  app-region: no-drag;
}
.titlebar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 100%;
  border: none;
  background: transparent;
  color: #b5bac1;
  cursor: pointer;
  padding: 0;
  transition: background 0.1s;
}
.titlebar-btn:hover {
  background: rgba(255,255,255,0.08);
}
.titlebar-btn:active {
  background: rgba(255,255,255,0.04);
}
.titlebar-close:hover {
  background: #e04040;
  color: #fff;
}
.titlebar-close:active {
  background: #c43030;
  color: #fff;
}

/* Push all content down so titlebar doesn't cover it */
body.is-desktop .auth-screen {
  padding-top: 32px;
}

body.is-desktop .app-layout {
  margin-top: 32px;
  height: calc(100vh - 32px);
  height: calc(100dvh - 32px);
}

.app-layout {
  display: flex;
  height: 100vh;
  height: 100dvh; /* dynamic viewport height for mobile browsers */
}

/* ─── Server Bar (leftmost icon rail) ─── */

.server-bar {
  width: var(--server-bar-width);
  background: var(--bg-darkest);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 8px;
  overflow-y: auto;
  flex-shrink: 0;
}

.server-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-radius var(--transition), background var(--transition), box-shadow var(--transition);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  flex-shrink: 0;
}

.server-icon:hover,
.server-icon.active {
  border-radius: 16px;
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(16,185,129,0.2);
}

.server-icon.home-icon {
  background: var(--accent);
}

.server-icon.home-icon .material-symbols-outlined {
  font-size: 24px;
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.server-icon.add-server {
  background: transparent;
  border: 2px dashed var(--bg-lighter);
  color: var(--green);
  font-size: 24px;
  margin-top: 4px;
}

.server-icon.add-server:hover {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
  box-shadow: 0 2px 8px rgba(52,211,153,0.2);
}

.server-separator {
  width: 32px;
  height: 2px;
  background: var(--bg-light);
  border-radius: 1px;
  margin: 4px 0;
}

.server-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* ─── DM Notification Pills (in server bar) ─── */

.dm-notif-pills {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.dm-notif-pills:empty {
  display: none;
}

.dm-notif-pill {
  position: relative;
  cursor: pointer;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  transition: border-radius var(--transition);
}

.dm-notif-pill:hover {
  border-radius: 16px;
}

.dm-notif-pill-avatar {
  width: 48px;
  height: 48px;
  border-radius: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: #fff;
  overflow: hidden;
  transition: border-radius var(--transition);
}

.dm-notif-pill-avatar .avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dm-notif-pill-badge {
  position: absolute;
  bottom: -3px;
  right: -3px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 0 0 3px var(--bg-darkest);
  pointer-events: none;
}

/* ─── Channel Sidebar ─── */

.channel-sidebar {
  width: var(--channel-sidebar-width);
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.channel-header {
  padding: 12px 16px;
  height: 48px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(0,0,0,0.3);
  box-shadow: var(--shadow-sm);
}

.channel-header h3 {
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.channel-category {
  padding: 16px 4px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.channel-item {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 15px;
  gap: 6px;
  transition: background var(--transition), color var(--transition);
}

.channel-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.channel-item.active {
  background: var(--bg-active);
  color: var(--text-primary);
}

.channel-item .channel-hash {
  color: var(--text-muted);
  font-size: 18px;
  font-weight: 600;
  width: 20px;
  text-align: center;
}

/* ─── DM Items ─── */

.dm-item {
  display: flex;
  align-items: center;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  gap: 10px;
  transition: background var(--transition), color var(--transition);
  position: relative;
}

.dm-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.dm-item.active {
  background: var(--bg-active);
  color: var(--text-primary);
}

.dm-close-btn {
  display: none;
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px;
  border-radius: var(--radius-sm);
  line-height: 1;
  font-size: 0;
  z-index: 1;
}

.dm-close-btn .material-symbols-outlined {
  font-size: 18px;
}

.dm-close-btn:hover {
  color: var(--text-primary);
}

.dm-item:hover .dm-close-btn {
  display: block;
}

.dm-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}

.dm-status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 3px solid var(--bg-dark);
}

.dm-status-dot.online  { background: var(--green); }
.dm-status-dot.offline { background: var(--text-muted); }
.dm-status-dot.away,
.dm-status-dot.idle    { background: var(--yellow); }
.dm-status-dot.busy    { background: var(--red); }
.dm-status-dot.invisible { background: var(--text-muted); }

/* ─── DM Message Request Badge ─── */

.dm-request-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--yellow, #faa61a);
  color: #000;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: auto;
  flex-shrink: 0;
  line-height: 16px;
}

.dm-item.dm-request {
  border-left: 2px solid var(--yellow, #faa61a);
}

/* ─── DM Request Accept/Deny Bar ─── */

.dm-request-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid rgba(255,255,255,0.06);
  gap: 12px;
  flex-shrink: 0;
}

.dm-request-bar-info {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  font-size: 14px;
  min-width: 0;
}

.dm-request-bar-info .material-symbols-outlined {
  font-size: 24px;
  color: var(--yellow, #faa61a);
  flex-shrink: 0;
}

.dm-request-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.dm-request-bar-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.dm-request-btn {
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition);
}

.dm-request-btn:hover {
  opacity: 0.85;
}

.dm-request-btn.accept {
  background: var(--green, #3ba55d);
  color: #fff;
}

.dm-request-btn.deny {
  background: var(--red, #ed4245);
  color: #fff;
}

/* ─── User Panel ─── */

.user-panel {
  padding: 8px;
  background: rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(0,0,0,0.15);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  margin: -2px -4px;
  flex: 1;
  min-width: 0;
  transition: background var(--transition);
}

.user-info:hover {
  background: var(--bg-hover);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}

.user-status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2.5px solid var(--bg-dark);
  background: var(--text-muted);
}

.user-status-dot.online  { background: var(--green); }
.user-status-dot.away,
.user-status-dot.idle    { background: var(--yellow); }
.user-status-dot.busy    { background: var(--red); }
.user-status-dot.invisible,
.user-status-dot.offline { background: var(--text-muted); }

.user-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-tag {
  font-size: 11px;
  color: var(--text-muted);
}

.user-panel-btns {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

/* ─── Icon Button ─── */

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  transition: background var(--transition), color var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn .material-symbols-outlined {
  font-size: 20px;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
