
* {
    box-sizing: border-box;
}

:root {
    color-scheme: dark;
    font-family: Tahoma, Arial, sans-serif;
    background: #101722;
    color: #e8edf7;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    background: #101722;
    direction: rtl;
}

button,
input {
    font: inherit;
}

button {
    border: none;
    cursor: pointer;
}

.app-shell {
    width: min(1200px, 100%);
    height: 100vh;
    min-height: 550px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background: #17212e;
    overflow: hidden;
}

/* Top bar */

.topbar {
    height: 70px;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    background: #202c3b;
    border-bottom: 1px solid #2c3a4d;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon,
.welcome-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #5278d8;
    color: white;
    font-weight: bold;
    border-radius: 50%;
}

.brand-icon {
    width: 42px;
    height: 42px;
    font-size: 21px;
}

.brand h1 {
    margin: 0;
    font-size: 17px;
}

.brand p {
    margin: 4px 0 0;
    color: #93a5bc;
    font-size: 11px;
}

.connection-status {
    color: #aab8cb;
    font-size: 12px;
}

.connection-status.connected {
    color: #6dd7a0;
}

/* Login */

.login-view {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.login-card {
    width: min(100%, 390px);
    padding: 30px;
    background: #202c3b;
    border: 1px solid #304056;
    border-radius: 14px;
}

.login-card h2 {
    margin-top: 0;
    font-size: 22px;
}

.login-card > p {
    color: #9eafc4;
    font-size: 13px;
    line-height: 1.8;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 11px;
    margin-top: 25px;
}

#login-form label {
    color: #c4d0df;
    font-size: 13px;
}

input {
    width: 100%;
    min-width: 0;
    padding: 12px;
    color: #edf3fa;
    background: #17212e;
    border: 1px solid #35465c;
    border-radius: 8px;
    outline: none;
}

input:focus {
    border-color: #668be9;
}

input::placeholder {
    color: #788ba3;
}

#login-button,
.admin-form button,
#send-button {
    padding: 12px 18px;
    color: white;
    background: #5278d8;
    border-radius: 8px;
}

#login-button:hover,
.admin-form button:hover,
#send-button:hover {
    background: #4168cb;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.error {
    color: #ff8585;
    font-size: 12px;
}

.success-text {
    color: #6dd7a0;
    font-size: 12px;
}

/* Main layout */

.chat-layout {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    overflow: hidden;
}

.sidebar {
    grid-column: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    background: #202c3b;
    border-left: 1px solid #304056;
}

.chat-area {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: #17212e;
}

/* Sidebar header */

.sidebar-header {
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid #304056;
}

.sidebar-header h2 {
    margin: 0 0 5px;
    font-size: 16px;
}

.sidebar-header span {
    color: #9eafc4;
    font-size: 11px;
}

.icon-button {
    padding: 8px 12px;
    color: #dce6f3;
    background: #35465c;
    border-radius: 7px;
}

.icon-button:hover,
.small-button:hover {
    background: #465b76;
}

/* Sidebar tabs */

.sidebar-tabs {
    display: flex;
    padding: 8px;
    gap: 6px;
    border-bottom: 1px solid #304056;
}

.tab-button {
    flex: 1;
    padding: 10px;
    color: #aab8cb;
    background: transparent;
    border-radius: 7px;
    font-size: 13px;
}

.tab-button.active {
    color: #ffffff;
    background: #354b6b;
}

/* Conversation and user lists */

.sidebar-panel {
    min-height: 0;
}

.conversation-list {
    display: flex;
    flex-direction: column;
}

.conversation-item {
    width: 100%;
    min-height: 72px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    text-align: right;
    color: #e8edf7;
    background: transparent;
    border-bottom: 1px solid #2b394b;
}

.conversation-item:hover {
    background: #2a394c;
}

.conversation-item.selected {
    background: #354b6b;
}

.list-avatar,
.conversation-avatar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: white;
    background: #5278d8;
    font-weight: bold;
}

.list-avatar {
    width: 43px;
    height: 43px;
}

.conversation-details {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    gap: 7px;
}

.conversation-details strong {
    font-size: 13px;
}

.conversation-details small {
    overflow: hidden;
    color: #98a9be;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.empty-state {
    padding: 20px;
    color: #98a9be;
    text-align: center;
    font-size: 13px;
    line-height: 1.8;
}

/* Admin panel */

#admin-panel {
    margin-top: auto;
    padding: 14px;
    border-top: 1px solid #35465c;
    background: #1b2735;
}

.admin-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

.admin-heading h3 {
    margin: 0;
    font-size: 13px;
}

.admin-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-form input {
    padding: 9px;
    font-size: 11px;
}

.admin-form button {
    padding: 9px;
    font-size: 12px;
}

#admin-message {
    margin: 0;
}

.small-button {
    padding: 7px 9px;
    color: white;
    background: #35465c;
    border-radius: 6px;
    font-size: 10px;
}

.danger {
    background: #a94350;
}

.danger:hover {
    background: #c34d5c;
}

.admin-user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 0;
    border-bottom: 1px solid #304056;
    font-size: 11px;
}

.admin-user-row > span {
    overflow-wrap: anywhere;
}

.admin-user-row > div {
    display: flex;
    gap: 4px;
}

/* Welcome screen */

.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 25px;
    text-align: center;
}

.welcome-icon {
    width: 85px;
    height: 85px;
    font-size: 40px;
}

.welcome-screen h2 {
    margin: 22px 0 8px;
    font-size: 23px;
}

.welcome-screen p {
    max-width: 330px;
    color: #93a5bc;
    font-size: 13px;
    line-height: 1.9;
}

/* Conversation view */

.conversation-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.conversation-header {
    height: 68px;
    min-height: 68px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 17px;
    background: #202c3b;
    border-bottom: 1px solid #304056;
}

.conversation-avatar {
    width: 42px;
    height: 42px;
}

.conversation-heading {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.conversation-heading strong {
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
}

.conversation-heading small {
    color: #91a5bd;
    font-size: 11px;
}

.back-button {
    display: none;
}

/* Messages */

.messages {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px;
    overflow-y: auto;
    background: #17212e;
}

.message {
    width: fit-content;
    max-width: min(78%, 500px);
    padding: 10px 13px;
    border-radius: 12px 12px 12px 3px;
    background: #26384d;
    overflow-wrap: anywhere;
}

.message.own-message {
    align-self: flex-start;
    background: #354f78;
    border-radius: 12px 12px 3px 12px;
}

.message strong {
    display: block;
    margin-bottom: 6px;
    color: #a9c5ff;
    font-size: 11px;
}

.message-delete-button {
    margin-top: 8px;
    padding: 3px 8px;
    border: 1px solid rgba(255, 160, 160, 0.45);
    border-radius: 6px;
    background: transparent;
    color: #ffb5b5;
    font-size: 10px;
    cursor: pointer;
}

.message-delete-button:disabled {
    opacity: 0.55;
    cursor: wait;
}

.message div {
    color: #f0f4fa;
    font-size: 13px;
    line-height: 1.9;
    white-space: pre-wrap;
}

.message small {
    display: block;
    margin-top: 5px;
    color: #a4b5ca;
    font-size: 10px;
    text-align: left;
    direction: ltr;
}

/* Message input */

.message-form {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 72px;
    padding: 12px 16px;
    background: #202c3b;
    border-top: 1px solid #304056;
}

#message-input {
    flex: 1;
    height: 44px;
    padding: 10px 14px;
    border-radius: 22px;
    background: #17212e;
}

#send-button {
    min-width: 76px;
    height: 44px;
    border-radius: 22px;
}

/* File attachments */

#attach-button {
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
}

#attach-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.message-attachment {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
    padding: 9px 11px;
    border: 1px solid #506783;
    border-radius: 9px;
    background: rgba(0, 0, 0, 0.12);
}

.attachment-link {
    color: #a9c5ff;
    font-size: 13px;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.attachment-link:hover {
    text-decoration: underline;
}

.message .attachment-size {
    margin: 0;
    text-align: right;
    direction: ltr;
}


/* Scrollbars */

.sidebar::-webkit-scrollbar,
.messages::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb,
.messages::-webkit-scrollbar-thumb {
    background: #40536c;
    border-radius: 10px;
}

/* Mobile */

@media (max-width: 700px) {
    .app-shell {
        min-height: 100dvh;
        height: 100dvh;
    }

    .topbar {
        height: 58px;
        min-height: 58px;
        padding: 0 13px;
    }

    .brand-icon {
        width: 36px;
        height: 36px;
    }

    .brand h1 {
        font-size: 15px;
    }

    .chat-layout {
        position: relative;
        display: block;
    }

    .sidebar {
        width: 100%;
        height: 100%;
        border: none;
    }

    .sidebar.mobile-hidden {
        display: none;
    }

    .chat-area {
        display: none;
        width: 100%;
        height: 100%;
    }

    .chat-area.mobile-visible {
        display: flex;
    }

    .back-button {
        display: block;
    }

    .message {
        max-width: 88%;
    }

    #admin-panel {
        margin-top: 10px;
    }

    .login-card {
        padding: 23px;
    }
}

@media (min-width: 701px) {
    .back-button {
        display: none;
    }
}

.attachment-image {
    display: block;
    max-width: 100%;
    max-height: 320px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 10px;
    cursor: zoom-in;
}

.message-attachment:has(.attachment-image) {
    align-items: flex-start;
}

.message-attachment:has(.attachment-image) small {
    overflow-wrap: anywhere;
}

