/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #2c2f33;
    color: #dcddde;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
}

/* Top Navigation Header */
.nav-header {
    background: #23272a;
    border-bottom: 1px solid #40444b;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Remove space-between to eliminate unwanted gap */
    height: 60px;
    flex-shrink: 0;
}

.logo {
    font-weight: bold;
    font-size: 27px;
    color: #7289da;
    min-width: 40px; /* Reduced from 60px */
}

.tab-container {
    flex: 1;
    display: flex;
    align-items: center;
    margin: 0 0 0 2px; /* Minimal left margin - almost flush with site name */
    overflow: hidden;
    /* Removed max-width - let it take all available space to user-info */
}

.tab-scroll-left,
.tab-scroll-right {
    background: #40444b;
    border: none;
    color: #dcddde;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 3px;
    margin: 0 4px;
}

/* Debug styles removed */

.tab-scroll-left:hover,
.tab-scroll-right:hover {
    background: #4f545c;
}

.tabs-wrapper {
    flex: 1;
    overflow: hidden;
}

.tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    background: #40444b;
    border: 2px solid transparent;
    padding: 6px 10px; /* Reduced padding to account for border */
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: fit-content;
    white-space: nowrap;
    color: #dcddde;
    font-size: 14px;
    transition: all 0.2s ease;
}

.tab.active {
    background: #40444b;
    border-color: #7289da;
    color: #dcddde;
}

.tab.unread {
    background: #7289da;
    color: white;
    border-color: transparent;
}

.tab.unread.active {
    background: #40444b;
    border-color: #7289da;
    color: #dcddde;
}

.tab:hover:not(.active):not(.unread) {
    background: #4f545c;
}

.tab-icon {
    font-size: 12px;
}

.tab-name {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tab-close {
    margin-left: 4px;
    font-size: 16px;
    opacity: 0.7;
}

.tab-close:hover {
    opacity: 1;
}

.user-info {
    display: flex;
    align-items: center;
    justify-content: flex-end; /* Right-justify social controls within the space */
    gap: 12px;
    width: 240px; /* Optimal width for spacing and future expansion */
    flex-shrink: 0; /* Don't allow shrinking */
    margin-left: auto; /* Push to the right since we removed space-between */
}

#currentUser {
    color: #7289da;
    font-weight: 500;
}

.top-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.social-controls-container {
    display: flex;
    align-items: center;
    gap: 4px;
}

.social-btn {
    background: transparent;
    border: 1px solid #72767d;
    color: #dcddde;
    padding: 5px 7px; /* Slightly increased padding */
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px; /* 15% bigger than 24px */
    height: 28px; /* 15% bigger than 24px */
    position: relative; /* For notification counter positioning */
}

.social-btn:hover {
    background: #4f545c;
    border-color: #dcddde;
    transform: translateY(-1px);
}

.social-btn img {
    filter: brightness(0) saturate(100%) invert(87%) sepia(6%) saturate(213%) hue-rotate(200deg) brightness(93%) contrast(89%);
    transition: filter 0.2s ease;
}

.social-btn:hover img {
    filter: brightness(0) saturate(100%) invert(100%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(100%) contrast(100%);
}

.notification-counter {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #7289da;
    color: white;
    font-size: 10px;
    font-weight: bold;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.logout-btn {
    background: transparent;
    border: 1px solid #72767d;
    color: #dcddde;
    padding: 5px 9px; /* 15% bigger padding */
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px; /* 15% bigger font (12px * 1.15 ≈ 14px) */
    transition: all 0.2s ease;
    font-weight: 500;
}

.logout-btn:hover {
    background: #f04747;
    border-color: #f04747;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(240, 71, 71, 0.3);
}

/* Old expandable menu styles removed - using direct buttons now */

/* Main Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    height: calc(100vh - 60px);
    min-height: 0;
    position: relative;
}

/* Chat Panel - expands to fill available space */
.chat-panel {
    flex: 1;
    display: flex;
    z-index: 1; /* Below users panel */
    flex-direction: column;
    background: #36393f;
    border-right: 1px solid #40444b;
    height: 100%;
    min-height: 0; /* Important for proper flex behavior */
}

.chat-header {
    background: #2f3136;
    padding: 12px 16px;
    border-bottom: 1px solid #40444b;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.chat-header h2 {
    color: #dcddde;
    font-size: 16px;
    font-weight: 600;
}

/* Chat header room-info styles removed - simplified header */

.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0; /* Important for proper scrolling */
    max-height: 100%; /* Prevent expansion beyond container */
    scroll-behavior: smooth;
    /* Ensure messages don't break layout */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.messages-container.loading {
    background: linear-gradient(90deg, transparent 25%, rgba(255,255,255,0.1) 50%, transparent 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .messages-container.loading {
        animation: none;
        background: rgba(255,255,255,0.05);
    }
}

.message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 4px 0;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #7289da;
    padding: 2px;
    background: #f8f9fa;
    flex-shrink: 0;
    filter: brightness(0.7);
}

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

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

.message-username {
    font-weight: 600;
    color: #dcddde;
    font-size: 14px;
}

.message-timestamp {
    color: #72767d;
    font-size: 11px;
}

.message-text {
    color: #dcddde;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.system-message {
    color: #7289da;
    font-style: italic;
    text-align: center;
    padding: 8px;
}

.loading-messages {
    color: #72767d;
    font-style: italic;
    text-align: center;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.loading-messages::after {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid #72767d;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Input Panel */
.input-panel {
    flex-shrink: 0;
    background: #40444b;
    border-top: 1px solid #2f3136;
    padding: 16px;
    min-height: auto; /* Ensure it doesn't shrink too much */
    position: relative; /* Ensure it stays in place */
}

.input-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-display {
    background: #2f3136;
    border: 1px solid #40444b;
    color: #dcddde;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    min-width: 80px;
    text-align: center;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.user-display:hover {
    background: #36393f;
    border-color: #7289da;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.hamburger-icon {
    font-size: 14px;
    color: #b9bbbe;
    transition: color 0.2s ease;
}

.user-display:hover .hamburger-icon {
    color: #ffffff;
}

/* User Dropdown Menu */
.user-dropdown-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: #2f3136;
    border: 1px solid #40444b;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 200px;
    z-index: 1000;
    display: none;
    padding: 8px 0;
    margin-bottom: 0;
}

.user-dropdown-menu.show {
    display: block;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: #dcddde;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.menu-item:hover {
    background: #36393f;
}

.menu-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.menu-text {
    font-size: 14px;
    font-weight: 500;
}

.menu-separator {
    height: 1px;
    background: #40444b;
    margin: 6px 12px;
}

.input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.input-controls {
    display: flex;
    gap: 4px;
}

.format-btn {
    background: #2f3136;
    border: 1px solid #40444b;
    color: #dcddde;
    padding: 6px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    min-width: 28px;
}

.format-btn:hover {
    background: #36393f;
}

.format-btn.active {
    background: #7289da;
    border-color: #7289da;
}

#messageInput {
    flex: 1;
    background: #2f3136;
    border: 1px solid #40444b;
    color: #dcddde;
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 14px;
}

#messageInput:focus {
    outline: none;
    border-color: #7289da;
}

#sendBtn {
    background: #7289da;
    border: none;
    color: white;
    padding: 10px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

#sendBtn:hover {
    background: #5b73d9;
}

/* Users Rail - fixed width container */
.users-panel {
    width: 250px;
    background: #2f3136;
    overflow: hidden;
    transition: width 0.3s ease;
    flex-shrink: 0;
}

.users-panel.collapsed {
    width: 45px; /* Rail shrinks to show only edge */
}

/* Users Content - slides inside the rail */
.users-content {
    width: 250px;
    height: 100%;
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform 0.3s ease;
}

.users-panel.collapsed .users-content {
    transform: translateX(-205px); /* Content slides left inside rail */
}

.users-panel.collapsed::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 80px;
    height: 100%;
    cursor: pointer;
    z-index: 12;
    background: rgba(47, 49, 54, 0.1); /* Subtle highlight to show it's clickable */
}

.users-panel.collapsed:hover::before {
    background: rgba(116, 137, 218, 0.1); /* Slight blue tint on hover */
}

.users-header {
    padding: 12px 16px;
    border-bottom: 1px solid #40444b;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative; /* For absolute positioning of collapse button */
}

.users-header h3 {
    color: #dcddde;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    flex: 1; /* Take up remaining space between buttons */
    margin-left: 30px; /* Space for caret button */
}

#usersCount {
    color: #72767d;
    font-size: 11px;
}

.room-settings-btn {
    background: transparent;
    border: none;
    color: #dcddde;
    padding: 5px 7px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
}

.room-settings-btn:hover {
    background: #4f545c;
    transform: translateY(-1px);
}

.room-settings-btn img {
    filter: brightness(0) saturate(100%) invert(87%) sepia(6%) saturate(213%) hue-rotate(200deg) brightness(93%) contrast(89%);
    transition: filter 0.2s ease;
}

.room-settings-btn:hover img {
    filter: brightness(0) saturate(100%) invert(100%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(100%) contrast(100%);
}

.users-collapse-btn {
    background: transparent;
    border: none;
    color: #dcddde;
    padding: 3px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 15;
}


.users-panel.collapsed .users-collapse-btn img {
    width: 24px; /* 2 times bigger than 12px - fits better in 28px container */
    height: 24px; /* 2 times bigger than 12px */
}

.users-collapse-btn:hover {
    background: #4f545c;
    transform: translateY(-50%) translateX(2px);
}

.users-collapse-btn img {
    filter: brightness(0) saturate(100%) invert(87%) sepia(6%) saturate(213%) hue-rotate(200deg) brightness(93%) contrast(89%);
    transition: filter 0.2s ease;
}

.users-collapse-btn:hover img {
    filter: brightness(0) saturate(100%) invert(100%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(100%) contrast(100%);
}

.users-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 2px;
}

.user-item:hover {
    background: #40444b;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid #7289da;
    padding: 2px;
    background: #f8f9fa;
    flex-shrink: 0;
    filter: brightness(0.7);
}

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

.username {
    color: #dcddde;
    font-size: 13px;
    font-weight: 500;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-status {
    font-size: 10px;
}

.demo-label {
    font-size: 8px;
    color: #7289da;
    font-weight: bold;
    text-transform: uppercase;
    margin-left: 4px;
    opacity: 0.8;
}

/* Discovery Panel */
.discovery-panel {
    position: fixed;
    top: 60px;
    right: -350px;
    width: 350px;
    height: calc(100vh - 60px);
    background: #2f3136;
    border-left: 1px solid #40444b;
    transition: right 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.discovery-panel.open {
    right: 0;
}

.discovery-header {
    background: #23272a;
    padding: 12px 16px;
    border-bottom: 1px solid #40444b;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.discovery-header h3 {
    color: #dcddde;
    font-size: 16px;
}

#closeDiscovery {
    background: none;
    border: none;
    color: #72767d;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
}

#closeDiscovery:hover {
    color: #dcddde;
}

.discovery-content {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.create-room-section {
    flex-shrink: 0;
    margin-bottom: 24px;
}

.room-list-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.create-room-section h4,
.room-list-section h4 {
    color: #dcddde;
    font-size: 14px;
    margin-bottom: 12px;
    text-transform: uppercase;
    font-weight: 600;
}

#newRoomName,
#newRoomDisplayName,
#newRoomDescription,
#roomType {
    width: 100%;
    background: #40444b;
    border: 1px solid #2f3136;
    color: #dcddde;
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 14px;
}

#newRoomName:focus,
#roomType:focus {
    outline: none;
    border-color: #7289da;
}

#createRoomBtn {
    width: 100%;
    background: #43b581;
    border: none;
    color: white;
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

#createRoomBtn:hover {
    background: #369968;
}

.room-categories {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.category-label {
    color: #dcddde;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.category-dropdown {
    background: #40444b;
    border: 1px solid #2f3136;
    color: #dcddde;
    padding: 6px 8px;
    border-radius: 3px;
    font-size: 12px;
    cursor: pointer;
}

.category-dropdown:focus {
    outline: none;
    border-color: #7289da;
}

.checkbox-option {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #dcddde;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    cursor: pointer;
    white-space: nowrap;
}

.checkbox-option input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: #7289da;
}

.room-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.config-btn {
    flex: 1;
    background: #7289da;
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 12px;
}

.config-btn:hover {
    background: #5b73d9;
}

.create-btn {
    flex: 1;
    background: #43b581;
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 12px;
}

.create-btn:hover {
    background: #369968;
}

.rooms-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
    min-height: 0;
}

.rooms-list::-webkit-scrollbar {
    width: 6px;
}

.rooms-list::-webkit-scrollbar-track {
    background: #2f3136;
}

.rooms-list::-webkit-scrollbar-thumb {
    background: #40444b;
    border-radius: 3px;
}

.rooms-list::-webkit-scrollbar-thumb:hover {
    background: #4f545c;
}

.loading-rooms {
    text-align: center;
    color: #72767d;
    padding: 20px;
    font-style: italic;
}

.room-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: #40444b;
    border-radius: 4px;
    margin-bottom: 8px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
}

.room-item:hover {
    background: #4f545c;
    border-color: #7289da;
    transform: translateY(-1px);
}

.room-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.room-name {
    color: #dcddde;
    font-weight: 500;
    font-size: 14px;
    line-height: 1.2;
}

.room-description {
    color: #b9bbbe;
    font-size: 12px;
    line-height: 1.3;
    margin: 0;
}

.room-users {
    color: #72767d;
    font-size: 11px;
    margin-top: 2px;
}


/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

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

.modal-content {
    background: #36393f;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    background: #2f3136;
    padding: 16px;
    border-bottom: 1px solid #40444b;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    color: #dcddde;
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    color: #72767d;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
}

.modal-close:hover {
    color: #dcddde;
}

.profile-content {
    padding: 24px;
    text-align: center;
}

.profile-avatar img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid #7289da;
    padding: 8px;
    background: #f8f9fa;
    margin-bottom: 16px;
    filter: brightness(0.7);
}

.profile-details {
    margin-bottom: 24px;
    text-align: left;
}

.profile-details h4 {
    color: #dcddde;
    font-size: 20px;
    margin-bottom: 16px;
    text-align: center;
}

.profile-details p {
    color: #dcddde;
    margin-bottom: 8px;
    font-size: 14px;
}

.profile-details strong {
    color: #7289da;
}

.profile-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.action-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
}

.action-btn.primary {
    background: #7289da;
    color: white;
}

.action-btn.primary:hover {
    background: #5b73d9;
}

.action-btn:not(.primary):not(.danger) {
    background: #40444b;
    color: #dcddde;
}

.action-btn:not(.primary):not(.danger):hover {
    background: #4f545c;
}

.action-btn.danger {
    background: #f04747;
    color: white;
}

.action-btn.danger:hover {
    background: #d84040;
}

/* Config Room Modal */
.config-modal {
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
}

.config-content {
    padding: 20px;
    max-height: calc(85vh - 60px);
    overflow-y: auto;
}

.config-section {
    margin-bottom: 20px;
}

.config-section:last-child {
    margin-bottom: 0;
}

/* Room Basic Info */
.room-basic-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.room-name-field, .room-description-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.room-name-field label, .room-description-field label, .category-field label {
    color: #dcddde;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.room-name-field input, .room-description-field textarea {
    background: #40444b;
    border: 1px solid #2f3136;
    color: #dcddde;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

.room-name-field input:focus, .room-description-field textarea:focus {
    outline: none;
    border-color: #7289da;
}

/* Category Field */
.category-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 200px;
}

.config-dropdown {
    background: #40444b;
    border: 1px solid #2f3136;
    color: #dcddde;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
}

.config-dropdown:focus {
    outline: none;
    border-color: #7289da;
}

/* Category Tabs */
.config-tabs {
    display: flex;
    background: #2f3136;
    border-radius: 6px 6px 0 0;
    border: 1px solid #40444b;
    margin-bottom: 0;
}

.config-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: #b9bbbe;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 0;
}

.config-tab:first-child {
    border-radius: 6px 0 0 0;
}

.config-tab:last-child {
    border-radius: 0 6px 0 0;
}

.config-tab:hover {
    background: #36393f;
    color: #dcddde;
}

.config-tab.active {
    background: #7289da;
    color: #ffffff;
    font-weight: 600;
}

/* Options Panels */
.config-options-panel {
    display: none;
    background: #36393f;
    border: 1px solid #40444b;
    border-top: none;
    border-radius: 0 0 6px 6px;
    padding: 20px;
    min-height: 180px;
}

.config-options-panel.active {
    display: block;
}

.config-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.config-option {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #dcddde;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 0;
}

.config-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #7289da;
    cursor: pointer;
}

.config-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    grid-column: span 2;
}

.config-input-group input[type="number"] {
    background: #40444b;
    border: 1px solid #2f3136;
    color: #dcddde;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    width: 100px;
}

.config-input-group input[type="number"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.config-input-group input[type="number"]:focus {
    outline: none;
    border-color: #7289da;
}

.input-suffix {
    color: #b9bbbe;
    font-size: 13px;
}

.config-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #40444b;
}

/* Private Message Window */
.pm-window {
    position: fixed;
    bottom: 0;
    right: 20px;
    width: 300px;
    height: 400px;
    background: #36393f;
    border: 1px solid #40444b;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    display: none;
    flex-direction: column;
    z-index: 1500;
}

.pm-window.show {
    display: flex;
}

.pm-window.minimized {
    height: 40px;
}

.pm-header {
    background: #2f3136;
    padding: 8px 12px;
    border-bottom: 1px solid #40444b;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.pm-user {
    color: #dcddde;
    font-weight: 500;
    font-size: 14px;
}

.pm-controls {
    display: flex;
    gap: 4px;
}

.pm-controls button {
    background: none;
    border: none;
    color: #72767d;
    cursor: pointer;
    padding: 2px 6px;
    font-size: 14px;
}

.pm-controls button:hover {
    color: #dcddde;
}

.pm-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    font-size: 13px;
}

.pm-input {
    border-top: 1px solid #40444b;
    padding: 8px;
    display: flex;
    gap: 4px;
}

#pmMessageInput {
    flex: 1;
    background: #40444b;
    border: 1px solid #2f3136;
    color: #dcddde;
    padding: 6px 8px;
    border-radius: 3px;
    font-size: 12px;
}

#pmMessageInput:focus {
    outline: none;
    border-color: #7289da;
}

#pmSendBtn {
    background: #7289da;
    border: none;
    color: white;
    padding: 6px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

#pmSendBtn:hover {
    background: #5b73d9;
}

/* Bottom Controls */

/* Bottom Notification Area */
.bottom-notification-area {
    background: #23272a;
    border-top: 1px solid #40444b;
    padding: 8px 16px;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    flex-shrink: 0;
    min-height: 48px;
}

.dm-notification-section, .message-notification-section {
    flex: 1;
    background: #2f3136;
    border: 1px solid #40444b;
    border-radius: 4px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.placeholder-text {
    color: #72767d;
    font-size: 12px;
    font-style: italic;
}

.control-btn {
    background: #40444b;
    border: none;
    color: #dcddde;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    flex-grow: 0;
    flex-basis: auto;
    white-space: nowrap;
    width: auto;
    min-width: auto;
    max-width: none;
}

.control-btn:hover {
    background: #4f545c;
}

/* Specific fix for create room button sizing issue */
#createRoomBtn {
    flex: none !important;
    width: auto !important;
    max-width: 200px !important;
}

/* Small screens (phones and small tablets) */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }
    
    .nav-header {
        padding: 4px 8px;
        height: 50px;
    }
    
    .chat-container {
        height: calc(100vh - 50px);
    }
    
    .messages-container {
        padding: 8px;
        gap: 6px;
    }
    
    .input-panel {
        padding: 8px;
    }
    
    .message {
        padding: 6px 0;
    }
    
    .message-text {
        font-size: 13px;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-container {
        grid-template-columns: 1fr;
        height: calc(100vh - 60px); /* Ensure proper height on mobile */
    }
    
    .chat-panel {
        height: 100%;
        min-height: 0;
    }
    
    .messages-container {
        padding: 12px;
        min-height: 0;
    }
    
    .users-panel {
        position: fixed;
        top: 60px;
        right: -250px;
        width: 250px;
        height: calc(100vh - 60px);
        background: #2f3136;
        border-left: 1px solid #40444b;
        transition: right 0.3s ease;
        z-index: 1000;
    }
    
    .users-panel.open {
        right: 0;
    }
    
    .tab-container {
        margin: 0 0 0 2px; /* Keep consistent with desktop - almost flush */
    }
    
    .tab-name {
        max-width: 60px;
    }
    
    .discovery-panel {
        width: 100%;
        right: -100%;
    }
    
    .pm-window {
        width: calc(100% - 40px);
        right: 20px;
        left: 20px;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px;
    }
}

@media (max-width: 480px) {
    .nav-header {
        padding: 8px;
    }
    
    .logo {
        font-size: 16px;
        min-width: 40px; /* Keep consistent with desktop - smaller width */
    }
    
    .user-info {
        gap: 8px;
    }
    
    .input-row {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }
    
    .user-display {
        align-self: flex-start;
        min-width: 60px;
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .input-area {
        flex-direction: column;
        gap: 6px;
    }
    
    .input-controls {
        order: 1;
        justify-content: center;
    }
    
    #messageInput {
        order: 0;
    }
    
    #sendBtn {
        order: 2;
        align-self: flex-end;
        min-width: 60px;
    }
    
    #currentUser {
        display: none;
    }
    
    .tab {
        padding: 6px 8px;
        font-size: 12px;
    }
    
    .tab-name {
        max-width: 40px;
    }
    
    .input-panel {
        padding: 12px;
    }
    
    .input-controls {
        flex-wrap: wrap;
        gap: 2px;
    }
    
    .format-btn {
        padding: 4px 6px;
        min-width: 24px;
    }
}

/* Text Formatting Styles */
.message-text b,
.message-text strong {
    font-weight: bold;
}

.message-text u {
    text-decoration: underline;
}

.message-text s,
.message-text strike {
    text-decoration: line-through;
}

/* Scrollbar Styling */
.messages-container::-webkit-scrollbar,
.users-list::-webkit-scrollbar,
.discovery-content::-webkit-scrollbar,
.pm-messages::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track,
.users-list::-webkit-scrollbar-track,
.discovery-content::-webkit-scrollbar-track,
.pm-messages::-webkit-scrollbar-track {
    background: #2f3136;
}

.messages-container::-webkit-scrollbar-thumb,
.users-list::-webkit-scrollbar-thumb,
.discovery-content::-webkit-scrollbar-thumb,
.pm-messages::-webkit-scrollbar-thumb {
    background: #40444b;
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover,
.users-list::-webkit-scrollbar-thumb:hover,
.discovery-content::-webkit-scrollbar-thumb:hover,
.pm-messages::-webkit-scrollbar-thumb:hover {
    background: #4f545c;
}