/**
 * Mission Testimonials Map - CSS
 * Compatible with Mission Testimonials plugin branding
 * Version: 1.0.1 - Fixed mobile touches and tooltip z-index
 */

:root {
    --contrast: #000000;
    --contrast-2: #575760;
    --contrast-3: #b2b2be;
    --base: #f0f0f0;
    --base-2: #f7f8f9;
    --base-3: #ffffff;
    --accent: #759e41;
    --accent-1: #d3dec4;
    --pagehero-green: #759E41;
    --pagehero-white: #FFFFFF;
    --pagehero-black: #000000;
}

/* Main Map Container */
.mission-testimonials-map-container {
    margin: 40px auto;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: start;
}

/* Map Section */
.mission-map-section {
    background-color: var(--base-2);
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.1);
}

.mission-map-section h2,
.mission-testimonials-section h2{
    font-weight: 900;
    text-transform: uppercase;
    margin-bottom: 40px;
    color: var(--accent);
    font-size: 35px;
    margin: 0 0 25px 0;
    text-align: center;
}

/* Map Container */
.mission-map-container {
    position: relative;
    overflow: hidden;
    max-width: 100%;
    margin: 0 auto;
}

.mission-map-image {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

/* *** SAFARI COMPATIBILITY FIXES *** */
.mission-map-pin {
    position: absolute;
    transform: translate(-50%, -100%);
    z-index: 10;
    cursor: pointer;
    transition: all 0.3s ease;
    
    /* Safari-specific fixes */
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.2);
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    pointer-events: auto !important;
    
    /* Touch action for Safari */
    touch-action: manipulation;
    
    /* Isolation for tooltip */
    isolation: isolate;
}

/* Safari-specific pin interaction */
.mission-map-pin:active {
    transform: translate(-50%, -100%) scale(1.05);
    transition: transform 0.1s ease;
}

.mission-pin-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
    
    /* Safari touch optimization */
    -webkit-tap-highlight-color: rgba(117, 158, 65, 0.3);
    pointer-events: auto;
    
    /* Isolation */
    isolation: isolate;
}

/* Safari SVG rendering fix */
.mission-pin-icon svg {
    width: 28px;
    height: 28px;
    color: var(--pagehero-green);
    transition: all 0.3s ease;
    
    /* Safari SVG optimization */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* *** SAFARI-COMPATIBLE TOOLTIP *** */
.mission-pin-tooltip {
    /* RESET wszystkich możliwych nadpisań */
    position: absolute !important;
    bottom: calc(100% + 20px) !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    
    /* STYLING */
    background: linear-gradient(135deg, var(--pagehero-green) 0%, #638536 100%) !important;
    color: var(--pagehero-white) !important;
    padding: 10px 16px !important;
    border-radius: 20px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    
    /* VISIBILITY CONTROL */
    opacity: 0 !important;
    visibility: hidden !important;
    
    /* SAFARI Z-INDEX FIX */
    z-index: 999999 !important;
    
    /* ANIMATION */
    transition: all 0.3s ease !important;
    
    /* EFFECTS */
    box-shadow: 0 8px 25px rgba(117, 158, 65, 0.4) !important;
    backdrop-filter: blur(10px) !important;
    
    /* INTERACTION */
    pointer-events: none !important;
    
    /* SAFARI ISOLATION FIX */
    isolation: isolate !important;
    will-change: transform, opacity !important;
    
    /* Safari-specific rendering optimizations */
    -webkit-transform: translateX(-50%) !important;
    -webkit-backface-visibility: hidden !important;
    -webkit-perspective: 1000 !important;
}

/* Strzałka tooltip - Safari compatible */
.mission-pin-tooltip::after {
    content: "" !important;
    position: absolute !important;
    top: 100% !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    -webkit-transform: translateX(-50%) !important;
    border: 8px solid transparent !important;
    border-top-color: var(--pagehero-green) !important;
    z-index: 999999 !important;
    isolation: isolate !important;
}

/* HOVER STATE - Safari compatible */
.mission-map-pin:hover .mission-pin-tooltip {
    opacity: 1 !important;
    visibility: visible !important;
    z-index: 999999 !important;
    transform: translateX(-50%) translateY(-8px) !important;
    -webkit-transform: translateX(-50%) translateY(-8px) !important;
    pointer-events: none !important;
    isolation: isolate !important;
}

/* Safari touch feedback */
.mission-map-pin:active .mission-pin-tooltip {
    opacity: 1 !important;
    visibility: visible !important;
    z-index: 999999 !important;
    transform: translateX(-50%) translateY(-8px) !important;
    -webkit-transform: translateX(-50%) translateY(-8px) !important;
    pointer-events: none !important;
    isolation: isolate !important;
}

/* MOBILE TOOLTIP: Safari-specific */
.mission-map-pin.touched .mission-pin-tooltip {
    opacity: 1 !important;
    visibility: visible !important;
    z-index: 999999 !important;
    transform: translateX(-50%) translateY(-8px) !important;
    -webkit-transform: translateX(-50%) translateY(-8px) !important;
    pointer-events: none !important;
    isolation: isolate !important;
}

/* *** MOBILE ENHANCED PIN STYLING *** */
@media (hover: none) and (pointer: coarse) {
    .mission-map-pin {
        /* Większy obszar touch na mobile */
        min-width: 50px !important;
        min-height: 50px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        
        /* Touch optimizations */
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
        user-select: none !important;
        
        /* Visual feedback */
        transition: transform 0.2s ease !important;
    }
    
    .mission-map-pin:active {
        transform: translate(-50%, -100%) scale(1.1) !important;
    }
    
    .mission-pin-tooltip {
        /* Mobile-specific tooltip adjustments */
        font-size: 11px !important;
        padding: 8px 12px !important;
        max-width: 200px !important;
        white-space: normal !important;
        text-align: center !important;
        line-height: 1.3 !important;
    }
}

/* Testimonials Section */
.mission-testimonials-section {
    background-color: var(--base-2);
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.1);
    height: fit-content;
    height: 100%;
}

/* Testimonials List - Modern Design */
.mission-testimonials-list {
    min-height: 500px;
    display: flex;
    flex-direction: column;
}

.mission-testimonials-list-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 500px;
    background: linear-gradient(135deg, var(--base-3) 0%, var(--base-2) 100%);
    border-radius: 12px;
    border: 2px dashed var(--accent-1);
}

.placeholder-content {
    text-align: center;
    color: var(--contrast-2);
}

.placeholder-icon {
    font-size: 48px;
    margin-bottom: 20px;
    opacity: 0.6;
    filter: grayscale(1);
}

.placeholder-content h3 {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 12px 0;
    color: var(--pagehero-green);
}

.placeholder-content p {
    font-size: 16px;
    line-height: 1.5;
    margin: 0;
    max-width: 300px;
}

/* Testimonial Detail View */
.mission-testimonial-detail-view {
    background: linear-gradient(135deg, var(--base-3) 0%, var(--base-2) 100%);
    border-radius: 16px;
    padding: 0;
    box-shadow: 0 8px 32px rgba(117, 158, 65, 0.15);
    border: 1px solid var(--accent-1);
    overflow: hidden;
}

.testimonial-detail-header {
    background: linear-gradient(135deg, var(--pagehero-green) 0%, #638536 100%);
    color: var(--pagehero-white);
    padding: 24px 28px;
    position: relative;
}

.testimonial-detail-header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="dots" width="10" height="10" patternUnits="userSpaceOnUse"><circle cx="5" cy="5" r="1" fill="rgba(255,255,255,0.1)"/></pattern></defs><rect width="100" height="100" fill="url(%23dots)"/></svg>');
    opacity: 0.3;
}

.testimonial-detail-header h3 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 8px 0;
    position: relative;
    z-index: 1;
}

.testimonial-detail-company {
    font-size: 16px;
    opacity: 0.9;
    font-weight: 500;
    position: relative;
    z-index: 1;
}

.testimonial-detail-content {
    max-height: 500px;
    overflow-y: auto;
    padding: 28px;
}

/* Video Content */
.testimonial-video-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.testimonial-video-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 12px;
}

/* Text Content */
.testimonial-text-content {
    line-height: 1.7;
    color: var(--contrast);
    font-size: 16px;
}

.testimonial-text-content p {
    margin-bottom: 18px;
}

.testimonial-text-content p:last-child {
    margin-bottom: 0;
}

.testimonial-text-content h1,
.testimonial-text-content h2,
.testimonial-text-content h3,
.testimonial-text-content h4 {
    color: var(--pagehero-green);
    margin-top: 24px;
    margin-bottom: 12px;
}

.testimonial-text-content ul,
.testimonial-text-content ol {
    margin: 16px 0;
    padding-left: 24px;
}

.testimonial-text-content li {
    margin-bottom: 8px;
}

/* *** SAFARI IMAGE FIXES *** */
.testimonial-text-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 20px 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    
    /* Safari-specific optimizations */
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    pointer-events: auto;
    
    /* Safari rendering optimization */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    backface-visibility: hidden;
}

.testimonial-text-content img:hover,
.testimonial-text-content img:active {
    transform: scale(1.02);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.15);
}

/* Safari-compatible image links */
.testimonial-text-content a[href*=".jpg"],
.testimonial-text-content a[href*=".jpeg"],
.testimonial-text-content a[href*=".png"],
.testimonial-text-content a[href*=".gif"],
.testimonial-text-content a[href*=".webp"] {
    border: none;
    text-decoration: none;
    display: inline-block;
    cursor: pointer;
    
    /* Safari touch optimization */
    -webkit-tap-highlight-color: rgba(117, 158, 65, 0.2);
    pointer-events: auto;
    
    /* Safari visual feedback */
    transition: opacity 0.2s ease;
}

.testimonial-text-content a[href*=".jpg"]:active,
.testimonial-text-content a[href*=".jpeg"]:active,
.testimonial-text-content a[href*=".png"]:active,
.testimonial-text-content a[href*=".gif"]:active,
.testimonial-text-content a[href*=".webp"]:active {
    opacity: 0.8;
}

/* External Link */
.testimonial-external-link {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--accent-1);
    text-align: center;
}

.testimonial-external-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 28px;
    background: linear-gradient(135deg, var(--pagehero-green) 0%, #638536 100%);
    color: var(--pagehero-white);
    text-decoration: none;
    border-radius: 25px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(117, 158, 65, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.testimonial-external-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(117, 158, 65, 0.4);
    color: var(--pagehero-white);
    background: linear-gradient(135deg, #638536 0%, #5a7631 100%);
}

/* *** ADMIN PINS - Uproszczone style z lepszą widocznością *** */
.mission-map-pin.admin-pin {
    position: absolute !important;
    z-index: 100 !important;
    display: block !important;
    visibility: visible !important;
    width: 28px !important;
    height: 28px !important;
    background-color: var(--pagehero-white) !important;
    border: 3px solid var(--pagehero-green) !important;
    border-radius: 50% !important;
    box-shadow: 0 4px 12px rgba(117, 158, 65, 0.4) !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
}

.mission-map-pin.admin-pin .mission-pin-icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
    color: var(--pagehero-green) !important;
}

.mission-map-pin.admin-pin .mission-pin-icon svg {
    width: 18px !important;
    height: 18px !important;
    color: var(--pagehero-green) !important;
    display: block !important;
}

/* Admin Pin States */
.mission-map-pin.admin-pin.delete-mode {
    background-color: #dc3232 !important;
    border-color: #ffffff !important;
    animation: pulse-red 1s infinite;
}

.mission-map-pin.admin-pin.move-mode {
    background-color: #0073aa !important;
    border-color: #ffffff !important;
    animation: pulse-blue 1s infinite;
    cursor: grab !important;
}

.mission-map-pin.admin-pin.move-mode:hover {
    cursor: grabbing !important;
}

.mission-map-pin.admin-pin.dragging {
    z-index: 1000 !important;
    pointer-events: none;
    transform: translate(-50%, -100%) rotate(45deg) scale(1.2) !important;
    box-shadow: 0 8px 25px rgba(0, 115, 170, 0.5) !important;
    cursor: grabbing !important;
}

body.dragging-pin {
    cursor: grabbing !important;
    user-select: none;
}

body.dragging-pin * {
    cursor: grabbing !important;
}

@keyframes pulse-red {
    0% { 
        background-color: #dc3232;
        transform: translate(-50%, -100%) scale(1);
        box-shadow: 0 4px 12px rgba(220, 50, 50, 0.4);
    }
    50% { 
        background-color: #ff4444;
        transform: translate(-50%, -100%) scale(1.1);
        box-shadow: 0 6px 20px rgba(255, 68, 68, 0.6);
    }
    100% { 
        background-color: #dc3232;
        transform: translate(-50%, -100%) scale(1);
        box-shadow: 0 4px 12px rgba(220, 50, 50, 0.4);
    }
}

@keyframes pulse-blue {
    0% { 
        background-color: #0073aa;
        transform: translate(-50%, -100%) scale(1);
        box-shadow: 0 4px 12px rgba(0, 115, 170, 0.4);
    }
    50% { 
        background-color: #005a87;
        transform: translate(-50%, -100%) scale(1.05);
        box-shadow: 0 6px 20px rgba(0, 115, 170, 0.6);
    }
    100% { 
        background-color: #0073aa;
        transform: translate(-50%, -100%) scale(1);
        box-shadow: 0 4px 12px rgba(0, 115, 170, 0.4);
    }
}

/* Admin Interface Styles */
.mission-map-interface {
    background-color: var(--base-2);
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
}

#mission-map-container {
    border: 2px solid var(--accent-1);
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--base-3);
    position: relative;
}

#mission-pin-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

#mission-testimonial-select {
    background-color: var(--base-3);
    border: 2px solid var(--accent-1);
    border-radius: 5px;
    padding: 8px 12px;
    font-size: 14px;
    color: var(--contrast);
    min-width: 200px;
}

#mission-delete-pin-mode,
#mission-move-pin-mode {
    background-color: var(--accent-1);
    color: var(--contrast);
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

#mission-delete-pin-mode:hover,
#mission-delete-pin-mode.button-primary,
#mission-move-pin-mode:hover,
#mission-move-pin-mode.button-primary {
    background-color: var(--pagehero-green);
    color: var(--pagehero-white);
}

#mission-clear-all-pins {
    background-color: #dc3232;
    color: var(--pagehero-white);
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

#mission-clear-all-pins:hover {
    background-color: #c62d2d;
    transform: translateY(-1px);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .mission-testimonials-map-container {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    .mission-map-section,
    .mission-testimonials-section {
        padding: 25px;
    }
}

@media (max-width: 1024px) {
    .mission-map-section h2,
    .mission-testimonials-section h2 {
        font-size: 30px;
        margin-bottom: 20px;
    }
}

@media (max-width: 768px) {
    .mission-testimonials-map-container {
        margin: 20px auto;
        gap: 20px;
    }
    
    .mission-map-section,
    .mission-testimonials-section {
        padding: 20px;
    }
    
    .mission-map-section h2,
    .mission-testimonials-section h2 {
        font-size: 25px;
        margin-bottom: 20px;
    }
    
    .mission-testimonials-section {
        min-height: auto;
    }
    
    .mission-testimonials-list {
        min-height: 300px;
    }
    
    .mission-testimonials-list-placeholder {
        height: 300px;
        padding: 30px;
        font-size: 14px;
    }
    
    .mission-testimonial-detail-view {
        margin-bottom: 20px;
    }
    
    .testimonial-detail-content {
        padding: 20px;
        max-height: 400px;
    }
    
    .testimonial-detail-header {
        padding: 20px;
    }
    
    .testimonial-detail-header h3 {
        font-size: 20px;
    }
    
    /* *** POPRAWKA: Mobile pin styling *** */
    .mission-pin-icon {
        width: 32px !important;
        height: 32px !important;
    }
    
    .mission-pin-icon svg {
        width: 32px !important;
        height: 32px !important;
    }
    
    .mission-pin-tooltip {
        font-size: 11px;
        padding: 6px 10px;
        bottom: calc(100% + 10px); /* Mniejszy odstęp na mobile */
    }
    
    /* *** DODANO: Większy obszar kliknięcia na mobile *** */
    .mission-map-pin {
        min-width: 44px; /* Minimum touch target size */
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .mission-testimonials-map-container {
        margin: 15px auto;
    }
    
    .mission-map-section,
    .mission-testimonials-section {
        padding: 15px;
    }
    
    .mission-map-section h2,
    .mission-testimonials-section h2 {
        font-size: 18px;
        margin-bottom: 15px;
    }
    
    .testimonial-detail-content {
        padding: 15px;
        max-height: 350px;
    }
    
    .testimonial-detail-header {
        padding: 15px;
    }
    
    .testimonial-detail-header h3 {
        font-size: 18px;
    }
    
    .testimonial-text-content {
        font-size: 14px;
    }
    
    .testimonial-external-btn {
        padding: 10px 20px;
        font-size: 13px;
    }
    
    /* *** Mobile pin improvements *** */
    .mission-map-pin {
        min-width: 48px; /* Jeszcze większy obszar na małych ekranach */
        min-height: 48px;
    }
    
    .mission-pin-tooltip {
        font-size: 10px;
        padding: 5px 8px;
        max-width: 200px; /* Ograniczenie szerokości na mobile */
        white-space: normal; /* Pozwól na łamanie linii */
    }
    
    /* Admin controls responsive */
    #mission-pin-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    #mission-testimonial-select {
        min-width: auto;
        width: 100%;
        margin-bottom: 10px;
    }
}

/* *** DODANO: Lepsze style dla Featherlight modal na obrazach *** */
.featherlight .featherlight-content {
    border-radius: 8px;
    overflow: hidden;
}

.featherlight .featherlight-image {
    border-radius: 8px;
    max-width: 95vw;
    max-height: 95vh;
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .mission-pin-icon {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}