/* Tab Widget Styles - Animated Underline */

/* CSS Variables for consistent theming */
:root {
    --apc-tab-text-color: #333333;
    --apc-tab-text-color-active: #007cba;
    --apc-tab-underline-color: #007cba;
    --apc-tab-underline-height: 3px;
    --apc-tab-underline-duration: 0.3s;
    --apc-tab-transition: all 0.3s ease;
}

/* Base Container Styles */
.apc-tab-widget {
    position: relative;
    width: 100%;
    font-family: inherit;
    line-height: 1.6;
}

/* Tabs Container */
.apc-tabs-container {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0;
    position: relative;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 10px;
    margin-bottom: 0;
}

/* Individual Tab */
.apc-tab-title {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    margin: 0;
    cursor: pointer;
    transition: var(--apc-tab-transition);
    border: none;
    background: none;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    text-decoration: none;
    color: var(--apc-tab-text-color);
    user-select: none;
    overflow: hidden;
}

/* Tab Icon */
.apc-tab-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1em;
    transition: var(--apc-tab-transition);
}

/* Tab Text */
.apc-tab-text {
    display: inline-block;
    transition: var(--apc-tab-transition);
}

/* Underline using ::before pseudo-element */
.apc-tab-title::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: var(--apc-tab-underline-height);
    background-color: var(--apc-tab-underline-color);
    border-radius: 2px;
    transform: translateX(-50%);
    transition: all var(--apc-tab-underline-duration) ease;
    z-index: 1;
}

/* Underline using ::after pseudo-element (for different animations) */
.apc-tab-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: var(--apc-tab-underline-height);
    background-color: var(--apc-tab-underline-color);
    border-radius: 2px;
    transition: all var(--apc-tab-underline-duration) ease;
    z-index: 1;
}

/* Active Tab Styles */
.apc-tab-title.active {
    color: var(--apc-tab-text-color-active);
    font-weight: 600;
}

.apc-tab-title.active::before {
    width: 100%;
    left: 0;
    transform: translateX(0);
}

.apc-tab-title.active::after {
    width: 100%;
}

/* Hover Effects */
.apc-tab-title:hover {
    color: var(--apc-tab-text-color-active);
    transform: translateY(-1px);
}

/* Hover Underline Animation */
.apc-tab-widget[data-underline-trigger="hover"] .apc-tab-title:hover::before,
.apc-tab-widget[data-underline-trigger="both"] .apc-tab-title:hover::before {
    width: 100%;
    left: 0;
    transform: translateX(0);
}

.apc-tab-widget[data-underline-trigger="hover"] .apc-tab-title:hover::after,
.apc-tab-widget[data-underline-trigger="both"] .apc-tab-title:hover::after {
    width: 100%;
}

/* Animation Types */

/* Slide Animation */
.apc-tab-widget[data-underline-animation="slide"] .apc-tab-title::before {
    left: 0;
    transform: translateX(-100%);
}

.apc-tab-widget[data-underline-animation="slide"] .apc-tab-title.active::before,
.apc-tab-widget[data-underline-animation="slide"] .apc-tab-title:hover::before {
    transform: translateX(0);
}

/* Fade Animation */
.apc-tab-widget[data-underline-animation="fade"] .apc-tab-title::before,
.apc-tab-widget[data-underline-animation="fade"] .apc-tab-title::after {
    opacity: 0;
    width: 100%;
    left: 0;
    transform: translateX(0);
}

.apc-tab-widget[data-underline-animation="fade"] .apc-tab-title.active::before,
.apc-tab-widget[data-underline-animation="fade"] .apc-tab-title.active::after,
.apc-tab-widget[data-underline-animation="fade"] .apc-tab-title:hover::before,
.apc-tab-widget[data-underline-animation="fade"] .apc-tab-title:hover::after {
    opacity: 1;
}

/* Scale Animation */
.apc-tab-widget[data-underline-animation="scale"] .apc-tab-title::before,
.apc-tab-widget[data-underline-animation="scale"] .apc-tab-title::after {
    width: 100%;
    left: 0;
    transform: translateX(0) scaleX(0);
    transform-origin: center;
}

.apc-tab-widget[data-underline-animation="scale"] .apc-tab-title.active::before,
.apc-tab-widget[data-underline-animation="scale"] .apc-tab-title.active::after,
.apc-tab-widget[data-underline-animation="scale"] .apc-tab-title:hover::before,
.apc-tab-widget[data-underline-animation="scale"] .apc-tab-title:hover::after {
    transform: translateX(0) scaleX(1);
}

/* Bounce Animation */
.apc-tab-widget[data-underline-animation="bounce"] .apc-tab-title::before,
.apc-tab-widget[data-underline-animation="bounce"] .apc-tab-title::after {
    width: 100%;
    left: 0;
    transform: translateX(0) scaleY(0);
    transform-origin: bottom;
}

.apc-tab-widget[data-underline-animation="bounce"] .apc-tab-title.active::before,
.apc-tab-widget[data-underline-animation="bounce"] .apc-tab-title.active::after,
.apc-tab-widget[data-underline-animation="bounce"] .apc-tab-title:hover::before,
.apc-tab-widget[data-underline-animation="bounce"] .apc-tab-title:hover::after {
    transform: translateX(0) scaleY(1);
    animation: apc-bounce-in 0.6s ease;
}

/* Bounce Keyframes */
@keyframes apc-bounce-in {
    0% {
        transform: translateX(0) scaleY(0);
    }
    50% {
        transform: translateX(0) scaleY(1.2);
    }
    100% {
        transform: translateX(0) scaleY(1);
    }
}

/* Content Styles */
.apc-tabs-content {
    position: relative;
    width: 100%;
    min-height: 100px;
}

.apc-tab-content {
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    padding: 20px 0;
}

.apc-tab-content.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* RTL Support */
[dir="rtl"] .apc-tab-title {
    text-align: right;
}

[dir="rtl"] .apc-tab-title::before,
[dir="rtl"] .apc-tab-title::after {
    right: 0;
    left: auto;
}

[dir="rtl"] .apc-tab-widget[data-underline-animation="slide"] .apc-tab-title::before {
    transform: translateX(100%);
}

[dir="rtl"] .apc-tab-widget[data-underline-animation="slide"] .apc-tab-title.active::before,
[dir="rtl"] .apc-tab-widget[data-underline-animation="slide"] .apc-tab-title:hover::before {
    transform: translateX(0);
}

/* Responsive Design */
@media (max-width: 768px) {
    .apc-tabs-container {
        flex-direction: column;
        align-items: stretch;
        border-bottom: none;
        padding-bottom: 0;
    }
    
    .apc-tab-title {
        width: 100%;
        justify-content: center;
        margin-bottom: 10px;
        border-bottom: 1px solid #e0e0e0;
        padding: 15px 20px;
    }
    
    .apc-tab-title::before,
    .apc-tab-title::after {
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        transform: translateX(0) scaleX(0);
        transform-origin: center;
    }
    
    .apc-tab-title.active::before,
    .apc-tab-title.active::after,
    .apc-tab-title:hover::before,
    .apc-tab-title:hover::after {
        transform: translateX(0) scaleX(1);
    }
}

@media (max-width: 480px) {
    .apc-tab-title {
        padding: 12px 15px;
        font-size: 14px;
    }
    
    .apc-tab-content {
        padding: 15px 0;
    }
}

/* Accessibility Improvements */
.apc-tab-title:focus {
    outline: 2px solid var(--apc-tab-underline-color);
    outline-offset: 2px;
}

.apc-tab-title:focus-visible {
    outline: 2px solid var(--apc-tab-underline-color);
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .apc-tab-title {
        border: 1px solid currentColor;
    }
    
    .apc-tab-title::before,
    .apc-tab-title::after {
        background-color: currentColor;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .apc-tab-title,
    .apc-tab-title::before,
    .apc-tab-title::after,
    .apc-tab-content {
        transition: none;
        animation: none;
    }
}

/* Print Styles */
@media print {
    .apc-tab-title::before,
    .apc-tab-title::after {
        display: none;
    }
    
    .apc-tab-content {
        display: block !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* Performance Optimizations */
.apc-tab-title {
    contain: layout style;
    will-change: transform, color;
}

.apc-tab-title::before,
.apc-tab-title::after {
    contain: layout style;
    will-change: transform, width, opacity;
}

/* Custom Underline Position - Top */
.apc-tab-title[data-underline-position="top"]::before,
.apc-tab-title[data-underline-position="top"]::after {
    top: 0;
    bottom: auto;
}

/* Custom Underline Position - Bottom */
.apc-tab-title[data-underline-position="bottom"]::before,
.apc-tab-title[data-underline-position="bottom"]::after {
    bottom: 0;
    top: auto;
}

/* Advanced Animation Effects */
.apc-tab-title:hover .apc-tab-icon {
    transform: scale(1.1);
}

.apc-tab-title:hover .apc-tab-text {
    transform: translateX(2px);
}

[dir="rtl"] .apc-tab-title:hover .apc-tab-text {
    transform: translateX(-2px);
}

/* Gradient Underline Support */
.apc-tab-title.gradient-underline::before,
.apc-tab-title.gradient-underline::after {
    background: linear-gradient(90deg, var(--apc-tab-underline-color), transparent, var(--apc-tab-underline-color));
}

/* Multiple Underline Lines */
.apc-tab-title.multiple-lines::before {
    height: calc(var(--apc-tab-underline-height) / 2);
    bottom: 2px;
}

.apc-tab-title.multiple-lines::after {
    height: calc(var(--apc-tab-underline-height) / 2);
    bottom: 0;
}
