/**
 * Chat Tabs Styling
 * Multi-tab support for concurrent chat conversations
 * Mobile-first responsive design
 */

/* ============================================
   TAB BAR CONTAINER
   ============================================ */
.chat-tabs-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: #ffffff;
    border-bottom: none;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(14, 19, 105, 0.3) transparent;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
}

.chat-tabs-bar::-webkit-scrollbar {
    height: 4px;
}

.chat-tabs-bar::-webkit-scrollbar-track {
    background: transparent;
}

.chat-tabs-bar::-webkit-scrollbar-thumb {
    background: rgba(14, 19, 105, 0.3);
    border-radius: 2px;
}

/* ============================================
   INDIVIDUAL TAB
   ============================================ */
.chat-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #e5e7eb;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
    max-width: 200px;
    flex-shrink: 0;
    position: relative;
}

.chat-tab:hover {
    background: #d1d5db;
}

.chat-tab.active {
    background: #0e1369;
    box-shadow: 0 2px 4px rgba(14, 19, 105, 0.2);
}

.chat-tab.active::after {
    display: none;
}

/* Tab Name */
.chat-tab-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-tab.active .chat-tab-name {
    color: #ffffff;
}

/* Tab Close Button */
.chat-tab-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 12px;
    padding: 0;
    opacity: 0;
}

.chat-tab:hover .chat-tab-close {
    opacity: 1;
}

.chat-tab.active .chat-tab-close {
    opacity: 1;
    color: rgba(255, 255, 255, 0.8);
}

.chat-tab-close:hover {
    background: rgba(255, 100, 100, 0.2);
    color: #ff6b6b;
}

/* Activity Indicator (for background processing) */
.chat-tab-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: transparent;
    flex-shrink: 0;
}

.chat-tab-indicator.processing {
    background: #ffffff;
    animation: pulse-indicator 1.5s infinite;
}

.chat-tab-indicator.has-response {
    background: #ffc107;
}

@keyframes pulse-indicator {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

/* ============================================
   NEW TAB BUTTON
   ============================================ */
.chat-tab-new {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(14, 19, 105, 0.1);
    border: 1px dashed rgba(14, 19, 105, 0.4);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: rgba(14, 19, 105, 0.7);
    font-size: 16px;
    flex-shrink: 0;
}

.chat-tab-new:hover {
    background: rgba(14, 19, 105, 0.2);
    border-color: #0e1369;
    color: #0e1369;
}

.chat-tab-new:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chat-tab-new:disabled:hover {
    background: rgba(14, 19, 105, 0.1);
    border-color: rgba(14, 19, 105, 0.4);
    color: rgba(14, 19, 105, 0.7);
}

/* Tab limit tooltip */
.chat-tab-new[data-tooltip]:hover::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background: #333;
    color: white;
    font-size: 11px;
    border-radius: 4px;
    white-space: nowrap;
    margin-bottom: 4px;
}

/* ============================================
   MOBILE RESPONSIVE (< 768px)
   ============================================ */
@media (max-width: 768px) {
    .chat-tabs-bar {
        padding: 6px 8px;
        gap: 6px;
    }
    
    .chat-tab {
        min-width: 100px;
        max-width: 150px;
        padding: 6px 10px;
        gap: 6px;
    }
    
    .chat-tab-name {
        font-size: 12px;
    }
    
    .chat-tab-close {
        width: 20px;
        height: 20px;
        opacity: 1; /* Always show on mobile for easier touch */
    }
    
    .chat-tab-new {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    /* Swipe hint gradient on edges */
    .chat-tabs-bar::after {
        content: '';
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 20px;
        background: linear-gradient(90deg, transparent, #ffffff);
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.2s;
    }
    
    .chat-tabs-bar.has-scroll::after {
        opacity: 1;
    }
}

/* ============================================
   SMALL MOBILE (< 480px)
   ============================================ */
@media (max-width: 480px) {
    .chat-tabs-bar {
        padding: 4px 6px;
        gap: 4px;
    }
    
    .chat-tab {
        min-width: 80px;
        max-width: 120px;
        padding: 6px 8px;
        gap: 4px;
        border-radius: 6px 6px 0 0;
    }
    
    .chat-tab-name {
        font-size: 11px;
    }
    
    .chat-tab-close {
        width: 18px;
        height: 18px;
        font-size: 10px;
    }
    
    .chat-tab-indicator {
        width: 6px;
        height: 6px;
    }
    
    .chat-tab-new {
        width: 32px;
        height: 32px;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */
.chat-tab {
    animation: tabSlideIn 0.2s ease-out;
}

@keyframes tabSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-tab.closing {
    animation: tabSlideOut 0.15s ease-in forwards;
}

@keyframes tabSlideOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.9);
    }
}

/* ============================================
   DARK MODE ADJUSTMENTS (if needed)
   ============================================ */
/* Chat tabs bar is already dark themed to match chat popup - no overrides needed */

/* High contrast mode support */
@media (prefers-contrast: high) {
    .chat-tab {
        border-width: 2px;
    }
    
    .chat-tab.active {
        border-color: #0e1369;
    }
    
    .chat-tab-name {
        color: #ffffff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .chat-tab,
    .chat-tab-indicator,
    .chat-tab-new {
        transition: none;
        animation: none;
    }
}
