/* ========================================
   DESKTOP TAB STYLES (768px and above)
   ======================================== */

/* Frontend Styles */
.accessible-tabs {
    margin: 20px 0;
    font-family: inherit;
    position: relative;
}

/* Tab Navigation Styles */
.tab-navigation {
    display: flex;
    border-bottom: var(--tab-border-width, 2px) solid var(--tab-border-color, #ddd);
    margin-bottom: 0;
    background: inherit;
    border-radius: inherit;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    overflow: hidden;
}

/* Tab Alignment Options (Desktop Only) */
.tabs-align-left .tab-navigation {
    justify-content: flex-start;
}

.tabs-align-center .tab-navigation {
    justify-content: center;
}

.tabs-align-right .tab-navigation {
    justify-content: flex-end;
}

/* Tab Button Styles */
.tab-button {
    background: #f9f9f9;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    color: #666;
    position: relative;
    /* Allow custom font styles to override defaults */
    font-family: inherit;
}

.tab-button:hover {
    background: #e9e9e9;
    /* Maintain font color on hover unless overridden */
}

/* Custom background color buttons need special hover handling */
.tab-button.has-custom-bg:hover {
    filter: brightness(0.9);
    background: inherit; /* Don't override custom background */
}

.tab-button.active {
    background: white;
    border-bottom-color: #0073aa;
    /* Custom font color will override this if set */
}

/* Active state for custom background buttons */
.tab-button.active.has-custom-bg {
    border-bottom-color: #0073aa;
    /* Keep custom background on active state */
    background: inherit;
}

.tab-button.active:not([style*="color"]):not(.has-custom-bg) {
    color: #0073aa;
}

/* Active tab styling with container-level overrides */
.accessible-tabs.has-active-text-color .tab-button.active,
.accessible-tabs.has-active-text-color .accordion-button.active,
.accessible-tabs.has-active-text-color .accordion-header.active {
    color: var(--active-tab-text-color) !important;
}

.accessible-tabs.has-active-bg-color .tab-button.active,
.accessible-tabs.has-active-bg-color .accordion-button.active,
.accessible-tabs.has-active-bg-color .accordion-header.active {
    background-color: var(--active-tab-bg-color) !important;
}

/* Ensure custom colors override individual tab styling */
.accessible-tabs.has-active-text-color .tab-button.active.has-custom-bg {
    color: var(--active-tab-text-color) !important;
}

.accessible-tabs.has-active-bg-color .tab-button.active.has-custom-bg {
    background-color: var(--active-tab-bg-color) !important;
}

.tab-button:focus {
    outline: 2px solid #0073aa;
    outline-offset: -2px;
    z-index: 1;
    position: relative;
}

/* Content Styles */
.tab-content-container {
    position: relative;
    min-height: 200px;
}

.tab-content {
    display: none;
    padding: 20px;
    animation: fadeIn 0.3s ease-in-out;
    outline: none; /* Remove default focus outline since we handle it with border */
}

.tab-content:focus {
    border: 2px solid #0073aa;
    border-top: none; /* Don't double up the border with tab navigation */
    outline: none;
}

.tab-content.active {
    display: block;
}

/* Hidden state for screen readers */
.tab-content[hidden] {
    display: none !important;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========================================
   MOBILE ACCORDION STYLES (767px and below)
   ======================================== */

@media (max-width: 768px) {
    /* Hide tab navigation on mobile */
    .tab-navigation {
        display: none;
    }
    
    .tab-content-container {
        display: none;
    }

    /* Accordion Container */
    .accordion-container {
        width: 100%;
    }

    /* Accordion Item */
    .accordion-item {
        border-bottom: var(--tab-border-width, 1px) solid var(--tab-border-color, #ddd);
        margin-bottom: 0;
    }

    .accordion-item:last-child {
        border-bottom: none;
    }

    /* Accordion Headers (converted tab buttons) */
    .accordion-button,
    .accordion-header {
        width: 100%;
        text-align: left;
        background: #f9f9f9;
        border: none;
        padding: 16px 20px;
        cursor: pointer;
        font-size: 16px;
        font-weight: 500;
        color: #333;
        position: relative;
        transition: all 0.3s ease;
        border-radius: 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        min-height: 60px; /* Touch-friendly height */
    }

    /* Add expand/collapse icon */
    .accordion-button::after,
    .accordion-header::after {
        content: '+';
        font-size: 18px;
        font-weight: bold;
        color: inherit;
        transition: transform 0.3s ease;
    }

    .accordion-button.active::after,
    .accordion-header.active::after {
        content: '−';
        transform: rotate(0deg);
    }

    .accordion-button:hover,
    .accordion-header:hover {
        background: #e9e9e9;
    }

    .accordion-button.active,
    .accordion-header.active {
        background: #fff;
        color: #0073aa;
        border-bottom: 2px solid #0073aa;
    }

    /* Container-level active styling for mobile */
    .accessible-tabs.has-active-text-color .accordion-button.active,
    .accessible-tabs.has-active-text-color .accordion-header.active {
        color: var(--active-tab-text-color) !important;
    }

    .accessible-tabs.has-active-bg-color .accordion-button.active,
    .accessible-tabs.has-active-bg-color .accordion-header.active {
        background-color: var(--active-tab-bg-color) !important;
    }

    /* Custom background handling for accordion */
    .accordion-button.has-custom-bg,
    .accordion-header.has-custom-bg {
        /* Custom background styles are preserved */
    }

    .accordion-button.has-custom-bg:hover,
    .accordion-header.has-custom-bg:hover {
        filter: brightness(0.9);
        background: inherit;
    }

    .accordion-button:focus,
    .accordion-header:focus {
        outline: 2px solid #0073aa;
        outline-offset: -2px;
        z-index: 1;
    }

    /* Accordion Content */
    .accordion-content {
        padding: 20px;
        border-top: var(--tab-border-width, 1px) solid var(--tab-border-color, #eee);
        animation: slideDown 0.3s ease-out;
    }

    .accordion-content[hidden] {
        display: none !important;
    }

    .accordion-content:focus {
        outline: 2px solid #0073aa;
        outline-offset: -2px;
    }

    /* Accordion slide animation */
    @keyframes slideDown {
        from {
            opacity: 0;
            max-height: 0;
            padding-top: 0;
            padding-bottom: 0;
        }
        to {
            opacity: 1;
            max-height: 1000px;
            padding-top: 20px;
            padding-bottom: 20px;
        }
    }

    /* Override tab-specific styles that might conflict */
    .tab-button {
        display: none;
    }
}

/* ========================================
   DEVELOPER-FRIENDLY CLASSES
   ======================================== */

/* Border Style Variations */
.tabs-style-dashed .tab-navigation {
    border-style: dashed;
}

.tabs-style-dotted .tab-navigation {
    border-style: dotted;
}

.tabs-style-none .tab-navigation {
    border: none;
}

/* Font Weight Variations */
.font-weight-100 { font-weight: 100; }
.font-weight-300 { font-weight: 300; }
.font-weight-500 { font-weight: 500; }
.font-weight-600 { font-weight: 600; }
.font-weight-700 { font-weight: 700; }
.font-weight-800 { font-weight: 800; }
.font-weight-900 { font-weight: 900; }

/* Custom Font Family Indicator */
.font-family-custom {
    /* This class is added when a custom font family is set */
}

/* Custom Background Indicator */
.has-custom-background {
    /* This class is added when a custom title background color is set */
}

.has-custom-bg {
    /* This class is added to buttons with custom background colors */
    border-radius: 4px 4px 0 0;
}

@media (max-width: 768px) {
    .has-custom-bg {
        border-radius: 0; /* Remove border radius on mobile accordion */
    }
}

/* High Border Width Styling */
.tabs-width-5,
.tabs-width-6,
.tabs-width-7,
.tabs-width-8,
.tabs-width-9,
.tabs-width-10 {
    /* For thick borders, add subtle shadow */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* High Border Radius Styling */
.tabs-radius-25,
.tabs-radius-30,
.tabs-radius-35,
.tabs-radius-40,
.tabs-radius-45,
.tabs-radius-50 {
    overflow: hidden; /* Ensure content doesn't overflow rounded corners */
}

/* ========================================
   RESPONSIVE OVERRIDE (Tablet Portrait)
   ======================================== */

@media (max-width: 768px) and (orientation: landscape) {
    /* On landscape tablets, keep accordion but adjust spacing */
    .accordion-button,
    .accordion-header {
        padding: 12px 16px;
        min-height: 50px;
    }
    
    .accordion-content {
        padding: 16px;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .accessible-tabs {
        break-inside: avoid;
    }
    
    .accordion-container .accordion-item,
    .tab-content-container .tab-content {
        display: block !important;
        page-break-inside: avoid;
    }
    
    .accordion-button::after,
    .accordion-header::after {
        display: none;
    }
}