/**
 * CIR Product Options — Frontend Modal Styles
 * Design spec from .pen file
 */

/* ── Fonts ───────────────────────────────────────────────────────── */
/* Lora, Outfit and Inter should be loaded by the theme or enqueued separately. */

/* ── Hidden utility ──────────────────────────────────────────────── */
.cir-hidden {
    display: none !important;
}

/* ── Body scroll lock (JS sets padding-right inline to compensate for scrollbar) ── */
body.cir-modal-open {
    overflow: hidden !important;
}

/* ── Choose Options button (product page) ────────────────────────── */
#cir-options-wrapper {
    margin: 0;
    width: 100%;
}

/* Hide WooCommerce default add-to-cart button */
.single_add_to_cart_button {
    display: none !important;
}

#cir-choose-options {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 18px 0;
    background: #832E31;
    color: #FFFFFF;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-align: center;
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition: background 0.2s ease;
}

#cir-choose-options .cir-btn-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

#cir-choose-options:hover {
    background: #6B2225;
}

/* ── Modal overlay ───────────────────────────────────────────────── */
#cir-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    z-index: 999998;
    transition: background 0.3s ease;
}

#cir-modal-overlay.cir-modal-active {
    background: rgba(0, 0, 0, 0.5);
}

/* ── Modal panel ─────────────────────────────────────────────────── */
#cir-modal-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 650px;
    height: 100vh;
    height: 100dvh;
    background: #FFFFFF;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.cir-modal-active #cir-modal-panel {
    transform: translateX(0);
}

/* ── Modal header ────────────────────────────────────────────────── */
#cir-modal-panel .cir-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background-color: #1A1A1A !important;
    flex-shrink: 0;
}

#cir-modal-panel .cir-modal-header h3 {
    margin: 0;
    font-family: 'Lora', serif;
    font-size: 18px;
    font-weight: normal;
    color: #FFFFFF !important;
}

#cir-modal-panel .cir-modal-close {
    width: 20px;
    height: 20px;
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    color: #FFFFFF !important;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Modal body ──────────────────────────────────────────────────── */
.cir-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    scrollbar-gutter: stable;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 0;
    -webkit-overflow-scrolling: touch;
}

/* ── Modal footer ────────────────────────────────────────────────── */
.cir-modal-footer {
    background: #F5F0EA;
    padding: 20px 24px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cir-modal-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cir-modal-total span:first-child {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: normal;
    color: #8A8278;
}

#cir-modal-total-price {
    font-family: 'Outfit', sans-serif;
    font-size: 24px;
    font-weight: 700;
    color: #832E31;
}

#cir-modal-complete {
    display: block;
    width: 100%;
    padding: 18px 0;
    background: #832E31;
    color: #FFFFFF;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-align: center;
    border: none;
    cursor: pointer;
    border-radius: 0;
    transition: background 0.2s ease;
}

#cir-modal-complete:hover {
    background: #6B2225;
}

/* ── Accordion sections ──────────────────────────────────────────── */
.cir-accordion-section {
    padding: 16px 0;
}

.cir-accordion-section:first-child {
    padding-top: 0;
}

.cir-accordion-section:last-child {
    padding-bottom: 0;
}

/* ── Accordion header (collapsed view) ───────────────────────────── */
.cir-accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    gap: 12px;
    user-select: none;
}

.cir-accordion-thumb {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 4px;
    overflow: hidden;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cir-accordion-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cir-no-thumb {
    display: block;
    width: 100%;
    height: 100%;
    background: #E8E3DC;
    border-radius: 4px;
}

.cir-accordion-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cir-accordion-category {
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    font-weight: 500;
    color: #1A1A1A;
    line-height: 1.3;
}

.cir-accordion-selection {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: normal;
    color: #8A8278;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cir-accordion-price {
    color: inherit;
}

.cir-accordion-chevron {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    transition: transform 0.2s ease;
}

.cir-accordion-chevron svg {
    display: block;
    width: 18px;
    height: 18px;
    color: #8A8278;
}

.cir-accordion-chevron.cir-chevron-up,
.cir-accordion-expanded .cir-accordion-chevron {
    transform: rotate(180deg);
}

/* ── Accordion body (expanded view) ──────────────────────────────── */
.cir-accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease-in-out;
}

.cir-accordion-body-open {
    max-height: 3000px;
    overflow: visible;
    padding-top: 12px;
}

/* ── Paginated grid wrapper ─────────────────────────────────────── */
.cir-grid-paginated {
    display: flex;
    flex-direction: row;
    gap: 12px;
    align-items: stretch;
}

/* ── Pagination dots (vertical column on desktop) ───────────────── */
.cir-grid-dots {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cir-grid-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: none;
    background: #E8E3DC;
    cursor: pointer;
    padding: 0;
    transition: background 0.15s ease;
}

.cir-grid-dot:hover {
    background: #C5A467;
}

.cir-grid-dot-active {
    background: #832E31;
}

/* ── Colour section ─────────────────────────────────────────────── */
.cir-colour-pages {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Expanded colour section head row ───────────────────────────── */
.cir-colour-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.cir-colour-title {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: #1A1A1A;
}

.cir-colour-head .cir-accordion-price {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #832E31;
}

/* ── Colour sub-group heading ────────────────────────────────────── */
.cir-colour-subgroup-name {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    color: #8A8278;
    text-transform: uppercase;
}

/* ── Option grid ─────────────────────────────────────────────────── */
.cir-option-grid {
    flex: 1;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    grid-template-rows: 1fr 1fr;
}

/* ── Option card ─────────────────────────────────────────────────── */
.cir-option-card {
    border: 1px solid #E8E3DC;
    border-radius: 4px;
    padding: 4px 4px 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s ease;
    position: relative;
    overflow: hidden;
    will-change: border-color;
    align-self: start;
}

.cir-option-card:hover {
    border-color: #C5A467;
}

.cir-option-card.cir-option-selected {
    border: 2px solid #832E31;
}

.cir-option-image {
    width: 100%;
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cir-option-image img {
    max-width: 100%;
    max-height: 76px;
    width: 76px;
    object-fit: contain;
    border-radius: 4px;
}

.cir-no-image {
    display: block;
    width: 60px;
    height: 60px;
    background: #E8E3DC;
    border-radius: 4px;
}

.cir-option-name {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: normal;
    color: #5A5549;
    line-height: 1.3;
    text-align: center;
    height: 28px;
    flex-shrink: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.cir-option-price {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 500;
    color: #832E31;
    text-align: center;
    flex-shrink: 0;
}

/* ── Finish filter classes ───────────────────────────────────────── */
.cir-finish-match {
    border-color: #2e7d32;
    background: rgba(46, 125, 50, 0.04);
}

.cir-finish-dimmed {
    opacity: 0.5;
}

/* ── Dividers — single 1px line between sections ────────────────── */
.cir-accordion-section + .cir-accordion-section {
    border-top: 1px solid #E8E3DC;
}

/* ── Summary grid (on product page) ──────────────────────────────── */
#cir-summary-grid:empty,
#cir-summary-grid.cir-summary-hidden {
    display: none;
}

#cir-summary-grid {
    margin-top: 16px;
}

.cir-summary-cell {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid #E8E3DC;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.cir-summary-cell:hover {
    border-color: #C5A467;
}

.cir-summary-thumb {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    border-radius: 4px;
    overflow: hidden;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cir-summary-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cir-summary-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cir-summary-category {
    font-family: 'Outfit', sans-serif;
    font-size: 11px;
    font-weight: 600;
    color: #832E31;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.cir-summary-option {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 400;
    color: #1A1A1A;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cir-summary-price {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: #832E31;
}

.cir-summary-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: #8A8278;
    font-size: 13px;
    padding: 8px 0;
    margin: 0;
}

/* ── Summary header ─────────────────────────────────────────── */
.cir-summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.cir-summary-label {
    font-family: 'Outfit', sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #C5A467;
}

.cir-summary-edit {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: #832E31;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}

.cir-summary-edit:hover {
    text-decoration: underline;
}

/* ── Design A — Icon Strip ──────────────────────────────────── */
.cir-summary-a {
    display: none; /* Hidden by default, toggle to show */
}

.cir-summary-a.cir-summary-active {
    display: block;
}

.cir-summary-strip {
    display: flex;
    gap: 16px;
    justify-content: space-between;
}

.cir-summary-strip-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.cir-summary-strip-thumb {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    background: #F5F0EA;
    border: 2px solid #E8E3DC;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cir-summary-strip-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cir-summary-strip-cat {
    font-family: 'Inter', sans-serif;
    font-size: 9px;
    font-weight: 400;
    color: #8A8278;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}

.cir-summary-strip-name {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 400;
    color: #1A1A1A;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* ── Design B — 3-Col Grid ──────────────────────────────────── */
.cir-summary-b {
    display: none;
}

.cir-summary-b.cir-summary-active {
    display: block;
}

.cir-summary-compact-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.cir-summary-compact-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    border: 1px solid #E8E3DC;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    background: #FDFAF7;
    text-align: center;
}

.cir-summary-compact-cell:hover {
    border-color: #C5A467;
}

.cir-summary-compact-thumb {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    overflow: hidden;
    background: #F5F0EA;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cir-summary-compact-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cir-summary-compact-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 0;
    width: 100%;
}

.cir-summary-compact-cat {
    font-family: 'Outfit', sans-serif;
    font-size: 8px;
    font-weight: 600;
    color: #8A8278;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}

.cir-summary-compact-name {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 500;
    color: #1A1A1A;
    text-align: center;
    word-break: break-word;
}

.cir-summary-compact-price {
    font-family: 'Outfit', sans-serif;
    font-size: 10px;
    font-weight: 600;
    color: #832E31;
    text-align: center;
}

/* ── Summary card states ────────────────────────────────────────────── */

/* Not Selected state — grey/muted, minus icon */
.cir-selection-card--not-selected {
    border-color: #E8E3DC;
    background: #FDFAF7;
}

.cir-selection-card--not-selected .cir-summary-compact-cat {
    color: #8A8278;
}

.cir-not-selected-text {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-style: italic;
    color: #B5AFA6 !important;
    text-align: center;
}

/* Selected state — gold border */
.cir-selection-card--selected {
    border: 2px solid #C5A467;
}

/* Warning state — red border, red background, red text */
.cir-selection-card--warning {
    border: 2px solid #D44040 !important;
    background: #FDF6F6;
}

.cir-selection-card--warning .cir-summary-compact-cat {
    color: #D44040;
}

.cir-warning-text {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-style: italic;
    color: #D44040 !important;
    text-align: center;
}

/* Icon thumb (for minus, alert, X icons instead of images) */
.cir-summary-icon-thumb {
    width: 28px;
    height: 28px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cir-summary-icon-thumb svg {
    width: 28px;
    height: 28px;
}

/* Warning state icon sizing */
.cir-selection-card--warning .cir-summary-icon-thumb svg {
    width: 28px;
    height: 28px;
}

/* Black Primer sublabel */
.cir-summary-sublabel {
    font-family: 'Inter', sans-serif;
    font-size: 8px;
    font-weight: 400;
    color: #8A8278;
    line-height: 1.2;
    margin-top: 1px;
    text-align: center;
}

/* Price for £0.00 options — same red as other prices */
.cir-price-zero {
    color: #832E31 !important;
}

/* ── Responsive: mobile (below 768px) ────────────────────────────── */
@media (max-width: 768px) {
    #cir-modal-panel {
        width: 100%;
    }

    .cir-option-grid {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: 1fr 1fr;
    }

    .cir-summary-compact-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .cir-summary-strip {
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Paginated wrapper: stack vertically on mobile */
    .cir-grid-paginated {
        flex-direction: column;
    }

    /* Dots become horizontal row on mobile */
    .cir-grid-dots {
        flex-direction: row;
        justify-content: center;
        padding-top: 8px;
    }
}

/* ── Mobile modal refinements ──────────────────────────────────────── */
@media (max-width: 768px) {
    .cir-option-grid {
    }

    .cir-modal-footer {
        flex-direction: row;
        align-items: center;
        gap: 16px;
        padding: 16px 24px;
    }

    .cir-modal-total {
        flex-direction: column;
        align-items: flex-start;
        flex-shrink: 0;
    }

    .cir-modal-total span:first-child {
        font-size: 11px;
    }

    #cir-modal-total-price {
        font-size: 20px;
    }

    #cir-modal-complete {
        flex: 2;
        padding: 16px 0;
        font-size: 12px;
    }
}

/* ── Fix modal scroll on mobile ──────────────────────────────────── */
@media (max-width: 768px) {
    .cir-modal-body {
        overflow-y: auto;
    }
}

/* ── Stock status badges on colour option cards ─────────────────── */
.cir-option-badge {
    font-family: 'Inter', sans-serif;
    font-size: 9px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

.cir-option-badge--stock {
    background: #E8F5E9;
    color: #2E7D32;
}

.cir-option-badge--mto {
    background: #FFF3E0;
    color: #92400E;
}

.cir-badge-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

/* ── Lead time pill on colour group headings ─────────────────────── */
.cir-colour-subgroup-name {
    display: flex;
    align-items: center;
    gap: 0;
    width: 100%;
}

.cir-group-leadtime {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    margin-left: auto;
    border-radius: 3px;
    background: #E8F5E9;
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    font-weight: 700;
    color: #2E7D32;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    line-height: 1;
}

.cir-group-leadtime svg {
    width: 11px;
    height: 11px;
    flex-shrink: 0;
}
