/* ====== Local variables for Light (ไม่ทับ global) ====== */
.totp-modal {
    --tm-accent: #7c3aed;
    --tm-accent2: #22d3ee;
    --tm-text: #0f172a;              /* slate-900 */
    --tm-muted: #475569;             /* slate-600 */
    --tm-card: #ffffff;
    --tm-card-border: rgba(15, 23, 42, .10);
    --tm-shadow-xl: 0 18px 60px rgba(2, 6, 23, .12);
    --tm-ghost: #f8fafc;             /* bg for chips/ghost */
    --tm-ghost-h: #eef2ff;
}

/* ---------- dialog ---------- */
.totp-modal .modal-dialog {
    max-width: 560px;
}

@media (max-width: 576px) {
    .totp-modal .modal-dialog {
        max-width: calc(100% - 24px);
        margin: 12px auto;
    }
}

/* ---------- content/card ---------- */
.totp-modal .totp-card {
    border: 1px solid var(--tm-card-border);
    border-radius: 18px;
    overflow: hidden;
    background: var(--tm-card);
    color: var(--tm-text);
    box-shadow: var(--tm-shadow-xl);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* ---------- header ---------- */
.totp-modal .totp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--tm-card-border);
    background: linear-gradient(135deg,
        color-mix(in oklab, var(--tm-accent) 20%, white 80%),
        color-mix(in oklab, var(--tm-accent2) 18%, white 82%));
}

.totp-modal .totp-badge {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--tm-accent), var(--tm-accent2));
    color: #ffffff;
    font-size: 16px;
    font-weight: 800;
    box-shadow: 0 10px 24px rgba(124, 58, 237, .25);
}

.totp-modal .totp-heading h5 {
    margin: 0;
    font-weight: 800;
    color: #0b1020;
    font-size: 1.05rem;
}

.totp-modal .totp-sub {
    font-size: .85rem;
    color: #334155;
}

/* ---------- body ---------- */
.totp-modal .totp-body {
    padding: 16px;
}

.totp-modal .totp-text-muted {
    color: var(--tm-muted);
}

/* ---------- soft alert ---------- */
.totp-modal .totp-alert {
    background: #fff7ed;                    /* warm soft */
    border: 1px solid #fed7aa;
    color: #9a3412;
    border-radius: 12px;
    padding: 12px 14px;
}

/* ---------- QR & Secret ---------- */
.totp-modal .totp-qr-secret {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 576px) {
    .totp-modal .totp-qr-secret {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
}

.totp-modal .totp-qrbox {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 6px 18px rgba(2, 6, 23, .10);
    display: inline-block;
}

.totp-modal .totp-secret {
    flex: 1;
    min-width: 0;
}

.totp-modal .totp-secret-chip {
    background: var(--tm-ghost);
    border: 1px dashed var(--tm-card-border);
    padding: 8px 10px;
    border-radius: 10px;
    color: var(--tm-text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    word-break: break-all;
}

/* ---------- buttons (ghost/primary fallback) ---------- */
.totp-modal .totp-btn-ghost {
    background: var(--tm-ghost);
    border: 1px solid var(--tm-card-border);
    color: var(--tm-text);
}

.totp-modal .totp-btn-ghost:hover {
    background: var(--tm-ghost-h);
    color: #0b1020;
}

/* ถ้าโครงการไม่มี .btn-accent จาก login.css ให้ใช้สไตล์ fallback ด้านล่าง */
.totp-modal .totp-fallback-primary:not(.btn-accent) {
    position: relative;
    background: linear-gradient(135deg, var(--tm-accent), var(--tm-accent2));
    border: 0;
    color: #ffffff;
    font-weight: 800;
    letter-spacing: .3px;
    border-radius: 12px;
    padding: 12px 18px;
    box-shadow: 0 12px 30px rgba(124, 58, 237, .25);
}

.totp-modal .totp-fallback-primary:not(.btn-accent) .btn-glow {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .8), transparent);
    width: 40%;
    height: 160%;
    transform: rotate(20deg) translateX(-180%);
    animation: tmGlow 3s ease-in-out infinite;
}

@keyframes tmGlow {
    0%,
    60% {
        transform: rotate(20deg) translateX(-180%);
        opacity: 0;
    }
    80% {
        opacity: .65;
    }
    100% {
        transform: rotate(20deg) translateX(260%);
        opacity: 0;
    }
}

/* ---------- store badges ---------- */
.totp-modal .totp-store a {
    text-decoration: none;
}

.totp-modal .totp-store .btn {
    height: 40px;
    display: flex;
    align-items: center;
}

/* ---------- divider ---------- */
.totp-modal .totp-hr {
    border: 0;
    border-top: 1px solid var(--tm-card-border);
}

/* ---------- OTP grid ---------- */
.totp-modal .totp-otp-grid {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 8px auto 16px;
    max-width: 380px;
    flex-wrap: nowrap;
}

.totp-modal .otp-input {
    width: 48px !important;
    height: 56px;
    flex: 0 0 48px !important;
    display: inline-block !important;
    background: #ffffff;
    border: 1px solid var(--tm-card-border);
    border-radius: 12px;
    color: var(--tm-text);
    text-align: center;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0;
    outline: none;
    transition: box-shadow .15s ease, border-color .15s ease;
}

.totp-modal .otp-input:focus {
    border-color: color-mix(in oklab, var(--tm-accent) 55%, white 45%);
    box-shadow: 0 0 0 4px color-mix(in oklab, var(--tm-accent) 18%, transparent);
}

.totp-modal .otp-input.is-invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, .15);
}

@media (max-width: 400px) {
    .totp-modal .otp-input {
        width: 42px !important;
        height: 50px;
        flex: 0 0 42px !important;
        font-size: 1.1rem;
    }
    
    .totp-modal .totp-otp-grid {
        gap: 8px;
        max-width: 320px;
    }
}

/* ---------- help text / close ---------- */
.totp-modal .totp-help {
    font-size: .75rem;
    color: var(--tm-muted);
}

.totp-modal .btn-close-white {
    filter: brightness(0) saturate(100%);
    opacity: .7;
}

/* ปรับเป็นปุ่มปิดสีเข้มในธีมสว่าง */
.totp-modal .btn-close-white:hover {
    opacity: 1;
}