/**
 * Frontend CSS
 *
 * @package Tlocrti_Nekretnina
 */

/* Ensure container has no padding/margin to display immediately below header */
.tn-floorplan-container {
    display: flex;
    gap: 20px;
    margin: 0 !important;
    margin-left: 0 !important;
    margin-right: auto;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    max-width: 100%;
    padding: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    width: 100%;
    box-sizing: border-box;
}

.tn-gallery-section {
    flex: 0 0 60%;
    min-width: 0;
    position: relative;
}

.tn-gallery-content {
    display: block;
    width: 100%;
    height: 100%;
}

.tn-gallery-section.tn-video-active .tn-gallery-content {
    display: none;
}

.tn-gallery-section {
    display: block;
}

.tn-floorplan-section {
    flex: 0 0 40%;
    min-width: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #ffffff;
}

.tn-main-image-container {
    position: relative;
    width: 100%;
    padding-bottom: 50%;
    overflow: hidden;
    background: #f5f5f5;
    border-radius: 4px;
    margin-bottom: 15px;
    cursor: pointer;
}

.tn-main-image-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #fd363b;
    color: #fd363b;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 10;
    font-size: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.tn-main-image-nav-btn:hover {
    background: #fd363b;
    color: #fff;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(253, 54, 59, 0.4);
}

.tn-main-image-nav-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.tn-main-image-prev {
    left: 15px;
}

.tn-main-image-next {
    right: 15px;
}

.tn-main-image-nav-btn.hidden {
    display: none;
}

.tn-fullscreen-button {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid #fd363b;
    color: #fff;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 10;
}

.tn-fullscreen-button:hover {
    background: #fd363b;
    transform: scale(1.1);
}

.tn-fullscreen-button i {
    font-size: 18px;
}

.tn-main-image-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.tn-no-images {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #999;
    text-align: center;
}

.tn-thumbnails-wrapper {
    position: relative;
    width: 100%;
}

.tn-thumbnails-container {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #fd363b #f5f5f5;
    scroll-behavior: smooth;
}

/* Desktop: Navigation arrows for thumbnails */
@media (min-width: 769px) {
    .tn-thumbnails-wrapper {
        position: relative;
    }

    .tn-thumbnails-scroll-btn {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        background: rgba(255, 255, 255, 0.9);
        border: 2px solid #fd363b;
        color: #fd363b;
        width: 35px;
        height: 35px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.3s;
        z-index: 10;
        font-size: 14px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }

    .tn-thumbnails-scroll-btn:hover {
        background: #fd363b;
        color: #fff;
        transform: translateY(-50%) scale(1.1);
        box-shadow: 0 4px 12px rgba(253, 54, 59, 0.4);
    }

    .tn-thumbnails-scroll-btn:active {
        transform: translateY(-50%) scale(0.95);
    }

    .tn-thumbnails-scroll-left {
        left: -15px;
    }

    .tn-thumbnails-scroll-right {
        right: -15px;
    }

    .tn-thumbnails-scroll-btn.hidden {
        display: none;
    }
}

/* Hide arrows on mobile */
@media (max-width: 768px) {
    .tn-thumbnails-scroll-btn {
        display: none;
    }

    .tn-main-image-nav-btn {
        display: none;
    }
}

.tn-thumbnails-container::-webkit-scrollbar {
    height: 8px;
}

.tn-thumbnails-container::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 4px;
}

.tn-thumbnails-container::-webkit-scrollbar-thumb {
    background: #fd363b;
    border-radius: 4px;
}

.tn-thumbnails-container::-webkit-scrollbar-thumb:hover {
    background: #d32e33;
}

.tn-thumbnail-item {
    flex: 0 0 100px;
    height: 75px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    transition: border-color 0.3s, transform 0.3s;
}

.tn-thumbnail-item:hover {
    border-color: #fd363b;
    transform: scale(1.05);
}

.tn-thumbnail-item.active {
    border-color: #fd363b;
    box-shadow: 0 2px 8px rgba(253, 54, 59, 0.3);
}

.tn-thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.tn-floor-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.tn-floor-tab {
    padding: 10px 20px;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
    color: #333;
}

.tn-floor-tab:hover {
    border-color: #fd363b;
    color: #fd363b;
}

.tn-floor-tab.active {
    background: #fd363b;
    border-color: #fd363b;
    color: #fff;
}

.tn-floorplan-wrapper {
    display: none;
    position: relative;
    width: 100%;
    margin: 0 auto;
}

.tn-floorplan-wrapper.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin: 0 auto;
    flex: 1;
}

.tn-floorplan-image-container {
    position: relative;
    width: 100%;
    padding-bottom: 75%;
    overflow: hidden;
    background: #ffffff;
    border-radius: 4px;
    margin-bottom: 15px;
    margin-left: auto;
    margin-right: auto;
}

.tn-floorplan-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

/* Ensure all floorplans have same dimensions - fixed height */
.tn-floorplan-image-container {
    height: 450px;
    padding-bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin: 0 auto;
    width: 100%;
    max-width: 100%;
    flex-shrink: 0;
    background: #ffffff;
}


.tn-floorplan-svg {
    position: absolute;
    pointer-events: all;
    z-index: 2;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* Size will be set by JavaScript to match image exactly */
}

.tn-shape {
    transition: all 0.3s;
    fill: #dfdfdf !important;
    fill-opacity: 0.3 !important;
    stroke: #dfdfdf !important;
    stroke-width: 2 !important;
}

.tn-shape-active {
    fill: #fd363b !important;
    fill-opacity: 0.3 !important;
    stroke: #fd363b !important;
    stroke-width: 4 !important;
}

.tn-shape:hover,
.tn-shape-hover {
    fill: #fd363b !important;
    fill-opacity: 0.3 !important;
    stroke: #fd363b !important;
    stroke-width: 2 !important;
}


.tn-floorplan-default {
    width: 100%;
    padding-bottom: 75%;
    position: relative;
    background: #f5f5f5;
    border-radius: 4px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tn-floorplan-default img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 70%;
    max-height: 70%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.tn-view-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Desktop: Fixed position at bottom center of floorplan section */
@media (min-width: 769px) {
    .tn-floorplan-section {
        display: flex;
        flex-direction: column;
    }
    
    .tn-view-buttons {
        position: absolute;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 100;
        background: rgba(255, 255, 255, 0.95);
        padding: 10px 20px;
        border-radius: 30px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        width: auto;
    }
}

.tn-view-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s;
    color: #333;
}

.tn-view-button:hover {
    border-color: #fd363b;
    color: #fd363b;
}

.tn-view-button.active {
    background: #fd363b;
    border-color: #fd363b;
    color: #fff;
}

.tn-button-icon {
    font-size: 18px;
}

.tn-video-container {
    display: none;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    min-height: 100%;
    z-index: 10;
}

.tn-gallery-section.tn-video-active .tn-video-container {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.tn-video-container iframe,
.tn-video-container video {
    width: 100% !important;
    height: 100% !important;
    min-height: 100%;
    border-radius: 4px;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: absolute;
    top: 0;
    left: 0;
}

/* Mobile Styles */
@media (max-width: 768px) {
    .tn-floorplan-container {
        flex-direction: column;
        gap: 0;
        margin: 0;
        margin-left: 0;
        padding: 0;
        width: 100%;
    }

    .tn-hide-on-mobile {
        display: none !important;
    }

    .tn-gallery-section {
        flex: 1;
        width: 100%;
        order: 1;
        position: relative;
    }

    .tn-main-image-container {
        padding-bottom: 55%;
    }

    .tn-gallery-section.tn-video-active .tn-gallery-content {
        display: none !important;
    }

    .tn-gallery-section.tn-video-active {
        display: block !important;
        min-height: 0;
        height: auto;
    }

    /* Video container should match the exact height of main image container */
    .tn-gallery-section.tn-video-active .tn-video-container {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        width: 100% !important;
        padding-bottom: 55% !important;
        min-height: 0 !important;
        margin-bottom: 15px !important;
        border-radius: 4px;
        overflow: hidden;
        background: #f5f5f5;
    }

    .tn-video-container {
        display: none;
        position: relative;
        width: 100%;
        padding-bottom: 55%;
        min-height: 0;
        margin-bottom: 15px;
        border-radius: 4px;
        overflow: hidden;
        background: #f5f5f5;
    }

    .tn-video-container iframe,
    .tn-video-container video {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
    }

    .tn-floorplan-section {
        flex: 1;
        width: 100%;
        order: 3;
        margin-top: 0;
        position: relative;
        z-index: 100;
        display: flex;
        flex-direction: column;
    }

    .tn-gallery-section.tn-loaded {
        animation: tnFadeIn 0.5s ease-in;
    }

    .tn-floorplan-section.tn-slide-in {
        animation: tnSlideInFromTop 0.8s ease-out;
    }

    /* Collapse floorplan after 3 seconds on mobile */
    .tn-floorplan-section.tn-slide-in {
        animation: tnSlideInFromTop 0.8s ease-out;
    }

    .tn-floorplan-section.tn-collapsed {
        max-height: 30vh !important;
        overflow: hidden;
        transition: max-height 0.5s ease-out;
        cursor: pointer;
        position: relative;
    }

    .tn-floorplan-section.tn-expanded {
        max-height: none !important;
        transition: max-height 0.5s ease-in;
    }

    .tn-floorplan-section.tn-collapsed::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 40px;
        background: linear-gradient(to top, rgba(255, 255, 255, 0.95), transparent);
        pointer-events: none;
        z-index: 10;
    }

    .tn-view-buttons {
        position: sticky !important;
        top: auto !important;
        bottom: 0 !important;
        left: auto !important;
        transform: none !important;
        order: 999;
        margin-top: auto;
        margin-bottom: 0;
        background: #ffffff !important;
        padding: 15px 20px !important;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1) !important;
        z-index: 1000 !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 100%;
        flex-shrink: 0;
        gap: 10px !important;
        justify-content: center !important;
        flex-wrap: nowrap !important;
    }

    .tn-view-button {
        flex: 0 0 auto !important;
        min-width: 0 !important;
        white-space: nowrap !important;
    }

    /* Floorplan image container height on mobile */
    .tn-floorplan-image-container {
        height: 280px !important;
        padding-bottom: 0 !important;
    }

    /* When floorplan wrapper exists (comes before buttons), buttons can move down */
    .tn-floorplan-wrapper ~ .tn-view-buttons,
    .tn-floor-selector ~ .tn-view-buttons {
        position: relative !important;
        bottom: auto !important;
        margin-top: 15px;
        margin-bottom: 15px;
    }

    /* When only default floorplan (hidden on mobile), buttons stay fixed */
    .tn-floorplan-default.tn-hide-on-mobile ~ .tn-view-buttons {
        position: sticky !important;
        bottom: 0 !important;
        margin-top: auto;
        margin-bottom: 0;
    }

    .tn-floor-selector {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        padding-bottom: 5px;
    }

    .tn-floor-tab {
        white-space: nowrap;
        flex: 0 0 auto;
    }

    .tn-thumbnails-container {
        -webkit-overflow-scrolling: touch;
    }
}

/* Animations */
@keyframes tnFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes tnSlideInFromTop {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Image Protection */
.tn-main-image,
.tn-floorplan-image,
.tn-thumbnail-item img {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

/* Fullscreen Lightbox */
.tn-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: tnFadeIn 0.3s ease-in;
}

.tn-fullscreen-content {
    position: relative;
    width: 90%;
    height: 90%;
    max-width: 1400px;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tn-fullscreen-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

.tn-fullscreen-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid #fd363b;
    color: #fff;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 10;
    font-size: 20px;
}

.tn-fullscreen-close:hover {
    background: #fd363b;
    transform: scale(1.1);
}

.tn-fullscreen-prev,
.tn-fullscreen-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid #fd363b;
    color: #fff;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 10;
    font-size: 20px;
}

.tn-fullscreen-prev {
    left: 20px;
}

.tn-fullscreen-next {
    right: 20px;
}

.tn-fullscreen-prev:hover,
.tn-fullscreen-next:hover {
    background: #fd363b;
    transform: translateY(-50%) scale(1.1);
}

/* Mobile: Position arrows at bottom right below image */
@media (max-width: 768px) {
    .tn-fullscreen-content {
        width: 100%;
        height: 100%;
        padding: 60px 20px 100px 20px;
        box-sizing: border-box;
    }

    .tn-fullscreen-image {
        max-width: 100%;
        max-height: calc(100% - 80px);
    }

    .tn-fullscreen-prev,
    .tn-fullscreen-next {
        top: auto;
        bottom: 20px;
        transform: none;
        width: 45px;
        height: 45px;
        font-size: 18px;
    }

    .tn-fullscreen-prev {
        left: auto;
        right: 70px;
    }

    .tn-fullscreen-next {
        right: 20px;
    }

    .tn-fullscreen-prev:hover,
    .tn-fullscreen-next:hover {
        transform: scale(1.05);
    }

    .tn-fullscreen-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .tn-fullscreen-counter {
        bottom: 20px;
        left: 20px;
        right: auto;
        transform: none;
        padding: 8px 16px;
        font-size: 12px;
    }
}

.tn-fullscreen-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    border: 2px solid #fd363b;
}

body.tn-fullscreen-active {
    overflow: hidden;
}

