/* ============================================================
   REAPER INC. UPGRADE — LAYOUT CSS
   Discord-inspired 3-panel shell
   ============================================================ */

/* ── SHELL STRUCTURE ──────────────────────────────────────── */
:root {
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 60px;
  --right-panel-width: 260px;
  --topbar-height: 52px;
  --userbar-height: 56px;
}

body {
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

#grain {
  position: fixed; inset: 0; z-index: 9998;
  pointer-events: none; opacity: 0.025;
  background-image: url('data:image/svg+xml,%3Csvg viewBox=%220 0 200 200%22 xmlns=%22http://www.w3.org/2000/svg%22%3E%3Cfilter id=%22n%22%3E%3CfeTurbulence type=%22fractalNoise%22 baseFrequency=%220.85%22 numOctaves=%224%22 stitchTiles=%22stitch%22/%3E%3C/filter%3E%3Crect width=%22100%25%22 height=%22100%25%22 filter=%22url(%23n)%22/%3E%3C/svg%3E');
}

#app-shell {
  display: flex;
  flex: 1;
  height: calc(100vh - var(--userbar-height) - 28px);
  overflow: hidden;
  position: relative;
}

/* ── ANTHEM PLAYER ────────────────────────────────────────── */
#anthem-player {
  display: flex; align-items: center; gap: 10px;
  width: calc(var(--right-panel-width) + var(--sidebar-width));
  min-width: calc(var(--right-panel-width) + var(--sidebar-width));
  max-width: calc(var(--right-panel-width) + var(--sidebar-width));
  padding-left: 14px;
  border-left: 1px solid rgba(139,0,0,.15);
  margin-left: auto;
  overflow: hidden;
}
#anthem-player.hidden-player { display: none; }
#anthem-left { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
#anthem-play-btn {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(139,0,0,.25); border: 1px solid rgba(139,0,0,.4);
  color: #cc0000; font-size: 9px; cursor: pointer; transition: all .15s;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
#anthem-play-btn:hover { background: rgba(139,0,0,.45); color: #d4c9a8; }
#anthem-info { min-width: 0; overflow: hidden; }
#anthem-title {
  font-family: 'Cinzel', serif; font-size: 10px; color: #d4c9a8;
  letter-spacing: .5px; white-space: nowrap; max-width: 120px;
  overflow: hidden; display: block;
}
#anthem-title.scrolling { animation: anthemScroll 10s linear infinite; }
@keyframes anthemScroll {
  0%   { transform: translateX(100%); }
  100% { transform: translateX(-100%); }
}
#anthem-sub { font-family: 'Orbitron', monospace; font-size: 7px; color: #8b0000; letter-spacing: 2px; text-transform: uppercase; }
#anthem-center { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
#anthem-progress-wrap { height: 3px; background: #1a1a1a; border-radius: 2px; cursor: pointer; position: relative; }
#anthem-progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, #8b0000, #cc0000); border-radius: 2px; transition: width .1s linear; pointer-events: none; }
#anthem-time { font-family: 'Orbitron', monospace; font-size: 7px; color: #444; letter-spacing: 1px; text-align: right; }
#anthem-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
#anthem-mute-btn, #anthem-repeat-btn { background: none; border: none; color: #555; font-size: 13px; cursor: pointer; transition: color .15s; padding: 2px; }
#anthem-mute-btn:hover, #anthem-repeat-btn:hover { color: #d4c9a8; }
#anthem-vol { width: 60px; height: 3px; accent-color: #8b0000; cursor: pointer; }
#anthem-close-btn { background: none; border: none; color: #333; font-size: 10px; cursor: pointer; transition: color .15s; padding: 2px 4px; }
#anthem-close-btn:hover { color: #cc0000; }
#user-bar { bottom: 0; }

/* ── MARQUEE BAR ──────────────────────────────────────────── */
#marquee-bar {
  height: 28px; background: #080808;
  border-bottom: 1px solid rgba(139,0,0,.15);
  overflow: hidden; position: relative; z-index: 200; flex-shrink: 0;
}
#marquee-track {
  display: inline-flex; align-items: center; white-space: nowrap;
  animation: marqueeScroll 120s linear infinite; height: 100%; padding-left: 100%;
}
#marquee-track:hover { animation-play-state: paused; }
.marquee-item { display: inline-flex; align-items: center; gap: 6px; padding: 0 20px; }
.marquee-icon { font-size: 11px; }
.marquee-text { font-family: 'Rajdhani', sans-serif; font-size: 11px; letter-spacing: 1.5px; color: #8a7d5e; text-transform: uppercase; }
.marquee-sep { color: rgba(139,0,0,.3); font-size: 9px; padding: 0 6px; }
@keyframes marqueeScroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ── NOTIFICATION PANEL ───────────────────────────────────── */
@keyframes notifPanelIn {
  from { opacity:0; transform:translateY(-8px); }
  to   { opacity:1; transform:translateY(0); }
}
#topbar-notif-btn.active { border-color:rgba(139,0,0,.5) !important; color:#cc0000 !important; }

/* ── LEFT SIDEBAR ─────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width); min-width: var(--sidebar-width);
  height: 100%; background: #050505;
  border-right: 1px solid rgba(140,144,153,.12);
  display: flex; flex-direction: column;
  overflow: hidden; transition: width .25s ease, min-width .25s ease;
  position: relative; z-index: 100; flex-shrink: 0;
}
#sidebar.collapsed { width: var(--sidebar-collapsed-width); min-width: var(--sidebar-collapsed-width); }
#sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 14px; border-bottom: 1px solid rgba(139,0,0,.15);
  cursor: pointer; flex-shrink: 0; transition: background .2s;
  min-height: var(--topbar-height);
}
#sidebar-logo:hover { background: rgba(139,0,0,.06); }
#sidebar-logo-img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; border: 1px solid rgba(139,0,0,.5); flex-shrink: 0; }
#sidebar-logo-text { overflow: hidden; transition: opacity .2s, width .2s; white-space: nowrap; }
.logo-name { font-family: 'Cinzel Decorative', serif; font-size: 11px; color: #d4c9a8; letter-spacing: 1.5px; line-height: 1.3; }
.logo-sub { font-family: 'Orbitron', monospace; font-size: 7px; color: #8b0000; letter-spacing: 3px; }
#sidebar.collapsed #sidebar-logo-text { opacity: 0; width: 0; }
#sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 0; scrollbar-width: none; }
#sidebar-nav::-webkit-scrollbar { display: none; }
.nav-section-label {
  font-family: 'Orbitron', monospace; font-size: 9px; letter-spacing: 3px;
  color: #555; text-transform: uppercase; padding: 6px 16px 4px;
  white-space: nowrap; overflow: hidden; transition: opacity .2s;
}
#sidebar.collapsed .nav-section-label { opacity: 0; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; background: none; border: none; padding: 9px 14px;
  font-family: 'Cinzel', serif; font-size: 11px; letter-spacing: 1px;
  color: #555; text-transform: uppercase; cursor: pointer; white-space: nowrap;
  transition: color .15s, background .15s; text-align: left; border-left: 2px solid transparent;
}
.nav-item:hover { color: #8c9099; background: rgba(140,144,153,.04); }
.nav-item.active { color: #c4c8d0; border-left-color: #8b0000; background: rgba(139,0,0,.08); }
.nav-icon { font-size: 15px; flex-shrink: 0; width: 20px; text-align: center; }
.nav-label { overflow: hidden; transition: opacity .2s, width .2s; }
#sidebar.collapsed .nav-label { opacity: 0; width: 0; }
#sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
#sidebar-collapse-btn {
  position: absolute; bottom: 16px; right: 0; width: 20px; height: 40px;
  background: rgba(139,0,0,.15); border: 1px solid rgba(139,0,0,.2); border-right: none;
  color: #8b0000; cursor: pointer; font-size: 14px; transition: all .2s;
  display: flex; align-items: center; justify-content: center; border-radius: 4px 0 0 4px;
}
#sidebar-collapse-btn:hover { background: rgba(139,0,0,.3); color: #cc0000; }

/* ── CENTER COLUMN ────────────────────────────────────────── */
#center-column { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
#topbar {
  height: var(--topbar-height); min-height: var(--topbar-height);
  background: rgba(0,0,0,.98); border-bottom: 1px solid rgba(140,144,153,.15);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; gap: 12px; flex-shrink: 0;
  position: relative; z-index: 50; backdrop-filter: blur(8px);
}
#topbar-left { display: flex; align-items: center; gap: 12px; }
#topbar-right { display: flex; align-items: center; gap: 8px; }
#mobile-menu-btn {
  display: none; background: none; border: 1px solid rgba(139,0,0,.3);
  color: #8a7d5e; font-size: 16px; padding: 4px 9px;
  cursor: pointer; transition: all .2s; border-radius: 2px;
}
#mobile-menu-btn:hover { border-color: #cc0000; color: #d4c9a8; }
#topbar-page-name { display: flex; align-items: center; gap: 8px; }
#topbar-icon { font-size: 16px; }
#topbar-title { font-family: 'Cinzel', serif; font-size: 13px; letter-spacing: 2px; color: #d4c9a8; text-transform: uppercase; }
#topbar-right-toggle { background: none; border: 1px solid #222; color: #555; font-size: 16px; padding: 4px 8px; cursor: pointer; transition: all .2s; border-radius: 2px; }
#topbar-right-toggle:hover { border-color: rgba(139,0,0,.3); color: #8a7d5e; }
#topbar-right-toggle.active { border-color: rgba(139,0,0,.4); color: #cc0000; }
#topbar-notif-btn { background: none; border: 1px solid #1a1a1a; color: #555; font-size: 14px; padding: 4px 9px; cursor: pointer; transition: all .2s; border-radius: 2px; position: relative; }
#topbar-notif-btn:hover { border-color: rgba(139,0,0,.3); color: #cc0000; }
.notif-badge { position: absolute; top: -4px; right: -4px; background: #8b0000; color: #fff; font-family: 'Orbitron', monospace; font-size: 8px; padding: 1px 4px; border-radius: 8px; min-width: 16px; text-align: center; line-height: 1.4; }
#main-content {
  flex: 1; overflow-y: auto; overflow-x: hidden; background: #020202;
  position: relative; transition: opacity .18s ease, transform .18s ease;
  scrollbar-width: thin; scrollbar-color: #8b0000 #000;
}
#main-content::-webkit-scrollbar { width: 5px; }
#main-content::-webkit-scrollbar-track { background: #0a0a0a; }
#main-content::-webkit-scrollbar-thumb { background: #8b0000; border-radius: 3px; }

/* ── RIGHT PANEL ──────────────────────────────────────────── */
#right-panel {
  width: var(--right-panel-width); min-width: var(--right-panel-width);
  height: 100%; background: #050505;
  border-left: 1px solid rgba(140,144,153,.12);
  overflow: hidden; flex-shrink: 0;
  display: flex; flex-direction: column;
}
#right-panel-inner {
  width: 100%; flex: 1 1 0; min-height: 0; max-height: 100%;
  overflow-y: auto; overflow-x: hidden; padding: 12px 0 40px; scrollbar-width: none;
}
#right-panel-inner::-webkit-scrollbar { display: none; }

/* ── MORTICIA FIXED ZONE ──────────────────────────────────── */
#rp-morticia { flex-shrink: 0; flex-basis: auto; position: relative; border-top: 1px solid rgba(140,144,153,.2); cursor: pointer; overflow: hidden; }
#rp-morticia:hover #rp-morticia-av img { filter: brightness(0.95) contrast(1.15) saturate(0.9); }
#rp-morticia-av { width: 100%; height: 160px; position: relative; overflow: hidden; background: #020f0e; }
#rp-morticia-av img { width: 100%; height: 320px; object-fit: cover; object-position: center 30%; display: block; filter: brightness(0.75) contrast(1.1) saturate(0.85); transition: filter 0.3s ease; }
#rp-morticia-av::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg,transparent 0%,transparent 40%,rgba(2,10,10,0.6) 70%,rgba(8,8,8,0.98) 100%); pointer-events: none; }
#rp-morticia-av canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
#rp-morticia-label { position: absolute; bottom: 0; left: 0; right: 0; padding: 6px 12px 8px; display: flex; flex-direction: column; gap: 2px; pointer-events: none; }
#rp-morticia-status { width: 6px; height: 6px; border-radius: 50%; background: #2abaaa; box-shadow: 0 0 6px #2abaaa; display: inline-block; margin-bottom: 2px; animation: mStatusPulse 3s ease-in-out infinite; }
#rp-morticia-name { font-family: 'Cinzel Decorative', serif; font-size: 11px; color: #d4c9a8; letter-spacing: 1.5px; display: block; }
#rp-morticia-title { font-family: 'Orbitron', monospace; font-size: 7px; color: #2abaaa; letter-spacing: 2px; text-transform: uppercase; display: block; }
.rp-section { padding: 16px 14px; }
.rp-section-label { font-family: 'Orbitron', monospace; font-size: 9px; letter-spacing: 3px; color: #555; text-transform: uppercase; margin-bottom: 12px; }
.rp-divider { height: 1px; background: rgba(139,0,0,.12); margin: 4px 0; }
.rp-loading { font-family: 'Rajdhani', sans-serif; font-size: 11px; letter-spacing: 2px; color: #1a1a1a; text-transform: uppercase; padding: 8px 0; }
.rp-stat-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid #0d0d0d; }
.rp-stat-row:last-child { border-bottom: none; }
.rp-stat-label { font-family: 'Cinzel', serif; font-size: 10px; letter-spacing: 1px; color: #777; text-transform: uppercase; }
.rp-stat-val { font-family: 'Orbitron', monospace; font-size: 11px; color: #cc0000; font-weight: 700; }

/* ── BOTTOM USER BAR ──────────────────────────────────────── */
#user-bar {
  height: var(--userbar-height); background: #030303;
  border-top: 1px solid rgba(140,144,153,.12);
  display: flex; align-items: center; padding: 0 14px;
  flex-shrink: 0; position: relative; z-index: 200; gap: 0;
}
#user-bar-inner {
  display: flex; align-items: center; gap: 10px;
  width: var(--sidebar-width); min-width: var(--sidebar-width);
  transition: width .25s, min-width .25s;
}
#user-bar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #1a1a1a; border: 1px solid rgba(139,0,0,.3);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cinzel', serif; font-size: 12px; color: #8b0000;
  cursor: pointer; flex-shrink: 0; overflow: hidden; transition: border-color .2s;
}
#user-bar-avatar:hover { border-color: #cc0000; }
#user-bar-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
#user-bar-info { flex: 1; min-width: 0; cursor: pointer; overflow: hidden; }
#user-bar-name { font-family: 'Cinzel', serif; font-size: 11px; color: #d4c9a8; letter-spacing: .5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#user-bar-rank { font-family: 'Orbitron', monospace; font-size: 8px; color: #8b0000; letter-spacing: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#user-bar-actions { display: flex; gap: 4px; flex-shrink: 0; }
#user-bar-actions button { background: none; border: 1px solid #222; color: #555; font-size: 14px; padding: 4px 8px; cursor: pointer; transition: all .2s; border-radius: 2px; }
#user-bar-actions button:hover { border-color: rgba(139,0,0,.3); color: #cc0000; }

/* ── SIDEBAR OVERLAY (mobile) ─────────────────────────────── */
#sidebar-overlay { display: none; position: fixed; inset: 0; z-index: 99; background: rgba(0,0,0,.7); backdrop-filter: blur(2px); pointer-events: none; }
#sidebar-overlay.visible { display: block; pointer-events: all; }

/* ── MOBILE RESPONSIVE ────────────────────────────────────── */
@media (max-width: 900px) {
  #marquee-bar { display: none; }
  #app-shell { height: calc(100vh - var(--userbar-height)); }

  /* Sidebar slides in from left on mobile */
  #sidebar {
    position: fixed; top: 0; left: 0;
    height: calc(100vh - var(--userbar-height));
    z-index: 9000;
    transform: translateX(-100%);
    transition: transform .25s ease;
    width: var(--sidebar-width) !important;
    min-width: var(--sidebar-width) !important;
  }
  #sidebar.mobile-open { transform: translateX(0); }
  #sidebar-overlay.visible { display: block; z-index: 8999; }
  #sidebar-collapse-btn { display: none; }
  #mobile-menu-btn { display: flex !important; align-items: center; }
  #right-panel { display: none !important; }
  #user-bar-inner { width: 100%; min-width: unset; }
  #anthem-player { display: none; }

  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }
  .page-content, .page-content-full, .page-content-narrow { padding: 16px; }
  .card { padding: 16px !important; }

  .notification {
    left: 12px !important; right: 12px !important;
    bottom: 16px !important; width: auto !important; max-width: none !important;
  }
  #koia-launcher { bottom: 16px !important; right: 16px !important; }
}

/* ── PAGE CONTENT PADDING ─────────────────────────────────── */
.page-content { padding: 32px; max-width: 1100px; margin: 0 auto; }
.page-content-full { padding: 32px; }
.page-content-narrow { padding: 32px; max-width: 760px; margin: 0 auto; }

/* ── CHANNEL FEED (Dispatches) ────────────────────────────── */
.channel-feed { display: flex; flex-direction: column; }
.channel-message { display: flex; gap: 14px; padding: 10px 20px; border-bottom: 1px solid #0d0d0d; transition: background .15s; }
.channel-message:hover { background: rgba(139,0,0,.03); }
.channel-message.pinned { border-left: 2px solid #cc0000; background: rgba(139,0,0,.04); }
.channel-msg-avatar { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; margin-top: 2px; }
.channel-msg-body { flex: 1; min-width: 0; }
.channel-msg-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.channel-msg-author { font-family: 'Cinzel', serif; font-size: 13px; color: #d4c9a8; }
.channel-msg-date { font-family: 'Orbitron', monospace; font-size: 9px; color: #555; letter-spacing: 1px; }
.channel-msg-title { font-family: 'Cinzel', serif; font-size: 15px; color: #c4b898; margin-bottom: 6px; line-height: 1.4; }
.channel-msg-text { font-family: 'Rajdhani', sans-serif; font-size: 15px; color: #666; line-height: 1.7; }
.channel-msg-pin-badge { font-family: 'Orbitron', monospace; font-size: 8px; color: #c9a84c; letter-spacing: 1px; border: 1px solid rgba(201,168,76,.3); padding: 2px 6px; }
