/* Simple Slack Chat v3.0 */
* { box-sizing: border-box; }

#sc-app {
    display: flex;
    height: 600px;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    position: relative;
}

/* ── SIDEBAR ── */
.sc-sidebar {
    width: 240px;
    background: #3f0e40;
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sc-sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    flex-shrink: 0;
}

.sc-sidebar-top span {
    font-size: 16px;
    font-weight: 700;
}

#sc-close-btn {
    display: none;         /* hidden on desktop */
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
}

#sc-close-btn:hover { background: rgba(255,255,255,0.3); }

#sc-channels {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
    padding: 8px 0;
}

.sc-ch-item {
    padding: 10px 16px;
    cursor: pointer;
    color: rgba(255,255,255,0.75);
    font-size: 15px;
    transition: background 0.15s;
}
.sc-ch-item:hover  { background: rgba(255,255,255,0.1); color:#fff; }
.sc-ch-item.active { background: #1264a3; color: #fff; }

.sc-sidebar-footer {
    flex-shrink: 0;
    padding: 10px;
    border-top: 1px solid rgba(255,255,255,0.15);
}

#sc-new-channel {
    width: 100%;
    padding: 12px;
    background: #00cc44;
    color: #000;
    font-size: 15px;
    font-weight: 800;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
#sc-new-channel:hover { background: #00aa33; }

/* ── MEMBERS SECTION ── */
.sc-members-section {
    border-top: 1px solid rgba(255,255,255,0.15);
    flex-shrink: 0;
    max-height: 40%;
    display: flex;
    flex-direction: column;
}

.sc-members-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 700;
}

#sc-invite-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}
#sc-invite-btn:hover { background: rgba(255,255,255,0.2); }

#sc-members-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.sc-member-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 16px;
    color: rgba(255,255,255,0.85);
    font-size: 14px;
}

.sc-member-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.sc-member-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── OVERLAY (mobile) ── */
.sc-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 998;
}
.sc-overlay.show { display: block; }

/* ── MAIN ── */
.sc-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #fff;
}

.sc-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

#sc-menu-btn {
    display: none;
    background: #f0f0f0;
    border: 1px solid #ddd;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 4px;
}
#sc-menu-btn:hover { background: #e0e0e0; }

#sc-chan-title {
    font-size: 17px;
    font-weight: 700;
    color: #1d1c1d;
}

/* ── MESSAGES ── */
#sc-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
    background: #f8f8f8;
    min-height: 0;
}

.sc-msg-wrap {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    position: relative;
}

.sc-msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.sc-msg-body { flex: 1; min-width: 0; }

.sc-msg-meta {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 3px;
}

.sc-msg-author {
    font-weight: 700;
    color: #1d1c1d;
    font-size: 14px;
}

.sc-msg-time {
    font-size: 11px;
    color: #888;
}

.sc-pin-badge {
    font-size: 11px;
    color: #fff;
    background: #e8a900;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
}

.sc-edited-badge {
    font-size: 11px;
    color: #aaa;
    font-style: italic;
}

.sc-reply-preview {
    background: #e8f0fe;
    border-left: 3px solid #1264a3;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: #555;
    margin-bottom: 4px;
}

.sc-msg-text {
    font-size: 15px;
    color: #1d1c1d;
    line-height: 1.5;
    word-wrap: break-word;
}

/* Message action bar – shows on hover */
.sc-msg-actions {
    display: none;
    position: absolute;
    top: -8px;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 4px 8px;
    gap: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    z-index: 10;
}

.sc-msg-wrap:hover .sc-msg-actions { display: flex; }

.sc-act-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s;
    color: #555;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
}
.sc-act-btn:hover { background: #f0f0f0; color: #000; }
.sc-act-btn.liked { 
    background: #e01e5a; 
    color: #fff; 
}
.sc-act-btn.liked:hover { 
    background: #c01a4a; 
}

/* Like count */
.sc-like-count {
    font-size: 12px;
    color: #666;
    background: #f0f0f0;
    padding: 3px 8px;
    border-radius: 12px;
    margin-top: 3px;
    display: none;
    font-weight: 600;
}
.sc-like-count.show { display: inline-block; }

/* ── REPLY BAR ── */
.sc-reply-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #e8f0fe;
    border-left: 3px solid #1264a3;
    padding: 6px 12px;
    font-size: 13px;
    color: #333;
    flex-shrink: 0;
}
#sc-reply-cancel {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    padding: 2px 6px;
}

/* ── INPUT BAR ── */
.sc-inputbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
    background: #fff;
}

#sc-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 15px;
    outline: none;
}
#sc-input:focus { border-color: #1264a3; }

.sc-icon-btn {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 20px;
    padding: 8px 10px;
    cursor: pointer;
    flex-shrink: 0;
}
.sc-icon-btn:hover { background: #e0e0e0; }

#sc-send-btn {
    background: #007a5a;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 10px 18px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
}
#sc-send-btn:hover    { background: #006644; }
#sc-send-btn:disabled { background: #ccc; cursor: not-allowed; }

/* ── MODAL ── */
.sc-modal-bg {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.sc-modal {
    background: #fff;
    border-radius: 10px;
    padding: 28px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.sc-modal h3 { margin: 0 0 18px; font-size: 20px; }
.sc-modal input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 15px;
    margin-bottom: 12px;
}
.sc-modal input:focus { outline: none; border-color: #1264a3; }
.sc-modal-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.sc-btn-cancel { padding: 10px 18px; border: 1px solid #ccc; border-radius: 6px; background: #f8f8f8; cursor: pointer; font-size: 14px; }
.sc-btn-ok     { padding: 10px 18px; border: none; border-radius: 6px; background: #007a5a; color: #fff; cursor: pointer; font-size: 14px; font-weight: 700; }

.sc-empty { text-align: center; color: #aaa; padding: 40px 20px; font-size: 15px; }
.sc-empty-sm { text-align: center; color: #aaa; padding: 12px; font-size: 13px; }

/* User search results */
#sc-user-results {
    max-height: 300px;
    overflow-y: auto;
    margin: 12px 0;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}

.sc-user-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
}
.sc-user-result:last-child { border-bottom: none; }

.sc-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.sc-user-info {
    flex: 1;
    min-width: 0;
}

.sc-user-name {
    font-weight: 600;
    font-size: 14px;
    color: #1d1c1d;
}

.sc-user-email {
    font-size: 12px;
    color: #888;
}

.sc-add-user-btn {
    padding: 6px 14px;
    font-size: 13px;
}

/* ══════════════════════════════════
   MOBILE  ≤ 768 px
══════════════════════════════════ */
@media (max-width: 768px) {
    #sc-app {
        height: 100svh;          /* use small viewport height */
        height: 100vh;
        border: none;
        border-radius: 0;
    }

    /* Sidebar slides in from left */
    .sc-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: 260px;
        transform: translateX(-100%);
        transition: transform 0.28s ease;
        z-index: 999;
    }
    .sc-sidebar.open { transform: translateX(0); }

    /* Show close (✕) and menu (☰) buttons on mobile */
    #sc-close-btn  { display: flex; align-items: center; justify-content: center; }
    #sc-menu-btn   { display: block; }

    /* Add Channel button bigger on mobile */
    #sc-new-channel {
        padding: 15px;
        font-size: 16px;
    }

    /* Input bar: input + send button */
    .sc-inputbar {
        flex-wrap: nowrap;
        padding: 10px;
        gap: 8px;
        width: 100%;
        box-sizing: border-box;
    }
    #sc-input {
        flex: 1;
        min-width: 0;
        font-size: 16px;   /* prevent iOS zoom */
    }
    #sc-send-btn {
        flex: 0 0 auto;
        width: 100px;
        height: 48px;
        padding: 10px;
        font-size: 16px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: clip;
    }

    /* Message actions always visible (no hover needed) */
    .sc-msg-actions {
        display: flex;
        position: static;
        background: none;
        border: none;
        box-shadow: none;
        padding: 0;
        margin-top: 4px;
        flex-wrap: wrap;
    }

    .sc-act-btn { font-size: 11px; padding: 3px 6px; background: #f0f0f0; border-radius: 12px; }
}
