/* ==========================================================================
   Allergen Matrix Styles - Premium Parity
   ========================================================================== */

.allergen-matrix-wrapper {
    width: 100%;
    font-family: var(--ds-font-body, 'Inter', sans-serif);
    color: var(--ds-navy, #0a2a3a);
    padding-bottom: 60px;
}

/* ==========================================================================
   Hero Section
   ========================================================================== */
.hero-menu {
    position: relative;
    width: 100%;
    height: 45vh;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 40px;
}

.hero-bg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-size: cover;
    background-position: center;
}

.hero-bg::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 42, 58, 0.4);
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    color: var(--ds-ivory, #F0EBDD);
}

.hero-content h1 {
    font-family: var(--ds-font-abruzzo, 'Abruzzo', serif);
    font-size: 4.5rem;
    font-weight: 400;
    margin: 0;
    letter-spacing: -0.02em;
}

/* ==========================================================================
   Toolbar
   ========================================================================== */
.allergen-content-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.allergen-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(10, 42, 58, 0.1);
    flex-wrap: wrap;
    gap: 20px;
}

.last-updated {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.search-box input {
    padding: 12px 15px;
    font-size: 1rem;
    border: 1px solid rgba(10, 42, 58, 0.2);
    border-radius: 2px;
    min-width: 250px;
    outline: none;
    font-family: inherit;
}

.search-box input:focus {
    border-color: var(--ds-navy, #0a2a3a);
}

.toolbar-center {
    flex-grow: 1;
    display: flex;
    justify-content: center;
}

.filter-dropdown-wrapper {
    position: relative;
}

.btn-outline {
    background: transparent;
    color: var(--ds-navy, #0a2a3a);
    border: 1px solid var(--ds-navy, #0a2a3a);
    padding: 12px 24px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-outline:hover, .btn-outline.active {
    background: var(--ds-navy, #0a2a3a);
    color: var(--ds-ivory, #F0EBDD);
}

/* Popover for Ingredients */
.ingredient-popover {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 10px;
    background: #fff;
    border: 1px solid rgba(10, 42, 58, 0.1);
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    padding: 20px;
    min-width: 300px;
    z-index: 100;
    border-radius: 4px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.ingredient-popover.hidden {
    display: none;
}

.ingredient-popover label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    cursor: pointer;
}

.toolbar-right select {
    padding: 12px 30px 12px 15px;
    font-size: 1rem;
    border: 1px solid rgba(10, 42, 58, 0.2);
    border-radius: 2px;
    background: transparent;
    cursor: pointer;
    outline: none;
    font-family: inherit;
}

/* ==========================================================================
   Worksheet Tabs
   ========================================================================== */
.allergen-tabs-nav {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
    border-bottom: 2px solid rgba(10, 42, 58, 0.1);
    overflow-x: auto;
    scrollbar-width: none;
}

.allergen-tabs-nav::-webkit-scrollbar {
    display: none;
}

.allergen-tab {
    padding: 10px 0;
    background: none;
    border: none;
    font-size: 1.1rem;
    font-weight: 600;
    color: rgba(10, 42, 58, 0.4);
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.allergen-tab:hover {
    color: var(--ds-navy, #0a2a3a);
}

.allergen-tab.active {
    color: var(--ds-navy, #0a2a3a);
    border-bottom-color: var(--ds-navy, #0a2a3a);
}

.allergen-worksheet {
    display: none;
}

.allergen-worksheet.active {
    display: block;
    animation: fadeIn 0.4s ease forwards;
}

/* ==========================================================================
   Desktop Table
   ========================================================================== */
.allergen-table-wrap {
    width: 100%;
    overflow-x: auto;
    margin-bottom: 40px;
}

.allergen-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid rgba(10, 42, 58, 0.2);
    min-width: 900px;
    display: table !important;
}

.allergen-table tbody {
    display: table-row-group !important;
}

.allergen-table tr,
.allergen-table .dish-row,
.allergen-table .header-group-row,
.allergen-table .header-labels-row {
    display: table-row !important;
}

.allergen-table th, 
.allergen-table td {
    border: 1px solid rgba(10, 42, 58, 0.2);
    text-align: center;
    display: table-cell !important;
}

/* Sticky Headers */
.allergen-table thead th {
    background: var(--ds-ivory, #F0EBDD);
    position: sticky;
    z-index: 10;
}

.header-group-row th {
    top: 0;
    padding: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.9rem;
}

.header-labels-row th {
    top: 40px;
    vertical-align: bottom;
    padding: 15px 5px;
    height: 160px; /* Required space for vertical text to prevent collapse */
}

/* Vertical Text alignment */
.vertical-text {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: nowrap;
    margin: 0 auto;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--ds-navy, #0a2a3a);
}

/* Fixed First Column */
.allergen-table th.col-dish,
.allergen-table td.col-dish {
    text-align: left;
    width: 350px;
    min-width: 350px;
    background: #fff;
    left: 0;
    position: sticky;
    z-index: 5;
    vertical-align: top;
}

.allergen-table thead th.col-dish {
    z-index: 15;
    background: var(--ds-ivory, #F0EBDD);
    vertical-align: bottom;
}

/* Rows & Accordions */
.dish-row td {
    padding: 0;
    height: auto; /* Natural content-driven height */
}

.dish-row:nth-child(even) td.col-dish {
    background: rgba(10, 42, 58, 0.02);
}

.dish-title-wrapper {
    padding: 15px;
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
    min-height: 50px;
}

.dish-title-wrapper:hover {
    background: rgba(10, 42, 58, 0.05);
}

.chevron-icon {
    margin-right: 12px;
    transition: transform 0.3s;
    color: var(--ds-navy, #0a2a3a);
    flex-shrink: 0;
}

.dish-row.expanded .chevron-icon {
    transform: rotate(180deg);
}

/* Metadata Drawer - Full Width */
.dish-details-row td {
    padding: 0;
    border: none;
    background: #fff;
}

.allergen-details-wrapper {
    width: 100%;
    padding: 32px 40px;
    background: #fcfcfc;
    border-bottom: 1px solid rgba(10, 42, 58, 0.1);
    display: none;
}

.dish-details-row.expanded .allergen-details-wrapper {
    display: block;
    animation: fadeInDown 0.3s ease forwards;
}

/* Mobile cards expanded content */
.dish-card.expanded .dish-expanded-content {
    display: block;
    animation: fadeInDown 0.3s ease forwards;
}

.dish-expanded-content {
    display: none;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 32px;
}

.meta-section {
    margin-top: 0;
}

.meta-section strong {
    display: block;
    margin-bottom: 5px;
    color: var(--ds-navy, #0a2a3a);
}

.meta-section ul {
    margin: 0;
    padding-left: 20px;
    list-style-type: disc;
}

.meta-section li {
    margin-bottom: 3px;
}

.meta-section p {
    margin: 0;
    line-height: 1.4;
}

/* Allergen Marks */
.col-allergen {
    width: 45px;
    vertical-align: middle !important;
}

.has-allergen {
    color: #cc0000; /* Match Live Reference Red */
    font-weight: 600;
    font-size: 0.95rem;
}

/* ==========================================================================
   Mobile Cards (Hidden on Desktop)
   ========================================================================== */
.allergen-mobile-cards {
    display: none;
}

.dish-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

/* Dynamic Column Hiding */
.col-hidden {
    display: none !important;
}

/* ==========================================================================
   Responsive Logic
   ========================================================================== */
@media (max-width: 1024px) {
    .allergen-table-wrap {
        display: none; 
    }

    .allergen-mobile-cards {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    .dish-card {
        background: #fff;
        border: 1px solid rgba(10, 42, 58, 0.1);
        padding: 20px;
        border-radius: 4px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.03);
    }

    .dish-card h3 {
        margin: 0;
        font-size: 1.2rem;
        color: var(--ds-navy, #0a2a3a);
        font-family: var(--ds-font-abruzzo, serif);
    }
    
    .dish-card.expanded .chevron-icon {
        transform: rotate(180deg);
    }

    .card-attributes {
        margin-top: 15px;
        padding-top: 15px;
        border-top: 1px dashed rgba(10, 42, 58, 0.1);
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .attr-row {
        background: rgba(204, 0, 0, 0.08);
        color: #cc0000;
        padding: 5px 10px;
        border-radius: 4px;
        font-size: 0.85rem;
        font-weight: 600;
        display: flex;
        align-items: center;
        gap: 5px;
    }
    
    .dish-card .dish-expanded-content {
        padding: 15px 0 0 0;
        border-top: 1px dashed rgba(10, 42, 58, 0.1);
        margin-top: 15px;
    }
}

@media (max-width: 768px) {
    .allergen-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box input {
        width: 100%;
        min-width: 100%;
    }
    
    .toolbar-center {
        justify-content: flex-start;
    }

    .ingredient-popover {
        left: 0;
        transform: none;
        width: 100%;
        grid-template-columns: 1fr;
    }
    
    .hero-content h1 {
        font-size: 3rem;
    }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Custom allergen updates for Sprint 10.5 */
.allergen-details-wrapper,
.dish-expanded-content {
    text-align: left !important;
}

.removable {
    color: var(--ds-peach, #D88A5A) !important;
    font-size: 1.4rem !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    vertical-align: middle !important;
}

.attr-removable {
    background: rgba(216, 138, 90, 0.08) !important;
    color: var(--ds-peach, #D88A5A) !important;
}

.allergen-legend {
    font-family: var(--ds-font-body, 'Inter', sans-serif);
    font-size: 0.9rem;
    color: rgba(10, 42, 58, 0.7);
    margin-bottom: 0;
}
