/**
 * NetMkd DeskPortal — Messages CSS
 * Локација: assets/css/messages.css
 */

/* ============================================================
   ГЛАВЕН WRAP
   ============================================================ */

.nmdp-messages-wrap { animation: nmdpFadeIn 0.3s ease; }

.nmdp-messages-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.nmdp-messages-title {
    font-size: 20px;
    font-weight: 800;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.nmdp-messages-title .dashicons {
    font-size: 22px;
    width: 22px;
    height: 22px;
    color: var(--nmdp-primary);
}

.nmdp-messages-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: #ef4444;
    color: #fff;
    border-radius: 11px;
    font-size: 12px;
    font-weight: 700;
}

/* ============================================================
   ЛЕЈАУТ — SIDEBAR + CONTENT
   ============================================================ */

.nmdp-messages-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    min-height: 600px;
}

/* ============================================================
   ЛЕВА КОЛОНА — ЛИСТА
   ============================================================ */

.nmdp-messages-sidebar {
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    background: #fafafa;
}

/* Табови */
.nmdp-messages-tabs {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
}

.nmdp-msg-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 13px 8px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    position: relative;
}

.nmdp-msg-tab:hover { color: var(--nmdp-primary); background: #f8fafc; }

.nmdp-msg-tab.active {
    color: var(--nmdp-primary);
    border-bottom-color: var(--nmdp-primary);
    font-weight: 700;
    background: #fff;
}

.nmdp-msg-tab .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.nmdp-msg-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #ef4444;
    color: #fff;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 700;
}

/* Пребарување */
.nmdp-messages-search {
    position: relative;
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
}

.nmdp-messages-search-icon {
    position: absolute;
    left: 22px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.nmdp-messages-search-input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    color: #1e293b;
    background: #f8fafc;
    font-family: inherit;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.nmdp-messages-search-input:focus {
    outline: none;
    border-color: var(--nmdp-primary);
    background: #ffffff;
}

/* Листа на пораки */
.nmdp-messages-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.1) transparent;
}

.nmdp-messages-list::-webkit-scrollbar { width: 4px; }
.nmdp-messages-list::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 2px; }

/* Ред на порака */
.nmdp-msg-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 14px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.15s ease;
    position: relative;
}

.nmdp-msg-row:hover { background: #f1f5f9; }
.nmdp-msg-row.nmdp-msg-active { background: #eff6ff; border-left: 3px solid var(--nmdp-primary); }
.nmdp-msg-row.nmdp-msg-unread { background: #fafeff; }
.nmdp-msg-row.nmdp-msg-unread:hover { background: #eff6ff; }

.nmdp-msg-row-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--nmdp-primary);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

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

.nmdp-msg-row-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 3px;
}

.nmdp-msg-row-name {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nmdp-msg-row.nmdp-msg-unread .nmdp-msg-row-name { font-weight: 700; }

.nmdp-msg-row-time {
    font-size: 11px;
    color: #94a3b8;
    white-space: nowrap;
    flex-shrink: 0;
}

.nmdp-msg-row-subject {
    font-size: 13px;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.nmdp-msg-row.nmdp-msg-unread .nmdp-msg-row-subject { color: #1e293b; font-weight: 600; }

.nmdp-msg-row-preview {
    font-size: 12px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nmdp-msg-unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--nmdp-primary);
    position: absolute;
    top: 16px;
    right: 12px;
    flex-shrink: 0;
}

/* Пагинација */
.nmdp-messages-pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    padding: 10px;
    border-top: 1px solid #e2e8f0;
    background: #ffffff;
    flex-wrap: wrap;
}

/* Празна листа */
.nmdp-msg-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 20px;
    color: #94a3b8;
    font-size: 14px;
    text-align: center;
}

/* ============================================================
   ДЕСНА КОЛОНА — CONTENT
   ============================================================ */

.nmdp-messages-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #ffffff;
}

/* Празна состојба */
.nmdp-messages-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    height: 100%;
    padding: 40px;
    text-align: center;
    color: #94a3b8;
}

.nmdp-messages-empty-state h3 {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.nmdp-messages-empty-state p {
    font-size: 14px;
    margin: 0;
    max-width: 300px;
}

/* Детален приказ */
.nmdp-message-detail {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.nmdp-message-detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.nmdp-message-detail-subject {
    flex: 1;
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nmdp-message-detail-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.nmdp-message-detail-meta {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    background: #f8fafc;
    flex-shrink: 0;
}

.nmdp-msg-meta-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nmdp-msg-meta-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--nmdp-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.nmdp-message-detail-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.nmdp-msg-body-text {
    font-size: 14px;
    color: #374151;
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.nmdp-message-detail-attachment {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-top: 1px solid #f1f5f9;
    background: #f8fafc;
    font-size: 13px;
    color: #475569;
    flex-shrink: 0;
}

.nmdp-message-detail-attachment .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    color: var(--nmdp-primary);
}

.nmdp-message-detail-attachment a {
    color: var(--nmdp-primary);
    font-weight: 500;
    text-decoration: none;
}

.nmdp-message-detail-attachment a:hover { text-decoration: underline; }

/* ============================================================
   COMPOSE ФОРМА
   ============================================================ */

.nmdp-compose-form {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.nmdp-compose-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.nmdp-compose-title {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.nmdp-compose-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px 20px;
    gap: 12px;
    overflow-y: auto;
}

.nmdp-compose-field {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.nmdp-compose-field-grow { flex: 1; }

.nmdp-compose-label {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    width: 56px;
    flex-shrink: 0;
    padding-top: 10px;
}

.nmdp-compose-to-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nmdp-compose-recipient-fixed {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    color: #1e293b;
    font-weight: 500;
}

.nmdp-compose-recipient-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--nmdp-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.nmdp-compose-recipient-role {
    font-size: 11px;
    color: #94a3b8;
    margin-left: 4px;
}

.nmdp-compose-textarea {
    flex: 1;
    min-height: 200px;
    resize: vertical;
}

.nmdp-compose-field-grow .nmdp-compose-textarea {
    width: 100%;
}

.nmdp-compose-attachment {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.nmdp-compose-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
    margin-top: auto;
    flex-wrap: wrap;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    .nmdp-messages-layout {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .nmdp-messages-sidebar {
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        max-height: 400px;
    }

    .nmdp-message-detail-header { flex-wrap: wrap; gap: 8px; }
    .nmdp-message-detail-actions { flex-wrap: wrap; }

    .nmdp-compose-field { flex-direction: column; }
    .nmdp-compose-label { width: auto; padding-top: 0; }
}

@media (max-width: 480px) {
    .nmdp-msg-tab span:not(.nmdp-msg-tab-badge) { display: none; }
    .nmdp-compose-body { padding: 12px; }
}