/**
 * NigamaConnect Admin Web App — User Queries & Live Support Console Stylesheet
 * Standard: Glassmorphic Dark UI v5.0.0 (Cosmic Midnight Theme)
 * Reference: webofficial_appnigamaconnect/support/
 * File: NigamaConnect-Admin-webapp/css/v5/user-queries.css
 */

.queries-content {
    padding: 28px;
    height: calc(100vh - 84px);
    overflow: hidden;
    position: relative;
}

/* ===================================
   CONNECTION STATUS & BANNER
   =================================== */
.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(15, 23, 42, 0.65);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10B981;
    box-shadow: 0 0 10px #10B981;
    animation: pulse 2s infinite;
}

.connection-status.offline .status-dot {
    background: #ef4444;
    box-shadow: 0 0 10px #ef4444;
}

.status-text {
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    font-family: 'JetBrains Mono', monospace;
}

.connection-banner {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: #fbbf24;
    padding: 12px 20px;
    border-radius: 12px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 600;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.banner-icon {
    font-size: 18px;
}

/* ===================================
   LAYOUT: 2-COLUMN SPLIT PANE
   =================================== */
.queries-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 20px;
    height: 100%;
}

@media (max-width: 1024px) {
    .queries-layout {
        grid-template-columns: 320px 1fr;
        gap: 16px;
    }
}

@media (max-width: 768px) {
    .queries-layout {
        grid-template-columns: 1fr;
        position: relative;
    }
    
    .queries-content {
        padding: 16px;
        height: calc(100vh - 140px);
    }
}

/* ===================================
   CHAT LIST CONTAINER (LEFT COLUMN)
   =================================== */
.chat-list-container {
    background: rgba(11, 21, 40, 0.78);
    border-radius: 18px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(20px);
}

.chat-list-header {
    padding: 20px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 23, 42, 0.5);
}

.chat-list-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 800;
    color: #f8fafc;
    margin: 0 0 14px 0;
    letter-spacing: -0.02em;
}

.filter-tabs {
    display: flex;
    gap: 6px;
    background: rgba(2, 6, 23, 0.5);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.filter-tab {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: #94a3b8;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: center;
}

.filter-tab:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
}

.filter-tab.active {
    background: linear-gradient(135deg, #0FA3D9 0%, #0284c7 100%);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 14px rgba(15, 163, 217, 0.35);
}

.chat-list-search {
    padding: 14px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(15, 23, 42, 0.3);
}

.chat-list-search input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    background: rgba(2, 6, 23, 0.6);
    color: #f8fafc;
    font-size: 13.5px;
    transition: all 0.2s ease;
}

.chat-list-search input::placeholder {
    color: #64748b;
}

.chat-list-search input:focus {
    outline: none;
    border-color: #0FA3D9;
    box-shadow: 0 0 16px rgba(15, 163, 217, 0.25);
    background: rgba(2, 6, 23, 0.85);
}

.chat-list-items {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(15, 163, 217, 0.3) transparent;
}

.chat-list-items::-webkit-scrollbar {
    width: 5px;
}
.chat-list-items::-webkit-scrollbar-thumb {
    background: rgba(15, 163, 217, 0.35);
    border-radius: 4px;
}

/* ===================================
   CHAT ITEM (THREAD ROW)
   =================================== */
.chat-item {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    border-left: 3px solid transparent;
}

.chat-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.chat-item.active {
    background: rgba(15, 163, 217, 0.12);
    border-left: 3px solid #0FA3D9;
}

.chat-item.unread {
    background: rgba(139, 92, 246, 0.07);
}

.chat-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(15, 163, 217, 0.35);
}

.chat-avatar-placeholder {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0FA3D9 0%, #8B5CF6 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(15, 163, 217, 0.25);
}

.online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #10B981;
    border: 2px solid #0B1528;
    box-shadow: 0 0 8px #10B981;
}

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

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

.chat-name {
    font-family: 'Outfit', sans-serif;
    font-size: 14.5px;
    font-weight: 700;
    color: #f8fafc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item.unread .chat-name {
    color: #38bdf8;
}

.chat-time {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: #94a3b8;
}

.chat-preview {
    font-size: 13px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 6px;
    line-height: 1.4;
}

.chat-item.unread .chat-preview {
    font-weight: 600;
    color: #e2e8f0;
}

.unread-indicator {
    color: #0FA3D9;
    font-size: 11px;
}

.message-status {
    color: #38bdf8;
    font-size: 12px;
    font-weight: bold;
}

.chat-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-status {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: 0.02em;
}

.chat-status.solved {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.chat-status.unsolved {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.chat-unread {
    background: linear-gradient(135deg, #0FA3D9 0%, #8B5CF6 100%);
    color: white;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(15, 163, 217, 0.4);
}

/* ===================================
   EMPTY & LOADING SKELETON
   =================================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-state-icon {
    font-size: 52px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-state-title {
    font-family: 'Outfit', sans-serif;
    font-size: 17px;
    font-weight: 700;
    color: #f8fafc;
    margin-bottom: 8px;
}

.empty-state-text {
    font-size: 13.5px;
    color: #94a3b8;
}

.loading-skeleton {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.skeleton-item {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.skeleton-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.04) 25%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.04) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-content {
    flex: 1;
}

.skeleton-line {
    height: 12px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.04) 25%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.04) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-line.short {
    width: 60%;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===================================
   CHAT THREAD CONTAINER (RIGHT COLUMN)
   =================================== */
.chat-thread-container {
    background: rgba(11, 21, 40, 0.78);
    border-radius: 18px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(20px);
}

@media (max-width: 768px) {
    .chat-thread-container {
        position: fixed;
        inset: 0;
        z-index: 999;
        border-radius: 0;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
    
    .chat-thread-container.show {
        transform: translateX(0);
    }
}

.chat-thread-header {
    padding: 18px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(12px);
}

.back-btn {
    display: none;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 18px;
    color: #f8fafc;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 8px;
}

@media (max-width: 768px) {
    .back-btn {
        display: block;
    }
}

.thread-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #0FA3D9;
    box-shadow: 0 0 14px rgba(15, 163, 217, 0.35);
}

.thread-avatar-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0FA3D9 0%, #8B5CF6 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 700;
    box-shadow: 0 0 14px rgba(15, 163, 217, 0.35);
}

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

.thread-name {
    font-family: 'Outfit', sans-serif;
    font-size: 17px;
    font-weight: 700;
    color: #f8fafc;
    margin: 0 0 2px 0;
}

.thread-email {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: #94a3b8;
    margin: 0;
}

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

.btn-icon {
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.6);
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #f8fafc;
}

.btn-icon.solved {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.35);
}

.btn-icon.solved:hover {
    background: rgba(16, 185, 129, 0.25);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.3);
}

.btn-icon.delete {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

.btn-icon.delete:hover {
    background: rgba(239, 68, 68, 0.22);
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

/* ===================================
   MESSAGES STREAM
   =================================== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: rgba(2, 6, 23, 0.5);
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(15, 163, 217, 0.3) transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 5px;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(15, 163, 217, 0.35);
    border-radius: 4px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 82%;
}

.message-user {
    align-self: flex-start;
    flex-direction: row;
}

.message-ai,
.message-admin {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.8);
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-ai .message-avatar {
    background: rgba(139, 92, 246, 0.15);
    color: #c4b5fd;
    border-color: rgba(139, 92, 246, 0.3);
}

.message-admin .message-avatar {
    background: rgba(15, 163, 217, 0.15);
    color: #38bdf8;
    border-color: rgba(15, 163, 217, 0.3);
}

.message-bubble {
    display: flex;
    flex-direction: column;
    max-width: 100%;
}

.message-content {
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message-user .message-content {
    background: rgba(15, 23, 42, 0.85);
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.message-admin .message-content {
    background: linear-gradient(135deg, #0FA3D9 0%, #0284c7 100%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 16px rgba(15, 163, 217, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.message-ai .message-content {
    background: linear-gradient(135deg, #8B5CF6 0%, #6D28D9 100%);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.35);
}

.message-content strong {
    font-weight: 700;
}

.message-content em {
    font-style: italic;
}

.message-content code {
    background: rgba(0, 0, 0, 0.25);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

.message-content h2,
.message-content h3,
.message-content h4 {
    margin: 8px 0 4px 0;
    font-weight: 700;
}

.message-content h2 { font-size: 17px; }
.message-content h3 { font-size: 15px; }
.message-content h4 { font-size: 13.5px; }

.message-content .list-item {
    display: flex;
    gap: 8px;
    margin: 4px 0;
    align-items: flex-start;
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    font-size: 11px;
    color: #94a3b8;
}

.message-ai .message-meta,
.message-admin .message-meta {
    justify-content: flex-end;
}

.message-sender {
    font-weight: 600;
    color: #38bdf8;
}

.message-time {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    color: #94a3b8;
}

/* ===================================
   FLOATING COMPOSER DOCK
   =================================== */
.chat-input-container {
    padding: 16px 22px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(16px);
}

.chat-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input-wrapper textarea {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: rgba(2, 6, 23, 0.65);
    color: #f8fafc;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    transition: all 0.2s ease;
}

.chat-input-wrapper textarea::placeholder {
    color: #64748b;
}

.chat-input-wrapper textarea:focus {
    outline: none;
    border-color: #0FA3D9;
    box-shadow: 0 0 16px rgba(15, 163, 217, 0.25);
    background: rgba(2, 6, 23, 0.85);
}

.btn-send {
    padding: 12px 20px;
    background: linear-gradient(135deg, #0FA3D9 0%, #0284c7 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 14px rgba(15, 163, 217, 0.35);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(15, 163, 217, 0.5);
}

.btn-send svg {
    width: 16px;
    height: 16px;
}

/* ===================================
   IMAGE VIEWER MODAL
   =================================== */
.image-viewer-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.image-viewer-overlay {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.88);
    backdrop-filter: blur(14px);
}

.image-viewer-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background: rgba(11, 21, 40, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
}

.image-viewer-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.6);
}

.image-viewer-header h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: #f8fafc;
    margin: 0;
}

.image-viewer-close {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-viewer-body {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

.image-viewer-body img {
    max-width: 85vw;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 10px;
}

/* ===================================
   TOAST NOTIFICATIONS
   =================================== */
.notification-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1300;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification-toast {
    background: rgba(11, 21, 40, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 14px 20px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 12px;
    backdrop-filter: blur(16px);
    transition: all 0.3s ease;
}

.notification-toast.success {
    border-color: rgba(16, 185, 129, 0.5);
    background: rgba(6, 95, 70, 0.95);
}

.notification-toast.error {
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(153, 27, 27, 0.95);
}

.toast-close {
    background: transparent;
    border: none;
    color: #ffffff;
    cursor: pointer;
    font-size: 18px;
    opacity: 0.7;
    margin-left: auto;
}

.toast-close:hover {
    opacity: 1;
}
