/**
 * Product 360° View - Frontend CSS
 */

/* ===================================
   HERO FULL-WIDTH 360° VIEWER
   =================================== */

/* Ẩn gallery gốc */
body.p360v-hero-mode .woocommerce-product-gallery,
body.p360v-hero-mode .woocommerce div.product div.images,
body.p360v-hero-mode .woocommerce div.product div.images.woocommerce-product-gallery {
    display: none !important;
}

/* ── Phá layout 2 cột Flatsome / WooCommerce ── */
body.p360v-hero-mode .woocommerce div.product,
body.p360v-hero-mode .product-page .product,
body.p360v-hero-mode article.product {
    display: block !important;
    grid-template-columns: unset !important;
    -ms-grid-columns: unset !important;
}

body.p360v-hero-mode .woocommerce div.product .summary,
body.p360v-hero-mode .woocommerce div.product div.summary,
body.p360v-hero-mode .summary.entry-summary {
    display: none !important;
}

/* ── Hero wrapper - nằm ngoài div.product, full width tự nhiên ── */
.p360v-hero-wrapper {
    position: relative;
    width: 100%;
    background: #111;
    overflow: hidden;
    margin: 0;
    padding: 0;
    display: block;
    clear: both;
    /* Thoát padding của .container nếu có */
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    width: 100vw;
}

/* ── Viewer: chiều cao viewport ── */
#p360v-inline-viewer,
.p360v-hero-viewer {
    width: 100% !important;
    height: 70vh !important;
    min-height: 380px !important;
    max-height: 720px !important;
    background: #1a1a1a;
    position: relative !important;
    cursor: grab;
    overflow: hidden;
    display: block !important;
}

#p360v-inline-viewer:active,
.p360v-hero-viewer:active {
    cursor: grabbing;
}

#p360v-inline-viewer canvas,
.p360v-hero-viewer canvas {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
}

/* Loading indicator */
.p360v-loading-inline {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    padding: 20px 40px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    z-index: 10;
    border: 1px solid rgba(255,255,255,0.15);
}

.p360v-loading-inline::after {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    margin-left: 10px;
    vertical-align: middle;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Badge 360° góc trên phải */
.p360v-hero-badge {
    position: absolute;
    top: 20px;
    right: 24px;
    z-index: 20;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(6px);
    border-radius: 50%;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255,255,255,0.25);
    transition: all 0.3s ease;
}

.p360v-hero-badge:hover {
    background: rgba(0,0,0,0.75);
    transform: scale(1.1);
}

.p360v-hero-badge img {
    width: 34px;
    height: 34px;
    filter: brightness(0) invert(1);
    opacity: 0.9;
}

/* Controls bar nổi phía dưới viewer */
.p360v-hero-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 32px;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(8px);
}

.p360v-hero-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    background: transparent;
    border: 1.5px solid rgba(255,255,255,0.3);
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.25s ease;
    font-size: 14px;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    letter-spacing: 0.3px;
}

.p360v-hero-btn:hover,
.p360v-hero-btn.playing {
    background: #fff;
    border-color: #fff;
    color: #111;
}

.p360v-hero-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.p360v-hero-hint {
    display: flex;
    align-items: center;
    gap: 7px;
    color: rgba(255,255,255,0.5);
    font-size: 13px;
    font-style: italic;
    letter-spacing: 0.2px;
}

.p360v-hero-hint .dashicons {
    animation: rotate360hint 3s ease-in-out infinite;
    font-size: 16px;
    width: 16px;
    height: 16px;
    color: rgba(255,255,255,0.6);
}

@keyframes rotate360hint {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(180deg); }
}

/* Ẩn short description khi hero mode */
body.p360v-hero-mode .woocommerce-product-details__short-description {
    display: none !important;
}

/* Responsive */
@media (max-width: 1024px) {
    .p360v-hero-viewer {
        aspect-ratio: 16 / 9;
    }
}

@media (max-width: 768px) {
    .p360v-hero-viewer {
        aspect-ratio: 1 / 1;
    }

    .p360v-hero-controls {
        padding: 12px 16px;
    }

    .p360v-hero-btn span:last-child {
        display: none;
    }

    .p360v-hero-btn {
        padding: 10px 14px;
    }

    .p360v-hero-badge {
        width: 44px;
        height: 44px;
        top: 12px;
        right: 14px;
    }

    .p360v-hero-badge img {
        width: 26px;
        height: 26px;
    }
}

/* Legacy classes - giữ lại để tương thích */
.p360v-inline-viewer-wrapper { display: none; }



/* ===================================
   MODAL FULLSCREEN
   =================================== */

.p360v-trigger-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.p360v-trigger-button:hover {
    background: #005177;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.p360v-trigger-button img {
    width: 24px;
    height: 24px;
}

/* Modal */
.p360v-modal {
    display: none;
    position: fixed;
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.9);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.p360v-modal.p360v-modal-open {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.p360v-modal-content {
    position: relative;
    background-color: #fff;
    margin: auto;
    padding: 20px;
    width: 90%;
    max-width: 800px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.p360v-modal-close {
    position: absolute;
    right: 15px;
    top: 15px;
    color: #aaa;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
    transition: color 0.3s ease;
}

.p360v-modal-close:hover,
.p360v-modal-close:focus {
    color: #000;
}

/* Container 360 */
.p360v-container {
    position: relative;
    width: 100%;
    min-height: 400px;
}

.product-360-spinner {
    width: 100%;
    height: 500px;
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
}

/* ThreeSixty container */
.threesixty-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.threesixty-container canvas {
    width: 100%;
    height: 100%;
    cursor: grab;
    display: block;
}

.threesixty-container canvas:active {
    cursor: grabbing;
}

/* Loading indicator */
.p360v-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 40px;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.p360v-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #0073aa;
    border-top-color: transparent;
    border-radius: 50%;
    margin-left: 10px;
    vertical-align: middle;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Controls */
.p360v-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

.p360v-control-btn {
    padding: 10px 20px;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.p360v-control-btn:hover {
    background: #005177;
}

.p360v-control-btn .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.p360v-control-btn.playing {
    background: #dc3232;
}

.p360v-control-btn.playing:hover {
    background: #a02222;
}

/* Error message */
.p360v-error {
    text-align: center;
    padding: 40px 20px;
    color: #dc3232;
    font-size: 16px;
}

/* Shortcode styling */
.product-360-view-shortcode {
    margin: 20px 0;
}

.product-360-view-shortcode .product-360-spinner {
    height: 400px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

/* Fullscreen mode */
.p360v-modal-content:-webkit-full-screen {
    width: 100%;
    height: 100%;
    max-width: none;
    border-radius: 0;
}

.p360v-modal-content:-moz-full-screen {
    width: 100%;
    height: 100%;
    max-width: none;
    border-radius: 0;
}

.p360v-modal-content:fullscreen {
    width: 100%;
    height: 100%;
    max-width: none;
    border-radius: 0;
}

/* Body class khi modal mở */
body.p360v-modal-active {
    overflow: hidden;
}

/* Responsive */
@media (max-width: 768px) {
    .p360v-modal-content {
        width: 95%;
        padding: 15px;
    }
    
    .product-360-spinner {
        height: 350px;
    }
    
    .p360v-trigger-button {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .p360v-trigger-button img {
        width: 20px;
        height: 20px;
    }
    
    .p360v-control-btn {
        padding: 8px 16px;
    }
}

@media (max-width: 480px) {
    .product-360-spinner {
        height: 300px;
    }
    
    .p360v-modal-content {
        padding: 10px;
    }
    
    .p360v-controls {
        gap: 5px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .p360v-modal {
        background-color: rgba(0, 0, 0, 0.95);
    }
    
    .p360v-modal-content {
        background-color: #1e1e1e;
        color: #fff;
    }
    
    .product-360-spinner {
        background: #2a2a2a;
    }
    
    .p360v-loading {
        background: rgba(30, 30, 30, 0.95);
        color: #fff;
    }
}
