/* Marketing homepage template picker (mirrors tenant Design Your Webpage modal) */

.webpage-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1300;
    background: rgba(15, 23, 42, 0.82);
    align-items: center;
    justify-content: center;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.dark .webpage-modal {
    background: rgba(0, 0, 0, 0.72);
}

.webpage-modal.is-open {
    display: flex;
}

.webpage-modal-content {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.35);
    padding: 20px;
    max-height: 90vh;
    overflow: hidden;
    width: 100%;
    max-width: 560px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    color: #0f172a;
}

.dark .webpage-modal-content {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    color: #f1f5f9;
}

.webpage-modal-lg {
    max-width: 960px;
}

.webpage-modal-xl {
    max-width: 1100px;
}

.template-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.template-modal-header h2 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.homepage-template-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
    padding: 0.5rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.homepage-template-btn--secondary {
    background: transparent;
    border-color: #cbd5e1;
    color: #334155;
}

.dark .homepage-template-btn--secondary {
    border-color: #475569;
    color: #e2e8f0;
}

.homepage-template-btn--secondary:hover {
    background: rgba(99, 102, 241, 0.08);
    border-color: #6366f1;
    color: #4f46e5;
}

.homepage-template-btn--primary {
    background: linear-gradient(to right, #7c3aed, #4f46e5);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 10px 15px -3px rgba(124, 58, 237, 0.3);
}

.homepage-template-btn--primary:hover {
    filter: brightness(1.05);
}

.template-modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.template-preview-body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}

.template-preview-body .template-preview-frame {
    flex: 1 1 auto;
    width: 100%;
    height: min(70vh, 720px);
    min-height: 280px;
    max-height: min(70vh, 720px);
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
}

.template-preview-frame {
    width: 100%;
    height: min(70vh, 720px);
    min-height: 400px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}

.template-card {
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s;
    background: #ffffff;
    text-align: left;
    padding: 0;
    position: relative;
    width: 100%;
    font: inherit;
    color: inherit;
}

.dark .template-card {
    background: #0f172a;
    border-color: #334155;
}

.template-card:hover,
.template-card:focus {
    border-color: #6366f1;
    transform: translateY(-2px);
    outline: none;
}

.template-card-thumb {
    position: relative;
    display: block;
}

.template-card img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    display: block;
}

.template-card-swatches {
    display: none;
    position: absolute;
    inset: 0;
    grid-template-columns: repeat(4, 1fr);
}

.template-card img[data-failed="1"] + .template-card-swatches {
    display: grid;
}

.template-card-swatch {
    min-height: 110px;
}

.template-card-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.45);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.template-card:hover .template-card-overlay,
.template-card:focus .template-card-overlay {
    opacity: 1;
}

.template-preview-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
    flex-shrink: 0;
}

.template-preview-footer .homepage-template-btn {
    min-height: 44px;
}

#homepageTemplatePreviewModal {
    z-index: 1300;
}

.template-card-body {
    padding: 10px 12px;
}

.template-card-body strong {
    display: block;
    font-size: 14px;
}

.template-card-body span {
    font-size: 12px;
    color: #64748b;
}

.dark .template-card-body span {
    color: #94a3b8;
}

body.webpage-modal-open {
    overflow: hidden;
}

body.webpage-modal-open .homepage-bottom-nav {
    display: none !important;
}

@media (max-width: 1023px) {
    .webpage-modal {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }

    .webpage-modal-content.webpage-modal-sheet {
        max-width: none;
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
        border: 0;
        padding: max(12px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
        box-shadow: none;
    }

    .template-preview-body .template-preview-frame {
        height: auto;
        min-height: 0;
        max-height: none;
        border-radius: 8px;
        flex: 1;
    }

    .template-preview-footer {
        margin-top: 12px;
        padding-top: 4px;
        gap: 8px;
    }

    .template-preview-footer .homepage-template-btn {
        flex: 1;
        min-width: 0;
    }

    .template-card-overlay {
        opacity: 0.85;
        background: rgba(15, 23, 42, 0.35);
    }

    .template-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .template-grid {
        grid-template-columns: 1fr;
    }
}
