/* ==========================================================================
   Communication module — Komunikacja
   Slack/Teams-style messaging layout
   ========================================================================== */

.comm-app {
    display: flex;
    height: calc(100vh - 64px);
    background: #F8FAFC;
    font-family: 'Inter', sans-serif;
}

[data-theme="light"] .comm-app {
    background: #F8FAFC;
}

/* ===== Left sidebar ===== */
.comm-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: #FFFFFF;
    border-right: 1px solid #E2E8F0;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.comm-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.comm-sidebar-title {
    font-size: 20px;
    font-weight: 600;
    color: #0F172A;
    margin: 0;
}

.comm-add-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #E2E8F0;
    background: #FFFFFF;
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}

.comm-add-btn:hover {
    background: #F8FAFC;
    color: #2563EB;
}

.comm-section-label {
    font-size: 14px;
    font-weight: 500;
    color: #64748B;
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: .02em;
}

.comm-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.comm-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background .15s;
}

.comm-item:hover {
    background: #F8FAFC;
}

.comm-item.active {
    background: #EFF6FF;
    border-left-color: #2563EB;
}

.comm-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #2563EB;
    color: #FFFFFF;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.comm-avatar.lg {
    width: 40px;
    height: 40px;
    font-size: 15px;
}

.comm-avatar.sm {
    width: 24px;
    height: 24px;
    font-size: 11px;
}

.comm-item-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.comm-item-name {
    font-size: 14px;
    font-weight: 500;
    color: #0F172A;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.comm-item-preview {
    font-size: 13px;
    color: #94A3B8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.comm-badge {
    background: #2563EB;
    color: #FFFFFF;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.comm-channel-hash {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #F1F5F9;
    color: #475569;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.comm-item.active .comm-channel-hash {
    background: #DBEAFE;
    color: #2563EB;
}

.comm-cta {
    width: 100%;
    height: 40px;
    background: #2563EB;
    color: #FFFFFF;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: auto;
    transition: background .15s;
}

.comm-cta:hover {
    background: #1D4ED8;
}

/* ===== Main chat column ===== */
.comm-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #F8FAFC;
}

.comm-chat-head {
    height: 64px;
    background: #FFFFFF;
    border-bottom: 1px solid #E2E8F0;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.comm-chat-title {
    font-size: 16px;
    font-weight: 600;
    color: #0F172A;
    margin: 0;
}

.comm-chat-sub {
    font-size: 13px;
    color: #64748B;
}

.comm-chat-head-text {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.comm-chat-actions {
    display: flex;
    gap: 8px;
}

.comm-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid #E2E8F0;
    background: #FFFFFF;
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}

.comm-icon-btn:hover {
    background: #F8FAFC;
    color: #2563EB;
}

.comm-icon-btn.active {
    background: #EFF6FF;
    color: #2563EB;
    border-color: #BFDBFE;
}

/* ===== Message list ===== */
.comm-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.comm-message {
    display: flex;
    gap: 12px;
    max-width: 720px;
}

.comm-message.own {
    margin-left: auto;
    flex-direction: row-reverse;
}

.comm-message-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.comm-message-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.comm-message.own .comm-message-head {
    flex-direction: row-reverse;
}

.comm-message-name {
    font-size: 14px;
    font-weight: 500;
    color: #0F172A;
}

.comm-message-time {
    font-size: 12px;
    color: #94A3B8;
}

.comm-message-bubble {
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 15px;
    color: #0F172A;
    line-height: 1.5;
}

.comm-message.own .comm-message-bubble {
    background: #DBEAFE;
    border-color: #BFDBFE;
}

.comm-system {
    text-align: center;
    font-size: 13px;
    color: #64748B;
    padding: 8px 0;
}

/* ===== Input area ===== */
.comm-input-wrap {
    min-height: 120px;
    background: #FFFFFF;
    border-top: 1px solid #E2E8F0;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.comm-textarea {
    width: 100%;
    min-height: 60px;
    resize: none;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    padding: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    color: #0F172A;
    background: #F8FAFC;
    outline: none;
    transition: border-color .15s;
}

.comm-textarea:focus {
    border-color: #2563EB;
    background: #FFFFFF;
}

.comm-input-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.comm-input-tools {
    display: flex;
    gap: 4px;
}

.comm-tool-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: #64748B;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}

.comm-tool-btn:hover {
    background: #F1F5F9;
    color: #2563EB;
}

.comm-send {
    margin-left: auto;
    padding: 8px 18px;
    background: #2563EB;
    color: #FFFFFF;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background .15s;
}

.comm-send:hover {
    background: #1D4ED8;
}

/* ===== Right details column ===== */
.comm-details {
    width: 320px;
    flex-shrink: 0;
    background: #FFFFFF;
    border-left: 1px solid #E2E8F0;
    padding: 24px;
    overflow-y: auto;
    display: none;
    flex-direction: column;
    gap: 24px;
}

.comm-details.open {
    display: flex;
}

.comm-details-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: #0F172A;
    margin: 0 0 12px;
    text-transform: uppercase;
    letter-spacing: .02em;
}

.comm-details-field {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #F1F5F9;
    font-size: 14px;
}

.comm-details-field:last-child {
    border-bottom: none;
}

.comm-details-label {
    color: #64748B;
}

.comm-details-value {
    color: #0F172A;
    font-weight: 500;
}

.comm-members {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comm-member {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #0F172A;
}

.comm-add-member {
    margin-top: 8px;
    padding: 8px 12px;
    background: #F8FAFC;
    border: 1px dashed #CBD5E1;
    border-radius: 8px;
    color: #2563EB;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s;
}

.comm-add-member:hover {
    background: #EFF6FF;
}

.comm-files {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comm-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 8px;
    font-size: 13px;
    transition: background .15s;
    cursor: pointer;
}

.comm-file:hover {
    background: #F8FAFC;
}

.comm-file-name {
    flex: 1;
    color: #0F172A;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.comm-file-date {
    font-size: 12px;
    color: #94A3B8;
}

.comm-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comm-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #F8FAFC;
    border-radius: 8px;
    font-size: 13px;
    color: #0F172A;
    text-decoration: none;
    transition: background .15s;
}

.comm-link:hover {
    background: #EFF6FF;
    color: #2563EB;
}

.comm-link-label {
    color: #64748B;
    font-size: 12px;
    margin-right: 4px;
}

/* ===== New message modal ===== */
.comm-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.comm-modal-overlay.open {
    display: flex;
}

.comm-modal {
    width: 600px;
    max-width: 100%;
    background: #FFFFFF;
    border-radius: 16px;
    overflow: hidden;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.comm-modal-header {
    padding: 24px 32px;
    border-bottom: 1px solid #E2E8F0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.comm-modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #0F172A;
    margin: 0;
}

.comm-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #64748B;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.comm-modal-close:hover {
    background: #F1F5F9;
    color: #0F172A;
}

.comm-modal-body {
    padding: 32px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.comm-form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    margin-bottom: 6px;
}

.comm-select,
.comm-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: #0F172A;
    background: #FFFFFF;
    outline: none;
    transition: border-color .15s;
}

.comm-select:focus,
.comm-input:focus {
    border-color: #2563EB;
}

.comm-modal-textarea {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    padding: 12px;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: #0F172A;
    background: #FFFFFF;
    outline: none;
}

.comm-modal-textarea:focus {
    border-color: #2563EB;
}

.comm-upload {
    padding: 24px;
    border: 2px dashed #CBD5E1;
    border-radius: 8px;
    text-align: center;
    color: #64748B;
    font-size: 13px;
    cursor: pointer;
    transition: border-color .15s, color .15s;
}

.comm-upload:hover {
    border-color: #2563EB;
    color: #2563EB;
}

.comm-modal-footer {
    padding: 16px 32px;
    border-top: 1px solid #E2E8F0;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ===== Responsive ===== */
@media (max-width: 1200px) {
    .comm-details {
        width: 280px;
    }
}

@media (max-width: 1024px) {
    .comm-details {
        display: none !important;
    }
    .comm-sidebar {
        width: 240px;
        padding: 16px;
    }
}

@media (max-width: 768px) {
    .comm-app {
        height: calc(100vh - 56px);
    }
    .comm-sidebar {
        display: none;
    }
    .comm-sidebar.mobile-open {
        display: flex;
        position: fixed;
        inset: 56px 0 0 0;
        width: 100%;
        z-index: 100;
    }
    .comm-chat-head {
        padding: 0 16px;
    }
    .comm-messages {
        padding: 16px;
    }
    .comm-input-wrap {
        padding: 12px;
    }
    .comm-modal {
        border-radius: 12px;
    }
    .comm-modal-header,
    .comm-modal-body,
    .comm-modal-footer {
        padding-left: 20px;
        padding-right: 20px;
    }
}

/* ===== Dark theme ===== */
[data-theme="dark"] .comm-app,
[data-theme="dark"] .comm-main {
    background: #0F172A;
}

[data-theme="dark"] .comm-sidebar,
[data-theme="dark"] .comm-chat-head,
[data-theme="dark"] .comm-input-wrap,
[data-theme="dark"] .comm-details,
[data-theme="dark"] .comm-modal {
    background: #1E293B;
    border-color: #334155;
}

[data-theme="dark"] .comm-sidebar-title,
[data-theme="dark"] .comm-chat-title,
[data-theme="dark"] .comm-item-name,
[data-theme="dark"] .comm-message-name,
[data-theme="dark"] .comm-message-bubble,
[data-theme="dark"] .comm-details-value,
[data-theme="dark"] .comm-member,
[data-theme="dark"] .comm-file-name,
[data-theme="dark"] .comm-modal-title,
[data-theme="dark"] .comm-details-section h4 {
    color: #F1F5F9;
}

[data-theme="dark"] .comm-message-bubble {
    background: #1E293B;
    border-color: #334155;
}

[data-theme="dark"] .comm-message.own .comm-message-bubble {
    background: #1D4ED8;
    border-color: #2563EB;
    color: #FFFFFF;
}

[data-theme="dark"] .comm-item:hover,
[data-theme="dark"] .comm-icon-btn:hover,
[data-theme="dark"] .comm-add-btn:hover,
[data-theme="dark"] .comm-file:hover,
[data-theme="dark"] .comm-link:hover,
[data-theme="dark"] .comm-tool-btn:hover {
    background: #334155;
}

[data-theme="dark"] .comm-item.active {
    background: #1E3A8A;
}

[data-theme="dark"] .comm-channel-hash {
    background: #334155;
    color: #CBD5E1;
}

[data-theme="dark"] .comm-item.active .comm-channel-hash {
    background: #1D4ED8;
    color: #FFFFFF;
}

[data-theme="dark"] .comm-textarea,
[data-theme="dark"] .comm-select,
[data-theme="dark"] .comm-input,
[data-theme="dark"] .comm-modal-textarea {
    background: #0F172A;
    border-color: #334155;
    color: #F1F5F9;
}

[data-theme="dark"] .comm-icon-btn,
[data-theme="dark"] .comm-add-btn {
    background: #1E293B;
    border-color: #334155;
    color: #CBD5E1;
}

[data-theme="dark"] .comm-link,
[data-theme="dark"] .comm-add-member {
    background: #0F172A;
}
