/**
 * TGD Product Sections Accordion Styles
 * Styled to match the Bulk Discount accordion
 */

/* --- UNIFICACIÓN DE ESTILO DE ACORDEÓN (igual que Bulk Discount) --- */
.tgd-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 15px 15px 20px;
    background-color: #fff;
    margin: 0 !important;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    user-select: none;
    border: 1px solid #e5e5e5;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tgd-section-header:hover {
    background-color: #f9f9f9;
}

.tgd-section-active {
    background-color: #f9f9f9;
    border-bottom-color: transparent;
}

/* Arrow indicator - triangle style - using !important to ensure visibility */
.tgd-section-arrow {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #333;
    transition: transform 0.3s ease;
    margin-left: 10px;
    flex-shrink: 0;
    position: relative;
    z-index: 5; /* Ensure it's visible above other elements */
}

.tgd-section-active .tgd-section-arrow {
    transform: rotate(180deg);
}

/* Content styling - with important flags for critical properties */
.tgd-section-content {
    border: 1px solid #e5e5e5;
    border-top: none;
    padding: 0;
    margin: 0 0 15px 0;
    background-color: #fff;
}

/* Force display property - this ensures content is properly hidden initially */
.tgd-section-content[aria-hidden="true"] {
    display: none !important;
    max-height: 0 !important;
    overflow: hidden !important;
}

.tgd-section-content[aria-hidden="false"] {
    display: block !important;
    max-height: 2000px !important; /* Large value to accommodate all content */
    overflow-x: auto !important;
}

/* Special handling for nested elements in caps products */
.mb-3 .tgd-section-content {
    margin-top: 0 !important;
}

/* Adjust styling for composition in caps products */
p.product-short-desc strong:contains("Composició") {
    font-weight: 500;
}

/* Style for the composition content in caps */
.tgd-section-content .child-p\:mb-2 p {
    margin-bottom: 5px;
}

.tgd-section-content .child-p\:mb-2 p:last-child {
    margin-bottom: 0;
}

/* Improved focus states for accessibility */
.tgd-section-header:focus {
    outline: 2px solid rgba(0, 123, 255, 0.5);
    outline-offset: 2px;
}

/* Hide focus outline when using mouse */
.tgd-section-header:focus:not(:focus-visible) {
    outline: none;
}

/* Special styling for caps product structure */
.tgd-caps-composition-processed {
    display: none !important;
}

/* Fix for nested description content */
.tgd-section-content #description,
.tgd-section-content .mdl-tabs__panel,
.tgd-section-content .product-info,
.tgd-section-content .mdl-cell {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
}

/* Make sure typography is consistent */
.tgd-section-content p {
    margin-bottom: 8px;
}

.tgd-section-content p:last-child {
    margin-bottom: 0;
}

/* Responsive adjustments */
@media (max-width: 767px) {
    .tgd-section-content {
        overflow-x: auto;
    }
    .tgd-section-header {
        padding: 12px 15px;
        font-size: 13px;
    }
    .tgd-section-arrow {
        border-left: 5px solid transparent;
        border-right: 5px solid transparent;
        border-top: 5px solid #333;
    }
}

/* DTF Accordions */
.tgd-dtf-header {
    margin-top: 10px !important;
    margin-bottom: 0 !important;
    padding: 12px 15px 12px 20px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    border: 1px solid #e5e5e5 !important;
    background-color: #fff !important;
    font-weight: 500 !important;
    cursor: pointer !important;
}

.tgd-dtf-header:first-child {
    margin-top: 0 !important;
}

.tgd-dtf-header:hover {
    background-color: #f9f9f9 !important;
}

.tgd-dtf-header.tgd-section-active {
    background-color: #f9f9f9 !important;
    border-bottom-color: transparent !important;
}

.tgd-dtf-content {
    border: 1px solid #e5e5e5 !important;
    border-top: none !important;
    padding: 15px 20px !important;
    margin-bottom: 15px !important;
    background-color: #fff !important;
    display: none !important; /* Start hidden by default */
}

/* Ensure proper spacing for lists */
.tgd-dtf-content ul,
.tgd-dtf-content ol {
    padding-left: 20px !important;
    margin: 10px 0 !important;
}

.tgd-dtf-content li {
    margin-bottom: 5px !important;
}

.tgd-dtf-content hr {
    margin: 15px 0 !important;
    border-top: 1px solid #e5e5e5 !important;
}

/* Hide HRs when they're the last child in the content */
.tgd-dtf-content hr:last-child {
    display: none !important;
}

/* Size Table Accordions */
.tgd-size-table-header {
    margin-top: 15px !important;
    margin-bottom: 0 !important;
    padding: 12px 15px 12px 20px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    border: 1px solid #e5e5e5 !important;
    background-color: #fff !important;
    font-weight: 500 !important;
    cursor: pointer !important;
}

.tgd-size-table-header:first-child {
    margin-top: 0 !important;
}

.tgd-size-table-header:hover {
    background-color: #f9f9f9 !important;
}

.tgd-size-table-header.tgd-section-active {
    background-color: #f9f9f9 !important;
    border-bottom-color: transparent !important;
}

.tgd-size-table-content {
    border: 1px solid #e5e5e5 !important;
    border-top: none !important;
    padding: 15px 20px !important;
    margin-bottom: 15px !important;
    background-color: #fff !important;
    overflow-x: auto !important; /* For responsive tables */
    display: none !important; /* Start hidden by default */
}

/* Style for tables inside size table section */
.tgd-size-table-content table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin: 0 !important;
}

.tgd-size-table-content table th,
.tgd-size-table-content table td {
    padding: 8px !important;
    border: 1px solid #e5e5e5 !important;
}

.tgd-size-table-content table th {
    background-color: #f9f9f9 !important;
    text-align: center !important;
    font-weight: 500 !important;
}

/* Hide the size table heading if it's part of the table */
table th.tgd-section-header {
    display: none !important;
}

/* Responsive adjustments for mobile */
@media (max-width: 767px) {
    .tgd-size-table-content {
        padding: 10px !important;
    }
    
    .tgd-size-table-content table th,
    .tgd-size-table-content table td {
        padding: 5px !important;
        font-size: 12px !important;
    }
}

/* Style for elements that already have a toggle system */
.tgd-existing-toggle {
    position: relative !important;
}

/* Make sure our arrow doesn't conflict with existing arrows */
.tgd-existing-toggle .tgd-section-arrow {
    position: absolute !important;
    right: 15px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
}

/* Hide any duplicate arrows in existing toggle systems */
.tgd-existing-toggle:after {
    display: none !important;
}

/* Extra spacing and style fixes */
.tgd-section-header + .tgd-section-header {
    margin-top: 15px !important;
}

/* Fix for Firefox animation issues */
@-moz-document url-prefix() {
    .tgd-section-content {
        overflow-x: auto !important;
    }
}

/* Ensure toggle animations work properly */
.tgd-section-content, .tgd-dtf-content, .tgd-size-table-content {
    transition: max-height 0.3s ease !important;
}

/* --- FIN UNIFICACIÓN DE ESTILO --- */
