/* ============================================
   AR VIEWER — "Ver en tu Hogar"
   Zoco Alfombras — Premium Room Visualizer
   ============================================ */

/* --- Modal Overlay --- */
.arv-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(10, 10, 20, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    opacity: 0;
    transition: opacity 0.35s ease;
}

.arv-overlay.active {
    display: flex;
    flex-direction: column;
}

.arv-overlay.visible {
    opacity: 1;
}

/* --- Top Bar --- */
.arv-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1.2rem;
    background: rgba(20, 20, 35, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.arv-topbar-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
}

.arv-topbar-title svg {
    color: hsl(25, 60%, 45%);
}

.arv-topbar-product {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    font-family: 'Outfit', sans-serif;
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.arv-close-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.arv-close-btn:hover {
    background: rgba(255, 70, 70, 0.3);
    border-color: rgba(255, 70, 70, 0.5);
    transform: rotate(90deg);
}

/* --- Main Layout --- */
.arv-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* --- Workspace (Room + Rug) --- */
.arv-workspace {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #0a0a14;
    cursor: default;
    min-height: 0;
}

.arv-room-container {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 100%;
    line-height: 0;
}

.arv-room-img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 60px);
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

/* --- Rug Overlay --- */
.arv-rug-wrapper {
    position: absolute;
    cursor: grab;
    touch-action: none;
    user-select: none;
    z-index: 10;
    /* Transform origin centered */
    transform-origin: center center;
}

.arv-rug-wrapper:active {
    cursor: grabbing;
}

.arv-rug-wrapper img {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

/* Resize Handles */
.arv-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: hsl(25, 60%, 45%);
    border: 2px solid #fff;
    border-radius: 50%;
    z-index: 20;
    touch-action: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    transition: transform 0.15s ease;
}

.arv-handle:hover {
    transform: scale(1.3);
}

.arv-handle-tl { top: -7px; left: -7px; cursor: nwse-resize; }
.arv-handle-tr { top: -7px; right: -7px; cursor: nesw-resize; }
.arv-handle-bl { bottom: -7px; left: -7px; cursor: nesw-resize; }
.arv-handle-br { bottom: -7px; right: -7px; cursor: nwse-resize; }

/* Rotate Handle */
.arv-rotate-handle {
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid hsl(25, 60%, 45%);
    border-radius: 50%;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    touch-action: none;
    transition: background 0.2s;
}

.arv-rotate-handle:hover {
    background: rgba(255, 255, 255, 0.3);
}

.arv-rotate-handle::before {
    content: '↻';
    color: #fff;
    font-size: 12px;
    font-weight: bold;
}

/* Dashed connector from rug to rotate handle */
.arv-rotate-line {
    position: absolute;
    top: -28px;
    left: 50%;
    width: 1px;
    height: 22px;
    border-left: 1px dashed rgba(255, 255, 255, 0.3);
    z-index: 15;
}

/* Selection border on rug */
.arv-rug-wrapper.arv-selected {
    outline: 2px dashed rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* --- Placeholder (no room selected) --- */
.arv-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
    padding: 2rem;
}

.arv-placeholder svg {
    opacity: 0.3;
}

.arv-placeholder p {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
}

/* --- Controls Panel (Sidebar) --- */
.arv-controls {
    width: 280px;
    flex-shrink: 0;
    background: rgba(20, 20, 35, 0.98);
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.arv-controls::-webkit-scrollbar {
    width: 4px;
}

.arv-controls::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* --- Section inside controls --- */
.arv-section {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.arv-section:last-child {
    border-bottom: none;
}

.arv-section-title {
    font-family: 'Outfit', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 0.6rem;
}

/* --- Room Selector Grid --- */
.arv-room-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.arv-room-option {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.25s ease;
    aspect-ratio: 4/3;
}

.arv-room-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.arv-room-option:hover img {
    transform: scale(1.05);
}

.arv-room-option:hover {
    border-color: rgba(255, 255, 255, 0.3);
}

.arv-room-option.active {
    border-color: hsl(25, 60%, 45%);
    box-shadow: 0 0 0 1px hsl(25, 60%, 45%), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.arv-room-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 3px 6px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-size: 0.6rem;
    font-weight: 500;
    text-align: center;
}

/* --- Upload Button --- */
.arv-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0.55rem;
    margin-top: 6px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-family: 'Outfit', sans-serif;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.arv-upload-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: hsl(25, 60%, 45%);
    color: #fff;
}

.arv-upload-input {
    display: none;
}

/* --- Sliders --- */
.arv-slider-group {
    margin-bottom: 0.6rem;
}

.arv-slider-group:last-child {
    margin-bottom: 0;
}

.arv-slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
}

.arv-slider-label {
    font-family: 'Outfit', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.65);
}

.arv-slider-value {
    font-family: 'Outfit', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    color: hsl(25, 60%, 45%);
    min-width: 35px;
    text-align: right;
}

.arv-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    cursor: pointer;
}

.arv-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: hsl(25, 60%, 45%);
    border: 2px solid #fff;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease;
}

.arv-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.arv-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: hsl(25, 60%, 45%);
    border: 2px solid #fff;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* --- Quick Action Buttons --- */
.arv-quick-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.arv-action-btn {
    flex: 1;
    min-width: 50px;
    padding: 0.45rem 0.3rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.7);
    font-family: 'Outfit', sans-serif;
    font-size: 0.65rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.arv-action-btn svg {
    width: 16px;
    height: 16px;
}

.arv-action-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
}

.arv-action-btn.active {
    background: hsla(25, 60%, 45%, 0.2);
    border-color: hsl(25, 60%, 45%);
    color: hsl(25, 60%, 55%);
}

/* --- Export Buttons --- */
.arv-export-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.65rem;
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    border: none;
    margin-bottom: 6px;
}

.arv-export-btn:last-child {
    margin-bottom: 0;
}

.arv-export-download {
    background: linear-gradient(135deg, hsl(25, 60%, 45%), hsl(25, 70%, 38%));
    color: #fff;
    box-shadow: 0 4px 12px hsla(25, 60%, 45%, 0.3);
}

.arv-export-download:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px hsla(25, 60%, 45%, 0.4);
}

.arv-export-whatsapp {
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.25);
}

.arv-export-whatsapp:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(37, 211, 102, 0.35);
}

/* --- Rug Preview in Controls --- */
.arv-rug-preview {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.arv-rug-preview img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.arv-rug-preview-info {
    flex: 1;
    min-width: 0;
}

.arv-rug-preview-name {
    font-family: 'Outfit', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.arv-rug-preview-collection {
    font-family: 'Outfit', sans-serif;
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.4);
}

/* --- CTA Button in Product Page --- */
.arv-trigger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    background: linear-gradient(135deg, #00796b 0%, #00a884 100%);
    color: #fff;
    padding: 0.82rem 1.6rem;
    border-radius: 980px;
    font-family: 'Outfit', sans-serif;
    font-weight: 500;
    font-size: 0.95rem;
    text-decoration: none;
    cursor: pointer;
    border: none;
    box-shadow: 0 6px 18px rgba(0, 121, 107, 0.28);
    transition: all 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
    position: relative;
    overflow: hidden;
    max-width: 100%;
    min-width: 196px;
    white-space: normal;
    text-align: center;
    line-height: normal;
    letter-spacing: 0.01em;
}

.arv-trigger-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #00897b 0%, #26c6a8 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: inherit;
}

.arv-trigger-btn:hover::before {
    opacity: 1;
}

.arv-trigger-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(0, 121, 107, 0.34);
}

.arv-trigger-btn svg,
.arv-trigger-btn span {
    position: relative;
    z-index: 1;
}

.arv-trigger-btn svg {
    width: 20px;
    height: 20px;
}

.arv-trigger-btn .arv-btn-badge {
    display: none;
}

/* Pulse glow animation for the trigger button */
@keyframes arv-glow {
    0%, 100% { box-shadow: 0 6px 18px rgba(0, 121, 107, 0.28); }
    50% { box-shadow: 0 6px 18px rgba(0, 121, 107, 0.28), 0 0 20px rgba(38, 198, 168, 0.26); }
}

.arv-trigger-btn {
    animation: arv-glow 3s ease-in-out infinite;
}

/* --- Floating AR Button (FAB) --- */
.arv-fab {
    position: fixed;
    bottom: 90px;
    right: 25px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 2px solid hsl(25, 60%, 45%);
    border-radius: 50%;
    display: none; /* Shown via JS only on ficha page */
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    z-index: 997;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
    text-decoration: none;
    animation: arv-fab-pulse 2.5s ease-in-out infinite;
}

@keyframes arv-fab-pulse {
    0%, 100% {
        box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4),
                    0 0 0 0 hsla(25, 60%, 45%, 0.5);
    }
    50% {
        box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4),
                    0 0 0 10px hsla(25, 60%, 45%, 0);
    }
}

.arv-fab:hover {
    transform: scale(1.12);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
    animation: none;
}

.arv-fab:hover svg {
    transform: rotate(-8deg) scale(1.1);
    transition: transform 0.3s ease;
}

.arv-fab svg {
    width: 22px;
    height: 22px;
    transition: transform 0.3s ease;
}

/* Small fixed label above floating house icon */
.arv-fab::after {
    content: 'Ver en mi casa';
    position: absolute;
    left: 50%;
    top: -28px;
    transform: translateX(-50%);
    background: rgba(26, 26, 46, 0.92);
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 1;
    pointer-events: none;
    animation: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* --- Toast notification --- */
.arv-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 0.7rem 1.4rem;
    background: rgba(30, 30, 50, 0.95);
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    border-radius: 50px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.arv-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* --- Composite Canvas (renders the photorealistic rug) --- */
.arv-composite-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

/* --- Engine Section Titles --- */
.arv-section-subtitle {
    font-family: 'Outfit', sans-serif;
    font-size: 0.65rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.3);
    margin-top: 0.5rem;
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

/* --- Occlusion Geometric Tools --- */
.arv-section-hint {
    font-size: 0.62rem;
    color: hsla(220, 20%, 70%, 0.8);
    margin: 0 0 0.5rem;
    line-height: 1.4;
}

.arv-geo-tools {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin-bottom: 0.4rem;
}

.arv-geo-btn {
    flex-direction: column;
    gap: 3px;
    padding: 0.45rem 0.3rem;
    font-size: 0.6rem;
}

.arv-geo-btn.active {
    background: hsla(25, 60%, 45%, 0.25);
    border-color: hsl(25, 60%, 45%);
    color: hsl(25, 60%, 65%);
}

.arv-geo-erase {
    border-color: hsla(0, 60%, 50%, 0.3);
    color: hsla(0, 60%, 65%, 0.85);
}

.arv-geo-erase:hover {
    background: hsla(0, 60%, 45%, 0.15);
    border-color: hsl(0, 60%, 50%);
}

.arv-geo-erase.active {
    background: hsla(0, 60%, 45%, 0.25);
    border-color: hsl(0, 60%, 50%);
    color: hsl(0, 60%, 65%);
}

/* --- Engine Badge (PRO label) --- */
.arv-engine-badge {
    display: inline-block;
    font-size: 0.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 1px 5px;
    border-radius: 3px;
    background: linear-gradient(135deg, hsl(25, 60%, 45%), hsl(35, 80%, 50%));
    color: #fff;
    margin-left: 0.4rem;
    vertical-align: middle;
}

/* ==============================
   RESPONSIVE — Mobile Layout
   ============================== */
@media (max-width: 768px) {
    .arv-body {
        flex-direction: column;
    }

    .arv-controls {
        width: 100%;
        max-height: 40vh;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.06);
    }

    .arv-room-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .arv-workspace {
        flex: 1;
    }

    .arv-room-img {
        max-height: 50vh;
    }

    .arv-topbar-product {
        display: none;
    }

    .arv-handle {
        width: 18px;
        height: 18px;
    }

    .arv-handle-tl { top: -9px; left: -9px; }
    .arv-handle-tr { top: -9px; right: -9px; }
    .arv-handle-bl { bottom: -9px; left: -9px; }
    .arv-handle-br { bottom: -9px; right: -9px; }

    .arv-rotate-handle {
        width: 28px;
        height: 28px;
        top: -40px;
    }

    .arv-quick-actions {
        flex-wrap: nowrap;
    }

    .arv-fab {
        bottom: 85px;
        right: 18px;
        width: 44px;
        height: 44px;
    }

    #scroll-top {
        bottom: 160px !important;
    }
}

/* Avoid overlapping with scroll-to-top button on ficha.php on desktop */
#scroll-top {
    bottom: 175px !important;
}

@media (max-width: 480px) {
    .arv-room-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .arv-controls {
        max-height: 45vh;
    }
}
