/* ========================================
   SWATCH BOOK
   Digital swatch book with flip-through card stack interaction
   ======================================== */

/* ========================================
   CSS VARIABLES
   ======================================== */
:root {
    --swatch-card-width: 720px;
    --swatch-card-height: 440px;
    --swatch-card-radius: 12px;
    --stack-perspective: 2000px;
    --flip-duration: 0.5s;
    --flip-easing: cubic-bezier(0.4, 0, 0.2, 1);
    --filter-width: 280px;
}

/* ========================================
   PAGE LAYOUT - Filters left, cards center
   ======================================== */
.swatch-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0a1628 0%, #1a2a4a 50%, #0a1628 100%);
    position: relative;
    overflow-x: hidden;
}

.swatch-page__layout {
    display: flex;
    min-height: calc(100vh - 143px);
}

/* Filter Panel - Always visible on left */
.swatch-page__filters {
    width: var(--filter-width);
    flex-shrink: 0;
    height: calc(100vh - 143px);
    background: rgba(255, 255, 255, 0.98);
    overflow-y: auto;
    padding: 20px 16px;
    position: sticky;
    top: 143px;
}

/* Main Content - Full width centered */
.swatch-page__main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 30px 40px 60px;
    min-height: calc(100vh - 143px);
}

/* Right Sidebar - Slide-out drawer from right */
.swatch-page__sidebar {
    position: fixed;
    right: 0;
    top: 143px;
    width: 340px;
    height: calc(100vh - 143px);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    overflow-y: auto;
    padding: 24px 20px;
}

.swatch-page__sidebar.is-open {
    transform: translateX(0);
}

/* Panel Toggle Button - Only for right sidebar */
.panel-toggle {
    position: fixed;
    top: 160px;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--primary, #022662);
    transition: all 0.3s ease;
}

.panel-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.panel-toggle--filters {
    display: none; /* Filters always visible */
}

.panel-toggle--sidebar {
    right: 20px;
}

.panel-toggle.is-active {
    background: var(--primary, #022662);
    color: #fff;
}

/* Panel Overlay */
.panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 98;
}

.panel-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   SWATCH STACK - Flip-through container
   ======================================== */
.swatch-stack {
    position: relative;
    width: var(--swatch-card-width);
    height: var(--swatch-card-height);
    perspective: var(--stack-perspective);
    perspective-origin: 50% 50%;
}

.swatch-stack__viewport {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

/* ========================================
   SWATCH CARDS
   ======================================== */
.swatch-card {
    position: absolute;
    width: var(--swatch-card-width);
    height: var(--swatch-card-height);
    border-radius: var(--swatch-card-radius);
    background: #fff;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.1),
        0 4px 16px rgba(0, 0, 0, 0.05);
    transform-style: preserve-3d;
    transition:
        transform var(--flip-duration) var(--flip-easing),
        box-shadow var(--flip-duration) var(--flip-easing),
        opacity var(--flip-duration) var(--flip-easing);
    cursor: pointer;
    overflow: hidden;
    backface-visibility: hidden;
}

/* Card states for stack positioning */
.swatch-card--current {
    z-index: 10;
    transform: translateZ(0) rotateY(0deg) scale(1);
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.15),
        0 16px 48px rgba(0, 0, 0, 0.1);
}

.swatch-card--prev-1 {
    z-index: 8;
    transform: translateX(-120px) translateZ(-100px) rotateY(6deg) scale(0.94);
    opacity: 0.8;
}

.swatch-card--prev-2 {
    z-index: 6;
    transform: translateX(-220px) translateZ(-200px) rotateY(10deg) scale(0.88);
    opacity: 0.5;
}

.swatch-card--prev-3 {
    z-index: 4;
    transform: translateX(-300px) translateZ(-300px) rotateY(14deg) scale(0.82);
    opacity: 0.3;
}

.swatch-card--next-1 {
    z-index: 8;
    transform: translateX(120px) translateZ(-100px) rotateY(-6deg) scale(0.94);
    opacity: 0.8;
}

.swatch-card--next-2 {
    z-index: 6;
    transform: translateX(220px) translateZ(-200px) rotateY(-10deg) scale(0.88);
    opacity: 0.5;
}

.swatch-card--next-3 {
    z-index: 4;
    transform: translateX(300px) translateZ(-300px) rotateY(-14deg) scale(0.82);
    opacity: 0.3;
}

.swatch-card--hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateZ(-200px) scale(0.8);
}

/* Card hover effect on current */
.swatch-card--current:hover {
    transform: translateZ(10px) scale(1.02);
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.18),
        0 20px 60px rgba(0, 0, 0, 0.12);
}

/* ========================================
   SWATCH CARD CONTENT
   ======================================== */
.swatch-card__paper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 70%;
    background-color: var(--paper-color, #ffffff);
    border-radius: var(--swatch-card-radius) var(--swatch-card-radius) 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Paper color backgrounds for specific types */
.swatch-card__paper--natural {
    --paper-color: #f5f2eb;
}

.swatch-card__paper--white {
    --paper-color: #ffffff;
}

.swatch-card__paper--black {
    --paper-color: #1a1a1a;
}

.swatch-card__paper--colored {
    --paper-color: #e8e8e8;
}

.swatch-card__paper--clear {
    --paper-color: transparent;
    background:
        linear-gradient(45deg, #eee 25%, transparent 25%),
        linear-gradient(-45deg, #eee 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #eee 75%),
        linear-gradient(-45deg, transparent 75%, #eee 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.swatch-card__image {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.swatch-card__info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30%;
    padding: 16px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
}

.swatch-card__brand {
    font-size: 11px;
    font-weight: 600;
    color: var(--secondary, #f68b1f);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.swatch-card__name {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary, #022662);
    line-height: 1.3;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.swatch-card__specs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: auto;
}

.swatch-card__badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: var(--accent-light, #e7f0fb);
    color: var(--primary, #022662);
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
}

.swatch-card__badge--cover {
    background: var(--primary, #022662);
    color: #fff;
}

.swatch-card__badge--text {
    background: #e0e0e0;
    color: #666;
}

.swatch-card__badge--fsc {
    background: #e8f5e9;
    color: #2e7d32;
}

/* Card actions (favorite, compare) */
.swatch-card__actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.swatch-card--current:hover .swatch-card__actions {
    opacity: 1;
}

.swatch-card__action {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #666;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.swatch-card__action:hover {
    background: #fff;
    color: var(--secondary, #f68b1f);
    transform: scale(1.1);
}

.swatch-card__action--active {
    background: var(--secondary, #f68b1f);
    color: #fff;
}

/* ========================================
   COVER CARD
   ======================================== */
.swatch-card--cover {
    background: linear-gradient(135deg, var(--primary, #022662) 0%, #033a8c 100%);
}

.swatch-card--cover .swatch-card__paper {
    background: transparent;
    height: 100%;
    border-radius: var(--swatch-card-radius);
}

.swatch-card--cover .swatch-card__image {
    max-width: 85%;
    max-height: 85%;
}

/* Foil layer overlay */
.swatch-card__foil-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    mix-blend-mode: screen;
    pointer-events: none;
    opacity: 0.8;
}

/* ========================================
   PAGE HEADER (on dark background)
   ======================================== */
.swatch-page__main header {
    text-align: center;
    margin-bottom: 40px;
}

.swatch-page__main header h1 {
    font-size: 42px;
    font-weight: 900;
    color: #fff;
    margin-bottom: 8px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.swatch-page__main header p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 15px;
}

/* ========================================
   STACK NAVIGATION
   ======================================== */
.swatch-stack__nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin-top: 40px;
}

.swatch-stack__nav-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: var(--primary, #022662);
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.swatch-stack__nav-btn:hover {
    background: #fff;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.swatch-stack__nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.swatch-stack__counter {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.9);
    min-width: 80px;
    text-align: center;
}

.swatch-stack__counter-current {
    font-weight: 700;
    color: #fff;
}

/* ========================================
   QUICK REFERENCE SIDEBAR
   ======================================== */
.quick-ref {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.quick-ref__section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
}

.quick-ref__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.quick-ref__title {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary, #022662);
}

.quick-ref__count {
    font-size: 12px;
    color: #999;
}

.quick-ref__clear {
    font-size: 11px;
    color: var(--secondary, #f68b1f);
    background: none;
    border: none;
    cursor: pointer;
}

/* Favorites list */
.favorites-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.favorites-list__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.favorites-list__item:hover {
    background: var(--accent-light, #e7f0fb);
}

.favorites-list__swatch {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.favorites-list__name {
    flex: 1;
    font-size: 12px;
    color: var(--text, #363636);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.favorites-list__remove {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.favorites-list__remove:hover {
    background: #fee;
    color: #c00;
}

/* Compare panel */
.compare-panel {
    display: flex;
    gap: 8px;
}

.compare-panel__slot {
    flex: 1;
    min-height: 80px;
    border: 2px dashed #e0e0e0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    transition: border-color 0.2s;
}

.compare-panel__slot--filled {
    border-style: solid;
    border-color: var(--primary, #022662);
}

.compare-panel__slot-empty {
    font-size: 24px;
    color: #ccc;
}

.compare-panel__slot-swatch {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    margin-bottom: 4px;
}

.compare-panel__slot-name {
    font-size: 10px;
    color: var(--text, #363636);
    text-align: center;
    line-height: 1.2;
    max-height: 24px;
    overflow: hidden;
}

/* Export button */
.quick-ref__export {
    width: 100%;
    padding: 12px;
    background: var(--primary, #022662);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
}

.quick-ref__export:hover {
    background: #033a8c;
}

/* Empty state */
.quick-ref__empty {
    text-align: center;
    padding: 24px 16px;
    color: #999;
    font-size: 13px;
}

.quick-ref__empty-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

/* ========================================
   DETAIL MODAL
   ======================================== */
.swatch-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.swatch-modal.is-open {
    opacity: 1;
    visibility: visible;
}

.swatch-modal__content {
    background: #fff;
    border-radius: 12px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.swatch-modal.is-open .swatch-modal__content {
    transform: scale(1);
}

.swatch-modal__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 24px;
    border-bottom: 1px solid #f0f0f0;
}

.swatch-modal__close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f5f5f5;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.swatch-modal__close:hover {
    background: #e0e0e0;
}

.swatch-modal__body {
    display: flex;
    padding: 24px;
    gap: 32px;
}

.swatch-modal__preview {
    flex: 1;
    max-width: 360px;
}

.swatch-modal__image-container {
    aspect-ratio: 3/4;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e0e0e0;
}

.swatch-modal__image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.swatch-modal__specs {
    flex: 1;
}

.swatch-modal__brand {
    font-size: 12px;
    font-weight: 600;
    color: var(--secondary, #f68b1f);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.swatch-modal__name {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary, #022662);
    margin-bottom: 16px;
}

.swatch-modal__badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

/* Specs table */
.specs-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
}

.specs-table th,
.specs-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

.specs-table th {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    width: 40%;
}

.specs-table td {
    font-size: 14px;
    color: var(--text, #363636);
}

/* Compatibility matrix */
.compat-matrix {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.compat-matrix__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 12px;
}

.compat-matrix__icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.compat-matrix__icon--yes {
    background: #e8f5e9;
    color: #2e7d32;
}

.compat-matrix__icon--no {
    background: #ffebee;
    color: #c62828;
}

.swatch-modal__actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.swatch-modal__action-btn {
    flex: 1;
    padding: 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.swatch-modal__action-btn--primary {
    background: var(--secondary, #f68b1f);
    color: #fff;
    border: none;
}

.swatch-modal__action-btn--primary:hover {
    background: #e07a0e;
}

.swatch-modal__action-btn--secondary {
    background: #fff;
    color: var(--primary, #022662);
    border: 1px solid #e0e0e0;
}

.swatch-modal__action-btn--secondary:hover {
    background: var(--accent-light, #e7f0fb);
    border-color: var(--primary, #022662);
}

/* ========================================
   RESPONSIVE BREAKPOINTS
   ======================================== */

/* Large screens - slightly smaller landscape cards */
@media (max-width: 1600px) {
    :root {
        --swatch-card-width: 620px;
        --swatch-card-height: 380px;
    }
}

/* Medium-large screens */
@media (max-width: 1400px) {
    :root {
        --swatch-card-width: 540px;
        --swatch-card-height: 330px;
    }

    .swatch-card--prev-2,
    .swatch-card--prev-3,
    .swatch-card--next-2,
    .swatch-card--next-3 {
        opacity: 0;
        pointer-events: none;
    }
}

/* Medium screens - hide filter sidebar */
@media (max-width: 1024px) {
    :root {
        --swatch-card-width: 480px;
        --swatch-card-height: 300px;
    }

    .swatch-page__filters {
        position: fixed;
        left: 0;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 100;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }

    .swatch-page__filters.is-open {
        transform: translateX(0);
    }

    .panel-toggle--filters {
        display: flex;
        left: 20px;
    }

    .swatch-card--prev-1,
    .swatch-card--next-1 {
        transform: translateX(0) translateZ(-50px) scale(0.95);
        opacity: 0.4;
    }
}

/* Small screens */
@media (max-width: 768px) {
    :root {
        --swatch-card-width: 360px;
        --swatch-card-height: 220px;
    }

    .swatch-page__main {
        padding: 20px 16px 40px;
    }

    .swatch-page__main header h1 {
        font-size: 28px;
    }

    .swatch-card--prev-1,
    .swatch-card--next-1 {
        opacity: 0;
        pointer-events: none;
    }

    .swatch-modal__body {
        flex-direction: column;
    }

    .swatch-modal__preview {
        max-width: 100%;
    }

    .compat-matrix {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    :root {
        --swatch-card-width: 300px;
        --swatch-card-height: 185px;
    }

    .swatch-stack__nav {
        gap: 16px;
        margin-top: 24px;
    }

    .swatch-stack__nav-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .swatch-modal__content {
        width: 95%;
    }

    .swatch-modal__header,
    .swatch-modal__body {
        padding: 16px;
    }

    .compare-panel {
        flex-direction: column;
    }

    .compat-matrix {
        grid-template-columns: 1fr 1fr;
    }
}

/* ========================================
   FILTER SIDEBAR OVERRIDES
   Using existing filter-sidebar.css patterns
   ======================================== */
.swatch-filter {
    /* Inherits from .filter-sidebar */
}

.swatch-filter__search {
    margin-bottom: 16px;
}

.swatch-filter__search-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
}

.swatch-filter__search-input:focus {
    outline: none;
    border-color: var(--primary, #022662);
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    .swatch-page__filters,
    .swatch-page__sidebar,
    .swatch-stack__nav,
    .swatch-card__actions {
        display: none !important;
    }

    .swatch-page__layout {
        display: block;
    }

    .swatch-card {
        position: relative !important;
        page-break-inside: avoid;
        margin-bottom: 24px;
    }
}
