:root {
    --tab-bg-primary: #ffffff;
    --tab-bg-secondary: #f9fafb;
    --tab-border-color: #e5e7eb;
    --tab-text-primary: #111827;
    --tab-text-secondary: #4b5563;
    --tab-text-hover: #111827;
    --tab-hover-bg: #f3f4f6;
    --tab-active-indicator: #3b82f6;
    --tab-focus-ring: #3b82f6;
    --tab-close-hover: #e5e7eb;
}

body[data-theme='dark'] {
    --tab-bg-primary: #111827;
    --tab-bg-secondary: #1f2937;
    --tab-border-color: #374151;
    --tab-text-primary: #ffffff;
    --tab-text-secondary: #9ca3af;
    --tab-text-hover: #ffffff;
    --tab-hover-bg: #374151;
    --tab-active-indicator: #3b82f6;
    --tab-focus-ring: #3b82f6;
    --tab-close-hover: #4b5563;
}

.tab-navigation {
    @apply w-full h-full;
}

.tab-navigation.tab-navigation-fill {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.tab-list {
    @apply flex items-end;
    position: relative;
    min-width: 0;
    background-color: var(--tab-bg-primary);
    border-color: var(--tab-border-color);
}

.tab-items {
    flex: 1 1 auto;
}

.tab-navigation.tab-navigation-fill > .tab-list {
    flex: 0 0 auto;
}

.tab-navigation[data-style='github'] .tab-list {
    @apply border-b;
    background-color: var(--tab-bg-primary);
    border-color: var(--tab-border-color);
}

.tab-navigation[data-style='obsidian'] .tab-list {
    align-items: end;
    background-color: var(--tab-bg-secondary);
}

.tab-item {
    @apply relative flex items-center gap-2 font-medium transition-all duration-200 focus:outline-none;
    flex: 0 0 auto;
    color: var(--tab-text-secondary);
}

.tab-item:hover:not(.tab-item--disabled) {
    color: var(--tab-text-hover);
}

/* .tab-item:focus {
    @apply ring-2 ring-offset-2;
    --tw-ring-color: var(--tab-focus-ring);
} */

/* body[data-theme='dark'] .tab-item:focus {
    @apply ring-offset-gray-900;
} */

.tab-item--active {
    color: var(--tab-text-primary) !important;
}

.tab-item--disabled {
    @apply opacity-50 cursor-not-allowed;
}

.tab-navigation[data-style='github'] .tab-item {
    @apply border-b-2 border-transparent;
}

.tab-navigation[data-style='github'] .tab-item--active {
    border-bottom-color: var(--tab-active-indicator);
}

.tab-navigation[data-style='github'] .tab-item:hover:not(.tab-item--active, .tab-item--disabled) {
    border-bottom-color: var(--tab-border-color);
}

.tab-navigation[data-style='obsidian'] .tab-item {
    @apply rounded-t-md;
}

.tab-navigation[data-style='obsidian'] .tab-item:hover:not(.tab-item--active, .tab-item--disabled) {
    background-color: var(--tab-hover-bg);
}

.tab-navigation[data-style='obsidian'] .tab-item--active {
    @apply border-t border-l border-r -mb-px z-10;
    background-color: var(--tab-bg-primary);
    border-color: var(--tab-border-color);
    border-bottom: 1px solid var(--tab-bg-primary);
}

.tab-content {
    display: block;
    width: 100%;
    height: 100%;
}

.tab-navigation.tab-navigation-fill > .tab-content {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: auto;
}

.tab-icon {
    @apply flex-shrink-0;
}

.tab-label {
    @apply truncate;
}

.tab-badge {
    @apply inline-flex items-center justify-center rounded-full text-xs font-medium;
    @apply bg-blue-500 text-white transition-all duration-200 ease-in-out;
}

body[data-theme='dark'] .tab-badge {
    @apply bg-blue-600;
}

.tab-close {
    @apply flex-shrink-0 rounded-sm transition-all duration-150 ease-in-out;
}

.tab-close:hover {
    background-color: var(--tab-close-hover);
}

/* .tab-close:focus {
    @apply outline-none ring-2 ring-offset-1;
    --tw-ring-color: var(--tab-focus-ring);
} */

.tab-add-button {
    @apply flex items-center justify-center rounded transition-all duration-150 ease-in-out;
    flex: 0 0 auto;
    color: var(--tab-text-secondary);
}

.tab-add-button:hover {
    color: var(--tab-text-hover);
    background-color: var(--tab-hover-bg);
}

/* .tab-add-button:focus {
    @apply outline-none ring-2 ring-offset-2;
    --tw-ring-color: var(--tab-focus-ring);
} */

/* body[data-theme='dark'] .tab-add-button:focus {
    @apply ring-offset-gray-800;
} */

.tab-navigation[data-size='sm'] .tab-list {
    @apply h-8;
}

.tab-navigation[data-size='sm'] .tab-item {
    @apply px-3 py-1.5 text-sm;
}

.tab-navigation[data-size='sm'] .tab-icon {
    @apply w-3 h-3;
}

.tab-navigation[data-size='sm'] .tab-badge {
    @apply min-w-[16px] h-4 px-1;
}

.tab-navigation[data-size='sm'] .tab-close {
    @apply p-0.5;
}

.tab-navigation[data-size='sm'] .tab-add-button {
    @apply w-6 h-6 ml-1;
}

.tab-navigation[data-size='md'] .tab-list {
    @apply h-11;
}

.tab-navigation[data-size='md'] .tab-item {
    @apply px-4 py-2 text-sm;
}

.tab-navigation[data-size='md'] .tab-icon {
    @apply w-4 h-4;
}

.tab-navigation[data-size='md'] .tab-badge {
    @apply min-w-[18px] h-[18px] px-1.5;
}

.tab-navigation[data-size='md'] .tab-close {
    @apply p-1;
}

.tab-navigation[data-size='md'] .tab-add-button {
    @apply w-8 h-8 ml-2;
}

.tab-navigation[data-size='lg'] .tab-list {
    @apply h-12;
}

.tab-navigation[data-size='lg'] .tab-item {
    @apply px-6 py-3 text-base;
}

.tab-navigation[data-size='lg'] .tab-icon {
    @apply w-5 h-5;
}

.tab-navigation[data-size='lg'] .tab-badge {
    @apply min-w-[20px] h-5 px-2;
}

.tab-navigation[data-size='lg'] .tab-close {
    @apply p-1.5;
}

.tab-navigation[data-size='lg'] .tab-add-button {
    @apply w-10 h-10 ml-2;
}

@media (max-width: 640px) {
    .tab-navigation .tab-item {
        @apply px-2 py-1.5 text-xs;
    }

    .tab-navigation .tab-label {
        @apply max-w-[80px];
    }

    .tab-navigation .tab-icon {
        @apply w-3 h-3;
    }
}

@media (prefers-contrast: high) {
    .tab-navigation[data-style='github'] .tab-item--active {
        --tab-active-indicator: #2563eb;
    }

    .tab-navigation .tab-item {
        @apply border border-transparent;
    }

    .tab-navigation .tab-item--active {
        @apply border-blue-600;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tab-item,
    .tab-badge,
    .tab-close,
    .tab-add-button {
        @apply transition-none;
    }
}

.tab-navigation-actions {
    display: flex;
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    height: 100%;
}

.tab-navigation-actions input.form-input,
.tab-navigation-actions span.btn-wrapper > button.btn {
    height: 28px;
}

.tab-more-trigger {
    height: 100%;
    justify-content: center;
}

.tab-navigation[data-size='sm'] .tab-more-trigger {
    min-width: 34px;
}

.tab-navigation[data-size='md'] .tab-more-trigger {
    min-width: 42px;
}

.tab-navigation[data-size='lg'] .tab-more-trigger {
    min-width: 50px;
}

.tab-overflow-menu {
    min-width: 180px;
    max-width: 260px;
}

.tab-overflow-dropdown-content {
    z-index: 9999;
}

.tab-overflow-menu-item {
    display: flex !important;
    width: 100%;
    align-items: center;
    gap: 0.5rem;
    border: 0;
    background: transparent;
    text-align: left;
}

body[data-theme='dark'] .tab-overflow-menu .tab-overflow-menu-item {
    color: #e5e7eb;
}

.tab-overflow-menu-icon {
    @apply flex-shrink-0;
    width: 1rem;
}

.tab-overflow-menu-label {
    @apply truncate;
    min-width: 0;
    flex: 1 1 auto;
}

.tab-overflow-measurer {
    position: absolute;
    top: 0;
    left: 0;
    z-index: -1;
    display: flex;
    width: max-content;
    height: 0;
    overflow: hidden;
    visibility: hidden;
    pointer-events: none;
    white-space: nowrap;
}
