/* ============================================================
   popup.css — Derbaag Explorer 360 Guide Popup (Updated)
   ============================================================ */

:root {
    --popup-bg: #0f1623;
    --popup-bg-inner: #1a2235;
    --popup-border: #253047;
    --popup-accent: #00d4aa;
    --popup-accent-dim: rgba(0, 212, 170, 0.15);
    --popup-accent-glow: rgba(0, 212, 170, 0.3);
    --popup-text: #ffffff;
    --popup-text-sec: #c5d1e0;
    --popup-text-muted: #94a3bb;
    --popup-tip-bg: #162030;
    --popup-step-hover: #1e2d45;
}

/* === Overlay === */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 15, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    animation: popupFadeIn 0.5s ease forwards;
}

.overlay.closing {
    animation: popupFadeOut 0.35s ease forwards;
}

.overlay.closing .popup {
    animation: popupSlideOut 0.35s cubic-bezier(0.5, 0, 0.75, 0) forwards;
}

@keyframes popupFadeIn { to { opacity: 1; } }
@keyframes popupFadeOut { to { opacity: 0; } }
@keyframes popupSlideOut {
    to { opacity: 0; transform: translateY(20px) scale(0.97); }
}

/* === Popup Card === */
.popup {
    position: relative;
    width: 620px;
    max-width: 96vw;
    max-height: 94vh;
    background: linear-gradient(170deg, #141c2e 0%, var(--popup-bg) 100%);
    border: 1px solid var(--popup-border);
    border-radius: 20px;
    overflow: hidden;
    box-shadow:
        0 25px 80px rgba(0, 0, 0, 0.6),
        0 0 60px rgba(0, 212, 170, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    opacity: 0;
    transform: translateY(30px) scale(0.96);
    animation: popupSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.15s forwards;
    font-family: 'Sarabun', 'Kanit', sans-serif;
    display: flex;
    flex-direction: column;
}

@keyframes popupSlideIn {
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* === Header === */
.popup-header {
    position: relative;
    padding: 30px 36px 22px;
    text-align: center;
    background: linear-gradient(180deg, rgba(0, 212, 170, 0.06) 0%, transparent 100%);
    border-bottom: 1px solid var(--popup-border);
    flex-shrink: 0;
}

.popup-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--popup-accent), transparent);
    opacity: 1;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--popup-accent-dim);
    border: 1px solid rgba(0, 212, 170, 0.2);
    color: var(--popup-accent);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 6px 16px;
    border-radius: 20px;
    margin-bottom: 12px;
}

.badge i {
    font-size: 11px;
    animation: rotate360 4s linear infinite;
}

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

.popup-title {
    font-family: 'Kanit', sans-serif;
    font-size: 26px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.4;
    margin: 0;
}

.popup-subtitle {
    font-size: 15px;
    color: var(--popup-text-sec);
    margin-top: 5px;
    margin-bottom: 0;
}

.popup-headerPopup {
    font-size: 22px;
    color: var(--popup-text-sec);
    margin-top: 5px;
    margin-bottom: 0;
}

/* === ปุ่มปิด === */
.btn-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 40px;
    height: 40px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-size: 22px;
    font-weight: 300;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    padding: 0;
    line-height: 1;
    z-index: 10;
}

.btn-close:hover {
    background: rgba(255, 70, 70, 0.25);
    border-color: rgba(255, 70, 70, 0.5);
    color: #ff5555;
    transform: rotate(90deg);
    box-shadow: 0 0 15px rgba(255, 70, 70, 0.2);
}

.btn-close:active {
    transform: rotate(90deg) scale(0.92);
}

/* === Body (scrollable) === */
.popup-body {
    padding: 20px 28px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.popup-body::-webkit-scrollbar { width: 4px; }
.popup-body::-webkit-scrollbar-track { background: transparent; }
.popup-body::-webkit-scrollbar-thumb { background: var(--popup-border); border-radius: 4px; }

/* === Steps Grid === */
.steps-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.step-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    background: var(--popup-bg-inner);
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: default;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.step-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.04) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.step-card:hover {
    border-color: var(--popup-border);
    background: var(--popup-step-hover);
    transform: translateY(-1px);
}

.step-card:hover::before { opacity: 1; }

/* === Step Icon Box === */
.step-icon-box {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(145deg, #1e2a40 0%, #151d2e 100%);
    border: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    transition: all 0.25s ease;
}

.step-card:hover .step-icon-box {
    border-color: rgba(0, 212, 170, 0.2);
    box-shadow:
        0 4px 14px rgba(0, 0, 0, 0.4),
        0 0 12px rgba(0, 212, 170, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.step-icon-box svg {
    width: 32px;
    height: 32px;
    display: block;
}

.step-content {
    position: relative;
    z-index: 1;
    min-width: 0;
    padding-top: 3px;
}

.step-label {
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.4;
}

.step-desc {
    font-size: 12px;
    color: var(--popup-text-muted);
    margin-top: 3px;
    line-height: 1.4;
}

/* === Tips === */
.tips-section {
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--popup-tip-bg);
    border: 1px solid rgba(0, 212, 170, 0.1);
    border-radius: 10px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.tips-icon {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: rgba(255, 193, 7, 0.12);
    color: #ffc107;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}

.tips-text {
    font-size: 13px;
    color: var(--popup-text-sec);
    line-height: 1.6;
}

.tips-text strong {
    color: #ffc107;
    font-weight: 600;
}

/* === Preview Section === */
.preview-section {
    margin-top: 18px;
    flex-shrink: 0;
}

.preview-section__label {
    font-size: 12px;
    font-weight: 600;
    color: var(--popup-text-muted);
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.preview-section__label i {
    font-size: 13px;
    color: var(--popup-accent);
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.preview-card {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--popup-border);
    background: var(--popup-bg-inner);
    cursor: pointer;
    transition: all 0.3s ease;
    aspect-ratio: 16 / 10;
}

.preview-card:hover {
    border-color: var(--popup-accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 212, 170, 0.15);
}

.preview-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.preview-card:hover .preview-card__img {
    transform: scale(1.08);
}

.preview-card__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, rgba(10, 14, 23, 0.85) 0%, rgba(10, 14, 23, 0.1) 60%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 8px;
}

.preview-card__name {
    font-size: 11px;
    font-weight: 500;
    color: #ffffff;
    line-height: 1.3;
}

.preview-card__icon {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 212, 170, 0.85);
    color: #0a0e17;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.6);
    transition: all 0.25s ease;
}

.preview-card:hover .preview-card__icon {
    opacity: 1;
    transform: scale(1);
}

/* === Footer === */
.popup-footer {
    padding: 18px 28px 22px;
    border-top: 1px solid var(--popup-border);
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.15) 0%, transparent 100%);
    flex-shrink: 0;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.custom-checkbox {
    position: relative;
    width: 20px;
    height: 20px;
    cursor: pointer;
    flex-shrink: 0;
}

.custom-checkbox input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 2;
    margin: 0;
}

.checkmark {
    position: absolute;
    inset: 0;
    border: 2px solid var(--popup-text-muted);
    border-radius: 5px;
    background: transparent;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkmark::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 11px;
    color: var(--popup-bg);
    opacity: 0;
    transform: scale(0);
    transition: all 0.2s ease;
}

.custom-checkbox input:checked ~ .checkmark {
    background: var(--popup-accent);
    border-color: var(--popup-accent);
}

.custom-checkbox input:checked ~ .checkmark::after {
    opacity: 1;
    transform: scale(1);
}

.custom-checkbox input:focus-visible ~ .checkmark {
    box-shadow: 0 0 0 2px var(--popup-accent-glow);
}

.checkbox-label {
    font-size: 14px;
    color: var(--popup-text-sec);
    cursor: pointer;
    user-select: none;
}

/* === ปุ่มเริ่มการแสดง === */
.btn-start {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #00d4aa 0%, #00b894 50%, #00a381 100%);
    color: #0a0e17;
    font-family: 'Kanit', sans-serif;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.3px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 212, 170, 0.25);
}

.btn-start::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 212, 170, 0.35);
}

.btn-start:hover::before { left: 100%; }

.btn-start:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(0, 212, 170, 0.2);
}

.btn-start .btn-text {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-start .btn-text i {
    font-size: 16px;
    transition: transform 0.3s ease;
}

.btn-start:hover .btn-text i {
    transform: translateX(4px);
}

/* === Toast === */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: #111827;
    border: 1px solid var(--popup-border);
    color: #ffffff;
    padding: 14px 28px;
    border-radius: 12px;
    font-size: 15px;
    font-family: 'Sarabun', sans-serif;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 10000;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: none;
    white-space: nowrap;
}

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

.toast i {
    color: var(--popup-accent);
}

/* === Responsive === */
@media (max-width: 600px) {
    .steps-grid { grid-template-columns: 1fr; }
    .preview-grid { grid-template-columns: repeat(2, 1fr); }
    .popup-header { padding: 24px 20px 18px; }
    .popup-body { padding: 16px 18px; }
    .popup-footer { padding: 16px 18px 18px; }
    .popup-title { font-size: 22px; }
    .popup-subtitle { font-size: 14px; }
    .popup-headerPopup{font-size: 22px;}
    .btn-close { width: 36px; height: 36px; font-size: 20px; top: 12px; right: 12px; }
    .step-icon-box { width: 46px; height: 46px; border-radius: 12px; }
    .step-icon-box svg { width: 28px; height: 28px; }
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
    .overlay, .popup, .step-card, .step-icon-box, .preview-card,
    .preview-card__img, .preview-card__icon, .btn-close, .btn-start,
    .btn-start .btn-text i, .checkmark, .checkmark::after, .toast {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}