/**
 * WooCommerce Swatch Organizer - Styles
 * Version: 1.0.0
 * 
 * Organizuje próbki tkanin w elegancki sidebar z grupowaniem według kolekcji
 */

/* ========================================
   SIDEBAR
   ======================================== */

.swatches-sidebar {
    position: fixed;
    right: -470px;
    top: 0;
    width: 450px;
    height: 100vh;
    background: #ffffff;
    box-shadow: -5px 0 25px rgba(0,0,0,0.3);
    z-index: 9999;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.swatches-sidebar.open {
    right: 0;
}

/* Header sidebar */
.swatches-sidebar-header {
    padding: 10px;
    background: var(--wso-primary-color, #7ab530);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.swatches-sidebar-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.swatches-sidebar-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    border-radius: 50%;
}

.swatches-sidebar-close:hover {
    background: rgba(255,255,255,0.3);
    transform: rotate(90deg);
}

/* Podgląd obrazka w sidebarze (tylko mobile) */
.sidebar-image-preview {
    display: none;
    padding: 15px;
    background: white;
    border-bottom: 0px solid #e0e0e0;
    flex-shrink: 0;
}

.sidebar-preview-image {
    width: 100%;
    height: 0;
    padding-bottom: 100%;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    background: #f5f5f5;
}

.sidebar-preview-image img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
    transition: opacity 0.3s ease !important;
    transform: none !important;
}

.sidebar-preview-image.changing img {
    opacity: 0.7;
}

/* Zawartość sidebar */
.swatches-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f8f9fa;
}

/* ========================================
   GRUPY PRÓBEK W SIDEBAR
   ======================================== */

.iconic-swatches-grouped {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.swatch-group {
    background: white;
    border-radius: 10px;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    transition: all 0.3s;
}

.swatch-group:hover {
    box-shadow: 0 4px 10px rgba(0,0,0,0.12);
    transform: translateY(-1px);
}

.swatch-group-header {
    margin: 0;
    padding: 8px 8px;
    border-bottom: 0px solid #f0f0f0;
}

.swatch-group-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #333;
}

.swatch-group-items {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
}

.swatch-group-items .iconic-was-swatches__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s;
}

.swatch-group-items .iconic-was-swatches__item:hover {
    transform: translateY(-2px);
}

.swatch-group-items .iconic-was-swatch {
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.3s;
    display: block;
}

.swatch-group-items .iconic-was-swatch:hover {
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
}

.swatch-group-items .iconic-was-swatch__container {
    width: 70px !important;
    height: 70px !important;
}

.swatch-group-items .iconic-was-swatch__graphic {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    display: block !important;
}

/* Ukryj placeholder SVG */
.swatch-group-items img[src*="data:image/svg+xml"] {
    display: none !important;
}

.swatch-group-items .iconic-was-swatch__text {
    margin-top: 6px;
    font-size: 10px;
    text-align: center;
    white-space: nowrap;
    font-weight: 600;
    color: #495057;
}

.swatch-group-items .iconic-was-swatches__item--selected .iconic-was-swatch {
    transform: scale(1.05);
    box-shadow: 0 0 0 3px var(--wso-primary-color, #7ab530);
}

.swatch-group-items .iconic-was-swatches__item--selected {
    transform: translateY(-2px);
}

/* ========================================
   OVERLAY
   ======================================== */

.swatches-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9997;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    pointer-events: none;
}

.swatches-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Oryginalny kontener będzie ukryty przez JavaScript po inicjalizacji */
.iconic-was-swatches:not(.sidebar-swatches).wso-initialized {
    display: none !important;
}

/* ========================================
   SCROLLBAR W SIDEBARZE
   ======================================== */

.swatches-sidebar-content::-webkit-scrollbar {
    width: 8px;
}

.swatches-sidebar-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.swatches-sidebar-content::-webkit-scrollbar-thumb {
    background: var(--wso-primary-color, #7ab530);
    border-radius: 4px;
}

.swatches-sidebar-content::-webkit-scrollbar-thumb:hover {
    background: var(--wso-primary-dark-color, #6a9f28);
}

/* ========================================
   FOOTER SIDEBAR
   ======================================== */

.swatches-sidebar-footer {
    padding: 15px;
    background: white;
    border-top: 2px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.footer-selected-swatch {
    width: 55px;
    height: 55px;
    min-width: 55px;
    min-height: 55px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    flex-shrink: 0;
    position: relative;
    background: #f5f5f5;
}

.footer-selected-swatch img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
    transition: opacity 0.3s ease !important;
    transform: none !important;
}

.footer-selected-swatch.changing img {
    opacity: 0.7;
}

.footer-selected-swatch.empty {
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 12px;
}

.footer-info {
    flex: 1;
    min-width: 0;
}

.footer-color-name {
    font-weight: 600;
    font-size: 13px;
    color: #333;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.footer-stock-info {
    font-size: 11px;
    font-weight: 600;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.footer-stock-info.out-of-stock {
    color: #dc3545;
}

.footer-stock-info.in-stock {
    color: #28a745;
}

.footer-stock-info:empty {
    display: none;
}

.sidebar-stock-status {
    width: 100%;
    margin: 8px 0;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.sidebar-stock-status .stock {
    margin: 0;
    padding: 0;
}

.sidebar-stock-status .out-of-stock {
    color: #dc3545;
    background: #ffe6e6;
    padding: 6px 10px;
    border-radius: 4px;
    display: inline-block;
}

.sidebar-stock-status .in-stock {
    color: #28a745;
    background: #e6f7e6;
    padding: 6px 10px;
    border-radius: 4px;
    display: inline-block;
}

.footer-add-to-cart-btn {
    background: var(--wso-primary-color, #7ab530);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    flex-shrink: 0;
    white-space: nowrap;
}

.footer-add-to-cart-btn:hover {
    background: var(--wso-primary-dark-color, #6a9f28);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.footer-add-to-cart-btn:active {
    transform: translateY(0);
}

.footer-add-to-cart-btn.disabled,
.footer-add-to-cart-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.footer-add-to-cart-btn.disabled:hover,
.footer-add-to-cart-btn:disabled:hover {
    background: #ccc;
    transform: none;
    box-shadow: none;
}

/* ========================================
   COMPACT COLOR SELECTOR
   ======================================== */

.compact-color-selector {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    transition: all 0.3s;
}

.compact-color-selector:hover {
    border-color: var(--wso-primary-color, #7ab530);
    box-shadow: 0 4px 12px rgba(122, 181, 48, 0.1);
}

.compact-selector-preview {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.compact-selector-label {
    font-weight: 600;
    font-size: 14px;
    color: #333;
    white-space: nowrap;
}

.compact-selector-samples {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.compact-selector-sample {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.3s;
    cursor: pointer;
    position: relative;
}

.compact-selector-sample:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.compact-selector-sample.selected {
    box-shadow: 0 0 0 3px var(--wso-primary-color, #7ab530);
    transform: scale(1.05);
}

.compact-selector-sample img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.compact-selector-more {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    transition: all 0.3s;
}

.compact-selector-more:hover {
    background: var(--wso-primary-color, #7ab530);
    color: white;
    transform: scale(1.1);
}

/* ========================================
   ANIMACJE
   ======================================== */

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

.swatch-group {
    animation: fadeInUp 0.4s ease forwards;
}

.swatch-group:nth-child(1) { animation-delay: 0.05s; }
.swatch-group:nth-child(2) { animation-delay: 0.1s; }
.swatch-group:nth-child(3) { animation-delay: 0.15s; }
.swatch-group:nth-child(4) { animation-delay: 0.2s; }
.swatch-group:nth-child(5) { animation-delay: 0.25s; }
.swatch-group:nth-child(6) { animation-delay: 0.3s; }

/* ========================================
   RESPONSYWNOŚĆ
   ======================================== */

/* Tablet i większe telefony (481px - 768px) */
@media (max-width: 768px) {
    .swatches-sidebar {
        width: 100%;
        right: -100%;
    }

    .swatch-group-items {
        grid-template-columns: repeat(5, 1fr);
        gap: 2px;
    }

    .swatch-group-items .iconic-was-swatch__container {
        width: 60px !important;
        height: 60px !important;
    }

    .compact-selector-samples {
        justify-content: center;
    }

    /* Pokaż podgląd na mobile */
    .sidebar-image-preview {
        display: block !important;
        margin: 0 auto;
        width: 80%;
    }

    .swatches-sidebar-content {
        padding: 10px;
    }

    .iconic-swatches-grouped {
        gap: 10px;
    }
}

/* Średnie telefony (361px - 480px) */
@media (max-width: 480px) {
    .swatch-group-items {
        grid-template-columns: repeat(4, 1fr);
        gap: 2px;
    }

    .swatch-group-items .iconic-was-swatch__container {
        width: 55px !important;
        height: 55px !important;
    }

    .swatch-group-items .iconic-was-swatch__text {
        font-size: 9px;
    }
}

/* Małe telefony (≤360px) - iPhone SE, starsze Androidy */
@media (max-width: 360px) {
    .swatch-group-items {
        grid-template-columns: repeat(3, 1fr);
        gap: 2px;
    }

    .swatch-group-items .iconic-was-swatch__container {
        width: 50px !important;
        height: 50px !important;
    }

    .swatch-group-items .iconic-was-swatch__text {
        font-size: 8px;
    }

    .sidebar-image-preview {
        width: 90%;
    }
}
