/**
 * PCE Farma Logo - Frontend Styles & Editor Preview
 */

.farma-wrapper {
    width: 100%;
    position: relative;
    margin: 25px 0;
}

/* ==========================================================================
   SIATKA (GRID / FLEX-TILES) - DOWOLNA ILOŚĆ KOLUMN (1-10) + WYRÓWNANIE
   ========================================================================== */

.farma-grid-layout {
    display: flex;
    flex-wrap: wrap;
    justify-content: var(--pce-align, center);
    gap: var(--pce-gap, 20px);
    width: 100%;
    max-width: calc((var(--pce-cols, 5) * var(--pce-size, 160px)) + ((var(--pce-cols, 5) - 1) * var(--pce-gap, 20px)));
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

.farma-grid-layout .farma-item {
    flex: 0 0 var(--pce-size, 160px);
    width: var(--pce-size, 160px);
    max-width: 100%;
    box-sizing: border-box;
}

/* Responsywność siatki */
@media (max-width: 1024px) {
    .farma-grid-layout {
        max-width: calc((var(--pce-cols-tablet, 4) * var(--pce-size, 160px)) + ((var(--pce-cols-tablet, 4) - 1) * var(--pce-gap, 20px)));
    }
}

@media (max-width: 768px) {
    .farma-grid-layout {
        max-width: calc((var(--pce-cols-mobile, 3) * var(--pce-size, 160px)) + ((var(--pce-cols-mobile, 3) - 1) * var(--pce-gap, 20px)));
    }
}

@media (max-width: 480px) {
    .farma-grid-layout {
        max-width: 100%;
        justify-content: center;
    }
    .farma-grid-layout .farma-item {
        flex: 1 1 calc(50% - (var(--pce-gap, 20px) / 2));
        width: auto;
    }
}

/* ==========================================================================
   ELEMENTY KAFELKA (WSPÓLNE DLA GRID I KARUZELI)
   ========================================================================== */

.farma-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.farma-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    text-decoration: none;
}

.farma-link.is-clickable {
    cursor: pointer;
}

.farma-link.is-default-cursor {
    cursor: default;
}

.farma-link:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.farma-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: all 0.4s ease;
}

/* Filtry graficzne */
.farma-link.filter-grayscale .farma-img {
    filter: grayscale(100%);
    opacity: 0.85;
}

.farma-link.filter-sepia .farma-img {
    filter: sepia(100%);
    opacity: 0.85;
}

.farma-link:hover .farma-img {
    filter: grayscale(0) sepia(0);
    opacity: 1;
    transform: scale(1.05);
}

/* Nakładka kolorystyczna (Overlay) */
.farma-link.has-overlay::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--pce-overlay-color, transparent);
    mix-blend-mode: multiply;
    opacity: 1;
    transition: 0.3s ease;
    pointer-events: none;
}

.farma-link.has-overlay:hover::after {
    opacity: 0;
}

/* Miniatura zastępcza (Placeholder) */
.farma-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border-radius: 6px;
    padding: 10px;
    box-sizing: border-box;
    text-align: center;
    transition: background 0.2s ease;
}

.farma-link:hover .farma-placeholder {
    background: #f1f5f9;
}

.farma-placeholder svg {
    width: 26px;
    height: 26px;
    stroke: #64748b;
    margin-bottom: 5px;
    opacity: 0.85;
}

.farma-placeholder .farma-brand-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: #475569;
    line-height: 1.2;
    margin-bottom: 2px;
}

.farma-placeholder .farma-brand-url {
    font-size: 10px;
    font-weight: 600;
    color: #0284c7;
    letter-spacing: 0.2px;
}

.farma-item-title {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.3;
}

/* ==========================================================================
   KARUZELA (SWIPER)
   ========================================================================== */

.farma-wrapper .swiper-button-next,
.farma-wrapper .swiper-button-prev {
    color: #0284c7 !important;
    transform: scale(0.65);
}

.farma-wrapper .swiper-pagination-bullet-active {
    background: #0284c7 !important;
}

.farma-wrapper .swiper.has-dots {
    padding-bottom: 35px !important;
}

.farma-wrapper .swiper:not(.has-dots) {
    padding-bottom: 5px !important;
}

/* ==========================================================================
   PODGLĄD KARUZELI W EDYTORZE GUTENBERGA
   ========================================================================== */

.farma-editor-carousel-preview .farma-item {
    flex: 0 0 var(--pce-size, 160px);
    width: var(--pce-size, 160px);
}

/* ==========================================================================
   OKNA MODALNE (POP-UP)
   ========================================================================== */

.farma-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    backdrop-filter: blur(4px);
    padding: 20px;
}

.farma-modal.is-active {
    display: flex;
}

.farma-modal-content {
    background: #ffffff;
    padding: 36px 30px 30px;
    border-radius: 12px;
    max-width: 450px;
    width: 100%;
    position: relative;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.farma-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    font-size: 28px;
    cursor: pointer;
    color: #94a3b8;
    border: none;
    background: none;
    line-height: 1;
}

.farma-modal-img {
    max-height: 80px;
    margin-bottom: 16px;
    object-fit: contain;
}

/* ==========================================================================
   BACKEND ADMIN - TABELA WPISÓW I DRAG & DROP
   ========================================================================== */

.wp-list-table th.column-pce_drag,
.wp-list-table td.column-pce_drag {
    width: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    padding: 8px 4px !important;
    text-align: center !important;
    vertical-align: middle !important;
    box-sizing: border-box !important;
}

.pce-farma-drag-handle {
    cursor: grab;
    color: #94a3b8;
    font-size: 18px;
    line-height: 1;
    display: inline-block;
    transition: color 0.15s ease, transform 0.15s ease;
}

.pce-farma-drag-handle:hover {
    color: #0284c7;
    transform: scale(1.15);
}

.pce-farma-drag-handle:active {
    cursor: grabbing;
}