/* ============================================================
   CREATE YOUR OWN WRAP — Builder Styles
   ============================================================ */

/* ---- TEMPLATE PICKER ---- */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
    width: 100%;
    margin-bottom: 2rem;
}

.template-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 1.4rem 0.75rem;
    background: var(--card-bg);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    color: #fff;
    font-family: inherit;
}
.template-card:hover {
    transform: translateY(-2px);
    border-color: var(--pink);
    box-shadow: 0 4px 20px rgba(255,0,110,0.2);
}

.template-icon { font-size: 2rem; line-height: 1; }
.template-name {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
}
.template-desc {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.45);
}

/* ---- BUILDER LAYOUT ---- */
.builder-layout {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.editor-panel {
    width: 420px;
    min-width: 360px;
    background: #0d0d12;
    border-right: 1px solid rgba(255,255,255,0.08);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
}

.preview-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111118;
    padding: 2rem;
    min-height: 100vh;
}

/* ---- EDITOR HEADER ---- */
.editor-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.editor-back {
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    min-height: 36px;
}
.editor-back:hover { color: #fff; }

.wrap-title-input {
    flex: 1;
    background: none;
    border: none;
    color: #fff;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    outline: none;
    padding: 0.25rem 0;
}
.wrap-title-input::placeholder { color: rgba(255,255,255,0.25); }

/* ---- SLIDE LIST ---- */
.slide-list {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.slide-list-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}
.slide-list-item:hover { background: rgba(255,255,255,0.04); }
.slide-list-item.active {
    background: rgba(255,0,110,0.12);
    border: 1px solid rgba(255,0,110,0.3);
}

.slide-list-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    flex-shrink: 0;
    font-family: 'Space Grotesk', sans-serif;
}

.slide-list-title {
    flex: 1;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.slide-list-delete {
    background: none;
    border: none;
    color: rgba(255,255,255,0.2);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}
.slide-list-item:hover .slide-list-delete { opacity: 1; }
.slide-list-delete:hover { color: #e63946; }

.slide-list-actions {
    padding: 0.5rem 0.75rem 0.75rem;
}

.btn-small {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.45rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    min-height: 34px;
}
.btn-add {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.6);
    width: 100%;
    transition: background 0.15s, color 0.15s;
}
.btn-add:hover { background: rgba(255,255,255,0.1); color: #fff; }
.btn-add:disabled { opacity: 0.4; cursor: default; }

/* ---- SLIDE EDITOR FIELDS ---- */
.slide-editor {
    flex: 1;
    padding: 1rem 1.25rem;
    overflow-y: auto;
}

.editor-section {
    margin-bottom: 1rem;
}

.editor-row {
    display: flex;
    gap: 0.75rem;
}
.editor-half { flex: 1; }

.editor-label {
    display: block;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255,255,255,0.45);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.35rem;
}

.editor-sublabel {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.3);
}

.editor-input {
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
    font-family: 'DM Sans', sans-serif;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    color: #fff;
    outline: none;
    transition: border-color 0.2s;
    min-height: 38px;
}
.editor-input:focus { border-color: var(--pink); }
.editor-input::placeholder { color: rgba(255,255,255,0.2); }

.editor-textarea {
    resize: vertical;
    min-height: 60px;
    max-height: 120px;
}

.emoji-input {
    max-width: 70px;
    text-align: center;
    font-size: 1.5rem;
    padding: 0.3rem;
}

/* ---- GRADIENT PRESETS ---- */
.gradient-presets {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.gradient-swatch {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s;
}
.gradient-swatch:hover { transform: scale(1.1); }
.gradient-swatch.active { border-color: #fff; }

.custom-gradient {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-pair {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.color-input {
    width: 36px;
    height: 30px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: none;
    padding: 0;
}
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border-radius: 6px; border: 1px solid rgba(255,255,255,0.15); }

.color-arrow {
    color: rgba(255,255,255,0.25);
    font-size: 0.9rem;
}

/* ---- EDITOR ACTIONS ---- */
.editor-actions {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.editor-actions-row {
    display: flex;
    gap: 0.5rem;
}

/* ---- PHONE FRAME PREVIEW ---- */
.phone-frame {
    width: 320px;
    height: 693px;
    background: #000;
    border-radius: 40px;
    border: 3px solid #333;
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.phone-notch {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 28px;
    background: #000;
    border-radius: 0 0 16px 16px;
    z-index: 10;
}

.phone-screen {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.phone-screen .slide-inner {
    min-height: 100% !important;
    width: 100% !important;
    padding: 2.5rem 1.25rem 1.5rem;
    background-size: 200% 200%;
    animation: gradientShift 8s ease infinite;
}

/* Disable heavy pseudo-elements in preview for perf */
.phone-screen .slide-inner::after { display: none; }

/* ---- SHARE MODAL ---- */
.share-link-box {
    text-align: center;
}

#share-link-input {
    text-align: center;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
}

/* ---- AD OVERLAY ---- */
.ad-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.ad-overlay.active { display: flex; }

.ad-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    max-width: 400px;
    width: 100%;
}

.ad-label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 2px;
    color: rgba(255,255,255,0.3);
    text-transform: uppercase;
}

.ad-slot {
    width: 100%;
    aspect-ratio: 16/9;
    background: #1a1a2e;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.ad-placeholder {
    color: rgba(255,255,255,0.15);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    letter-spacing: 1px;
}

.ad-timer {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.5);
}

.ad-progress-bar {
    width: 100%;
    height: 3px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
}

.ad-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--pink), var(--purple));
    border-radius: 3px;
    transition: width 1s linear;
}

/* Mid-show ad (smaller, inline) */
.midshow-ad-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.95);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.midshow-ad-overlay.active { display: flex; }

.midshow-ad-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    max-width: 340px;
    width: 100%;
}

.midshow-ad-slot {
    width: 100%;
    aspect-ratio: 16/9;
    background: #1a1a2e;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* ---- MOBILE RESPONSIVE ---- */
@media (max-width: 768px) {
    .builder-layout {
        flex-direction: column;
    }

    .editor-panel {
        width: 100%;
        min-width: 0;
        height: auto;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.08);
    }

    .preview-panel {
        padding: 1.5rem 1rem;
        min-height: auto;
    }

    .phone-frame {
        width: 280px;
        height: 607px;
        border-radius: 32px;
    }

    .template-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .editor-panel {
        min-width: 0;
    }

    .phone-frame {
        width: 260px;
        height: 563px;
        border-radius: 28px;
    }

    .phone-notch {
        width: 100px;
        height: 24px;
    }

    .template-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .template-card {
        padding: 1rem 0.5rem;
    }

    .editor-row {
        flex-direction: column;
        gap: 0.5rem;
    }
}
