:root {
  --bg: #181c20;
  --bg-sidebar: #21272e;
  --bg-message: #232931;
  --text: #cfd8dc;
  --text-meta: #86a1ab;
  --border: #252c34;
  --accent: #79b8ff;
  --group-bg: #232931;
  --group-selected: #2d3842;
  --action-hover: #23293b;
  --pin: gold;
}

body.dark-mode {
  background: var(--bg);
  color: var(--text);
}

body {
  margin: 0;
  font-family: sans-serif;
}

.layout {
  display: flex;
  height: 100vh;
}

.groups-nav {
  width: 58px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 10px;
}

.group-icon.add-group {
    background: var(--accent);
    color: black;
    font-size: 1.8em;
    line-height: 36px;
}

.group-icon.add-group:hover {
    background: #529eff;
}

.group-icon {
  background: var(--group-bg);
  width: 38px;
  height: 38px;
  margin: 8px 0;
  border-radius: 50%;
  text-align: center;
  line-height: 38px;
  font-size: 1.6em;
  cursor: pointer;
  transition: background 0.15s;
}

.group-icon:hover {
  background: var(--group-selected);
}

.channels-nav {
  width: 150px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 10px 0;
}

@media (max-width: 768px) {
  .mobile-channels {
    display: flex;
    flex-direction: column;
    width: 100%;
  }

  .channels-nav {
    border-bottom: none;
  }
}

.channel {
  padding: 8px 20px;
  color: var(--text-meta);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.channel-actions {
  color: var(--text-meta);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  opacity: 0;
  transition: opacity 0.2s;
}

.channel:hover .channel-actions {
  opacity: 1;
}

.channel-actions:hover {
  background: var(--action-hover);
  color: var(--accent);
}

.channel-menu {
  position: fixed;
  background: var(--bg-message);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  z-index: 30;
  min-width: 150px;
}

.channel-menu-item {
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.channel-menu-item:hover {
  background: var(--action-hover);
}

.channel-menu-item.delete {
  color: #ff6b6b;
}

.channel-menu-item.delete:hover {
  background: #ff6b6b;
  color: white;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

.modal-content {
  background: var(--bg-message);
  padding: 20px;
  border-radius: 8px;
  width: 90%;
  max-width: 400px;
}

.modal h3 {
  margin-top: 0;
  color: var(--accent);
}

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  color: var(--text-meta);
}

.form-group input {
  width: 100%;
  padding: 8px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.form-actions button {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.form-actions button[type="submit"] {
  background: var(--accent);
  color: black;
}

.form-actions button[type="button"] {
  background: var(--bg-sidebar);
  color: var(--text);
}

.channel:hover {
  background: var(--group-selected);
  color: var(--accent);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.header {
  background: var(--bg-message);
  padding: 10px 16px;
  font-size: 1.2em;
  border-bottom: 1px solid var(--border);
}

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  background: var(--bg);
}

.message {
  position: relative;
  background: var(--bg-message);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 14px;
}

.message:hover {
  background: #263240;
}

.meta-line {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.action-btn {
    cursor: pointer;
    font-size: 1.1em;
    color: var(--text-meta);
    padding: 2px 6px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

@media (max-width: 768px) {
    .action-btn {
        opacity: 1;
        transition: null;
    }
}

.message:hover .action-btn {
    opacity: 1;
}

.actions-menu {
    position: absolute;
    z-index: 31;
    right: 0;
    background: var(--bg-message);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    min-width: 120px;
}

.action-item {
    padding: 8px 12px;
    cursor: pointer;
    white-space: nowrap;
}

.action-item:hover {
    background: var(--action-hover);
}

.delete-item {
    color: #ff4d4f;
}

.action-item.delete {
    color: #ff6b6b;
}

.action-item.delete:hover {
    background: #ff6b6b;
    color: white;
}

/* Mobile styles */
@media (max-width: 768px) {
    .action-btn {
        opacity: 1;
    }
}

.action-btn.edit-btn,
.action-item.edit-item {
  display: none;
}

.message.can-edit .action-btn.edit-btn,
.message.can-edit .action-item.edit-item {
  display: inline-block;
}

.edit-input {
  width: 100%;
  background: var(--bg-message);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 8px;
  font-size: 1em;
  margin: 4px 0;
}

.edit-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(121, 184, 255, 0.2);
}

.action-btn:hover {
  background: var(--action-hover);
  color: var(--accent);
}

.reactions {
  margin-top: 8px;
}

.emoji {
  background: #2f3842;
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 14px;
  margin-right: 6px;
  cursor: pointer;
  font-size: 0.95em;
}

.emoji:hover {
  background: var(--accent);
  color: var(--bg-message);
}

.pin {
  color: var(--pin);
  margin-left: 6px;
}

.footer {
  border-top: 1px solid var(--border);
  padding: 12px;
  background: var(--bg-message);
  position: sticky;
  bottom: 0;
  z-index: 10;
}

#msg-input {
  flex: 1;
  background: #1a222d;
  color: var(--text);
  border: 1px solid #2a3240;
  border-radius: 4px;
  padding: 10px;
  font-size: 1em;
  resize: none;
  min-height: 44px;
  max-height: 200px;
  overflow-y: auto;
  line-height: 1.4;
}

#msg-input:focus {
  outline: none;
  border-color: var(--accent);
}

button {
  background: var(--accent);
  border: none;
  color: black;
  padding: 10px 16px;
  margin-left: 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1em;
}
button:hover {
  background: #529eff;
}
.tooltip {
    position: absolute;
    background: #111;
    color: #eee;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    white-space: nowrap;
    z-index: 10;
}

.emoji-picker {
    position: fixed;
    background: #2a2a2a;
    color: white;
    padding: 6px 8px;
    border-radius: 6px;
    display: flex;
    gap: 6px;
    box-shadow: 0 2px 10px #0007;
    z-index: 30;
    transform: translate(-50%, -100%);
}

.emoji-picker span {
    cursor: pointer;
    font-size: 1.2em;
}

.reply-quote {
    background: #1e242c;
    padding: 6px 10px;
    border-left: 3px solid var(--accent);
    color: #9aa0a6;
    font-size: 0.88em;
    margin-bottom: 6px;
    border-radius: 4px;
}

.reply-preview-container {
    background: #1e242c;
    padding: 4px 8px;
    border-left: 3px solid var(--accent);
    border-bottom: 1px solid var(--border);
    box-sizing: border-box;
    font-size: 0.9em;
    display: flex;
    align-items: center;
}

.reply-preview-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
}

.reply-preview span {
    color: var(--accent);
    white-space: nowrap;
}

.reply-message {
    color: #9aa0a6;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reply-preview button {
    background: #2f3842;
    border: none;
    color: white;
    cursor: pointer;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    padding: 0;
    margin-left: 4px;
    flex-shrink: 0;
}

.reply-preview button:hover {
    background: #3a4552;
}

.reply-quote b,
.reply-preview .author,
.channel {
    color: var(--accent);
}

.emoji.add-btn {
    background: #1f2a33;
    color: #999;
    font-weight: bold;
}

.emoji.add-btn:hover {
    background: var(--accent);
    color: var(--bg-message);
}

.mention {
    background-color: rgba(121, 184, 255, 0.2);
    color: var(--accent);
    padding: 0 2px;
    border-radius: 3px;
    font-weight: 500;
}

.new-message-indicator {
    position: fixed;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: black;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.9em;
    z-index: 10;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.new-message-indicator a {
    color: black;
    text-decoration: underline;
    margin-left: 6px;
}

.modlog-entry {
    background: var(--bg-message);
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 4px;
    border-left: 3px solid var(--accent);
}

.modlog-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: bold;
}

.modlog-action {
    color: var(--accent);
}

.modlog-timestamp {
    color: var(--text-meta);
    font-size: 0.9em;
}

.modlog-details {
    font-size: 0.9em;
    color: var(--text-meta);
}

.modlog-details div {
    margin-bottom: 4px;
}

.modlog-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.modlog-controls select {
    background: var(--bg-sidebar);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 6px;
    border-radius: 4px;
}

.modlog-channel {
    color: #ff6b6b;
}

.flag-entry {
    background: var(--bg-message);
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 4px;
    border-left: 3px solid #ff6b6b;
}

.flag-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.flag-timestamp {
    color: var(--text-meta);
    font-size: 0.9em;
}

.flag-details {
    font-size: 0.9em;
    color: var(--text-meta);
    margin-bottom: 8px;
}

.flag-message {
    background: #1e242c;
    padding: 8px;
    border-radius: 4px;
    margin-top: 8px;
}

.flag-message-author {
    color: var(--accent);
    font-weight: bold;
}

.flag-message-text {
    margin-top: 4px;
}

.flag-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.flag-actions button {
    padding: 4px 8px;
    font-size: 0.9em;
    background: var(--bg-sidebar);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
}

.flag-actions button:hover {
    background: var(--action-hover);
}

.flags-channel {
    color: #ff6b6b;
}

.requests-channel {
    color: #ffb86c;
}

.requests-channel.has-pending::after {
    content: attr(data-count);
    display: inline-block;
    background: var(--accent);
    color: black;
    font-size: 0.7em;
    font-weight: 600;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    margin-left: 5px;
    vertical-align: middle;
}

.request-entry {
    background: var(--bg-message);
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 4px;
    border-left: 3px solid #ffb86c;
}

.request-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: bold;
}

.request-timestamp {
    color: var(--text-meta);
    font-size: 0.9em;
}

.request-status {
    color: #ffb86c;
    font-weight: bold;
}

.request-message {
    font-size: 0.9em;
    color: var(--text-meta);
    margin-bottom: 8px;
}

.request-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.request-actions button {
    padding: 4px 8px;
    font-size: 0.9em;
    background: var(--bg-sidebar);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
}

.request-actions button:hover {
    background: var(--action-hover);
}

.request-actions input {
    flex: 1;
    background: var(--bg-sidebar);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 4px 8px;
    border-radius: 4px;
}

.requests-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.flags-controls select {
    background: var(--bg-sidebar);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 6px;
    border-radius: 4px;
}

.unread-line {
    width: 100%;
    text-align: center;
    padding: 8px 0;
    margin: 10px 0;
    background: var(--accent);
    color: black;
    font-size: 0.9em;
    border-radius: 4px;
}

.meta-line {
    display: flex;
    gap: 1em;
    font-size: 0.9em;
    margin-bottom: 4px;
}

.message .author {
    color: var(--accent);
    font-weight: 600;
}

.timestamp {
    font-size: 0.85em;
    color: #828c94;
}

/* ---------- Login Form ---------- */
.login-container {
    max-width: 400px;
    margin: 50px auto;
    padding: 30px;
    background: var(--bg-message);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.login-container h1 {
    color: var(--accent);
    text-align: center;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-meta);
}

.form-group input {
    width: 100%;
    padding: 10px;
    background: #1a222d;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1em;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.error {
    color: #ff6b6b;
    margin-bottom: 20px;
    text-align: center;
}

/* ---------- Mobile View ---------- */
@media (max-width: 768px) {
    .layout {
        flex-direction: column;
    }

    .groups-nav,
    .channels-nav {
        flex-direction: column;
        width: 100%;
        overflow-x: auto;
        border: none;
    }

    .group-icon {
        margin: 0 6px;
        width: 40px;
        height: 40px;
        font-size: 1.4em;
    }

    .channel {
        padding: 10px;
        font-size: 0.95em;
        border-left: none;
    }

    .main {
        flex: 1;
        padding-top: 40px;
    }

    /* Mobile Navigation Header */
    .mobile-nav {
        position: fixed;
        top: 0;
        width: 100%;
        background: var(--bg-message);
        color: var(--text);
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 1em;
        padding: 10px 16px;
        z-index: 30;
        border-bottom: 1px solid var(--border);
    }

    .mobile-nav button {
        background: none;
        border: none;
        color: var(--accent);
        font-size: 1.4em;
        cursor: pointer;
    }

    .sidebar-mobile {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 50px;
        left: 0;
        right: 0;
        background-color: var(--bg-sidebar);
        box-shadow: 0 2px 5px rgba(0,0,0,0.25);
        z-index: 20;
        padding-bottom: 10px;
    }

    .sidebar-mobile.open {
        display: flex;
    }

    .mobile-channels {
        border-top: 1px solid var(--border);
    }

    .channels-nav .channel {
        border-left: none;
    }

    .chat {
        padding: 12px;
        overflow-y: auto;
        padding-bottom: 80px;
    }

    .emoji-picker {
        bottom: auto;
        top: -40px;
        margin-bottom: 0;
    }

    .footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 10px;
    }
}

.notification-toggle .icon {
   font-size: 1.1em;
}

.notification-toggle-mobile {
    padding: 12px 20px;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.notification-toggle-mobile:hover {
    background: var(--action-hover);
    color: var(--accent);
}

.notification-toggle-mobile .icon {
    font-size: 1.1em;
}

.notification-toggle-mobile.active .icon {
    animation: bell-ring 0.5s ease-in-out;
}

.content-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.join-group-container {
    max-width: 500px;
    margin: 50px auto;
    padding: 30px;
    background: var(--bg-message);
    border-radius: 8px;
    text-align: center;
}

.join-group-container h1 {
    color: var(--accent);
    margin-bottom: 30px;
}

.auth-prompt {
    margin: 20px 0;
    color: var(--text-meta);
}

.auth-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.auth-buttons a {
    padding: 10px 20px;
    background: var(--bg-sidebar);
    color: var(--text);
    border-radius: 4px;
    text-decoration: none;
}

.auth-buttons a:hover {
    background: var(--action-hover);
    color: var(--accent);
}

#request-join-btn {
    padding: 12px 24px;
    background: var(--accent);
    color: black;
    border: none;
    border-radius: 4px;
    font-size: 1em;
    cursor: pointer;
}

#request-join-btn:hover {
    background: #529eff;
}

@keyframes bell-ring {
   0% { transform: rotate(0deg); }
   25% { transform: rotate(15deg); }
   50% { transform: rotate(-15deg); }
   75% { transform: rotate(10deg); }
   100% { transform: rotate(0deg); }
}

.notification-toggle.active .icon {
   animation: bell-ring 0.5s ease-in-out;
}


#emoji-picker {
    position: absolute;
    display: none;
    z-index: 30;
}
