/* Base Styles */
/* Error Message Container */
.error-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    background-color: var(--color-danger);
    color: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    max-width: 90%;
    min-width: 300px;
    text-align: center;
    transition: all 0.3s ease;
    opacity: 1;
}

.error-container.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(-20px);
}

.error-message {
    word-break: break-word;
}

:root {
    --color-primary: #007bff;
    --color-secondary: #6c757d;
    --color-success: #28a745;
    --color-danger: #dc3545;
    --color-background: #f8f9fa;
    --color-text: #212529;
    --color-border: #dee2e6;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-background);
}

.hidden {
    display: none !important;
}

/* App Container */
.app {
    min-height: 100vh;
    display: grid;
}

/* Login Screen */
.login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.login__container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
}

.login__title {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--color-primary);
}

.login__form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login__input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.login__label {
    font-weight: 500;
}

.login__input {
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 1rem;
}

.login__button {
    padding: 0.75rem;
    background-color: var(--color-primary);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.login__button:hover {
    background-color: #0056b3;
}

/* Chat Screen */
.chat {
    display: grid;
    grid-template-areas:
        "header header"
        "main sidebar";
    grid-template-columns: 1fr 250px;
    grid-template-rows: auto 1fr;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
}

.chat__header {
    grid-area: header;
    background-color: white;
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat__title-container {
    display: flex;
    align-items: baseline;
    gap: 1rem;
}

.chat__title {
    color: var(--color-primary);
    margin: 0;
}

.chat__room-name {
    color: var(--color-secondary);
    font-size: 1.1rem;
}

.chat__status {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
}

.chat__connection-status {
    color: var(--color-success);
}

.chat__main {
    grid-area: main;
    display: flex;
    flex-direction: column;
    background-color: white;
    border-right: 1px solid var(--color-border);
    overflow: hidden;
    height: 100%;
}

.chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
    scroll-behavior: smooth;
}

.chat__input-form {
    padding: 1rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 0.5rem;
}

.chat__input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 1rem;
}

.chat__send-button {
    padding: 0.75rem 1.5rem;
    background-color: var(--color-primary);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.chat__send-button:hover {
    background-color: #0056b3;
}

.chat__sidebar {
    grid-area: sidebar;
    background-color: white;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
    max-height: calc(100vh - 60px); /* Account for header */
}

.chat__sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat__sidebar-title {
    color: var(--color-secondary);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.chat__room-info {
    font-size: 0.9rem;
    color: var(--color-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat__room-info code {
    background-color: var(--color-background);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
    color: var(--color-primary);
}

.chat__participants {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Message Styles (will be created dynamically) */
.message {
    display: flex;
    margin: 0.5rem 0;
    max-width: 80%;
}

.message--self {
    align-self: flex-end;
    margin-left: auto;
}

.message--other {
    align-self: flex-start;
    margin-right: auto;
}

.message--system {
    background-color: transparent;
    color: var(--color-secondary);
    font-style: italic;
    align-self: center;
    text-align: center;
    max-width: 100%;
    padding: 0.5rem 1rem;
    border-radius: 0;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
}

.message--system .message__content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.message--system .message__time {
    display: none;
}

.message__content-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.message__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 500;
    flex-shrink: 0;
    cursor: help;
    transition: transform 0.2s;
}

.message__avatar:hover {
    transform: scale(1.1);
}

.message__container {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.message__content {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.message--self .message__content {
    border-bottom-right-radius: 4px;
    color: white;
}

.message--other .message__content {
    border-bottom-left-radius: 4px;
    color: var(--color-text);
}

.message__time {
    font-size: 0.75rem;
    opacity: 0.7;
    margin: 0.25rem 0.5rem 0;
    color: var(--color-secondary);
}

.message--self .message__time {
    text-align: right;
}

.message--self .message__content-wrapper {
    justify-content: flex-end;
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat {
        grid-template-areas:
            "header"
            "main"
            "sidebar";
        grid-template-columns: 1fr;
    }

    .chat__sidebar {
        border-top: 1px solid var(--color-border);
    }
}

/* Utility Classes */
.participant--bot {
    color: var(--color-secondary);
}

.participant--self {
    font-weight: 500;
}
