* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    font-family: 'gg sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: #1e1f22;
    color: #dbdee1;
    overflow: hidden;
}

button, input {
    font-family: inherit;
}

.hidden {
    display: none !important;
}

/* Auth Screen */
.screen {
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #313338;
}

.box {
    width: 480px;
    padding: 32px;
    background: #2b2d31;
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.24);
}

.box h1 {
    margin: 0 0 8px;
    text-align: center;
    font-size: 24px;
    color: #f2f3f5;
}

.subtitle {
    color: #b5bac1;
    font-size: 14px;
    text-align: center;
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #b5bac1;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.box input, .modal input {
    width: 100%;
    height: 40px;
    padding: 10px;
    background: #1e1f22;
    color: #dbdee1;
    border: 1px solid #111214;
    border-radius: 4px;
    outline: none;
    font-size: 15px;
}

.box input:focus, .modal input:focus {
    border-color: #5865f2;
}

.box button {
    width: 100%;
    height: 44px;
    margin-top: 20px;
    border: 0;
    border-radius: 4px;
    background: #5865f2;
    color: white;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.17s ease;
}

.box button:hover {
    background: #4752c4;
}

#error, #friendError {
    color: #fa5252;
    margin-top: 10px;
    font-size: 13px;
}

/* App Main Layout */
.chat-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    background: #313338;
}

/* Left Guild Bar */
.guilds-bar {
    width: 72px;
    height: 100%;
    background: #1e1f22;
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.guild-icon {
    width: 48px;
    height: 48px;
    background: #5865f2;
    border-radius: 16px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 20px;
    cursor: pointer;
}

/* Sidebar */
.sidebar {
    width: 240px;
    height: 100%;
    background: #2b2d31;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #1f2023;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.sidebar-header h2 {
    font-size: 15px;
    color: #f2f3f5;
    margin: 0;
}

.sidebar-content {
    padding: 10px 8px;
    flex: 1;
    overflow-y: auto;
}

.add-friend-btn {
    width: 100%;
    height: 36px;
    border: 0;
    border-radius: 4px;
    background: #232428;
    color: #dbdee1;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 16px;
    transition: background 0.15s;
}

.add-friend-btn:hover {
    background: #35373c;
    color: #fff;
}

.dm-section-title {
    font-size: 12px;
    font-weight: 700;
    color: #949ba4;
    padding: 0 8px 8px;
}

.friend {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 2px;
    border-radius: 4px;
    color: #949ba4;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.friend:hover {
    background: #35373c;
    color: #dbdee1;
}

.friend.active {
    background: #404249;
    color: #f2f3f5;
}

/* Chat Section */
.chat-main {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #313338;
    min-width: 0;
}

.empty {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: #949ba4;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.dm {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.dm-header {
    height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #1f2023;
    font-weight: bold;
    font-size: 16px;
    color: #f2f3f5;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.dm-header::before {
    content: "@ ";
    color: #80848e;
}

/* Messages Area */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

.message {
    width: 100%;
    display: flex;
    flex-direction: column;
    background: transparent;
    padding: 2px 0;
}

.message b {
    color: #f2f3f5;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
}

.message span {
    color: #dbdee1;
    font-size: 14px;
    line-height: 1.375rem;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Input Bar */
.messageBox {
    padding: 0 16px 24px 16px;
    display: flex;
    gap: 10px;
    background: #313338;
    flex-shrink: 0;
}

#messageInput {
    flex: 1;
    height: 44px;
    padding: 0 16px;
    background: #383a40;
    color: #dbdee1;
    border: 0;
    border-radius: 8px;
    outline: none;
    font-size: 15px;
}

#messageInput::placeholder {
    color: #80848e;
}

#sendBtn {
    width: 70px;
    height: 44px;
    border: 0;
    border-radius: 8px;
    background: #5865f2;
    color: white;
    font-weight: 600;
    cursor: pointer;
}

#sendBtn:hover {
    background: #4752c4;
}

#sendBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}

.modal-buttons button {
    width: auto;
    padding: 10px 24px;
    margin-top: 0;
}

#cancelBtn {
    background: transparent;
    color: white;
}

#cancelBtn:hover {
    text-decoration: underline;
    background: transparent;
}