/* Discord-style CSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Discord Dark Theme */
    --bg-primary: #313338;
    --bg-secondary: #2b2d31;
    --bg-tertiary: #1e1f22;
    --bg-modifier-hover: rgba(79, 84, 92, 0.4);
    --bg-modifier-active: rgba(79, 84, 92, 0.6);
    --text-normal: #dbdee1;
    --text-muted: #949ba4;
    --text-link: #00a8fc;
    --header-primary: #f2f3f5;
    --header-secondary: #b5bac1;
    --accent: #5865F2;
    --green: #23a55a;
    --yellow: #f0b232;
    --red: #f23f43;
    --channel-icon: #80848e;
    --scrollbar-thin-thumb: #1a1b1e;
    --scrollbar-auto-thumb: #1a1b1e;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f2f3f5;
    --bg-tertiary: #e3e5e8;
    --bg-modifier-hover: rgba(116, 127, 141, 0.16);
    --bg-modifier-active: rgba(116, 127, 141, 0.24);
    --text-normal: #313338;
    --text-muted: #5c5e66;
    --header-primary: #060607;
    --header-secondary: #4e5058;
    --channel-icon: #6d6f78;
}

body {
    font-family: 'gg sans', 'Noto Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: var(--bg-tertiary);
    color: var(--text-normal);
    height: 100vh;
    overflow: hidden;
}

#app {
    display: flex;
    height: 100vh;
}

/* Server List (Left vertical bar) */
.server-list {
    width: 72px;
    background: var(--bg-tertiary);
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    overflow-y: auto;
    flex-shrink: 0;
}

.server-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: border-radius 0.2s, background 0.2s;
    position: relative;
}

.server-icon:hover,
.server-icon.active {
    border-radius: 16px;
    background: var(--accent);
}

.server-icon.home {
    background: var(--accent);
}

.server-icon.add {
    background: transparent;
    border: 1px dashed var(--text-muted);
    color: var(--green);
    font-size: 24px;
}

.server-icon.add:hover {
    background: var(--green);
    color: white;
    border: none;
}

.server-separator {
    width: 32px;
    height: 2px;
    background: var(--bg-modifier-active);
    border-radius: 1px;
}

/* Active indicator pill */
.server-icon.active::before {
    content: '';
    position: absolute;
    left: -16px;
    width: 8px;
    height: 40px;
    background: var(--header-primary);
    border-radius: 0 4px 4px 0;
}

/* Channel Sidebar */
.channel-sidebar {
    width: 240px;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.channel-header {
    height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 0 rgba(0,0,0,.2), 0 1.5px 0 rgba(0,0,0,.05), 0 2px 0 rgba(0,0,0,.05);
    cursor: pointer;
    transition: background 0.1s;
}

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

.server-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--header-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-arrow {
    color: var(--text-muted);
    transition: transform 0.2s;
}

.channel-header.open .dropdown-arrow {
    transform: rotate(180deg);
}

/* Server Dropdown */
.server-dropdown {
    display: none;
    position: absolute;
    top: 52px;
    left: 76px;
    width: 220px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    padding: 6px 8px;
    box-shadow: 0 8px 16px rgba(0,0,0,.24);
    z-index: 1000;
}

.server-dropdown.open {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 3px;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}

.dropdown-item:hover {
    background: var(--accent);
    color: white;
}

.dropdown-item.danger:hover {
    background: var(--red);
}

.dropdown-separator {
    height: 1px;
    background: var(--bg-modifier-active);
    margin: 4px 0;
}

/* Channel List */
.channel-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px;
}

.channel-list.hidden {
    display: none;
}

.channel-category {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 16px 0 4px 2px;
    font-size: 12px;
    font-weight: 600;
    color: var(--channel-icon);
    text-transform: uppercase;
    cursor: pointer;
}

.channel-category:hover {
    color: var(--text-normal);
}

.category-arrow {
    transition: transform 0.1s;
}

.channel-category.collapsed .category-arrow {
    transform: rotate(-90deg);
}

.channel {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    margin: 1px 0;
    border-radius: 4px;
    cursor: pointer;
    color: var(--channel-icon);
    transition: background 0.1s, color 0.1s;
}

.channel:hover {
    background: var(--bg-modifier-hover);
    color: var(--text-normal);
}

.channel.active {
    background: var(--bg-modifier-active);
    color: var(--header-primary);
}

.channel-hash {
    font-size: 20px;
    font-weight: 500;
    opacity: 0.8;
}

.channel-name {
    font-size: 16px;
    font-weight: 500;
}

/* User Area */
.user-area {
    height: 52px;
    padding: 0 8px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    position: relative;
}

.status-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 3px solid var(--bg-tertiary);
}

.status-dot.online { background: var(--green); }
.status-dot.idle { background: var(--yellow); }
.status-dot.dnd { background: var(--red); }
.status-dot.invisible { background: var(--text-muted); }

.user-info {
    flex: 1;
    min-width: 0;
}

.username {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--header-primary);
    line-height: 1.2;
}

.user-status {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
}

.user-settings-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-settings-btn:hover {
    background: var(--bg-modifier-hover);
    color: var(--text-normal);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Header */
.header {
    height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-primary);
    box-shadow: 0 1px 0 rgba(0,0,0,.2), 0 1.5px 0 rgba(0,0,0,.05), 0 2px 0 rgba(0,0,0,.05);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-hash {
    font-size: 24px;
    color: var(--channel-icon);
}

.header-channel {
    font-size: 16px;
    font-weight: 600;
    color: var(--header-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.network-quality {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 16px;
}

.network-quality .bar {
    width: 4px;
    background: var(--green);
    border-radius: 2px;
}

.network-quality .bar:nth-child(1) { height: 6px; }
.network-quality .bar:nth-child(2) { height: 10px; }
.network-quality .bar:nth-child(3) { height: 14px; }

.network-quality.poor .bar:nth-child(2),
.network-quality.poor .bar:nth-child(3) { background: var(--text-muted); }

.network-quality.offline .bar { background: var(--red); }

.header-btn {
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.header-btn:hover {
    color: var(--text-normal);
}

/* Messages */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.welcome-message {
    padding: 16px;
    margin-bottom: 16px;
}

.welcome-icon {
    width: 68px;
    height: 68px;
    background: var(--bg-modifier-active);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 42px;
    color: var(--text-normal);
    margin-bottom: 8px;
}

.welcome-message h2 {
    font-size: 32px;
    font-weight: 700;
    color: var(--header-primary);
    margin-bottom: 8px;
}

.welcome-message p {
    color: var(--text-muted);
}

/* Message */
.message {
    display: flex;
    gap: 16px;
    padding: 2px 16px;
    margin: 0 -16px;
    position: relative;
}

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

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    cursor: pointer;
}

.message-avatar.user {
    background: var(--green);
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}

.message-author {
    font-weight: 500;
    color: var(--header-primary);
    cursor: pointer;
}

.message-author:hover {
    text-decoration: underline;
}

.message-timestamp {
    font-size: 12px;
    color: var(--text-muted);
}

.message-text {
    color: var(--text-normal);
    line-height: 1.375;
    word-wrap: break-word;
}

.message-text a {
    color: var(--text-link);
}

.message-text code {
    background: var(--bg-tertiary);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.875em;
}

.message-text pre {
    background: var(--bg-tertiary);
    border-radius: 4px;
    padding: 8px;
    margin: 8px 0;
    overflow-x: auto;
    position: relative;
}

.message-text pre code {
    background: none;
    padding: 0;
}

/* Code block copy button */
.code-block {
    position: relative;
}

.code-copy-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    padding: 4px 8px;
    background: var(--bg-modifier-active);
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.1s;
}

.code-block:hover .code-copy-btn {
    opacity: 1;
}

.code-copy-btn:hover {
    background: var(--accent);
    color: white;
}

/* Mentions */
.mention {
    background: rgba(88, 101, 242, 0.3);
    color: var(--text-link);
    padding: 0 2px;
    border-radius: 3px;
    cursor: pointer;
}

.mention:hover {
    background: var(--accent);
    color: white;
}

/* Message actions */
.message-actions {
    position: absolute;
    top: -16px;
    right: 16px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    display: none;
    box-shadow: 0 0 0 1px rgba(0,0,0,.1), 0 2px 4px rgba(0,0,0,.1);
}

.message:hover .message-actions {
    display: flex;
}

.message-action {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-action:hover {
    color: var(--text-normal);
    background: var(--bg-modifier-hover);
}

/* Reply */
.message-reply {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 14px;
    color: var(--text-muted);
}

.reply-avatar {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
}

.reply-content {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.reply-content:hover {
    color: var(--text-normal);
}

/* Edited indicator */
.edited {
    font-size: 10px;
    color: var(--text-muted);
    margin-left: 4px;
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 14px;
    color: var(--text-muted);
}

.typing-indicator.visible {
    display: flex;
}

.typing-avatar {
    width: 24px;
    height: 24px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Input Area */
.input-area {
    padding: 0 16px 24px;
    display: flex;
    gap: 8px;
}

.input-btn {
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.input-btn:hover {
    color: var(--text-normal);
}

.input-wrapper {
    flex: 1;
    position: relative;
}

.input-wrapper input {
    width: 100%;
    padding: 11px 16px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 8px;
    color: var(--text-normal);
    font-size: 16px;
    font-family: inherit;
    outline: none;
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
}

.slash-hint {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: var(--text-muted);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s;
}

.input-wrapper input:focus + .slash-hint {
    opacity: 1;
}

/* Panels */
.panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100%;
    background: var(--bg-secondary);
    box-shadow: -2px 0 8px rgba(0,0,0,.2);
    transition: right 0.2s;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.panel.open {
    right: 0;
}

.panel-header {
    height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--bg-modifier-active);
}

.panel-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--header-primary);
}

.panel-close {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.panel-close:hover {
    background: var(--bg-modifier-hover);
    color: var(--text-normal);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.history-date {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    margin-bottom: 8px;
    color: var(--text-normal);
    cursor: pointer;
}

.history-date:hover {
    background: var(--bg-modifier-hover);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.open {
    display: flex;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 8px;
    width: 440px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--bg-modifier-active);
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--header-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    border-radius: 4px;
}

.modal-close:hover {
    background: var(--bg-modifier-hover);
}

.modal-body {
    padding: 16px;
    overflow-y: auto;
}

/* Settings */
.settings-section {
    margin-bottom: 24px;
}

.settings-section h3 {
    font-size: 12px;
    font-weight: 700;
    color: var(--header-secondary);
    text-transform: uppercase;
    margin-bottom: 12px;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

.setting-row span {
    color: var(--text-normal);
}

.setting-row select {
    background: var(--bg-tertiary);
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    color: var(--text-normal);
    font-size: 14px;
}

/* Color picker */
.color-picker {
    display: flex;
    gap: 8px;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s;
    border: 2px solid transparent;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.active {
    border-color: white;
}

/* Status options */
.status-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.status-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.1s;
}

.status-option:hover {
    background: var(--bg-modifier-hover);
}

.status-option.active {
    background: var(--bg-modifier-active);
}

/* Toggle */
.toggle {
    position: relative;
    width: 40px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--text-muted);
    border-radius: 12px;
    transition: 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
}

.toggle input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(16px);
}

/* Shortcuts list */
.shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.shortcut {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    color: var(--text-normal);
}

.shortcut kbd {
    background: var(--bg-tertiary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-family: inherit;
    min-width: 28px;
    text-align: center;
}

.shortcut span {
    margin-left: auto;
    color: var(--text-muted);
}

/* Command Palette */
.command-palette {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    width: 500px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,.4);
    display: none;
    z-index: 1001;
    overflow: hidden;
}

.command-palette.open {
    display: block;
}

.command-palette input {
    width: 100%;
    padding: 16px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--bg-modifier-active);
    color: var(--text-normal);
    font-size: 16px;
    outline: none;
}

.command-list {
    max-height: 300px;
    overflow-y: auto;
}

.command-item {
    padding: 12px 16px;
    color: var(--text-normal);
    cursor: pointer;
    transition: background 0.1s;
}

.command-item:hover,
.command-item.selected {
    background: var(--bg-modifier-hover);
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: var(--bg-tertiary);
    border-radius: 4px;
    padding: 6px 8px;
    box-shadow: 0 8px 16px rgba(0,0,0,.24);
    z-index: 1002;
    display: none;
    min-width: 180px;
}

.context-menu.open {
    display: block;
}

.context-item {
    padding: 8px 10px;
    border-radius: 3px;
    color: var(--text-normal);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.1s;
}

.context-item:hover {
    background: var(--accent);
    color: white;
}

.context-item.danger:hover {
    background: var(--red);
}

.context-separator {
    height: 1px;
    background: var(--bg-modifier-active);
    margin: 4px 0;
}

/* Link embeds */
.embed {
    background: var(--bg-secondary);
    border-left: 4px solid var(--accent);
    border-radius: 4px;
    padding: 12px;
    margin: 8px 0;
    max-width: 520px;
}

.embed-provider {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.embed-title {
    color: var(--text-link);
    font-weight: 600;
    margin-bottom: 4px;
}

.embed-description {
    font-size: 14px;
    color: var(--text-normal);
}

.embed-thumbnail {
    max-width: 100%;
    border-radius: 4px;
    margin-top: 8px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thin-thumb);
    border-radius: 4px;
}

/* Mobile */
@media (max-width: 768px) {
    .server-list {
        display: none;
    }
    
    .channel-sidebar {
        position: fixed;
        left: -240px;
        top: 0;
        height: 100%;
        z-index: 100;
        transition: left 0.2s;
    }
    
    .channel-sidebar.open {
        left: 0;
    }
    
    .panel {
        width: 100%;
        right: -100%;
    }
}
