/* =============================================================
   Nova COA Page Styles -- Phase 05 Figma Rewrite
   Works in tandem with global nova-shop.css layouts.
   ============================================================= */

/* ---- Sidebar: Guide/Example Card ---- */

.nova-coa-guide {
    background: var(--nova-bg-white);
    border: 1px solid var(--nova-border-light);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
    width: 100%;
}

/* Header Area */
.nova-coa-guide__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--nova-border-light);
}

.nova-coa-guide__title {
    font-family: var(--nova-font-heading);
    font-size: 13px; /* Matches Figma size */
    font-weight: 700;
    color: var(--nova-text-dark);
    margin: 0;
    line-height: 1;
}

.nova-coa-guide__logo {
    height: 24px; /* Slightly smaller to match Figma proportions */
    width: auto;
    display: block;
    object-fit: contain;
}

/* Row List */
.nova-coa-guide__list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nova-coa-guide__list li {
    display: flex;
    justify-content: space-between; /* Pushes label left, value group right */
    align-items: center;
    margin-bottom: 14px;
    font-family: var(--nova-font-body);
}

.nova-coa-guide__list li:last-child {
    margin-bottom: 16px;
}

.nova-coa-guide__list .label {
    color: var(--nova-text-dark-muted);
    font-size: 13px;
    font-weight: 400;
    white-space: nowrap; /* Prevents 2nd line */
}

/* Groups the text value and the icon together on the right */
.val-group {
    display: flex;
    align-items: center;
    gap: 8px; /* Exact spacing between value text and icon */
    justify-content: flex-end;
}

.nova-coa-guide__list .val {
    color: var(--nova-text-dark);
    font-size: 13px;
    font-weight: 600; /* Bolded to match Figma */
    text-align: right;
    white-space: nowrap; /* Prevents 2nd line */
}

.icon-spacer {
    width: 16px;
    height: 16px;
    display: block;
    flex-shrink: 0;
}

/* ---- Tooltip & Interactive Icon ---- */
.nova-info-trigger {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.nova-info-svg {
    display: block;
    transition: all 0.2s ease;
}

/* Color Inversions on Hover using tokens */
.nova-info-trigger:hover .info-circle {
    fill: var(--nova-accent);
}
.nova-info-trigger:hover .info-i-dot {
    fill: var(--nova-bg-white);
}
.nova-info-trigger:hover .info-i-line {
    stroke: var(--nova-bg-white);
}

/* Floating Popup Tooltip Box */
.nova-tooltip {
    position: absolute;
    bottom: calc(100% + 12px); 
    right: -8px; 
    width: 280px;
    background: var(--nova-bg-white);
    border: 1px solid var(--nova-border-light);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08); 
    border-radius: var(--nova-radius-input);
    padding: 16px;
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: left;
    pointer-events: none; 
}

/* Reveal Tooltip on Hover */
.nova-info-trigger:hover .nova-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nova-tooltip strong {
    display: block;
    font-family: var(--nova-font-heading);
    font-size: 13px;
    font-weight: 700;
    color: var(--nova-text-dark);
    margin-bottom: 6px;
}

.nova-tooltip p {
    font-family: var(--nova-font-body);
    font-size: 13px;
    color: var(--nova-text-dark-muted);
    line-height: 1.5;
    margin: 0;
    white-space: normal; 
}

/* Bottom Footer / Link */
.nova-coa-guide__footer {
    border-top: 1px solid var(--nova-border-light);
    padding-top: 16px;
    margin-top: 8px;
}

.nova-coa-guide__link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--nova-font-body);
    font-size: 13px;
    font-weight: 600;
    color: var(--nova-accent);
    text-decoration: underline;
    text-underline-offset: 4px;
    transition: color 0.2s ease;
}

.nova-coa-guide__link:hover {
    color: var(--nova-accent-hover);
}

/* -------------------------------------------------------- */
/* DATE RANGE FILTER                                        */
/* -------------------------------------------------------- */

/* Two-column grid: From | To */
.nova-coa-date-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
    width: 100%;
    box-sizing: border-box;
}

/* Each field: label stacked above input — min-width:0 lets grid cells shrink */
.nova-coa-date-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
}

/* Label — matches .nova-price-control label in nova-shop.css */
.nova-coa-date-label {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: #0a0a0e;
    opacity: 0.6;
    font-weight: 500;
    display: block;
    line-height: 1;
}

/* Input — matches .nova-price-box border/radius/bg style */
.nova-coa-date-input {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 8px 6px;
    background: #ffffff;
    border: 1px solid #e4e6f2;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: #0a0a0e;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    display: block;
}

.nova-coa-date-input:focus {
    outline: none;
    border-color: #8a4fff;
    box-shadow: 0 0 0 3px rgba(138, 79, 255, 0.1);
}

.nova-coa-date-input::-webkit-calendar-picker-indicator {
    opacity: 0.4;
    cursor: pointer;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
}

.nova-coa-date-input::-webkit-calendar-picker-indicator:hover {
    opacity: 0.7;
}

/* Mobile: stack From / To vertically */
@media (max-width: 480px) {
    .nova-coa-date-grid {
        grid-template-columns: 1fr;
    }
}

/* ---- Mobile sidebar: add padding-top so close button doesn't overlap content ---- */
@media (max-width: 767px) {
    #nova-coa-sidebar {
        padding-top: 56px;
    }
}

/* ---- Main Area: Yellow Tooltip ---- */
.nova-coa-tooltip {
    background: var(--nova-bg-white); 
    border: 1px solid var(--nova-border-light);
    border-radius: 12px;
    margin-bottom: 32px;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Keeps the header background inside the rounded corners */
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

/* Yellow Top Bar */
.nova-coa-tooltip__header {
    background: #FFFCD9; /* Pale yellow from design (no existing variable for this) */
    border-bottom: 1px solid var(--nova-border-light);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
}

.nova-coa-tooltip__header .icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.nova-coa-tooltip__header h3 {
    margin: 0;
    font-family: var(--nova-font-heading);
    font-size: 16px;
    font-weight: 700;
    color: var(--nova-text-dark);
    line-height: 1;
}

/* White Content Area */
.nova-coa-tooltip__body {
    padding: 24px;
    background: var(--nova-bg-white);
}

.nova-coa-tooltip__body p {
    margin: 0;
    font-family: var(--nova-font-body);
    font-size: 14px;
    line-height: 1.6;
    color: var(--nova-text-dark-muted);
}

.nova-coa-tooltip__body p strong {
    font-weight: 600;
    color: var(--nova-text-dark); /* Bolds it and makes it pure black */
}
/* ---- Main Area: Search & Results Bar Tweaks ---- */
.nova-coa-main-search {
    margin-bottom: 32px;
}

.nova-coa-results-bar {
    margin-bottom: 24px;
}

.nova-shop-results-bar__count strong {
    font-weight: 600;
}

/* ---- View Toggles ---- */
.nova-coa-view-toggles {
    display: flex;
    gap: 8px;
}

.nova-coa-view-toggles button {
    background: transparent;
    border: none;
    color: #0a0a0e;
    opacity: 0.3;
    cursor: pointer;
    padding: 4px;
    transition: all 0.2s ease;
    border-radius: 4px;
}

.nova-coa-view-toggles button.active,
.nova-coa-view-toggles button:hover {
    opacity: 1;
    color: #8a4fff;
    background: rgba(138, 79, 255, 0.08);
}

/* ---- Product Grid & Cards ---- */
.nova-coa-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

.nova-coa-product-card {
    background: var(--nova-bg-white);
    border: 1px solid var(--nova-border-light);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s ease;
}

.nova-coa-product-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* 1. Left Sidebar Area */
.nova-coa-product-card__sidebar {
    background: var(--nova-surface-light);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--nova-border-light);
}

.nova-coa-product-card__img {
    width: 48px;
    height: 48px;
    background: var(--nova-bg-white);
    border: 1px solid var(--nova-border-light);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.nova-coa-product-card__img img {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
}

/* Title Area - Allows wrapping for long product names */
.nova-coa-product-card__title-wrap {
    flex: 1;
    min-width: 0; 
}

.nova-coa-product-card__title-wrap .title {
    margin: 0;
    font-family: var(--nova-font-heading);
    font-size: 16px;
    font-weight: 700;
    color: var(--nova-text-dark);
    line-height: 1.3;
    white-space: normal;
    overflow-wrap: break-word; 
}

/* 2. Middle Category Area */
.nova-coa-product-card__category {
    padding: 12px 20px;
    border-bottom: 1px solid var(--nova-border-light);
    font-family: var(--nova-font-body);
    font-size: 13px;
    color: var(--nova-text-dark-muted);
    display: flex;
    align-items: center;
}

/* 3. Right Batches Area */
.nova-coa-product-card__batches {
    display: flex;
    flex-direction: column;
}

/* ── Variation accordion ── */
.nova-coa-variant-group {
    border-bottom: 1px solid var(--nova-border-light);
}

.nova-coa-variant-group:last-child {
    border-bottom: none;
}

.nova-coa-variant-group__header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: rgba(138, 79, 255, 0.04);
    border: none;
    border-left: 3px solid transparent;
    font-family: var(--nova-font-body);
    font-size: 13px;
    color: var(--nova-text-dark);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.nova-coa-variant-group__header:hover {
    background: rgba(138, 79, 255, 0.08);
}

.nova-coa-variant-group.is-open .nova-coa-variant-group__header {
    background: rgba(138, 79, 255, 0.08);
    border-left-color: var(--nova-accent);
}

.nova-coa-variant-group__title {
    flex: 1;
    font-weight: 600;
    color: var(--nova-text-dark);
}

.nova-coa-variant-group__count {
    font-size: 12px;
    color: var(--nova-text-muted);
    white-space: nowrap;
}

.nova-coa-variant-group__caret {
    flex-shrink: 0;
    color: var(--nova-text-muted);
    transition: transform 0.2s ease;
}

.nova-coa-variant-group.is-open .nova-coa-variant-group__caret {
    transform: rotate(180deg);
}

.nova-coa-variant-group__body {
    display: none;
}

.nova-coa-variant-group.is-open .nova-coa-variant-group__body {
    display: block;
}

.nova-coa-variant-group__body .nova-coa-batch-row {
    padding-left: 32px;
}

.nova-coa-variant-group__body .nova-coa-batch-row:last-child {
    border-bottom: none;
}

/* Batch Rows - Strict 12px Gap & Equal Spacing */
.nova-coa-batch-row {
    display: flex;
    align-items: center;
    gap: 12px; /* Strict 12px gap between all columns */
    padding: 12px 20px;
    border-bottom: 1px solid var(--nova-border-light);
    font-family: var(--nova-font-body);
    font-size: 13px;
}

.nova-coa-batch-row:last-child {
    border-bottom: none;
}

/* Forces info columns to share space equally and wrap text */
.nova-coa-batch-row > div:not(.col-action) {
    flex: 1;
    min-width: 0; 
}

.nova-coa-batch-row .lbl {
    color: var(--nova-text-dark-muted);
    margin-right: 4px;
    white-space: nowrap; /* Keeps labels from wrapping */
}

.nova-coa-batch-row .val {
    font-weight: 600;
    color: var(--nova-text-dark);
    overflow-wrap: break-word; /* Wraps long values to next line */
    word-break: break-word;
}

/* Green Pill for Date */
.nova-date-wrapper {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    margin-left: -10px;
    max-width: 100%;
}

.nova-date-wrapper.active-pill {
    background: #ebf9eb; 
}

.nova-date-wrapper.active-pill .lbl,
.nova-date-wrapper.active-pill .val {
    color: #1e8e3e; 
}

.nova-date-wrapper.active-pill .lbl {
    opacity: 0.8;
}

/* Download Action */
.nova-coa-batch-row .col-action {
    margin-left: auto; /* Pushes to far right */
    flex-shrink: 0; /* Protects button from being squished */
    text-align: right;
}

.download-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--nova-accent);
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 4px;
    transition: opacity 0.2s;
    white-space: nowrap; /* Keeps icon and text together */
}

.download-link:hover {
    opacity: 0.8;
}

/* -------------------------------------------------------- */
/* LIST VIEW OVERRIDES */
/* -------------------------------------------------------- */

.nova-coa-grid.nova-list-view {
    grid-template-columns: 1fr;
}

.nova-coa-grid.nova-list-view .nova-coa-product-card {
    flex-direction: row;
    align-items: stretch;
}

/* Fluid Width: Scales up to 360px before forcing text wrap */
.nova-coa-grid.nova-list-view .nova-coa-product-card__sidebar {
    width: 32%; 
    min-width: 240px;
    max-width: 360px;
    border-bottom: none;
    border-right: 1px solid var(--nova-border-light);
    flex-shrink: 0;
}

.nova-coa-grid.nova-list-view .nova-coa-product-card__category {
    width: 15%;
    min-width: 100px;
    max-width: 140px;
    border-bottom: none;
    border-right: 1px solid var(--nova-border-light);
    justify-content: center;
    flex-shrink: 0;
}

/* Centered vertical batches */
.nova-coa-grid.nova-list-view .nova-coa-product-card__batches {
    flex: 1;
    min-width: 0; 
    display: flex;
    flex-direction: column;
    justify-content: center; 
    max-height: 240px;
    overflow-y: auto; 
}
/* ---- Responsive Formatting ---- */
@media (max-width: 1024px) {
    .nova-coa-grid {    
        grid-template-columns: 1fr; /* Stack cards into a single column */
    }
}

@media (max-width: 767px) {
    /* Reset List view to standard card stack on mobile */
    .nova-coa-grid.nova-list-view .nova-coa-product-card {
        flex-direction: column;
    }
    
    .nova-coa-grid.nova-list-view .nova-coa-product-card__header {
        width: 100%;
        border-right: none;
        align-items: center;
    }

    /* Wrap batch row contents so it fits neatly on small screens */
    .nova-coa-batch-row {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .nova-coa-batch-row .col-batch,
    .nova-coa-batch-row .col-date {
        width: 48%; /* Split batch and date to 50% width */
    }
    
    .nova-coa-batch-row .col-action {
        width: 100%;
        text-align: left;
        margin-top: 4px;
        padding-top: 8px;
        border-top: 1px solid var(--nova-surface-light); /* Subtle divider for mobile */
    }

    .nova-coa-grid {
        grid-template-columns: 1fr;
        gap: 16px; /* Slightly tighter gap for mobile */
    }

    /* 2. Allow Batch row data to wrap if there are too many columns (Purity, Conc, etc.) */
    .nova-coa-batch-row {
        flex-wrap: wrap; 
        gap: 8px 12px; /* 8px vertical gap if it wraps, 12px horizontal */
    }
    
    /* Ensure the download button takes up the full width on its own line if it wraps */
    .nova-coa-batch-row .col-action {
        width: 100%;
        margin-top: 4px;
    }

    /* 3. Disable horizontal "List View" on mobile (forces it back to a stacked card) */
    .nova-coa-grid.nova-list-view .nova-coa-product-card {
        flex-direction: column;
    }
    
    /* Remove the fixed widths from the sidebar and category */
    .nova-coa-grid.nova-list-view .nova-coa-product-card__sidebar,
    .nova-coa-grid.nova-list-view .nova-coa-product-card__category {
        width: 100%;
        max-width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--nova-border-light);
    }
    
    .nova-coa-grid.nova-list-view .nova-coa-product-card__category {
        justify-content: flex-start; /* Aligns category to the left again on mobile */
    }
    
    .nova-coa-grid.nova-list-view .nova-coa-product-card__batches {
        max-height: none; /* Let it expand fully on mobile instead of scrolling */
    }

}

.nova-coa-load-more{
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}