/* ===== Browser-Style Tab Bar ===== */

.tab-bar {
    display: flex;
    align-items: flex-end;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    min-height: 38px;
    max-height: 38px;
    padding: 0 0 0 4px;
    gap: 1px;
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE */
    user-select: none;
    position: relative;
    z-index: 11;
}

.tab-bar::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

/* Individual Tab */
.tab-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px 6px 12px;
    min-width: 0;
    max-width: 180px;
    background: transparent;
    border: none;
    border-top: 2px solid transparent;
    cursor: pointer;
    color: var(--text-dim);
    font-size: 0.78rem;
    font-family: var(--font-body);
    transition: all var(--transition-fast);
    position: relative;
    white-space: nowrap;
    flex-shrink: 0;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    height: 34px;
}

.tab-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
}

/* Active Tab */
.tab-item.active {
    background: var(--bg-app);
    color: var(--accent);
    border-top-color: var(--accent);
    position: relative;
}

/* Active tab bottom border mask — makes the tab visually "connect" to the editor area */
.tab-item.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--bg-app);
    z-index: 1;
}

/* Tab icon (emoji) */
.tab-icon {
    font-size: 0.85rem;
    flex-shrink: 0;
    line-height: 1;
}

/* Tab label */
.tab-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 120px;
    font-weight: 400;
    letter-spacing: 0.2px;
}

.tab-item.active .tab-label {
    font-weight: 500;
}

/* Unsaved indicator dot */
.tab-item.unsaved .tab-label::after {
    content: '';
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    margin-left: 5px;
    vertical-align: middle;
    animation: tabUnsavedPulse 2s ease-in-out infinite;
}

@keyframes tabUnsavedPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* Close button */
.tab-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    font-size: 0.65rem;
    color: var(--text-dim);
    transition: all var(--transition-fast);
    flex-shrink: 0;
    opacity: 0;
    line-height: 1;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-family: var(--font-body);
}

.tab-item:hover .tab-close,
.tab-item.active .tab-close {
    opacity: 1;
}

.tab-close:hover {
    background: rgba(229, 72, 77, 0.15);
    color: var(--error);
}

/* Separator between tabs */
.tab-item:not(.active) + .tab-item:not(.active)::before {
    content: '';
    position: absolute;
    left: -1px;
    top: 8px;
    bottom: 8px;
    width: 1px;
    background: var(--border);
}

/* ===== Empty state / hint ===== */
.tab-bar-empty {
    display: flex;
    align-items: center;
    padding: 0 14px;
    color: var(--text-dim);
    font-size: 0.75rem;
    font-style: italic;
    white-space: nowrap;
    letter-spacing: 0.3px;
    opacity: 0.6;
    user-select: none;
    height: 100%;
}

/* ===== Mobile Responsiveness ===== */
@media (max-width: 768px) {
    .tab-bar {
        padding: 0 0 0 2px;
    }

    .tab-item {
        max-width: 140px;
        padding: 5px 8px 5px 10px;
        font-size: 0.72rem;
        height: 32px;
    }

    .tab-label {
        max-width: 80px;
    }
}
