/**
 * BeeJobs Mesagerie – stiluri pagină + completări agency two-pane
 * Layout principal: assets/agency/agency.css (.ag-msg-*)
 */

/* —— Candidat (layout clasic msg-*) —— */
:root {
    --msg-bg: #fff;
    --msg-sidebar-bg: #f8f9fa;
    --msg-head-candidat: linear-gradient(135deg, #fff9f0 0%, #fff5eb 100%);
    --msg-head-agentie: linear-gradient(135deg, #e8f0ff 0%, #d4e1ff 100%);
    --msg-bubble-me: linear-gradient(135deg, #ff7f00 0%, #ffa040 100%);
    --msg-bubble-them: #e9ecef;
    --msg-active-candidat: #ff7f00;
    --msg-active-agentie: #5a7bd4;
    --msg-radius: 12px;
    --msg-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

body:not(.ag-app) {
    padding-top: 0;
    background: #fff url('/hexellence.fw.png');
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #333;
}

.msg-layout {
    display: flex;
    height: calc(100vh - 140px);
    min-height: 450px;
    border: 1px solid #e0e0e0;
    border-radius: var(--msg-radius);
    overflow: hidden;
    background: var(--msg-bg);
    box-shadow: var(--msg-shadow);
}

.msg-sidebar {
    width: 340px;
    min-width: 280px;
    border-right: 1px solid #eee;
    overflow-y: auto;
    background: var(--msg-sidebar-bg);
    display: flex;
    flex-direction: column;
}

.msg-sidebar-header {
    padding: 1rem 1.25rem;
    background: var(--msg-bg);
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.msg-conv-list { flex: 1; overflow-y: auto; padding: 0.5rem; }

.msg-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.msg-head {
    padding: 1rem 1.25rem;
    background: var(--msg-head-candidat);
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
    font-weight: 600;
}

.msg-body-agentie .msg-head { background: var(--msg-head-agentie); }

.msg-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.msg-composer {
    padding: 1rem;
    border-top: 1px solid #eee;
    background: var(--msg-sidebar-bg);
    flex-shrink: 0;
}

.msg-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.msg-form .form-control { flex: 1; }
.msg-form .btn { flex-shrink: 0; }

.conv-item {
    padding: 1rem;
    cursor: pointer;
    border-radius: 10px;
    margin-bottom: 0.25rem;
    transition: background 0.2s, border-color 0.2s;
    border-left: 4px solid transparent;
}

.conv-item:hover { background: rgba(255,127,0,0.08); }
.msg-body-agentie .conv-item:hover { background: rgba(90,123,212,0.08); }

.conv-item.active {
    background: rgba(255,127,0,0.12);
    border-left-color: var(--msg-active-candidat);
}
.msg-body-agentie .conv-item.active {
    background: rgba(90,123,212,0.1);
    border-left-color: var(--msg-active-agentie);
}

.conv-item.unread { background: #fffef8; }
.conv-item .conv-item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.25rem; }
.conv-item .conv-time { font-size: 0.75rem; color: #888; }
.conv-item .conv-item-job { font-size: 0.85rem; color: #666; }
.conv-item .conv-item-preview { font-size: 0.85rem; color: #888; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.msg-bubble {
    max-width: 78%;
    padding: 0.65rem 1rem;
    border-radius: var(--msg-radius);
    align-self: flex-start;
}
.msg-bubble.me {
    background: var(--msg-bubble-me);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.msg-bubble.them {
    background: var(--msg-bubble-them);
    color: #333;
    border-bottom-left-radius: 4px;
}
.msg-bubble .msg-text { word-wrap: break-word; }
.msg-bubble .msg-time { font-size: 0.7rem; opacity: 0.85; margin-top: 0.25rem; }

/* —— Shared empty / feedback —— */
.msg-empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem;
    color: #666;
}
.msg-empty-state i { font-size: 2.5rem; color: #ccc; margin-bottom: 1rem; display: block; }
.msg-empty-state p { margin-bottom: 1rem; }
.msg-empty-thread { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 280px; }
.msg-placeholder { text-align: center; padding: 2rem; color: #888; }
.msg-error { padding: 1rem; color: #c62828; font-size: 0.9rem; }
.msg-loading { padding: 1.5rem; text-align: center; color: #666; }

.msg-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(2rem);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    background: #333;
    color: #fff;
    font-size: 0.95rem;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
}
.msg-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.msg-toast-error { background: #c62828; }
.msg-toast-success { background: #2e7d32; }

.msg-send-error {
    margin-top: 0.5rem;
    padding: 0.5rem 0.65rem;
    font-size: 0.85rem;
    color: #b71c1c;
    background: #ffebee;
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}
.msg-retry-btn {
    border: none;
    background: transparent;
    color: #ff7f00;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    font-size: inherit;
}

@media (max-width: 768px) {
    .msg-layout { flex-direction: column; height: auto; min-height: 520px; }
    .msg-sidebar { width: 100%; max-height: 220px; }
}

/* —— Agency shell mesagerie —— */
body.ag-app .ag-content--flush {
    padding-left: 0;
    padding-right: 0;
    max-width: none;
}
body.ag-app .ag-page-header--compact {
    padding-left: 1.15rem;
    padding-right: 1.15rem;
    margin-bottom: 0.75rem;
}
body.ag-app .ag-page-header--compact h1 {
    font-size: 1.35rem;
    margin-bottom: 0.25rem;
}
body.ag-app .ag-msg-layout {
    margin: 0 1rem 1.25rem;
}
@media (min-width: 900px) {
    body.ag-app .ag-msg-layout {
        margin-left: 1.15rem;
        margin-right: 1.15rem;
    }
}

.msg-list-head {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--ag-line2, #eee);
    background: var(--ag-white, #fff);
    font-size: 0.95rem;
}

.ag-conv-item.is-unread {
    background: rgba(255, 127, 0, 0.06);
}
.msg-conv-meta {
    font-size: 0.78rem;
    color: var(--ag-mute, #888);
    margin: 0.15rem 0;
}
.msg-unread-badge {
    display: inline-block;
    min-width: 1.25rem;
    padding: 0.1rem 0.4rem;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.2;
    border-radius: 999px;
    background: #ff7f00;
    color: #fff;
    vertical-align: middle;
}

.ag-msg-thread-head {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-weight: 600;
}
.msg-back-btn {
    display: none;
    border: none;
    background: transparent;
    padding: 0.35rem 0.5rem;
    color: inherit;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
}
@media (max-width: 899.98px) {
    .msg-back-btn { display: inline-flex; align-items: center; }
    body.ag-app .ag-msg-layout {
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        min-height: calc(100vh - 120px);
    }
    body.ag-app .ag-page-header--compact { display: none; }
}

.ag-msg-thread-body {
    display: flex;
    flex-direction: column;
}
.ag-msg-thread-body .ag-bubble .msg-text {
    word-wrap: break-word;
    white-space: pre-wrap;
}

.msg-send-form {
    display: flex;
    flex: 1;
    gap: 0.5rem;
    align-items: center;
    width: 100%;
}
.msg-send-form .form-control { flex: 1; min-width: 0; }

.ag-msg-composer {
    flex-direction: column;
    align-items: stretch;
}
