/* Variables */
/* Variables */
:root {
    --background: #f4f3ff;
    --border: #d1d1e6;
    --chat-bg: #ffffff;
    --hover-bg: #e2e1ff;
    --input-bg: #f9f9ff;
    --message-bg: #ececff;
    --notification-dot: #ff4081;
    --own-message-bg: #e6ebff;
    --own-message-text: #005b9f;
    --text: #1e1e2e;
    --text-secondary: #6b6b8b;
}

[data-theme="dark"] {
    --background: #1c1c2e;
    --border: #4b4b6b;
    --chat-bg: #242444;
    --hover-bg: #2a2a3f;
    --input-bg: #2a2a3f;
    --message-bg: #2a2a3f;
    --notification-dot: #ff4081;
    --own-message-bg: #33335e;
    --own-message-text: #e0e0e0;
    --text: #e0e0e0;
    --text-secondary: #8b8bad;
}

/* Base Styles */
body {
    background-color: var(--background);
    color: var(--text);
    display: flex;
    flex-direction: column;
    font-family: Arial, sans-serif;
    font-size: 16px;
    height: 100vh;
    margin: 0;
    overflow: hidden;
}

h1 {
    margin: 0;
    padding: 8px;
    line-height: 1;
}

/* Header */
header {
    background-color: var(--background);
    border-bottom: 1px solid var(--border);
    padding: 6px 0;
    margin: 0 auto;
    max-width: 780px;
    width: 100%;
}

#standard-header-body {
    align-items: center;
    display: flex;
    justify-content: space-between;
}

#chat-header-body {
    align-items: center;
    display: flex;
    gap: 10px;
    padding: 3px;
}

#header-right {
    align-items: center;
    display: flex;
    gap: 10px;
}

/* Navigation */
nav#nav-menu {
    align-items: center;
    display: flex;
    gap: 10px;
}

nav#nav-menu .icon-button {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
}

nav#nav-menu .icon-button svg {
    height: 24px;
    pointer-events: none;
    stroke: var(--text);
    width: 24px;
}

nav#nav-menu .icon-button.has-new-messages,
nav#nav-menu .icon-button.has-notifications {
    position: relative;
}

nav#nav-menu .icon-button.has-new-messages::after,
nav#nav-menu .icon-button.has-notifications::after {
    background-color: var(--notification-dot);
    border-radius: 50%;
    content: "";
    height: 8px;
    position: absolute;
    right: 0;
    top: 0;
    width: 8px;
}

/* Authentication */
#auth {
    align-items: center;
    display: flex;
    position: relative;
}

#auth:hover .dropdown {
    display: block;
}

#auth .dropdown {
    background-color: var(--background);
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    width: 100%;
    z-index: 10;
}

#auth .dropdown button {
    align-items: center;
    background-color: var(--background);
    border: none;
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    display: flex;
    font-size: 18px;
    justify-content: center;
    min-height: 44px;
    padding: 8px;
    width: 100%;
}

#auth .dropdown button#toggle-theme {
    margin-top: 8px;
}

#auth .dropdown button:hover {
    background-color: var(--hover-bg);
}

#profile {
    align-items: center;
    background-color: var(--background);
    border: none;
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    display: flex;
    font-size: 18px;
    justify-content: center;
    min-height: 44px;
    padding: 8px;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#profile:hover {
    background-color: var(--hover-bg);
}

#connect-wallet {
    align-items: center;
    background-color: var(--background);
    border: none;
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    display: flex;
    font-size: 18px;
    gap: 10px;
    justify-content: center;
    min-height: 44px;
    padding: 8px;
}

#connect-wallet svg {
    height: 20px;
    pointer-events: none;
    stroke: var(--text);
    width: 20px;
}

#connect-wallet:hover {
    background-color: var(--hover-bg);
}

#user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

#user-info-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

#user-info-username {
    font-size: 18px;
    font-weight: bold;
    color: var(--text);
    padding: 6px;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Main Content */
main {
    flex-grow: 1;
    margin: 0 auto;
    max-width: 780px;
    overflow-y: auto;
    width: 100%;
}

.chat-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

#chat-messages {
    align-content: end;
    background-color: var(--chat-bg);
    flex-grow: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none;
    padding: 10px;
}

#chat-input {
    background-color: var(--chat-bg);
    bottom: 0;
    padding: 10px;
    position: sticky;
}

#chat-form {
    align-items: flex-start;
    display: flex;
    gap: 8px;
}

#message-input {
    background-color: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    flex-grow: 1;
    padding: 12px;
    resize: none;
    font-size: 14px;
}

#message-input:focus {
    border-color: var(--own-message-text);
    outline: none;
}

#send-message {
    align-items: center;
    background-color: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    height: 42px;
    justify-content: center;
    padding: 0;
    width: 42px;
}

#back-to-channels svg,
#send-message svg {
    width: 24px;
    height: 24px;
    pointer-events: none;
    stroke: var(--text);
}

#back-to-channels:hover,
#send-message:hover {
    background-color: var(--hover-bg);
}

.message {
    background-color: var(--message-bg);
    border-radius: 12px;
    color: var(--text);
    line-height: 1.3;
    max-width: 80%;
    margin: 4px 0;
    padding: 8px;
    white-space: pre-wrap;
    width: fit-content;
    word-break: break-all;
}

.message.own-message {
    background-color: var(--own-message-bg);
    color: var(--own-message-text);
    margin-left: auto;
}

/* Request Channel */
#request-channel {
    align-items: center;
    display: flex;
    gap: 8px;
    padding: 10px;
}

#request-channel input {
    background-color: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    flex-grow: 1;
    padding: 12px;
    font-size: 14px;
}

#back-to-channels {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    width: 42px;
    height: 42px;
}

#request-channel button {
    align-items: center;
    background-color: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    height: 42px;
    justify-content: center;
    padding: 0;
    width: 42px;
}

#request-channel button svg {
    stroke: var(--text);
}

#request-channel button svg[data-theme="dark"] {
    stroke: #ffffff;
}

#request-channel button:hover {
    background-color: var(--hover-bg);
}

/* Lists */
.channel-avatar-container.has-new-messages::after {
    background-color: var(--notification-dot);
    border-radius: 50%;
    content: "";
    display: block;
    height: 6px;
    width: 6px;
    position: absolute;
    top: 0;
    right: 0;
    border: 1px solid var(--background);
}

#notifications,
#channels-list {
    background-color: var(--chat-bg);
    height: 100%;
}
ul#notifications-list,
ul#channels {
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0;
    margin: 0;
    background-color: var(--chat-bg);
}

#notifications-list li,
#channels li {
    align-items: center;
    cursor: pointer;
    display: flex;
    list-style: none;
    padding: 12px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#notifications-list .notification.has-new-notifications::before {
    background-color: var(--notification-dot);
    border-radius: 50%;
    content: "";
    display: inline-block;
    height: 8px;
    margin-right: 8px;
    vertical-align: middle;
    width: 8px;
}

#notifications-list .channel-request {
    flex-direction: column;
}

#notifications-list .channel-request .request-text {
    margin-bottom: 8px;
    width: 100%;
}

#notifications-list .channel-request .request-actions {
    display: flex;
    gap: 24px;
    max-width: 480px;
    width: 100%;
}

#notifications-list .channel-request .reject,
#notifications-list .channel-request .approve {
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    flex: 1;
    padding: 8px;
    text-align: center;
}
#notifications-list .channel-request .approve {
    background-color: #00b7eb;
    color: #fff;
}
#notifications-list .channel-request .reject {
    background-color: #ff4081;
    color: #fff;
}
[data-theme="dark"] #notifications-list .channel-request .approve {
    background-color: #00b7eb;
    color: #fff;
}
[data-theme="dark"] #notifications-list .channel-request .reject {
    background-color: #ff4081;
    color: #fff;
}

.channel {
    padding: 0.5rem;
    cursor: pointer;
    border-radius: var(--border-radius);
}

.channel:hover {
    background: var(--hover-bg);
}

.channel-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.channel-avatar-container {
    flex-shrink: 0;
    position: relative;
}

.channel-avatar {
    width: 32px;
    height: 32px;
}

.channel-text {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
}

.channel-name {
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-preview {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Placeholder */
#placeholder {
    padding-left: 10px;
    padding-right: 10px;
    padding-top: 16px;
}

/* Utility */
.hidden {
    display: none;
}

/* Media Queries */
@media (max-width: 280px) {
    #notifications-list .channel-request .request-actions {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
}