/**
 * TABS - PharmData Design System v2.0
 * Navegação por abas com múltiplos estilos
 *
 * Inclui: Tabs básicas, Pills, Underline, Bordered, Vertical
 * Com suporte a ícones, badges e estados.
 */

/* ===================
   CSS CUSTOM PROPERTIES
   =================== */

:root {
    /* Tab sizing */
    --tab-height: 2.75rem;
    --tab-padding: 0.75rem 1.25rem;
    --tab-gap: 0.25rem;

    /* Colors */
    --tab-bg: transparent;
    --tab-bg-hover: rgba(183, 228, 213, 0.08);
    --tab-bg-active: rgba(42, 161, 152, 0.1);
    --tab-text: var(--soft-steel, #374151);
    --tab-text-hover: var(--graphite-depth, #1F2937);
    --tab-text-active: var(--teal-intense, #1a8b7d);

    /* Border */
    --tab-border-color: rgba(183, 228, 213, 0.3);
    --tab-border-active: var(--teal-intense, #1a8b7d);
    --tab-border-width: 2px;

    /* Animation */
    --tab-transition: all 0.15s ease;
}

/* Dark mode */
:root.dark-mode {
    --tab-bg-hover: rgba(183, 228, 213, 0.1);
    --tab-bg-active: rgba(42, 161, 152, 0.15);
    --tab-border-color: rgba(183, 228, 213, 0.2);
}

/* ===================
   TAB LIST CONTAINER
   =================== */

.tabs {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.tab-list {
    display: flex;
    gap: var(--tab-gap);
    border-bottom: 1px solid var(--tab-border-color);
    margin: 0;
    padding: 0;
    list-style: none;
}

.tab-list[role="tablist"] {
    /* Semantic list for accessibility */
}

/* ===================
   TAB BUTTON BASE
   =================== */

.tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: var(--tab-padding);
    min-height: var(--tab-height);
    background: var(--tab-bg);
    color: var(--tab-text);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    border-bottom: var(--tab-border-width) solid transparent;
    margin-bottom: calc(-1px);
    cursor: pointer;
    transition: var(--tab-transition);
    white-space: nowrap;
    position: relative;
}

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

.tab:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--teal-intense, #1a8b7d);
    border-radius: 0.25rem 0.25rem 0 0;
}

/* Active state */
.tab.active,
.tab[aria-selected="true"] {
    color: var(--tab-text-active);
    border-bottom-color: var(--tab-border-active);
    background: var(--tab-bg-active);
}

/* Disabled */
.tab:disabled,
.tab[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ===================
   TAB WITH ICON
   =================== */

.tab-icon {
    font-size: 1rem;
    opacity: 0.7;
}

.tab.active .tab-icon,
.tab[aria-selected="true"] .tab-icon {
    opacity: 1;
}

/* Icon only tab */
.tab-icon-only {
    padding: 0.75rem;
    min-width: var(--tab-height);
}

.tab-icon-only .tab-icon {
    margin: 0;
}

/* ===================
   TAB WITH BADGE
   =================== */

.tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.375rem;
    font-size: 0.6875rem;
    font-weight: 600;
    background: rgba(100, 116, 139, 0.15);
    color: var(--soft-steel, #374151);
    border-radius: 10rem;
}

.tab.active .tab-badge,
.tab[aria-selected="true"] .tab-badge {
    background: rgba(42, 161, 152, 0.15);
    color: var(--teal-intense, #1a8b7d);
}

/* ===================
   TAB PANEL
   =================== */

.tab-panel {
    padding: 1.5rem 0;
    display: none;
}

.tab-panel.active,
.tab-panel[data-state="active"] {
    display: block;
}

/* With animation */
.tab-panel-animated {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.tab-panel-animated.active {
    opacity: 1;
    transform: translateY(0);
}

/* ===================
   TABS VARIANTS
   =================== */

/* --- Pills --- */
.tabs-pills .tab-list {
    border-bottom: none;
    gap: 0.5rem;
}

.tabs-pills .tab {
    border: none;
    border-radius: 0.5rem;
    margin-bottom: 0;
    background: transparent;
}

.tabs-pills .tab:hover {
    background: var(--tab-bg-hover);
}

.tabs-pills .tab.active,
.tabs-pills .tab[aria-selected="true"] {
    background: var(--teal-intense, #1a8b7d);
    color: white;
}

.tabs-pills .tab.active .tab-badge {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* --- Underline Only --- */
.tabs-underline .tab-list {
    gap: 0;
}

.tabs-underline .tab {
    background: transparent;
    padding: 0.75rem 1.5rem;
}

.tabs-underline .tab:hover {
    background: transparent;
    color: var(--tab-text-hover);
}

.tabs-underline .tab.active {
    background: transparent;
}

/* Animated underline */
.tabs-underline-animated .tab-list {
    position: relative;
}

.tabs-underline-animated .tab-indicator {
    position: absolute;
    bottom: -1px;
    height: var(--tab-border-width);
    background: var(--tab-border-active);
    transition: left 0.2s ease, width 0.2s ease;
}

.tabs-underline-animated .tab {
    border-bottom-color: transparent;
}

/* --- Bordered/Boxed --- */
.tabs-bordered .tab-list {
    border: 1px solid var(--tab-border-color);
    border-radius: 0.5rem;
    padding: 0.25rem;
    background: rgba(183, 228, 213, 0.05);
    gap: 0.25rem;
}

.tabs-bordered .tab {
    border: none;
    border-radius: 0.375rem;
    margin-bottom: 0;
}

.tabs-bordered .tab.active,
.tabs-bordered .tab[aria-selected="true"] {
    background: var(--cloud);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

:root.dark-mode .tabs-bordered .tab.active {
    background: var(--arctic-mist, #E9ECEF);
}

/* --- Soft --- */
.tabs-soft .tab-list {
    border-bottom: none;
    gap: 0.5rem;
}

.tabs-soft .tab {
    border: none;
    border-radius: 0.5rem;
    margin-bottom: 0;
    background: rgba(100, 116, 139, 0.08);
}

.tabs-soft .tab:hover {
    background: rgba(100, 116, 139, 0.15);
}

.tabs-soft .tab.active {
    background: var(--tab-bg-active);
    color: var(--tab-text-active);
}

/* ===================
   TAB SIZES
   =================== */

.tabs-sm .tab {
    padding: 0.5rem 0.875rem;
    min-height: 2.25rem;
    font-size: 0.8125rem;
}

.tabs-sm .tab-icon {
    font-size: 0.875rem;
}

.tabs-sm .tab-badge {
    min-width: 1rem;
    height: 1rem;
    font-size: 0.625rem;
}

.tabs-lg .tab {
    padding: 1rem 1.5rem;
    min-height: 3.25rem;
    font-size: 0.9375rem;
}

.tabs-lg .tab-icon {
    font-size: 1.125rem;
}

/* ===================
   VERTICAL TABS
   =================== */

.tabs-vertical {
    flex-direction: row;
    gap: 1.5rem;
}

.tabs-vertical .tab-list {
    flex-direction: column;
    border-bottom: none;
    border-right: 1px solid var(--tab-border-color);
    padding-right: 0;
    min-width: 12rem;
}

.tabs-vertical .tab {
    justify-content: flex-start;
    border-bottom: none;
    border-right: var(--tab-border-width) solid transparent;
    margin-bottom: 0;
    margin-right: calc(-1px);
    text-align: left;
}

.tabs-vertical .tab.active,
.tabs-vertical .tab[aria-selected="true"] {
    border-right-color: var(--tab-border-active);
}

.tabs-vertical .tab-panel {
    flex: 1;
    padding: 0;
}

/* Vertical pills */
.tabs-vertical.tabs-pills .tab-list {
    border-right: none;
}

.tabs-vertical.tabs-pills .tab {
    border-right: none;
    margin-right: 0;
}

/* ===================
   FULL WIDTH TABS
   =================== */

.tabs-full .tab-list {
    width: 100%;
}

.tabs-full .tab {
    flex: 1;
}

/* ===================
   SCROLLABLE TABS
   =================== */

.tabs-scrollable .tab-list {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
    padding-bottom: 1px; /* Prevent border cut */
}

.tabs-scrollable .tab-list::-webkit-scrollbar {
    display: none;
}

/* Scroll indicators */
.tabs-scrollable-container {
    position: relative;
}

.tabs-scroll-btn {
    position: absolute;
    top: 0;
    bottom: 1px;
    width: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to right, var(--cloud, white), transparent);
    border: none;
    cursor: pointer;
    z-index: 1;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.tabs-scroll-btn-left {
    left: 0;
}

.tabs-scroll-btn-right {
    right: 0;
    background: linear-gradient(to left, var(--cloud, white), transparent);
}

.tabs-scrollable-container.can-scroll-left .tabs-scroll-btn-left,
.tabs-scrollable-container.can-scroll-right .tabs-scroll-btn-right {
    opacity: 1;
    pointer-events: auto;
}

/* ===================
   TAB CLOSE BUTTON
   =================== */

.tab-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    margin-left: 0.25rem;
    margin-right: -0.25rem;
    border-radius: 0.25rem;
    border: none;
    background: transparent;
    color: currentColor;
    opacity: 0.5;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tab-close:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.1);
}

.tab.active .tab-close:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error, #EF4444);
}

/* ===================
   CARD TABS
   Tabs com conteúdo em card
   =================== */

.tabs-card {
    border: 1px solid var(--tab-border-color);
    border-radius: 0.5rem;
    overflow: hidden;
}

.tabs-card .tab-list {
    background: rgba(183, 228, 213, 0.05);
    border-bottom: 1px solid var(--tab-border-color);
    padding: 0 0.5rem;
}

.tabs-card .tab {
    border-radius: 0;
}

.tabs-card .tab-panel {
    padding: 1.5rem;
    background: var(--modal-bg, white);
}

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

/* Keyboard navigation indicator */
.tab:focus:not(:focus-visible) {
    box-shadow: none;
}

/* Screen reader */
.tab[aria-selected="true"] {
    /* Announced as selected */
}

/* High contrast */
@media (prefers-contrast: high) {
    .tab {
        border: 1px solid transparent;
    }

    .tab.active,
    .tab[aria-selected="true"] {
        border-color: currentColor;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .tab,
    .tab-panel-animated,
    .tabs-underline-animated .tab-indicator {
        transition: none;
    }
}

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

@media (max-width: 640px) {
    /* Vertical becomes horizontal on mobile */
    .tabs-vertical {
        flex-direction: column;
        gap: 0;
    }

    .tabs-vertical .tab-list {
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid var(--tab-border-color);
        min-width: 0;
        overflow-x: auto;
        padding-right: 0;
    }

    .tabs-vertical .tab {
        border-right: none;
        border-bottom: var(--tab-border-width) solid transparent;
        margin-right: 0;
        margin-bottom: calc(-1px);
    }

    .tabs-vertical .tab.active {
        border-bottom-color: var(--tab-border-active);
        border-right-color: transparent;
    }

    /* Default to scrollable on mobile */
    .tab-list {
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .tab-list::-webkit-scrollbar {
        display: none;
    }

    .tab {
        flex-shrink: 0;
    }
}
