/* =====================================================
   Global reset
   ===================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;

    margin: 0;
    padding: 0;

    overflow: hidden;

    background: #111;
    color: #e0e0e0;

    font-family:
        Arial,
        Helvetica,
        sans-serif;
}

button,
input {
    font: inherit;
}


/* =====================================================
   Main chat layout
   ===================================================== */

.chat-container {
    display: flex;
    flex-direction: column;

    width: 100%;
    height: 100%;

    min-width: 0;
    min-height: 0;

    overflow: hidden;

    background: #313338;
    color: #dbdee1;
}


/* =====================================================
   Chat header
   ===================================================== */

.chat-header {
    display: flex;
    flex: 0 0 auto;

    align-items: center;
    justify-content: space-between;

    min-height: 58px;
    padding: 8px 14px;

    border-bottom:
        1px solid rgba(0, 0, 0, 0.35);

    background: #2b2d31;

    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.025);
}

.chat-header-info {
    display: flex;
    align-items: center;

    min-width: 0;
    gap: 10px;
}

.chat-status-dot {
    flex: 0 0 auto;

    width: 10px;
    height: 10px;

    border-radius: 50%;

    background: #23a559;

    box-shadow:
        0 0 8px rgba(35, 165, 89, 0.55);
}

.chat-title {
    margin: 0;

    color: #f2f3f5;

    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
}

.chat-subtitle {
    margin: 3px 0 0;

    color: #949ba4;

    font-size: 11px;
    line-height: 1.2;
}


/* =====================================================
   Message list
   ===================================================== */

.chat-messages {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;

    min-width: 0;
    min-height: 0;

    padding: 14px 12px 18px;

    overflow-x: hidden;
    overflow-y: auto;

    background: #313338;

    scroll-behavior: smooth;
    scrollbar-color: #1e1f22 #2b2d31;
    scrollbar-width: thin;
}

.chat-messages::-webkit-scrollbar {
    width: 10px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #2b2d31;
}

.chat-messages::-webkit-scrollbar-thumb {
    border: 2px solid #2b2d31;
    border-radius: 10px;

    background: #1e1f22;
}

.chat-empty {
    margin: auto;
    padding: 20px;

    color: #949ba4;

    font-size: 13px;
    text-align: center;
}


/* =====================================================
   Message rows
   ===================================================== */

.chat-message {
    display: grid;

    grid-template-columns:
        38px
        minmax(0, 1fr);

    gap: 12px;

    width: 100%;
    padding: 10px 12px;

    border-radius: 8px;
    transition: background 150ms ease;
}

.chat-message:hover {
    background:
        rgba(0, 0, 0, 0.15);
}

.chat-message + .chat-message {
    margin-top: 3px;
}

.chat-avatar {
    display: grid;
    place-items: center;

    width: 38px;
    height: 38px;

    border-radius: 50%;

    background: linear-gradient(135deg, #5865f2, #4752c4);
    color: #fff;

    font-size: 13px;
    font-weight: 700;

    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.chat-avatar img {
    width: 100%;
    height: 100%;

    object-fit: cover;
}

.chat-message-body {
    min-width: 0;
}

.chat-message-header {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;

    gap: 8px;
    margin-bottom: 4px;
}

.chat-username {
    color: #f2f3f5;

    font-size: 13px;
    font-weight: 700;
}

.chat-timestamp {
    color: #949ba4;

    font-size: 10px;
    white-space: nowrap;
}

.chat-message-text {
    color: #dbdee1;

    font-size: 13.5px;
    line-height: 1.5;

    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.chat-message-text a {
    color: #00a8fc;
    text-decoration: none;
}

.chat-message-text a:hover {
    text-decoration: underline;
}


/* =====================================================
   Own messages
   ===================================================== */

.chat-message.own-message {
    border-left:
        3px solid #5865f2;

    background:
        rgba(88, 101, 242, 0.06);
}

.chat-message.own-message:hover {
    background:
        rgba(88, 101, 242, 0.1);
}


/* =====================================================
   System messages
   ===================================================== */

.chat-message.system-message {
    display: block;

    margin: 6px 0;
    padding: 8px 12px;

    border-left:
        3px solid #686b74;

    border-radius: 6px;
    background: #2b2d31;
    color: #b5bac1;

    font-size: 11.5px;
    font-style: italic;
}


/* =====================================================
   Shared GIFs and images
   ===================================================== */

.chat-message-image,
.chat-gif {
    display: block;

    width: auto;
    max-width: min(420px, 100%);
    max-height: 320px;

    margin-top: 8px;

    object-fit: contain;

    border-radius: 8px;

    background: #1e1f22;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}


/* =====================================================
   Shared media and file cards
   ===================================================== */

.chat-media-card,
.chat-file-card {
    display: flex;
    align-items: center;

    width: min(420px, 100%);

    margin-top: 8px;
    padding: 10px 14px;

    overflow: hidden;

    border:
        1px solid rgba(255, 255, 255, 0.06);

    border-radius: 8px;

    background: #2b2d31;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    gap: 12px;
}

.chat-file-icon {
    display: grid;
    place-items: center;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    background: #1e1f22;
    border-radius: 6px;
    font-size: 18px;
}

.chat-file-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
}

.chat-file-link {
    color: #00a8fc;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-file-link:hover {
    text-decoration: underline;
}

.chat-file-size {
    color: #949ba4;
    font-size: 11px;
}

.chat-card-title {
    overflow: hidden;

    color: #f2f3f5;

    font-size: 12px;
    font-weight: 700;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-card-meta {
    margin-top: 4px;

    color: #949ba4;

    font-size: 10px;
}

.chat-card-actions {
    display: flex;
    flex-wrap: wrap;

    gap: 6px;
    margin-top: 8px;
}

.chat-card-button {
    padding: 6px 10px;

    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;

    background: #4e5058;
    color: #dbdee1;

    cursor: pointer;

    font-size: 11.5px;
    font-weight: 600;
    transition: background 120ms ease;
}

.chat-card-button:hover {
    background: #686b74;
    color: #fff;
}


/* =====================================================
   Chat input area (Buttons aligned cleanly to the right)
   ===================================================== */

.chat-input-area {
    display: flex;
    flex: 0 0 auto;
    align-items: center;

    gap: 8px;
    padding: 12px 14px;

    border-top:
        1px solid rgba(0, 0, 0, 0.35);

    background: #2b2d31;
}

.message-input-wrapper {
    flex: 1 1 auto;
    min-width: 0;

    border:
        1px solid transparent;

    border-radius: 8px;

    background: #383a40;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.message-input-wrapper:focus-within {
    border-color: #5865f2;
    box-shadow: 0 0 0 2px rgba(88, 101, 242, 0.2);
}

.message-input {
    width: 100%;
    height: 40px;

    padding: 0 14px;

    border: 0;
    outline: 0;

    background: transparent;
    color: #f2f3f5;

    font-size: 13.5px;
}

.message-input::placeholder {
    color: #949ba4;
}


/* =====================================================
   Chat input buttons (Grouped cleanly on the right)
   ===================================================== */

.chat-input-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.chat-action-button {
    height: 40px;
    min-width: 44px;

    padding: 0 12px;

    border: 0;
    border-radius: 8px;

    cursor: pointer;

    font-size: 12.5px;
    font-weight: 600;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    transition:
        background 120ms ease,
        opacity 120ms ease,
        transform 120ms ease;
}

.chat-action-button:active {
    transform: translateY(1px);
}

.gif-button,
.file-button {
    border:
        1px solid rgba(255, 255, 255, 0.08);

    background: #383a40;
    color: #b5bac1;
}

.gif-button:hover,
.file-button:hover {
    background: #4e5058;
    color: #fff;
}

.send-button {
    background: #5865f2;
    color: #fff;
    box-shadow: 0 2px 6px rgba(88, 101, 242, 0.3);
}

.send-button:hover {
    background: #4752c4;
}

.chat-action-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}


/* =====================================================
   Mention and highlight styling
   ===================================================== */

.chat-mention {
    padding: 1px 4px;

    border-radius: 4px;

    background:
        rgba(88, 101, 242, 0.25);

    color: #c9cdfb;
    font-weight: 500;
}

.chat-message.mentioned {
    border-left:
        3px solid #f0b232;

    background:
        rgba(240, 178, 50, 0.06);
}


/* =====================================================
   Responsive layout
   ===================================================== */

@media (max-width: 520px) {
    .chat-header {
        min-height: 52px;
        padding: 7px 10px;
    }

    .chat-messages {
        padding:
            10px
            8px
            14px;
    }

    .chat-input-area {
        gap: 6px;
        padding: 10px;
    }

    .chat-action-button {
        height: 38px;
        min-width: 38px;
        padding: 0 10px;

        font-size: 11px;
    }

    .chat-message {
        grid-template-columns:
            32px
            minmax(0, 1fr);

        gap: 8px;
        padding: 8px 6px;
    }

    .chat-avatar {
        width: 32px;
        height: 32px;

        font-size: 11px;
    }

    .chat-unread-badge {
        display: inline-grid;
        place-items: center;

        min-width: 18px;
        height: 18px;

        margin-left: 5px;
        padding: 0 5px;

        border-radius: 20px;

        background: #ed4245;
        color: #fff;

        font-size: 10px;
        font-weight: 700;
    }
}
