/* ========================= */
/* DISCORD THEME COLORS     */
/* ========================= */
:root {
    --color-bg: #36393f;
    --color-sidebar: #2f3136;
    --color-userlist: #2f3136;
    --color-message-bg: #36393f;
    --color-white: #dcddde;
    --color-gray: #72727d;
    --color-online: #43b581;
    --color-away: #faa61a;
    --color-offline: #747f8d;
    --color-highlight: #5865f2;
    --color-danger: #ed4245;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* ========================= */
/* GENERAL STYLES           */
/* ========================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--color-bg);
    color: var(--color-white);
    overflow: hidden;
}

/* ========================= */
/* SCREENS                  */
/* ========================= */
.screen {
    display: none;
    width: 100%;
    height: 100%;
}

.screen.active {
    display: flex;
}

/* ========================= */
/* LOGIN SCREEN            */
/* ========================= */
#loginScreen {
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-sidebar) 0%, var(--color-bg) 100%);
}

.login-container {
    background: var(--color-sidebar);
    border-radius: 8px;
    padding: 40px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-container h1 {
    font-size: 48px;
    margin-bottom: 10px;
    color: var(--color-highlight);
}

.login-container p {
    color: var(--color-gray);
    margin-bottom: 30px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.input-field {
    padding: 12px 15px;
    background: var(--color-message-bg);
    border: 1px solid var(--color-gray);
    border-radius: 4px;
    color: var(--color-white);
    font-size: 14px;
    transition: border-color 0.2s;
}

.input-field:focus {
    outline: none;
    border-color: var(--color-highlight);
}

.login-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
}

.btn-primary {
    background: var(--color-highlight);
    color: white;
}

.btn-primary:hover {
    background: #4752c4;
}

.btn-success {
    background: var(--color-online);
    color: white;
}

.btn-success:hover {
    background: #3fa372;
}

.btn-danger {
    background: var(--color-danger);
    color: white;
}

.btn-danger:hover {
    background: #d83c33;
}

.btn-gray {
    background: var(--color-gray);
    color: white;
}

.btn-gray:hover {
    background: #626878;
}

.error-message {
    color: var(--color-danger);
    font-size: 12px;
    margin-top: 10px;
    display: none;
}

.error-message.active {
    display: block;
}

/* ========================= */
/* MAIN APP LAYOUT         */
/* ========================= */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

.sidebar {
    width: 250px;
    background: var(--color-sidebar);
    border-right: 1px solid rgba(0, 0, 0, 0.3);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 20px;
}

.profile-card {
    display: flex;
    align-items: center;
    padding: 15px;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.profile-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--color-highlight);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    overflow: hidden;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.profile-name {
    font-size: 16px;
    font-weight: 700;
}

.profile-status {
    font-size: 12px;
    color: var(--color-gray);
}

.channel-list .server-item,
.dm-list .dm-item {
    cursor: pointer;
}

.user-item {
    padding: 10px 12px;
    border-radius: 6px;
}

.status-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-highlight);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    font-size: 12px;
    flex-shrink: 0;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    transition: background 0.2s;
}

.user-item:hover {
    background: var(--color-message-bg);
}

.message-avatar {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--color-highlight);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    overflow: hidden;
    flex-shrink: 0;
}

.message-avatar img.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-avatar .avatar-fallback {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 18px;
}

.logout-btn {
    background: none;
    border: none;
    color: var(--color-gray);
    font-size: 20px;
    cursor: pointer;
    padding: 5px 10px;
    transition: color 0.2s;
}

.logout-btn:hover {
    color: var(--color-white);
}

.sidebar-section {
    padding: 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}

.sidebar-section h3 {
    font-size: 12px;
    color: var(--color-gray);
    text-transform: uppercase;
    margin-bottom: 10px;
    font-weight: 600;
}

.sidebar-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.btn.small {
    padding: 6px 10px;
    font-size: 12px;
}

.server-list, .dm-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.role-badge,
.friend-badge,
.pin-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    background: rgba(255,255,255,0.08);
    color: var(--color-gray);
}

.role-badge {
    background: rgba(88, 101, 242, 0.16);
    color: #b9bbd8;
}

.friend-badge {
    background: rgba(67, 181, 129, 0.16);
    color: #b9f4d4;
}

.pin-badge {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-white);
}

.message.pinned {
    border-left: 3px solid var(--color-highlight);
    padding-left: 9px;
}

.emoji-picker {
    position: absolute;
    bottom: 90px;
    left: 280px;
    width: calc(100% - 560px);
    max-width: 320px;
    background: rgba(32, 34, 37, 0.96);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(6, minmax(32px, 1fr));
    gap: 8px;
    z-index: 20;
}

.emoji-picker button {
    width: 100%;
    padding: 8px;
    border: none;
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    color: var(--color-white);
    cursor: pointer;
    font-size: 18px;
}

.emoji-picker button:hover {
    background: rgba(255,255,255,0.12);
}

.context-menu {
    position: absolute;
    background: rgba(32, 34, 37, 0.98);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    box-shadow: var(--shadow);
    min-width: 180px;
    z-index: 30;
    padding: 8px 0;
}

.context-menu.hidden {
    display: none;
}

.hidden {
    display: none !important;
}

.context-menu button {
    width: 100%;
    background: none;
    border: none;
    color: var(--color-white);
    padding: 10px 16px;
    text-align: left;
    cursor: pointer;
}

.context-menu button:hover {
    background: rgba(255,255,255,0.08);
}

.server-item, .dm-item {
    padding: 10px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.server-item:hover, .dm-item:hover {
    background: var(--color-message-bg);
}

.server-item.active, .dm-item.active {
    background: var(--color-highlight);
    color: white;
}

.server-item span, .dm-item span {
    margin-right: 5px;
}

.empty-state {
    color: var(--color-gray);
    font-size: 12px;
    text-align: center;
    padding: 20px 0;
}

/* ========================= */
/* MAIN CONTENT             */
/* ========================= */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--color-message-bg);
    min-width: 0;
}

.header {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h2 {
    font-size: 18px;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--color-white);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    transition: color 0.2s;
}

.icon-btn:hover {
    color: var(--color-highlight);
}

/* ========================= */
/* MESSAGES CONTAINER       */
/* ========================= */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.messages-loading {
    text-align: center;
    color: var(--color-gray);
    padding: 40px;
}

.message {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-highlight);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 5px;
}

.message-author {
    font-weight: 600;
    color: var(--color-white);
}

.message-time {
    font-size: 12px;
    color: var(--color-gray);
}

.message-text {
    color: var(--color-white);
    word-wrap: break-word;
    line-height: 1.4;
}

/* ========================= */
/* MESSAGE INPUT            */
/* ========================= */
.message-input-area {
    padding: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.3);
    display: flex;
    gap: 10px;
}

.message-input {
    flex: 1;
    padding: 12px 15px;
    background: var(--color-sidebar);
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--color-white);
    font-size: 14px;
    transition: border-color 0.2s;
}

.message-input:focus {
    outline: none;
    border-color: var(--color-highlight);
}

.send-btn {
    padding: 10px 25px;
    background: var(--color-highlight);
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.send-btn:hover {
    background: #4752c4;
}

/* ========================= */
/* USER LIST                */
/* ========================= */
.user-list {
    width: 150px;
    background: var(--color-userlist);
    border-left: 1px solid rgba(0, 0, 0, 0.3);
    overflow-y: auto;
    padding: 15px;
}

.user-list h3 {
    font-size: 12px;
    color: var(--color-gray);
    text-transform: uppercase;
    margin-bottom: 15px;
    font-weight: 600;
}

.users {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-item {
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
    font-size: 14px;
}

.user-item:hover {
    background: var(--color-message-bg);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.online {
    background: var(--color-online);
}

.status-dot.away {
    background: var(--color-away);
}

.status-dot.offline {
    background: var(--color-offline);
}

/* ========================= */
/* VOICE CALL POPUP         */
/* ========================= */
.voice-call-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.voice-call-popup.hidden {
    display: none;
}

.voice-call-content {
    background: var(--color-sidebar);
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow);
    text-align: center;
    min-width: 350px;
}

.voice-call-content h3 {
    margin-bottom: 30px;
    font-size: 18px;
}

.audio-meters {
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.meter-item {
    text-align: left;
}

.meter-item label {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--color-gray);
}

.meter-bar {
    width: 100%;
    height: 6px;
    background: var(--color-message-bg);
    border-radius: 3px;
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-online), var(--color-away));
    width: 0%;
    transition: width 0.1s;
}

.voice-call-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.voice-call-buttons .btn {
    flex: 1;
}

.call-time {
    font-size: 24px;
    font-weight: bold;
    color: var(--color-highlight);
}

/* ========================= */
/* SETTINGS POPUP           */
/* ========================= */
.settings-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.settings-popup.hidden {
    display: none;
}

.settings-content {
    background: var(--color-sidebar);
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow);
    min-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
}

.settings-content h2 {
    margin-bottom: 20px;
}

.settings-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-section h3 {
    font-size: 14px;
    margin-bottom: 15px;
    color: var(--color-white);
}

.settings-section label {
    display: block;
    margin-bottom: 12px;
    cursor: pointer;
    font-size: 14px;
}

.settings-section input[type="checkbox"] {
    margin-right: 10px;
    cursor: pointer;
}

.settings-section textarea {
    width: 100%;
    min-height: 80px;
    padding: 8px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: var(--color-bg-secondary);
    color: var(--color-white);
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
}

.settings-buttons {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.settings-buttons .btn {
    flex: 1;
}

.invite-link {
    margin: 10px 0;
    font-size: 13px;
    color: var(--color-white);
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 10px;
    word-break: break-all;
}

.role-list {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.role-item {
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(88, 101, 242, 0.12);
    color: #d1d9ff;
    font-size: 12px;
}

::-webkit-scrollbar-thumb {
    background: var(--color-gray);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-white);
}

/* ========================= */
/* RESPONSIVE              */
/* ========================= */
@media (max-width: 768px) {
    .user-list {
        display: none;
    }

    .sidebar {
        width: 200px;
    }

    .login-container {
        max-width: 90%;
    }

    .voice-call-content {
        min-width: 85vw;
    }
}
