/* --- Theme Variables --- */
:root {
  --bg-main: #36393f;
  --bg-sidebar: #2f3136;
  --bg-hover: #393c43;
  --bg-msg-hover: #32353b;
  --bg-input: #40444b;
  --text-main: #dcddde;
  --text-bright: #ffffff;
  --text-muted: #72767d;
  --border: #202225;
  --overlay: rgba(0,0,0,0.6);
}

body.light-theme {
  --bg-main: #ffffff;
  --bg-sidebar: #f2f3f5;
  --bg-hover: #e3e5e8;
  --bg-msg-hover: #f8f9f9;
  --bg-input: #ebedef;
  --text-main: #2e3338;
  --text-bright: #060607;
  --text-muted: #4f5660;
  --border: #e3e5e8;
  --overlay: rgba(255,255,255,0.6);
}

/* --- Base & Decoy --- */
* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }

/* FIX: Using 100dvh dynamically calculates the height to prevent mobile browser bars from hiding the bottom */
html, body { height: 100%; height: 100dvh; width: 100%; overflow: hidden; }
body { background-color: #f4f4f4; display: flex; justify-content: center; align-items: center; transition: background-color 0.2s; }

#decoy-screen { background: white; padding: 40px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); max-width: 400px; text-align: center; width: 90%; }
#decoy-screen h2 { font-family: "Georgia", serif; margin-bottom: 10px; color: black; }
#decoy-screen p { color: #555; margin-bottom: 20px; font-size: 14px; }
#decoy-screen input { width: 100%; padding: 10px; margin-bottom: 15px; border: 1px solid #ccc; border-radius: 4px; }
#decoy-screen button { width: 100%; padding: 10px; background: #000; color: #fff; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; }

/* --- Chat App --- */
/* FIX: Using 100% height instead of 100vh so it respects the body's dynamic boundaries */
#chat-app { width: 100%; height: 100%; background: var(--bg-main); color: var(--text-main); font-family: 'JetBrains Mono', monospace; position: relative; }
#chat-app input, #chat-app button { font-family: 'JetBrains Mono', monospace; }

.sidebar { width: 250px; background: var(--bg-sidebar); display: flex; flex-direction: column; padding: 20px 0; z-index: 10; border-right: 1px solid var(--border); }
.sidebar-header { display: flex; justify-content: space-between; align-items: center; padding: 0 20px 20px; border-bottom: 1px solid var(--border); margin-bottom: 10px;}
.brand { color: var(--text-bright); }
.icon-btn { background: none; border: none; color: var(--text-main); font-size: 20px; cursor: pointer; display: flex; align-items: center; padding: 4px; }
.icon-btn:hover { color: var(--text-bright); }

#channel-list { list-style: none; flex-grow: 1; overflow-y: auto; }
.channel-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 20px; cursor: pointer; opacity: 0.7; color: var(--text-main); }
.channel-item:hover, .channel-item.active { opacity: 1; background: var(--bg-hover); color: var(--text-bright); }
.delete-channel-btn { background: none; border: none; color: #ed4245; cursor: pointer; font-size: 14px; display: none; font-weight: bold; }
.channel-item:hover .delete-channel-btn { display: block; }

.export-btn { margin: 20px; padding: 10px; background: #5865F2; color: white; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; }

.main-chat { flex-grow: 1; display: flex; flex-direction: column; width: calc(100% - 250px); height: 100%; }
.chat-header { display: flex; align-items: center; justify-content: space-between; padding: 20px; font-weight: bold; color: var(--text-bright); border-bottom: 1px solid var(--border); }
#mobile-menu-btn { display: none; margin-right: 15px; font-size: 24px; }
.message-list { flex-grow: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; }

.message { display: flex; flex-direction: column; padding: 2px 10px; border-radius: 4px; transition: background 0.2s; color: var(--text-main); }
.message.new-group { margin-top: 15px; padding-top: 5px; }
.message:hover { background: var(--bg-msg-hover); }
.message-header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.message .author { font-weight: bold; color: var(--text-bright); font-size: 14px; }
.message .timestamp { font-size: 11px; color: var(--text-muted); }
.message .text { font-size: 14px; word-wrap: break-word; color: var(--text-main); }

.message-input-container { padding: 20px; background: var(--bg-main); display: flex; gap: 10px; }
#message-input { flex-grow: 1; padding: 12px; border-radius: 8px; border: none; background: var(--bg-input); color: var(--text-main); outline: none; }
#send-btn { padding: 0 20px; background: #5865F2; color: white; border: none; border-radius: 8px; cursor: pointer; font-weight: bold; }
#mobile-overlay { display: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: var(--overlay); z-index: 5; }

/* --- Mobile Responsive Layout --- */
@media (max-width: 768px) {
  .main-chat { width: 100%; }
  #mobile-menu-btn { display: block; }
  .channel-item .delete-channel-btn { display: block; }
  .sidebar { position: absolute; left: -250px; height: 100%; transition: left 0.3s ease; }
  .sidebar.open { left: 0; }
  #mobile-overlay.active { display: block; }
}
