/* MainLayout styles */
.page {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    background: #36393f;
    color: #dcddde;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* Chat component styles - Discord-style dark theme */
.username-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: #202225;
}

.username-container h2 {
    color: #fff;
    margin-bottom: 2rem;
    font-size: 2.5rem;
}

.username-form {
    display: flex;
    gap: 1rem;
    background: #2f3136;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px 0 rgba(0,0,0,.2);
    margin: 0 1rem;
}

@media (max-width: 600px) {
    .username-form {
        flex-direction: column;
        width: 90%;
        max-width: 300px;
    }
    
    .username-container h2 {
        font-size: 1.75rem;
        text-align: center;
        padding: 0 1rem;
    }
}

.username-input {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid #040405;
    border-radius: 3px;
    width: 300px;
    background: #40444b;
    color: #dcddde;
    transition: border-color 0.3s;
}

@media (max-width: 600px) {
    .username-input {
        width: 100%;
    }
}

.username-input:focus {
    outline: none;
    border-color: #00aff4;
}

.join-button {
    padding: 0.75rem 2rem;
    background: #5865f2;
    color: white;
    border: none;
    border-radius: 3px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s;
}

@media (max-width: 600px) {
    .join-button {
        width: 100%;
    }
}

.join-button:hover:not(:disabled) {
    background: #4752c4;
}

.join-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #36393f;
}

.chat-header {
    background: #202225;
    color: #fff;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 0 rgba(4,4,5,0.2),0 1.5px 0 rgba(6,6,7,0.05),0 2px 0 rgba(4,4,5,0.05);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.users-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: none;
    color: #b9bbbe;
    cursor: pointer;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}

.users-toggle:hover {
    background: rgba(79, 84, 92, 0.4);
    color: #dcddde;
}

.users-toggle svg {
    width: 20px;
    height: 20px;
}

.online-count {
    font-size: 0.875rem;
    font-weight: 500;
}

@media (max-width: 600px) {
    .chat-header {
        padding: 0.75rem 1rem;
    }
    
    .chat-header h3 {
        font-size: 1.25rem;
    }
}

.connection-status {
    font-size: 0.875rem;
    padding: 0.25rem 0.75rem;
    border-radius: 3px;
}

.connection-status.connected {
    background: #3ba55c;
}

.connection-status.disconnected {
    background: #ed4245;
}

.chat-main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.messages-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #36393f;
    position: relative;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
}

.message-group {
    padding: 0.125rem 1rem;
}

.message-group:hover:not(.system-message) {
    background: #32353b;
}

/* Add spacing only when username is shown (first message from user) */
.message-group:has(.message-header) {
    margin-top: 1.0625rem;
}

.message-group:first-child {
    margin-top: 0;
}

.message-header {
    display: flex;
    align-items: baseline;
    margin-bottom: 0.125rem;
}

.message-username {
    color: #fff;
    font-size: 1rem;
    font-weight: 500;
    margin-right: 0.5rem;
}

.message-time {
    color: #a3a6aa;
    font-size: 0.75rem;
    font-weight: 400;
}

.message-content {
    color: #dcddde;
    font-size: 1rem;
    line-height: 1.375;
    padding-left: 0;
    word-wrap: break-word;
    margin: 0;
}

/* System messages styling */
.system-message {
    text-align: center;
    margin: 0.25rem 0;
}

/* Remove spacing between consecutive system messages */
.system-message + .system-message {
    margin-top: 0;
}

.system-message .message-content {
    display: inline-block;
    color: #a3a6aa;
    font-style: italic;
    font-size: 0.875rem;
    padding: 0.25rem 1rem;
    background: transparent;
}

.message-image {
    max-width: 400px;
    max-height: 300px;
    border-radius: 3px;
    cursor: pointer;
    margin-top: 0.25rem;
}

.message-image:hover {
    box-shadow: 0 0 0 2px #00aff4;
}

.message-input-container {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: #36393f;
}

.message-input {
    flex: 1;
    padding: 0.6875rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    background: #40444b;
    color: #dcddde;
    margin-right: 0.5rem;
}

.message-input:focus {
    outline: none;
}

.message-input::placeholder {
    color: #72767d;
}

.send-button {
    display: none; /* Discord style - send with Enter */
}

.image-upload-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: transparent;
    color: #b9bbbe;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    transition: color 0.2s;
}

.image-upload-button:hover {
    color: #dcddde;
}

.users-sidebar {
    width: 240px;
    background: #2f3136;
    padding: 1rem;
    transition: transform 0.3s ease;
}

@media (max-width: 768px) {
    .users-sidebar {
        position: fixed;
        right: 0;
        top: 0;
        height: 100vh;
        transform: translateX(100%);
        z-index: 99;
    }
    
    .users-sidebar.sidebar-open {
        transform: translateX(0);
    }
    
    .chat-main {
        width: 100%;
    }
}

.users-sidebar h4 {
    color: #96989d;
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.users-list {
    display: flex;
    flex-direction: column;
}

.user-item {
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 1rem;
    color: #96989d;
    cursor: pointer;
    transition: all 0.2s;
}

.user-item:hover {
    background: #393c43;
    color: #dcddde;
}

.user-item.current-user {
    color: #fff;
}

.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
}

.image-modal img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

/* Scrollbar styling */
.messages::-webkit-scrollbar {
    width: 16px;
}

.messages::-webkit-scrollbar-track {
    background: #2f3136;
    border-radius: 8px;
}

.messages::-webkit-scrollbar-thumb {
    background: #202225;
    border: 4px solid #2f3136;
    border-radius: 8px;
}

.messages::-webkit-scrollbar-thumb:hover {
    background: #18191c;
}

/* Remove padding/margin for cleaner look */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: Whitney, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* Additional mobile adjustments */
@media (max-width: 600px) {
    .message-input-container {
        padding: 0.5rem;
    }
    
    .typing-indicator-container {
        height: 1.25rem;
    }
    
    .typing-indicator {
        font-size: 0.7rem;
        padding: 0 0.5rem;
    }
    
    .message-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .image-upload-button {
        width: 40px;
        height: 40px;
    }
    
    .message-group {
        padding: 0.125rem 0.5rem;
    }
    
    /* Add backdrop for mobile sidebar */
    .sidebar-backdrop {
        display: none;
    }
}

/* Backdrop should be outside media query to work properly */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 98;
}

@media (max-width: 768px) {
    .sidebar-backdrop.show {
        display: block;
    }
}

/* Typing indicator styles */
.typing-indicator-container {
    height: 1.5rem;
    background: #36393f;
    overflow: hidden;
}

.typing-indicator {
    height: 100%;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    font-size: 0.75rem;
    animation: fadeIn 0.2s ease;
}

.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    animation: fadeIn 0.3s ease;
}

.typing-dots .dot {
    width: 6px;
    height: 6px;
    background-color: #72767d;
    border-radius: 50%;
    animation: discordBounce 1.4s infinite ease-in-out;
}

.typing-dots .dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots .dot:nth-child(2) {
    animation-delay: -0.16s;
}

.typing-dots .dot:nth-child(3) {
    animation-delay: 0s;
}

@keyframes discordBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}