/* ============================================================
   AR VIEWER – Ướm tranh lên tường
   ============================================================ */

/* ===== OVERLAY FULLSCREEN ===== */
.ar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    background: #000;
    flex-direction: column;
}

.ar-overlay.active {
    display: flex;
}

/* ===== VIDEO CAMERA ===== */
.ar-video-container {
    position: relative;
    flex: 1;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111;
}

.ar-video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ===== ẢNH TRANH OVERLAY ===== */
.ar-painting {
    position: absolute;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    transition: box-shadow 0.2s ease;
    /* Không viền */
    border: none;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.15),
        0 8px 32px rgba(0, 0, 0, 0.35),
        0 2px 8px rgba(0, 0, 0, 0.2);
}

.ar-painting:active {
    cursor: grabbing;
}

.ar-painting img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* ===== HƯỚNG DẪN / LOADING ===== */
.ar-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    text-align: center;
    font-size: 1rem;
    opacity: 0.9;
    pointer-events: none;
    z-index: 5;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.ar-guide .ar-guide-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    animation: ar-pulse 2s ease-in-out infinite;
}

@keyframes ar-pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
    }
}

/* ===== THANH CÔNG CỤ PHÍA TRÊN ===== */
.ar-top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.6) 0%, transparent 100%);
    z-index: 10;
}

.ar-top-bar .ar-title {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 500;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    max-width: 60%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ar-close-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.ar-close-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* ===== THANH CÔNG CỤ PHÍA DƯỚI ===== */
.ar-toolbar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.7) 0%, transparent 100%);
    z-index: 10;
}

/* Hàng slider opacity */
.ar-opacity-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px;
}

.ar-opacity-row label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.75rem;
    white-space: nowrap;
    min-width: 65px;
}

.ar-opacity-slider {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    outline: none;
}

.ar-opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.ar-opacity-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* Hàng nút hành động */
.ar-actions-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.ar-action-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    font-size: 18px;
}

.ar-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.ar-action-btn .ar-btn-label {
    font-size: 0.55rem;
    letter-spacing: 0.3px;
    margin-top: 1px;
}

/* Nút chụp ảnh – nổi bật hơn */
.ar-capture-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 3px solid #fff;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
}

.ar-capture-btn::after {
    content: '';
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transition: all 0.15s ease;
}

.ar-capture-btn:hover::after {
    background: rgba(255, 255, 255, 0.5);
}

.ar-capture-btn:active::after {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.7);
}

/* ===== THÔNG BÁO FLASH ===== */
.ar-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    opacity: 0;
    pointer-events: none;
    z-index: 20;
    animation: ar-flash-anim 0.3s ease;
}

@keyframes ar-flash-anim {
    0% {
        opacity: 0.8;
    }

    100% {
        opacity: 0;
    }
}

/* ===== TOAST THÔNG BÁO ===== */
.ar-toast {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 10px 20px;
    border-radius: 24px;
    font-size: 0.85rem;
    z-index: 15;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.ar-toast.show {
    opacity: 1;
}

/* ===== THÔNG BÁO LỖI CAMERA ===== */
.ar-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #fff;
    z-index: 5;
    display: none;
}

.ar-error .ar-error-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.7;
}

.ar-error .ar-error-text {
    font-size: 0.95rem;
    line-height: 1.5;
    max-width: 280px;
    margin: 0 auto;
}

.ar-error .ar-error-retry {
    margin-top: 16px;
    padding: 10px 24px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.ar-error .ar-error-retry:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ===== NÚT "ƯỚM TRANH" TRÊN TRANG SẢN PHẨM ===== */
.ar-try-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 44px;
    padding: 0 16px;
    border: 1px dashed #796254;
    border-radius: 4px;
    background: transparent;
    color: #796254;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    text-transform: none;
    letter-spacing: 0.3px;
}

.ar-try-btn:hover {
    background: #796254;
    color: #fff;
    border-style: solid;
}

.ar-try-btn i {
    font-size: 1.1rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 767px) {
    .ar-top-bar {
        padding: 8px 12px;
        padding-top: max(8px, env(safe-area-inset-top));
    }

    .ar-toolbar {
        padding: 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .ar-action-btn {
        width: 46px;
        height: 46px;
        font-size: 16px;
    }

    .ar-capture-btn {
        width: 58px;
        height: 58px;
    }

    .ar-capture-btn::after {
        width: 44px;
        height: 44px;
    }

    /* Nút trên trang sản phẩm */
    .ar-try-btn {
        border-radius: 0;
        border: 1px solid #000;
        color: #000;
        font-size: 0.78rem;
        letter-spacing: 1px;
    }

    .ar-try-btn:hover {
        background: #000;
        color: #fff;
    }
}