/**
 * Modern Conversation Table Styles
 * Clean, responsive design with improved typography and spacing
 */

/* ==========================================================================
   TABLE CONTAINER & BASE STYLES
   ========================================================================== */

.table-container {
    position: relative;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.table-scroll-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch; 
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

.table-scroll-wrapper::-webkit-scrollbar {
    height: 6px;
}

.table-scroll-wrapper::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.table-scroll-wrapper::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.table-scroll-wrapper::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
/* ==========================================================================
   TABLE HEADER STYLES
   ========================================================================== */

.table-conversations thead {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-bottom: 2px solid #e2e8f0;
}

.table-conversations thead th {
    padding: 16px 12px;
    font-weight: 600;
    font-size: 13px;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    border-right: 1px solid #e2e8f0;
    white-space: nowrap;
    position: relative;
    transition: all 0.2s ease;
}

.table-conversations thead th:last-child {
    border-right: none;
}

.table-conversations thead th a,
.table-conversations thead th span {
    color: #475569;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    transition: color 0.2s ease;
}

.table-conversations thead th a:hover {
    color: #3b82f6;
}

/* Column widths */
.table-conversations .conv-current {
    width: 4px;
    padding: 0;
}

.table-conversations .conv-cb {
    width: 50px;
    text-align: center;
}

.table-conversations .conv-id {
    width: 80px;
}

.table-conversations .conv-customer {
    width: 220px;
    min-width: 180px;
}

.table-conversations .conv-queue {
    width: 140px;
}

.table-conversations .conv-status {
    width: 100px;
}

.table-conversations .conv-channel {
    width: 90px;
}

.table-conversations .conv-agent {
    width: 180px;
    min-width: 160px;
}

.table-conversations .conv-last-message {
    width: 120px;
}

.table-conversations .conv-created {
    width: 120px;
}

.table-conversations .conv-buttons {
    width: 100px;
}

/* ==========================================================================
   TABLE ROW STYLES
   ========================================================================== */

.table-conversations tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: all 0.15s ease;
    position: relative;
}

.table-conversations tbody tr:hover {
    background-color: #f8fafc;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.table-conversations tbody tr.conv-active {
    background-color: #eff6ff;
    border-left: 4px solid #3b82f6;
}

.table-conversations tbody tr.conv-active:hover {
    background-color: #dbeafe;
}

.table-conversations tbody tr.conv-spam {
    background-color: #fef2f2;
    opacity: 0.8;
}

.table-conversations tbody td {
    padding: 16px 12px;
    vertical-align: middle;
    border: none;
    font-size: 14px;
    line-height: 1.4;
}

/* ==========================================================================
   CHECKBOX STYLES
   ========================================================================== */

.conv-cb {
    padding: 16px 0;
    text-align: center;
}

.conv-cb input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: #3b82f6;
}

.conv-cb label {
    margin: 0;
    cursor: pointer;
}

/* ==========================================================================
   ID COLUMN STYLES
   ========================================================================== */

.conv-id {
    font-weight: 600;
    color: #374151;
}

.conv-id-link {
    color: #6b7280;
    text-decoration: none;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: inline-block;
}

.conv-id-link:hover {
    color: #3b82f6;
    background-color: #f1f5f9;
    text-decoration: none;
}

/* ==========================================================================
   CUSTOMER COLUMN STYLES
   ========================================================================== */

.conv-customer {
    /* Customer component styles are handled in the component itself */
}

/* ==========================================================================
   QUEUE COLUMN STYLES
   ========================================================================== */

.conv-queue {
    color: #6b7280;
}

.queue-name {
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    padding: 4px 8px;
    background-color: #f8fafc;
    border-radius: 4px;
    display: inline-block;
    border: 1px solid #e2e8f0;
}

/* ==========================================================================
   STATUS COLUMN STYLES
   ========================================================================== */

.conv-status {
    padding: 16px 8px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    gap: 6px;
    border: 1px solid;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
}

.status-badge.status-open {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border-color: #86efac;
    color: #065f46;
}

.status-badge.status-closed {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-color: #cbd5e1;
    color: #475569;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8);
}

.status-open .status-indicator {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.status-closed .status-indicator {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
}

/* ==========================================================================
   CHANNEL COLUMN STYLES
   ========================================================================== */

.conv-channel {
    color: #6b7280;
}

.channel-name {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}

/* ==========================================================================
   AGENT COLUMN STYLES
   ========================================================================== */

.conv-agent .agent-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.conv-agent .agent-avatar {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.conv-agent .agent-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.conv-agent .agent-avatar-text {
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

.conv-agent .agent-avatar-image {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    object-fit: cover;
}

.conv-agent .agent-details {
    flex: 1;
    min-width: 0;
}

.conv-agent .agent-name {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    text-decoration: none;
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s ease;
}

.conv-agent .agent-name:hover {
    color: #3b82f6;
    text-decoration: none;
}

.conv-agent .admin-badge {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: white;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 1px 2px rgba(220, 38, 38, 0.3);
}

.conv-agent .unassigned-text {
    font-size: 13px;
    color: #9ca3af;
    font-style: italic;
    font-weight: 500;
}

/* ==========================================================================
   TIME COLUMNS STYLES
   ========================================================================== */

.conv-last-message,
.conv-created {
    color: #6b7280;
}

.last-message-time,
.created-time {
    font-size: 13px;
    color: #6b7280;
    white-space: nowrap;
    font-weight: 500;
}

.no-message {
    font-size: 13px;
    color: #9ca3af;
    font-style: italic;
}

/* ==========================================================================
   BUTTONS COLUMN STYLES
   ========================================================================== */

.conv-buttons {
    text-align: right;
    padding-right: 16px;
}

.conversation-actions {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
}

.action-btn {
    padding: 0;
    background: transparent;
    color: #6b7280;
    border: none;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.action-btn:hover {
    background: #f1f5f9;
    color: #374151;
    text-decoration: none;
}

.action-btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.action-btn-primary {
    background: transparent;
    color: #3b82f6;
}

td a.action-btn-primary{
    display: inline-flex;
}

.table-conversations td a.action-btn-primary {
    display: inline-flex;

}

.action-btn-primary:hover {
    background: #eff6ff;
    color: #2563eb;
    text-decoration: none;
}

.action-btn i {
    position: relative;
    top: 0;
    left: 0;
    line-height: 1;
}

/* ==========================================================================
   VIEWER INDICATORS
   ========================================================================== */

.viewer-badge {
    position: absolute;
    top: 8px;
    left: 0;
    width: 4px;
    height: 100%;
    background: #10b981;
    border-radius: 0 2px 2px 0;
}

.viewer-badge.viewer-replying {
    background: #f59e0b;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

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

@media (max-width: 1200px) {
    .conv-queue,
    .conv-created {
        display: none;
    }
    
    .conv-customer {
        width: 200px;
    }
    
    .conv-agent {
        width: 160px;
    }
}

/* ==========================================================================
   TABLE FOOTER STYLES
   ========================================================================== */

.table-conversations tfoot {
    background-color: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.table-conversations tfoot td {
    padding: 16px 12px;
    color: #6b7280;
    font-size: 13px;
    font-weight: 500;
    border: none;
}

.table-conversations tfoot strong {
    color: #374151;
    font-weight: 600;
}

.table-pager {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
}

.table-pager a.pager-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: #6b7280;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.table-pager a.pager-nav:hover {
    color: #3b82f6;
    background: #f1f5f9;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

.table-pager a.pager-nav.disabled {
    color: #d1d5db;
    cursor: not-allowed;
    background: #f9fafb;
}

.table-pager a.pager-nav.disabled:hover {
    transform: none;
    color: #d1d5db;
    background: #f9fafb;
    border-color: #e5e7eb;
}

/* ==========================================================================
   LOADING STATES
   ========================================================================== */

.table-conversations.loading {
    position: relative;
    opacity: 0.7;
}

.table-conversations.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    border: 3px solid #e2e8f0;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ==========================================================================
   ACCESSIBILITY IMPROVEMENTS
   ========================================================================== */

.table-conversations tbody tr:focus-within {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.conv-id-link:focus,
.agent-name:focus,
.action-btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 4px;
}

.conv-filters-container {
    background: transparent;
    width: 100%;
    padding-top: 12px;
}

/* Main Filters Row */
.conv-filters-main {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
    justify-content: flex-end;
}

/* Filter Fields */
.conv-filter-field {
    width: 120px;
    flex-shrink: 0;
    position: relative;
}

.conv-filter-field:after {
    content: '▼';
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
    font-size: 10px;
}

.conv-filter-field-wide {
    min-width: 160px;
}

/* Remove dropdown arrow from customer search container */
.conv-customer-search-container:after {
    display: none;
}

.conv-filter-select {
    width: 100%;
    height: 36px;
    padding: 0 20px 0 8px;
    border: none;
    border-radius: 0;
    transition: all 0.2s ease;
    background: transparent;
    color: #374151;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    font-size: 14px;
}

.conv-filter-select:focus {
    outline: none;
    color: #3b82f6;
}

.conv-filter-select:hover {
    color: #1f2937;
}

/* Customer Search Styles */
.conv-customer-search-container {
    position: relative;
    width: 180px;
}

.conv-customer-search {
    width: 100%;
    height: 36px;
    padding: 0 30px 0 8px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: #374151;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.conv-customer-search:focus {
    color: #3b82f6;
}

.conv-customer-search:hover {
    color: #1f2937;
}

.conv-customer-search::placeholder {
    color: #9ca3af;
}

/* Search icon */
.conv-customer-search-container::before {
    content: '🔍';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    font-size: 12px;
    opacity: 0.6;
}

/* Customer Dropdown */
.conv-customer-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1001;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    margin-top: 2px;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.conv-customer-dropdown.conv-show {
    display: block;
    animation: convDropdownFadeIn 0.15s ease-out;
}

.conv-customer-option {
    padding: 8px 12px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s ease;
    border-bottom: 1px solid #f9fafb;
    position: relative;
}

.conv-customer-option:last-child {
    border-bottom: none;
}

.conv-customer-option:hover {
    background: #f9fafb;
    color: #1f2937;
}

.conv-customer-option.conv-selected {
    background: #eff6ff;
    color: #1d4ed8;
}

.conv-customer-option.conv-highlighted {
    background: #f3f4f6;
}

.conv-customer-option[data-email]:after {
    content: attr(data-email);
    display: block;
    font-size: 11px;
    color: #6b7280;
    margin-top: 2px;
}

.conv-customer-option.conv-loading {
    color: #6b7280;
    font-style: italic;
    text-align: center;
    padding: 12px;
}

.conv-customer-option.conv-error {
    color: #dc2626;
    text-align: center;
    padding: 12px;
}

.conv-customer-option.conv-no-results {
    color: #6b7280;
    text-align: center;
    padding: 12px;
    font-style: italic;
}

/* Button Base Styles */
.conv-btn {
    height: 36px;
    padding: 0 12px;
    border: none;
    border-radius: 0;
    font-weight: 400;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    white-space: nowrap;
    outline: none;
    background: transparent;
    color: #374151;
    font-family: inherit;
}

.conv-btn:focus {
    outline: none;
}

.conv-btn-secondary {
    background: transparent;
    color: #374151;
    border: none;
}

.conv-btn-secondary:hover {
    background: transparent;
    color: #1f2937;
}

.conv-btn-clear {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    border-radius: 6px;
}

.conv-btn-clear:hover {
    background: #fee2e2;
    border-color: #fca5a5;
}

.conv-btn-icon {
    width: 36px;
    padding: 0;
    justify-content: center;
    position: relative;
}

.conv-btn-icon-inline {
    font-size: 12px;
}

/* Filter Buttons Container */
.conv-filter-buttons {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

/* Menu dots for quick filters button */
.conv-menu-dots {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.conv-dot {
    width: 3px;
    height: 3px;
    background-color: #6b7280;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.conv-dropdown-toggle:hover .conv-dot {
    background-color: #1f2937;
}

/* Quick Filters Dropdown */
.conv-quick-filters-dropdown {
    position: relative;
    display: inline-block;
}

.conv-dropdown-toggle {
    position: relative;
    padding: 0 !important;
    width: 36px !important;
    justify-content: center;
}

.conv-dropdown-toggle:hover {
    background: transparent;
    color: #1f2937;
}

.conv-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    min-width: 200px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 6px 0;
    margin-top: 2px;
    display: none;
    max-height: 350px;
    overflow-y: auto;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.conv-dropdown-menu.conv-show {
    display: block;
    animation: convDropdownFadeIn 0.15s ease-out;
}

@keyframes convDropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.conv-dropdown-header {
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #f3f4f6;
    margin-bottom: 2px;
}

.conv-dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    color: #374151;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
    outline: none;
    position: relative;
    font-family: inherit;
}

.conv-dropdown-item:focus {
    outline: none;
}

.conv-dropdown-item:hover {
    background: #f9fafb;
    color: #1f2937;
}

.conv-dropdown-item.conv-active {
    background: #eff6ff;
    color: #1d4ed8;
}

.conv-dropdown-icon {
    width: 12px;
    font-size: 12px;
    opacity: 0.7;
    margin-right: 6px;
    display: inline-block;
}

.conv-dropdown-divider {
    height: 1px;
    background: #f3f4f6;
    margin: 4px 0;
}

.conv-clear-all-filters:hover {
    background: #fef2f2;
    color: #dc2626;
}

.conv-text-green {
    color: #10b981;
}

.conv-text-gray {
    color: #6b7280;
}

.conv-text-red {
    color: #ef4444;
}

/* Active Filters Display */
.conv-active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
}

.conv-filter-tag {
    display: flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
    padding: 4px 8px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #93c5fd;
}

.conv-filter-tag-label {
    font-weight: 600;
}

.conv-filter-tag-value {
    opacity: 0.9;
}

.conv-remove-filter {
    cursor: pointer;
    background: none;
    border: none;
    color: #1e40af;
    font-weight: bold;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.15s ease;
    font-size: 10px;
    padding: 0;
    outline: none;
    font-family: inherit;
}

.conv-remove-filter:focus {
    outline: none;
}

.conv-remove-filter:hover {
    background: #1e40af;
    color: white;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .conv-filters-main {
        gap: 12px;
    }

    .conv-filter-field {
        min-width: 120px;
    }

    .conv-customer-search-container {
        min-width: 160px;
    }
}

@media (max-width: 992px) {
    .conv-filter-field {
        min-width: 140px;
    }

    .conv-customer-search-container {
        min-width: 180px;
    }
}

@media (max-width: 768px) {
    .conv-filters-container {
        padding: 16px;
    }

    .conv-filters-main {
        flex-direction: column;
        align-items: stretch;
    }

    .conv-filter-field,
    .conv-customer-search-container {
        min-width: 100%;
        max-width: none;
    }

    .conv-filter-buttons {
        justify-content: stretch;
    }

    .conv-btn {
        flex: 1;
        justify-content: center;
    }

    .conv-dropdown-menu,
    .conv-customer-dropdown {
        right: 0;
        left: auto;
        min-width: 200px;
    }
}
