/* SHS Chat - Discord Alternative Theme */
:root {
    --bg-tertiary: #1e1f22;
    --bg-secondary: #2b2d31;
    --bg-primary: #313338;
    --bg-floating: #232428;
    --bg-modal: #313338;
    --channel-hover: #35373c;
    --channel-active: #404249;
    --input-bg: #383a40;
    
    --text-header: #f2f3f5;
    --text-normal: #dbdee1;
    --text-muted: #949ba4;
    --text-link: #00a8fc;
    
    --brand: #5865f2;
    --brand-hover: #4752c4;
    --brand-light: #5865f226;
    
    --green: #23a55a;
    --green-hover: #1f9450;
    --yellow: #f0b232;
    --red: #f23f43;
    --red-hover: #da373c;
    
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.15);
    
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-pill: 24px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-tertiary);
    color: var(--text-normal);
    user-select: none;
}

button {
    cursor: pointer;
    border: none;
    outline: none;
    background: none;
    font-size: 14px;
    color: inherit;
}

input, textarea, select {
    font-family: inherit;
    font-size: 14px;
    color: var(--text-header);
    background-color: var(--input-bg);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    outline: none;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--brand);
}

/* App Layout */
#app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* 1. Server Rail (Far Left) */
.server-rail {
    width: 72px;
    background-color: var(--bg-tertiary);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    gap: 8px;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
}

.server-rail::-webkit-scrollbar {
    display: none;
}

.rail-item {
    position: relative;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.rail-pill {
    position: absolute;
    left: -12px;
    width: 4px;
    height: 8px;
    border-radius: 0 4px 4px 0;
    background-color: var(--text-header);
    transition: height 0.2s ease, left 0.2s ease;
    opacity: 0;
}

.rail-item:hover .rail-pill {
    opacity: 1;
    height: 20px;
    left: -12px;
}

.rail-item.active .rail-pill {
    opacity: 1;
    height: 40px;
    left: -12px;
}

.rail-icon {
    width: 48px;
    height: 48px;
    border-radius: 24px;
    background-color: var(--bg-primary);
    color: var(--text-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background-size: cover;
    background-position: center;
    text-decoration: none;
    overflow: hidden;
}

.rail-item:hover .rail-icon, .rail-item.active .rail-icon {
    border-radius: 16px;
    background-color: var(--brand);
    color: #fff;
}

.rail-item.active .rail-icon {
    border-radius: 16px;
    background-color: var(--brand);
    color: #fff;
}

.rail-item.action .rail-icon {
    color: var(--green);
    background-color: var(--bg-primary);
}

.rail-item.action:hover .rail-icon {
    color: #fff;
    background-color: var(--green);
}

.rail-separator {
    width: 32px;
    height: 2px;
    background-color: var(--border-subtle);
    border-radius: 1px;
    margin: 4px 0;
}

.badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background-color: var(--red);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    border: 3px solid var(--bg-tertiary);
}

/* 2. Sidebar (Channels / Friends) */
.sidebar {
    width: 240px;
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-top-left-radius: var(--radius-md);
    overflow: hidden;
}

.sidebar-header {
    height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 15px;
    color: var(--text-header);
    border-bottom: 1px solid var(--bg-tertiary);
    cursor: pointer;
    transition: background 0.15s ease;
}

.sidebar-header:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-tertiary) transparent;
}

/* Categories & Channels */
.channel-category {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 8px 4px 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    cursor: pointer;
    text-transform: uppercase;
}

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

.channel-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    margin: 1px 0;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.15s ease;
}

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

.channel-item.active {
    background-color: var(--channel-active);
    color: var(--text-header);
}

.channel-icon {
    font-size: 16px;
    opacity: 0.8;
}

.voice-users-list {
    margin-left: 24px;
    margin-bottom: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.voice-user-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 6px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-normal);
}

.voice-user-row.speaking .avatar {
    box-shadow: 0 0 0 2px var(--green);
}

/* Voice Active Footer */
.voice-connected-bar {
    background-color: #1a2e22;
    border-bottom: 1px solid var(--border-subtle);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.voice-connected-info {
    display: flex;
    flex-direction: column;
}

.voice-connected-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--green);
    display: flex;
    align-items: center;
    gap: 6px;
}

.voice-connected-chan {
    font-size: 11px;
    color: var(--text-muted);
}

.voice-disconnect-btn {
    width: 28px;
    height: 28px;
    border-radius: 14px;
    background-color: var(--red);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.voice-disconnect-btn:hover {
    background-color: var(--red-hover);
}

/* User Footer Bar */
.user-bar {
    height: 52px;
    background-color: var(--bg-tertiary);
    padding: 0 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
}

.user-info-section {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    flex: 1;
    overflow: hidden;
}

.user-info-section:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.user-names {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.user-custom-status {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-controls {
    display: flex;
    align-items: center;
    gap: 2px;
}

.ctrl-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all 0.15s ease;
}

.ctrl-btn:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text-header);
}

.ctrl-btn.active {
    color: var(--red);
}

/* Avatars & Status */
.avatar-wrap {
    position: relative;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.avatar-wrap.large {
    width: 48px;
    height: 48px;
}

.avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    background-color: var(--brand);
    background-size: cover;
    background-position: center;
    transition: box-shadow 0.2s ease;
}

.status-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
}

.status-indicator.online { background-color: var(--green); }
.status-indicator.idle { background-color: var(--yellow); }
.status-indicator.dnd { background-color: var(--red); }
.status-indicator.offline { background-color: var(--text-muted); }

/* 3. Main Chat View */
.main-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    overflow: hidden;
}

.main-header {
    height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    color: var(--text-header);
    font-size: 16px;
}

.header-topic {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-muted);
    border-left: 1px solid var(--border-subtle);
    padding-left: 12px;
    max-width: 400px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.panel-badge-btn {
    background-color: var(--brand);
    color: #fff;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s ease;
}

.panel-badge-btn:hover {
    background-color: var(--brand-hover);
}

/* Chat Messages */
.messages-scroller {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-tertiary) transparent;
}

.message-group {
    display: flex;
    gap: 16px;
    position: relative;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background 0.1s ease;
}

.message-group:hover {
    background-color: rgba(0, 0, 0, 0.07);
}

.message-avatar-wrap {
    flex-shrink: 0;
}

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

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

.message-author {
    font-weight: 600;
    color: var(--text-header);
    font-size: 15px;
    cursor: pointer;
}

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

.role-tag {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 4px;
    border-radius: 3px;
    color: #fff;
    text-transform: uppercase;
}

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

.message-text {
    color: var(--text-normal);
    font-size: 15px;
    line-height: 1.4;
    word-break: break-word;
    user-select: text;
}

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

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

.message-text code {
    background-color: var(--bg-tertiary);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 13px;
}

.message-text pre {
    background-color: var(--bg-tertiary);
    padding: 8px 12px;
    border-radius: 4px;
    margin: 6px 0;
    overflow-x: auto;
    font-family: monospace;
    font-size: 13px;
}

.message-text blockquote {
    border-left: 4px solid var(--border-strong);
    padding-left: 8px;
    margin: 4px 0;
    color: var(--text-muted);
}

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

/* Reply Reference */
.message-reply-ref {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
    cursor: pointer;
}

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

.reply-line {
    width: 24px;
    height: 12px;
    border-left: 2px solid var(--border-strong);
    border-top: 2px solid var(--border-strong);
    border-top-left-radius: 4px;
    margin-right: 4px;
}

/* Attachments */
.attachment-card {
    margin-top: 8px;
    max-width: 400px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
}

.attachment-img {
    max-width: 100%;
    max-height: 350px;
    display: block;
    cursor: pointer;
    object-fit: cover;
}

.attachment-file {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
}

.attachment-file a {
    color: var(--text-link);
    text-decoration: none;
    font-weight: 500;
}

/* Reactions */
.reactions-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.reaction-pill {
    display: flex;
    align-items: center;
    gap: 4px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    padding: 2px 6px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.reaction-pill:hover {
    background-color: var(--input-bg);
}

.reaction-pill.reacted {
    background-color: var(--brand-light);
    border-color: var(--brand);
    color: var(--brand);
}

/* Message Hover Actions */
.message-actions-bar {
    position: absolute;
    top: -14px;
    right: 16px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    display: none;
    align-items: center;
    padding: 2px;
    gap: 2px;
    z-index: 5;
}

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

.action-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
}

.action-btn:hover {
    background-color: var(--channel-hover);
    color: var(--text-header);
}

/* Chat Input Bar */
.chat-input-area {
    padding: 0 16px 24px 16px;
    display: flex;
    flex-direction: column;
}

.typing-notice {
    height: 20px;
    font-size: 12px;
    color: var(--text-muted);
    padding: 0 4px;
    line-height: 20px;
}

.chat-input-box {
    background-color: var(--input-bg);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 12px;
}

.chat-upload-btn, .chat-emoji-btn, .chat-send-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s ease;
}

.chat-upload-btn:hover, .chat-emoji-btn:hover {
    color: var(--text-header);
}

.chat-send-btn {
    background-color: var(--brand);
    color: #fff;
}

.chat-send-btn:hover {
    background-color: var(--brand-hover);
}

.chat-textarea {
    flex: 1;
    background: none;
    border: none;
    resize: none;
    padding: 12px 0;
    max-height: 140px;
    line-height: 20px;
}

/* 4. Members Sidebar (Right) */
.members-sidebar {
    width: 240px;
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    padding: 16px 8px;
    overflow-y: auto;
    flex-shrink: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-tertiary) transparent;
}

.members-group-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    padding: 8px 8px 4px 8px;
    text-transform: uppercase;
}

.member-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.15s ease;
}

.member-row:hover {
    background-color: var(--channel-hover);
    color: var(--text-normal);
}

.member-name {
    font-weight: 500;
    font-size: 14px;
}

/* 5. Voice Lounge View */
.voice-lounge {
    flex: 1;
    background-color: var(--bg-tertiary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    gap: 24px;
    overflow: hidden;
}

.voice-lounge-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 20px;
    width: 100%;
    max-width: 900px;
}

.voice-card {
    width: 220px;
    height: 180px;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    position: relative;
    border: 2px solid transparent;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.voice-card.speaking {
    border-color: var(--green);
    transform: scale(1.02);
}

.voice-card .avatar {
    width: 72px;
    height: 72px;
    font-size: 26px;
}

.voice-card.speaking .avatar {
    box-shadow: 0 0 0 4px var(--green);
}

.voice-card-name {
    font-weight: 600;
    color: var(--text-header);
    font-size: 15px;
}

.voice-card-badges {
    position: absolute;
    bottom: 12px;
    display: flex;
    gap: 6px;
}

/* 6. Friends View */
.friends-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.friends-tabs-header {
    height: 48px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
}

.friends-tab-btn {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 14px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.friends-tab-btn:hover {
    color: var(--text-normal);
    background-color: rgba(255, 255, 255, 0.05);
}

.friends-tab-btn.active {
    color: var(--text-header);
    background-color: rgba(255, 255, 255, 0.1);
}

.friends-tab-btn.add-friend {
    color: var(--green);
}

.friends-tab-btn.add-friend.active {
    background-color: rgba(35, 165, 90, 0.15);
}

.friends-list-scroller {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.friends-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-top: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: background 0.15s ease;
}

.friends-row:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

.friend-details {
    display: flex;
    align-items: center;
    gap: 12px;
}

.friend-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--bg-tertiary);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.15s ease;
}

.icon-action-btn:hover {
    color: var(--text-header);
    background-color: var(--input-bg);
}

.icon-action-btn.accept:hover {
    color: #fff;
    background-color: var(--green);
}

.icon-action-btn.decline:hover {
    color: #fff;
    background-color: var(--red);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-overlay.open {
    display: flex;
}

.modal-card {
    width: 440px;
    max-width: 90vw;
    background-color: var(--bg-modal);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px 24px 12px 24px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-header);
}

.modal-body {
    padding: 0 24px 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-footer {
    background-color: var(--bg-secondary);
    padding: 16px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-primary {
    background-color: var(--brand);
    color: #fff;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    transition: background 0.15s ease;
}

.btn-primary:hover {
    background-color: var(--brand-hover);
}

.btn-secondary {
    color: var(--text-normal);
    font-weight: 500;
    padding: 10px 16px;
}

.btn-secondary:hover {
    text-decoration: underline;
}

.btn-danger {
    background-color: var(--red);
    color: #fff;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
}

.btn-danger:hover {
    background-color: var(--red-hover);
}

/* User Popover Profile Card */
.user-popover {
    position: absolute;
    width: 300px;
    background-color: var(--bg-floating);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
    z-index: 50;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

.popover-banner {
    height: 60px;
    background-color: var(--brand);
}

.popover-body {
    padding: 16px;
    position: relative;
}

.popover-avatar {
    position: absolute;
    top: -30px;
    left: 16px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 4px solid var(--bg-floating);
}

.popover-names {
    margin-top: 36px;
}

.popover-display-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-header);
}

.popover-username {
    font-size: 13px;
    color: var(--text-muted);
}
