/* ============================================
   غلام‌رسان — صفحه‌ی اصلی چت
   وابسته به variables.css (باید قبلش لود بشه)
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--night);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

.app {
    display: grid;
    grid-template-columns: 300px 1fr;
    height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    background: var(--night-2);
    border-left: 1px solid var(--line);
    display: flex;
    flex-direction: column;
}

.brand-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 28px 22px 20px;
    border-bottom: 1px solid var(--line);
}

.brand h1 {
    font-family: 'Estedad', sans-serif;
    font-weight: 800;
    font-size: 28px;
    color: var(--accent);
    letter-spacing: 0.5px;
}

.brand p {
    font-size: 12.5px;
    color: var(--muted);
    margin-top: 4px;
}

.new-group-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--night);
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
    transition: border-color 0.15s ease;
}

.new-group-btn:hover {
    border-color: var(--accent);
}

.new-group-btn svg {
    width: 17px;
    height: 17px;
}

.search {
    margin: 16px 22px;
    padding: 10px 14px;
    background: var(--night);
    border: 1px solid var(--line);
    border-radius: 10px;
    font-family: 'Estedad', sans-serif;
    color: var(--text);
    font-size: 13px;
}

.search::placeholder {
    color: var(--muted);
}

.convo-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 12px;
}

.convo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 10px;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    transition: background 0.15s ease;
}

.convo:hover {
    background: var(--night-3);
}

.convo.active {
    background: var(--accent-dim);
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--steel);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Estedad', sans-serif;
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
    flex-shrink: 0;
    position: relative;
}

.seal-dot {
    position: absolute;
    bottom: -1px;
    left: -1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--night-2);
}

.convo-info {
    flex: 1;
    min-width: 0;
}

.convo-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.convo-snippet {
    font-size: 12.5px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.convo-time {
    font-size: 11px;
    color: var(--muted);
    flex-shrink: 0;
}

/* ---------- Main chat ---------- */
.main {
    display: flex;
    flex-direction: column;
    background: radial-gradient(ellipse at top left, #16233d 0%, var(--night) 55%);
}

.chat-header {
    padding: 18px 28px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 14px;
}

.chat-header .avatar {
    width: 38px;
    height: 38px;
    font-size: 15px;
}

.chat-header-name {
    font-size: 15px;
    font-weight: 600;
}

.chat-header-status {
    font-size: 12px;
    color: var(--accent);
    margin-top: 2px;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.msg-row {
    display: flex;
}

.msg-row.mine {
    justify-content: flex-start;
}

.msg-row.theirs {
    justify-content: flex-end;
}

.msg {
    max-width: 420px;
    padding: 12px 16px 20px;
    font-size: 14px;
    line-height: 1.7;
    position: relative;
}

.msg.mine {
    background: var(--paper);
    color: var(--night);
    border-radius: 14px 14px 4px 14px;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 16px 100%, 0 calc(100% - 16px));
}

.msg.theirs {
    background: var(--night-2);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 14px 14px 14px 4px;
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%);
}

.postmark {
    position: absolute;
    bottom: 5px;
    left: 16px;
    font-size: 10px;
    letter-spacing: 0.3px;
}

.msg.mine .postmark {
    color: var(--muted);
}

.msg.theirs .postmark {
    color: var(--muted);
    right: 16px;
    left: auto;
}

.composer {
    padding: 18px 28px 24px;
    border-top: 1px solid var(--line);
    display: flex;
    gap: 12px;
    align-items: center;
}

.composer input {
    flex: 1;
    background: var(--night-2);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 13px 20px;
    color: var(--text);
    font-family: 'Estedad', sans-serif;
    font-size: 14px;
}

.composer input::placeholder {
    color: var(--muted);
}

.send-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.send-btn svg {
    width: 19px;
    height: 19px;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 3px;
}

/* ---------- Responsive ---------- */
.back-btn {
    display: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: var(--night-2);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.back-btn svg {
    width: 18px;
    height: 18px;
}

@media (max-width: 860px) {
    .app {
        grid-template-columns: 1fr;
        position: relative;
    }

    .sidebar {
        position: absolute;
        inset: 0;
        z-index: 2;
        transition: transform 0.25s ease;
    }

    .main {
        position: absolute;
        inset: 0;
        z-index: 1;
        transform: translateX(100%);
        transition: transform 0.25s ease;
    }

    .app.show-chat .sidebar {
        transform: translateX(100%);
    }

    .app.show-chat .main {
        transform: translateX(0);
    }

    .back-btn {
        display: flex;
    }

    .messages {
        padding: 20px 16px;
    }

    .msg {
        max-width: 78%;
    }

    .chat-header {
        padding: 14px 16px;
    }

    .composer {
        padding: 14px 16px 18px;
    }

    .brand-row {
        padding: 20px 18px 16px;
    }

    .brand h1 {
        font-size: 24px;
    }

    .search {
        margin: 12px 18px;
    }
}

@media (max-width: 420px) {
    .msg {
        max-width: 88%;
        font-size: 13.5px;
    }

    .convo-snippet {
        max-width: 160px;
    }
}

/* ---------- Group creation modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: #060a13cc;
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    width: 400px;
    max-width: 90vw;
    max-height: 86vh;
    overflow-y: auto;
    background: var(--night-2);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 26px 24px 24px;
    transform: translateY(10px);
    transition: transform 0.2s ease;
}

.modal-overlay.open .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
}

.modal-header h2 {
    font-family: 'Estedad', sans-serif;
    font-weight: 800;
    font-size: 19px;
    color: var(--text);
}

.modal-close {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close svg {
    width: 18px;
    height: 18px;
}

.group-avatar-picker {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
    cursor: pointer;
}

.group-avatar-circle {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: var(--night);
    border: 1.5px dashed var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
}

.group-avatar-circle svg {
    width: 24px;
    height: 24px;
}

.group-avatar-picker span {
    font-size: 12px;
    color: var(--muted);
}

.member-list {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.member-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 6px;
    border-radius: 10px;
    cursor: pointer;
}

.member-row:hover {
    background: var(--night-3);
}

.member-row .avatar {
    width: 34px;
    height: 34px;
    font-size: 13px;
}

.member-name {
    flex: 1;
    font-size: 13.5px;
    color: var(--text);
}

.member-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.submit-btn-modal {
    width: 100%;
    margin-top: 22px;
    padding: 13px;
    border: none;
    border-radius: 12px;
    background: var(--accent);
    color: var(--night);
    font-family: 'Estedad', sans-serif;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-size: 12.5px;
    color: var(--muted);
    margin-bottom: 7px;
}

.field input[type="text"] {
    width: 100%;
    background: var(--night);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    color: var(--text);
    font-family: 'Estedad', sans-serif;
    font-size: 13.5px;
}

.field input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}