/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    background: #313338;
    color: #dcddde;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    overflow: hidden;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }

/* ===== 3-COLUMN SHELL ===== */
.app-shell {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ===== COL 1: SERVER ICON STRIP ===== */
#server-list {
    width: 72px;
    min-width: 72px;
    background: #1e1f22;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    gap: 8px;
    overflow-y: auto;
    overflow-x: hidden;
}

#server-list::-webkit-scrollbar { width: 0; }

.server-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #313338;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #dcddde;
    font-size: 18px;
    font-weight: 700;
    border: none;
    transition: border-radius 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
    position: relative;
}

.server-icon:hover,
.server-icon.active {
    border-radius: 16px;
    background: #5865f2;
    color: white;
}

.server-icon img {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
}

.home-icon { background: #313338; color: #5865f2; }
.home-icon:hover { background: #5865f2; color: white; }

.add-server { background: #313338; color: #3ba55c; }
.add-server:hover { background: #3ba55c; color: white; }

.server-separator {
    width: 32px;
    height: 2px;
    background: #35373c;
    border-radius: 1px;
    flex-shrink: 0;
}

/* ===== COL 2: SIDEBAR (DMs or Channels) ===== */
.sidebar {
    width: 240px;
    min-width: 240px;
    background: #2b2d31;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 48px;
    border-bottom: 1px solid #1e1f22;
    font-weight: 600;
    font-size: 15px;
    color: #f2f3f5;
    flex-shrink: 0;
}

.server-name-header {
    font-size: 15px;
    font-weight: 700;
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 8px 4px 16px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #949ba4;
    text-transform: uppercase;
    flex-shrink: 0;
}

/* ===== ADD FRIEND FORM ===== */
.add-friend-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 12px 12px;
    border-bottom: 1px solid #1e1f22;
}

.add-friend-form input {
    background: #1e1f22;
    border: none;
    border-radius: 4px;
    color: #dcddde;
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
    width: 100%;
}

.add-friend-form input::placeholder { color: #6d6f78; }

.form-error {
    padding: 4px 12px 8px;
    font-size: 12px;
    color: #ed4245;
}

.form-success {
    padding: 4px 12px 8px;
    font-size: 12px;
    color: #3ba55c;
}

/* ===== FRIEND REQUEST ITEMS ===== */
.friend-request-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    margin: 2px 8px;
    border-radius: 4px;
}

.friend-request-item:hover { background: #35373c; }

/* ===== DM LIST ===== */
.dm-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin: 1px 8px;
    border-radius: 4px;
    color: #949ba4;
    font-size: 15px;
    font-weight: 500;
}

.dm-item:hover { background: #35373c; color: #dcddde; }
.dm-item.active { background: #404249; color: #f2f3f5; }

/* ===== CHANNEL LIST ===== */
.channel-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    margin: 1px 8px;
    border-radius: 4px;
    color: #949ba4;
    font-size: 15px;
    font-weight: 500;
}

.channel-item:hover { background: #35373c; color: #dcddde; }
.channel-item.active { background: #404249; color: #f2f3f5; }

.channel-hash {
    font-size: 18px;
    color: #6d6f78;
    font-weight: 400;
    flex-shrink: 0;
}

.channel-item.active .channel-hash,
.channel-item:hover .channel-hash { color: #949ba4; }

/* ===== FRIEND AVATAR ===== */
.friend-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #5865f2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

/* ===== SIDEBAR MISC ===== */
.sidebar-empty {
    padding: 24px 16px;
    color: #6d6f78;
    font-size: 13px;
    text-align: center;
}

.invite-section {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-bottom: 1px solid #1e1f22;
    font-size: 12px;
}

.invite-label { color: #949ba4; }
.invite-link { color: #5865f2; font-weight: 600; }
.invite-link:hover { text-decoration: underline; }

/* ===== COL 3: CONTENT AREA ===== */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #313338;
    overflow: hidden;
}

.content-header {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 48px;
    padding: 0 16px;
    border-bottom: 1px solid #1e1f22;
    font-weight: 600;
    color: #f2f3f5;
    flex-shrink: 0;
}

.content-header .channel-hash { font-size: 22px; }
.content-header .friend-avatar { width: 24px; height: 24px; font-size: 11px; }

/* ===== MESSAGES ===== */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.messages-container::-webkit-scrollbar { width: 8px; }
.messages-container::-webkit-scrollbar-track { background: transparent; }
.messages-container::-webkit-scrollbar-thumb { background: #1e1f22; border-radius: 4px; }

.message {
    display: flex;
    flex-direction: column;
    padding: 4px 8px;
    border-radius: 4px;
}

.message:hover { background: #2e3035; }

.message-author {
    font-size: 13px;
    font-weight: 600;
    color: #f2f3f5;
    margin-bottom: 2px;
}

.message.mine .message-author { color: #5865f2; }

.message-content { color: #dcddde; word-break: break-word; }

.message-time {
    font-size: 11px;
    color: #6d6f78;
    margin-top: 2px;
}

.typing-indicator {
    padding: 4px 16px;
    font-size: 12px;
    color: #949ba4;
    height: 20px;
    flex-shrink: 0;
}

/* ===== MESSAGE INPUT ===== */
.message-input-area {
    padding: 0 16px 24px;
    flex-shrink: 0;
}

.message-input-area form {
    display: flex;
    align-items: center;
    background: #383a40;
    border-radius: 8px;
    padding: 4px 4px 4px 16px;
    gap: 8px;
}

.message-input-area input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #dcddde;
    font-size: 15px;
    padding: 8px 0;
}

.message-input-area input::placeholder { color: #6d6f78; }

.message-input-area button {
    background: #5865f2;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
}

.message-input-area button:hover { background: #4752c4; }

/* ===== WELCOME SCREEN ===== */
.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: #949ba4;
    text-align: center;
    padding: 32px;
}

.welcome-icon { font-size: 64px; }
.welcome-screen h2 { color: #f2f3f5; font-size: 24px; }
.welcome-screen p { font-size: 15px; max-width: 400px; }

/* ===== BUTTONS ===== */
.icon-btn {
    background: none;
    border: none;
    color: #949ba4;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    flex-shrink: 0;
}

.icon-btn:hover { color: #dcddde; background: #35373c; }

.accept-btn:hover { color: #3ba55c; background: #2a3c2c; }
.reject-btn:hover { color: #ed4245; background: #3c2a2a; }

.friend-name { flex: 1; font-size: 14px; }

.btn-primary {
    background: #5865f2;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    width: 100%;
}

.btn-primary:hover { background: #4752c4; }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn-cancel {
    background: transparent;
    color: #949ba4;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
}

.btn-cancel:hover { color: #dcddde; }

/* ===== MODAL ===== */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal.hidden { display: none; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
}

.modal-content {
    position: relative;
    background: #313338;
    border-radius: 8px;
    padding: 32px;
    width: 440px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    font-size: 24px;
    font-weight: 700;
    color: #f2f3f5;
    text-align: center;
}

.modal-subtitle {
    font-size: 14px;
    color: #949ba4;
    text-align: center;
}

.modal-content input {
    background: #1e1f22;
    border: 1px solid #1e1f22;
    border-radius: 4px;
    color: #dcddde;
    padding: 10px 12px;
    font-size: 15px;
    outline: none;
    width: 100%;
}

.modal-content input:focus { border-color: #5865f2; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

/* ===== UTILITY ===== */
.hidden { display: none !important; }

/* ===== AUTH PAGES (Login/Register) ===== */
body.auth-page {
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.auth-container {
    background: #2b2d31;
    border-radius: 8px;
    padding: 32px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.auth-container h1 {
    text-align: center;
    margin-bottom: 24px;
    font-size: 24px;
    font-weight: 700;
    color: #f2f3f5;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-group label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: #949ba4;
    letter-spacing: 0.04em;
}

.form-group input {
    background: #1e1f22;
    border: 1px solid #1e1f22;
    border-radius: 4px;
    color: #dcddde;
    padding: 10px 12px;
    font-size: 15px;
    outline: none;
    width: 100%;
}

.form-group input:focus { border-color: #5865f2; }
