/* Custom styles for the CMS */

/* Table sorting styles */
.sortable {
    position: relative;
    user-select: none;
}

.sortable:hover {
    background-color: #f8f9fa;
}

.sortable.sort-asc::after {
    content: ' ▲';
    font-size: 0.8em;
    color: #007bff;
}

.sortable.sort-desc::after {
    content: ' ▼';
    font-size: 0.8em;
    color: #007bff;
}

/* Chat widget */
.chat-widget {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2050;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.chat-toggle {
    border-radius: 50px;
    padding: 0.6rem 1.2rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.2s ease;
}

.chat-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.chat-widget.collapsed .chat-panel {
    display: none;
}

.chat-panel {
    margin-top: 1rem;
    width: min(600px, 95vw);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 12px 28px rgba(0,0,0,0.12);
}

.chat-panel-body {
    display: flex;
    flex-direction: row;
    height: 450px; /* Increased height */
}

.chat-sidebar {
    width: 200px;
    border-right: 1px solid #f0f0f0;
    padding: 1rem;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-thread {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.chat-thread-header {
    padding: 0.8rem 1.2rem;
    border-bottom: 1px solid #f0f0f0;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    z-index: 2;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.2rem;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-compose {
    padding: 1rem 1.2rem;
    border-top: 1px solid #f0f0f0;
    background: #fff;
}

.chat-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #868e96;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.chat-list {
    max-height: 140px;
    overflow-y: auto;
}

.chat-contact {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    margin-bottom: 2px;
    color: #495057;
}

.chat-contact:hover {
    background: #e9ecef;
}

.chat-contact.active {
    background: #e7f1ff;
    color: #0d6efd;
    font-weight: 500;
}

.chat-contact.has-new {
    background: #fff3cd;
    color: #856404;
}

.chat-contact .badge {
    font-size: 0.65rem;
    padding: 0.35em 0.5em;
}

.chat-message-row {
    display: flex;
    margin-bottom: 0.2rem;
    width: 100%;
}

.chat-message-row.me {
    justify-content: flex-end;
}

.chat-bubble {
    max-width: 80%;
    padding: 0.6rem 0.9rem;
    border-radius: 18px;
    background: #f1f3f5;
    font-size: 0.92rem;
    line-height: 1.4;
    position: relative;
    color: #212529;
}

.chat-message-row.me .chat-bubble {
    background: #0d6efd;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-message-row:not(.me) .chat-bubble {
    border-bottom-left-radius: 4px;
}

.chat-bubble.broadcast {
    background: #fff8e1;
    border: 1px solid #ffeeba;
    color: #856404;
}

.chat-message-row.me .chat-bubble.broadcast {
    background: #fff3cd;
    color: #856404;
    border: none;
}

.chat-bubble .chat-time {
    display: block;
    font-size: 0.65rem;
    color: rgba(0,0,0,0.5);
    margin-top: 0.25rem;
    text-align: right;
}

.chat-message-row.me .chat-time {
    color: rgba(255,255,255,0.75);
}

.chat-status-dot {
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    background: #fa5252;
    display: inline-block;
    margin-left: 0.5rem;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.4rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.chat-toggle.chat-has-new {
    animation: chatPulse 2s infinite;
}

@keyframes chatPulse {
    0% { box-shadow: 0 0 0 0 rgba(13,110,253,0.4); }
    70% { box-shadow: 0 0 0 10px rgba(13,110,253,0); }
    100% { box-shadow: 0 0 0 0 rgba(13,110,253,0); }
}

.chat-toggle.chat-has-new .chat-status-dot {
    background: #fab005;
    color: #212529;
}

.chat-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 0.35rem;
    z-index: 5;
    max-height: 180px;
    overflow-y: auto;
    display: none;
}

.chat-search-results .chat-search-item {
    padding: 0.4rem 0.6rem;
    cursor: pointer;
}

.chat-search-results .chat-search-item:hover {
    background: #f5f5f5;
}

@media (max-width: 768px) {
    .chat-panel-body {
        flex-direction: column;
        height: 500px;
    }

    .chat-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #f1f1f1;
    }
}