/**
 * Ensueño Formula Table — public-facing styles
 *
 * Responsive table that stacks into cards on mobile.
 * Theme-agnostic: avoids overriding theme typography/colors aggressively.
 */

/* CSS Variables for easy theming */
.ensueno-formula-table-wrap {
    --ensueno-color-primary: #1B3A52;
    --ensueno-color-primary-text: #FFFFFF;
    --ensueno-color-cas: #1B3A52;
    --ensueno-color-text: #1F2937;
    --ensueno-color-muted: #6B7280;
    --ensueno-color-border: #E5E7EB;
    --ensueno-color-border-soft: #F3F4F6;
    --ensueno-color-row-alt: #FAFAFA;
    --ensueno-color-row-hover: #F0F4F8;
    --ensueno-radius: 6px;
    --ensueno-spacing: 0.75rem;

    margin: 2rem 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.ensueno-formula-title {
    margin: 2rem 0 1rem;
    font-size: 27px;
    font-weight: 700;
    color: #000000;
}

/* ============================================================================
   TABLE — desktop
   ============================================================================ */
.ensueno-formula-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    line-height: 1.5;
    border-radius: var(--ensueno-radius);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* High specificity + !important to override theme table styles (e.g. Salient) */
.ensueno-formula-table-wrap .ensueno-formula-table thead,
.ensueno-formula-table-wrap .ensueno-formula-table thead tr {
    background-color: var(--ensueno-color-primary) !important;
}

.ensueno-formula-table-wrap .ensueno-formula-table thead th {
    background-color: var(--ensueno-color-primary) !important;
    color: var(--ensueno-color-primary-text) !important;
    padding: var(--ensueno-spacing) 1rem;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    vertical-align: middle;
    border: none !important;
}

.ensueno-formula-table tbody tr {
    border-bottom: 1px solid var(--ensueno-color-border);
    transition: background-color 0.15s ease;
}

.ensueno-formula-table tbody tr:nth-child(even) {
    background: var(--ensueno-color-row-alt);
}

.ensueno-formula-table tbody tr:hover {
    background: var(--ensueno-color-row-hover);
}

.ensueno-formula-table tbody tr:last-child {
    border-bottom: none;
}

.ensueno-formula-table td {
    padding: var(--ensueno-spacing) 1rem;
    color: var(--ensueno-color-text);
    vertical-align: top;
}

/* CAS# column gets a monospace treatment for technical look */
.ensueno-formula-table td:first-child {
    font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', 'Courier New', monospace;
    color: var(--ensueno-color-cas);
    font-weight: 500;
    white-space: nowrap;
    font-size: 0.88rem;
}

/* Empty cell placeholder ("—") */
.ensueno-empty-cell {
    color: var(--ensueno-color-muted);
    font-weight: 400;
}

/* ============================================================================
   MESSAGES (error / empty)
   ============================================================================ */
.ensueno-message {
    padding: 1rem 1.25rem;
    border-radius: var(--ensueno-radius);
    margin: 1.5rem 0;
    font-size: 0.95rem;
    border-left: 4px solid;
}

.ensueno-message--error {
    background: #FEF2F2;
    border-left-color: #DC2626;
    color: #991B1B;
}

.ensueno-message--empty {
    background: #FEF3C7;
    border-left-color: #F59E0B;
    color: #78350F;
}

/* ============================================================================
   ACCESSIBILITY — visually hidden text
   ============================================================================ */
.ensueno-formula-table-wrap .screen-reader-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ============================================================================
   MOBILE — Stacked card layout (< 768px)
   ============================================================================ */
@media (max-width: 768px) {

    .ensueno-formula-table-wrap {
        overflow-x: visible;  /* No horizontal scroll on mobile */
    }

    .ensueno-formula-table {
        box-shadow: none;
        border-radius: 0;
    }

    .ensueno-formula-table thead {
        /* Hide header visually — labels appear inline via data-label */
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0,0,0,0);
        white-space: nowrap;
        border: 0;
    }

    .ensueno-formula-table tbody,
    .ensueno-formula-table tr,
    .ensueno-formula-table td {
        display: block;
        width: 100%;
    }

    .ensueno-formula-table tbody tr {
        margin-bottom: 1rem;
        border: 1px solid var(--ensueno-color-border);
        border-radius: var(--ensueno-radius);
        padding: 0.25rem 1rem;
        background: white;
    }

    .ensueno-formula-table tbody tr:nth-child(even) {
        background: white;
    }

    .ensueno-formula-table tbody tr:hover {
        background: white;
    }

    .ensueno-formula-table td {
        padding: 0.6rem 0;
        border-bottom: 1px solid var(--ensueno-color-border-soft);
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 1rem;
        text-align: right;
    }

    .ensueno-formula-table td:last-child {
        border-bottom: none;
    }

    /* Show the column label inline via data-label attribute */
    .ensueno-formula-table td::before {
        content: attr(data-label);
        font-weight: 600;
        text-transform: uppercase;
        font-size: 0.72rem;
        color: var(--ensueno-color-muted);
        letter-spacing: 0.06em;
        flex-shrink: 0;
        text-align: left;
    }

    /* On mobile, CAS# stays mono but loses fixed nowrap */
    .ensueno-formula-table td:first-child {
        white-space: normal;
    }
}

/* ============================================================================
   PRINT — clean for regulatory printouts
   ============================================================================ */
@media print {
    .ensueno-formula-table {
        box-shadow: none;
        font-size: 11pt;
        border: 1px solid #000;
    }

    .ensueno-formula-table thead {
        background: #f0f0f0;
        color: #000;
    }

    .ensueno-formula-table th,
    .ensueno-formula-table td {
        border: 1px solid #ccc;
        padding: 6pt 8pt;
    }
}

/* ============================================================================
   FORMULA HEAD (title + SDS link) and DESIGNATED LIST LINKS / NA
   ============================================================================ */
.ensueno-formula-head {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    margin: 2rem 0 0.5rem;
}
.ensueno-formula-head .ensueno-formula-title {
    margin: 0;
}
.ensueno-sds-link {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #9B1B47;
    text-decoration: none;
    border-bottom: 1px solid currentColor;
}
.ensueno-sds-link:hover,
.ensueno-sds-link:focus {
    color: #6f1334;
}
.ensueno-designated-lists a {
    color: #6a3fa0;
    text-decoration: underline;
}
.ensueno-designated-lists a:hover,
.ensueno-designated-lists a:focus {
    color: #59348a;
}
.ensueno-na {
    color: #6B7280;
}

/* ============================================================
   SmartLabel-style "label" layout (layout="label")
   ============================================================ */
.ensueno-label { margin: 1rem 0; }
.ensueno-label-list,
.ensueno-label-sublist { list-style: none !important; margin: 0; padding: 0; }
.ensueno-label-list li,
.ensueno-label-sublist li { list-style: none !important; margin: 0; }
.ensueno-label-list li::marker,
.ensueno-label-sublist li::marker { content: ""; }
.ensueno-label-item { border-bottom: 1px solid #e3e6ef; }

.ensueno-acc { width: 100%; }
.ensueno-acc-head {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .85rem .25rem;
    font-weight: 600;
    color: #0a1690;
}
.ensueno-acc-head::-webkit-details-marker { display: none; }
.ensueno-label-name { flex: 1 1 auto; font-size: 16px; line-height: 1.4; color: #0a1690; }

.ensueno-acc-chevron {
    flex: 0 0 auto;
    width: .55rem;
    height: .55rem;
    border-right: 2px solid #0a1690;
    border-bottom: 2px solid #0a1690;
    transform: rotate(-45deg);
    transition: transform .2s ease;
}
.ensueno-acc[open] .ensueno-acc-chevron { transform: rotate(45deg); }

.ensueno-ds-badge {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4rem;
    height: 1.4rem;
    padding: 0 .4rem;
    border-radius: 999px;
    background: #0a1690;
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .02em;
    line-height: 1;
}

.ensueno-acc-panel { padding: .15rem .25rem 1rem; color: #333; }
.ensueno-acc-desc { margin: 0 0 .75rem; line-height: 1.5; }
.ensueno-acc-meta { margin: 0; }
.ensueno-acc-row { display: flex; flex-wrap: wrap; gap: .35rem; padding: .15rem 0; }
.ensueno-acc-row dt { margin: 0; font-weight: 700; color: #0a1690; min-width: 9rem; }
.ensueno-acc-row dd { margin: 0; }

/* Fragrance group */
.ensueno-label-group > .ensueno-group-head {
    padding: .85rem .25rem;
    font-weight: 700;
    font-size: 16px;
    color: #0a1690;
}
.ensueno-label-sublist {
    padding-left: 1.5rem;
    margin-left: .25rem;
    border-left: 3px solid #c7ccea;
}
.ensueno-label-subitem:last-child { border-bottom: none; }

.ensueno-sds-link--label {
    display: inline-block;
    margin-top: 1rem;
    font-weight: 600;
}
/* SDS junto al título en el layout de acordeón */
.ensueno-formula-head--label {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}