/* ==========================================================
   PWA INSTALLATION WALKTHROUGHS & BOTTOM SHEET
   Framework-agnostic plain CSS with scoped prefixes:
   - .pg- for Phone Guide (Fixed 480x840 Stage)
   - .pd- for Desktop Guide (Document layout with browser mockups)
   ========================================================== */

/* 1. Modal Overlay & Sheet Container */
.pwa-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background-color: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.pwa-overlay.is-active {
    opacity: 1;
    pointer-events: auto;
}

.pwa-sheet {
    position: relative;
    background-color: #1c1c1e;
    color: #ffffff;
    width: 100%;
    max-width: 400px;
    border-radius: 20px 20px 0 0;
    padding: 16px 20px calc(20px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
}

@media (min-width: 769px) {
    .pwa-overlay {
        align-items: center;
    }
    .pwa-sheet {
        border-radius: 20px;
        transform: translateY(20px) scale(0.96);
    }
    .pwa-overlay.is-active .pwa-sheet {
        transform: translateY(0) scale(1);
    }
}

.pwa-overlay.is-active .pwa-sheet {
    transform: translateY(0);
}

/* Grab Handle & Close Button */
.pwa-sheet-handle {
    width: 36px;
    height: 4px;
    background-color: rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    margin: 0 auto 12px;
}

.pwa-sheet-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.15s;
    z-index: 10;
}

.pwa-sheet-close:hover {
    background-color: rgba(255, 255, 255, 0.25);
}

/* Variant: Desktop Guide Sheet Geometry */
.pwa-sheet.is-dguide {
    max-width: min(620px, 96vw);
    max-height: calc(100vh - 44px);
    overflow-y: auto;
    padding: 24px 28px calc(24px + env(safe-area-inset-bottom, 0px));
}

/* Simple Feedback Box (Already Installed / Toast) */
.pwa-feedback {
    text-align: center;
    padding: 20px 10px;
}
.pwa-feedback h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 8px;
}
.pwa-feedback p {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    margin: 0 0 16px;
}

/* ==========================================================
   PHONE WALKTHROUGH (Fixed 480 x 840 Stage)
   ========================================================== */
.pwa-guide {
    position: relative;
    margin: 0 auto;
    overflow: hidden;
    box-sizing: border-box;
}

.pwa-guide * {
    box-sizing: border-box;
}

.pwa-stage {
    position: absolute;
    top: 0;
    left: 0;
    width: 480px;
    height: 840px;
    transform-origin: top left;
    background: #f2f2f7;
    color: #000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    border-radius: 36px;
    overflow: hidden;
    box-shadow: 0 0 0 10px #2c2c2e;
}

/* Top Chrome Address Bar */
.pg-top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 76px;
    background: #ffffff;
    border-bottom: 1px solid #d1d1d6;
    padding: 24px 16px 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.pg-url-pill {
    flex: 1;
    height: 38px;
    background: #e5e5ea;
    border-radius: 19px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #1c1c1e;
}

.pg-share-top {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #007aff;
}

/* App Header in Guide */
.pg-hero-intro {
    position: absolute;
    top: 90px;
    left: 20px;
    right: 20px;
    text-align: center;
}

.pg-app-icon {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    margin: 0 auto 10px;
    background: #0f172a;
    border: 2px solid #c59b27;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #c59b27;
    font-weight: 800;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.pg-hero-intro h4 {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 4px;
    color: #1c1c1e;
}

.pg-hero-intro p {
    font-size: 13px;
    color: #636366;
    margin: 0;
}

/* Realistic iOS Share Sheet Mockup */
.pg-share-sheet {
    position: absolute;
    bottom: 56px;
    left: 12px;
    right: 12px;
    background: rgba(242, 242, 247, 0.96);
    backdrop-filter: blur(20px);
    border-radius: 20px 20px 0 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.15);
    padding: 12px 14px;
}

.pg-grabber {
    width: 36px;
    height: 5px;
    background: #aeaeb2;
    border-radius: 3px;
    margin: 0 auto 12px;
}

.pg-quick-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.pg-qa-item {
    background: #ffffff;
    border-radius: 12px;
    padding: 8px 4px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.pg-qa-icon {
    font-size: 16px;
    color: #007aff;
    margin-bottom: 4px;
}

.pg-qa-item span {
    display: block;
    font-size: 10px;
    color: #1c1c1e;
    font-weight: 500;
}

.pg-menu-card {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 10px;
}

.pg-menu-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    font-size: 14px;
    border-bottom: 0.5px solid #e5e5ea;
    color: #1c1c1e;
}

.pg-menu-row:last-child {
    border-bottom: none;
}

/* Highlighted Target Row */
.pg-target-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 2px solid #c59b27;
    box-shadow: 0 0 0 3px rgba(197, 155, 39, 0.25);
    background-color: #fffdf5;
}

.pg-target-title {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Safari Bottom Toolbar */
.pg-bottom-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: #f9f9f9;
    border-top: 1px solid #d1d1d6;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 16px;
    color: #007aff;
}

/* SVG Callout Overlay & Arrows */
.pg-callout-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 100;
}

.pg-badge-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #c59b27;
    color: #ffffff;
    font-size: 13px;
    font-weight: 800;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* ==========================================================
   DESKTOP WALKTHROUGH (.pd-)
   ========================================================== */
.pwa-dguide {
    box-sizing: border-box;
}

.pwa-dguide * {
    box-sizing: border-box;
}

.pd-header {
    margin-bottom: 20px;
    text-align: left;
}

.pd-header h3 {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 6px;
    color: #ffffff;
}

.pd-header p {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
}

.pd-steps-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: relative;
}

.pd-step-item {
    position: relative;
    padding-left: 44px;
}

/* Step Connector Line */
.pd-step-item::before {
    content: '';
    position: absolute;
    left: 14px;
    top: 32px;
    bottom: -28px;
    width: 2px;
    background: rgba(255, 255, 255, 0.15);
}

.pd-step-item:last-child::before {
    display: none;
}

.pd-step-badge {
    position: absolute;
    left: 0;
    top: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #c59b27;
    color: #0f172a;
    font-weight: 800;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pd-step-title {
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 8px;
}

.pd-mockup {
    background: #2c2c2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    overflow: hidden;
}

/* Browser Window Step 1 */
.pd-browser-window {
    padding: 10px 14px;
    background: #18181b;
}

.pd-browser-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.pd-dots {
    display: flex;
    gap: 4px;
}
.pd-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
}

.pd-tab {
    background: #27272a;
    color: #ffffff;
    padding: 4px 10px;
    border-radius: 6px 6px 0 0;
    font-size: 11px;
}

.pd-address-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #27272a;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
}

.pd-host-info {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.85);
}

.pd-install-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(197, 155, 39, 0.15);
    border: 1.5px solid #c59b27;
    color: #c59b27;
    font-size: 11px;
    font-weight: 600;
    animation: pd-pulse 2s infinite ease-in-out;
}

@keyframes pd-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Dialog Step 2 */
.pd-dialog-mockup {
    background: #27272a;
    padding: 14px;
    border-radius: 10px;
    margin: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pd-dialog-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pd-dialog-app-icon {
    width: 32px;
    height: 32px;
    background: #0f172a;
    border: 1.5px solid #c59b27;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #c59b27;
    font-weight: 700;
    font-size: 14px;
}

.pd-dialog-text b {
    display: block;
    font-size: 13px;
    color: #ffffff;
}

.pd-dialog-text small {
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
}

.pd-dialog-btns {
    display: flex;
    gap: 6px;
}

.pd-btn-cancel {
    padding: 4px 10px;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    border: none;
    font-size: 12px;
}

.pd-btn-install {
    padding: 4px 12px;
    background: #c59b27;
    color: #0f172a;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
}

/* Launcher Step 3 */
.pd-launcher-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 12px;
    background: #18181b;
}

.pd-app-tile {
    text-align: center;
    padding: 8px 4px;
    border-radius: 8px;
}

.pd-tile-box {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    margin: 0 auto 4px;
}

.pd-tile-label {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
}

.pd-app-tile.is-ringed {
    border: 2px solid #c59b27;
    background: rgba(197, 155, 39, 0.12);
}

.pd-app-tile.is-ringed .pd-tile-box {
    background: #0f172a;
    border: 1.5px solid #c59b27;
    color: #c59b27;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pd-app-tile.is-ringed .pd-tile-label {
    color: #c59b27;
    font-weight: 600;
}
