/* ============================================================
   Kasaya.ph — Template Editor
   Three-panel desktop layout
   ============================================================ */

/* ── Layout ─────────────────────────────────────────────────── */
.te-layout {
    display: grid;
    grid-template-columns: 200px 360px 1fr;
    height: 100svh;
    overflow: hidden;
    background: #F5F0E8;
    font-family: 'Jost', sans-serif;
}

/* ── LEFT NAV ───────────────────────────────────────────────── */
.te-nav {
    display: flex;
    flex-direction: column;
    background: #1A0F0C;
    padding: 20px 0 16px;
    overflow-y: auto;
    border-right: 1px solid #2E1A1A;
}

.te-nav-brand {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-style: italic;
    font-size: 18px;
    color: #C9A96E;
    padding: 0 16px 2px;
}

.te-nav-sub {
    font-size: 9px;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: rgba(255,255,255,.3);
    padding: 0 16px 16px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    margin-bottom: 12px;
}

.te-nav-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    padding-bottom: 16px;
}

.te-nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: rgba(255,255,255,.55);
    font-family: 'Jost', sans-serif;
    font-size: 12px;
    cursor: pointer;
    text-align: left;
    transition: background .15s, color .15s;
}
.te-nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.te-nav-item--active { background: rgba(196,139,159,.15); color: #C48B9F; }
.te-nav-item--new { color: rgba(201,169,110,.6); border: 1px dashed rgba(201,169,110,.2); }
.te-nav-item--new:hover { color: #C9A96E; border-color: rgba(201,169,110,.4); }

.te-nav-item-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.te-nav-sections {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0 8px;
    flex: 1;
}

.te-nav-section {
    padding: 8px 10px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: rgba(255,255,255,.45);
    font-family: 'Jost', sans-serif;
    font-size: 11px;
    letter-spacing: .06em;
    cursor: pointer;
    text-align: left;
    transition: background .15s, color .15s;
}
.te-nav-section:hover { background: rgba(255,255,255,.06); color: #fff; }
.te-nav-section--active { background: rgba(201,169,110,.12); color: #C9A96E; }

.te-nav-actions {
    padding: 16px 8px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px solid rgba(255,255,255,.06);
    margin-top: 12px;
}

.te-btn-save {
    padding: 9px 12px;
    background: #C48B9F;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-family: 'Jost', sans-serif;
    font-size: 11px;
    letter-spacing: .1em;
    cursor: pointer;
    transition: background .2s;
}
.te-btn-save:hover { background: #A06070; }

.te-btn-export {
    padding: 8px 12px;
    background: transparent;
    color: rgba(255,255,255,.4);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 4px;
    font-family: 'Jost', sans-serif;
    font-size: 11px;
    cursor: pointer;
    transition: all .2s;
}
.te-btn-export:hover { color: rgba(255,255,255,.8); border-color: rgba(255,255,255,.25); }

/* ── CENTER EDITOR ──────────────────────────────────────────── */
.te-editor {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid #E8DDD4;
    background: #FDFAF7;
}

.te-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #E8DDD4;
    flex-shrink: 0;
}

.te-editor-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-style: italic;
    font-size: 22px;
    font-weight: 300;
    color: #1A0F0C;
    margin: 0;
}

.te-saved-badge {
    font-size: 10px;
    letter-spacing: .12em;
    color: #8FAF8A;
    background: rgba(143,175,138,.1);
    padding: 3px 10px;
    border-radius: 2px;
    border: 1px solid rgba(143,175,138,.3);
}

/* ── EDITOR PANEL ───────────────────────────────────────────── */

.ep-panel {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ep-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ep-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.ep-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: #6B5B54;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ep-input {
    width: 100%;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid #D4C4B0;
    color: #3A3230;
    font-family: 'Jost', sans-serif;
    font-size: 13px;
    border-radius: 3px;
    outline: none;
    transition: border-color .2s;
    -webkit-appearance: none;
}
.ep-input:focus { border-color: #C48B9F; }
.ep-input-mono { font-family: 'Courier New', monospace; font-size: 12px; }

.ep-select { cursor: pointer; }
.ep-textarea { resize: vertical; min-height: 60px; line-height: 1.5; }

.ep-hint {
    font-size: 10px;
    color: #9E8C87;
    line-height: 1.5;
}

.ep-section-hint {
    font-size: 10px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: #C48B9F;
    margin: 4px 0 0;
    padding-bottom: 6px;
    border-bottom: 1px solid #E8DDD4;
}

.ep-divider { height: 1px; background: #E8DDD4; margin: 4px 0; }

.ep-color-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ep-color-swatch {
    width: 36px;
    height: 36px;
    border-radius: 3px;
    border: 1px solid #D4C4B0;
    cursor: pointer;
    padding: 0;
    background: none;
    flex-shrink: 0;
}

.ep-color-preview {
    height: 8px;
    border-radius: 2px;
    margin-top: 2px;
}

.ep-color-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 10px;
    background: #FAF6F1;
    border-radius: 4px;
    border: 1px solid #E8DDD4;
}

.ep-toggle-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.ep-toggle {
    padding: 6px 12px;
    border: 1px solid #D4C4B0;
    background: transparent;
    color: #9E8C87;
    border-radius: 3px;
    font-family: 'Jost', sans-serif;
    font-size: 11px;
    cursor: pointer;
    transition: all .15s;
}
.ep-toggle:hover { border-color: #C48B9F; color: #C48B9F; }
.ep-toggle--active { background: #C48B9F; border-color: #C48B9F; color: #fff; }

.ep-slider {
    width: 100%;
    accent-color: #C48B9F;
}

.ep-gradient-preview {
    height: 60px;
    border-radius: 4px;
    border: 1px solid #D4C4B0;
    margin-top: 4px;
}

.ep-preview-img img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #D4C4B0;
}

.ep-font-preview {
    padding: 16px;
    background: #FAF6F1;
    border: 1px solid #E8DDD4;
    border-radius: 4px;
}


/* ── Divider live preview inside editor panel ───────────────── */
.ep-divider-preview {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-radius: 3px;
}

    .ep-divider-preview .inv-rule-line {
        flex: 1;
        height: 1px;
        background: currentColor;
        opacity: .35;
    }

    .ep-divider-preview .inv-rule-dot {
        padding: 0 8px;
        font-size: 10px;
        opacity: .7;
    }


/* ── Date style grid ─────────────────────────────────────────── */
.ep-date-style-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.ep-ds-btn {
    padding: 7px 4px;
    background: transparent;
    border: 1px solid #D4C4B0;
    border-radius: 3px;
    font-family: 'Jost', sans-serif;
    font-size: 11px;
    color: #6B5B54;
    cursor: pointer;
    text-align: center;
    transition: all .15s;
}

    .ep-ds-btn:hover {
        border-color: #C48B9F;
        color: #C48B9F;
    }

.ep-ds-btn--active {
    background: #1A0F0C;
    color: #FAF6F1;
    border-color: #1A0F0C;
}


/* ── RIGHT PREVIEW ──────────────────────────────────────────── */
.te-preview {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #F0E8DC;
}

.te-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #FAF6F1;
    border-bottom: 1px solid #E8DDD4;
    flex-shrink: 0;
}

.te-preview-label {
    font-size: 10px;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: #9E8C87;
}

.te-preview-tabs {
    display: flex;
    gap: 4px;
}

.te-tab {
    padding: 5px 12px;
    border: 1px solid #D4C4B0;
    background: transparent;
    color: #9E8C87;
    border-radius: 3px;
    font-family: 'Jost', sans-serif;
    font-size: 10px;
    letter-spacing: .1em;
    cursor: pointer;
    transition: all .15s;
}
.te-tab:hover { color: #3A3230; border-color: #3A3230; }
.te-tab--active { background: #3A3230; color: #FAF6F1; border-color: #3A3230; }

.te-preview-frame {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px 12px;
}

.te-preview-card {
    position: relative;
    width: 260px;
    aspect-ratio: 5 / 7;
    border-radius: 3px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,.15);
    flex-shrink: 0;
}

.te-preview-card > div {
    position: absolute;
    inset: 0;
    min-height: unset !important;
    max-width: unset !important;
}

.te-preview-card .inv-hero {
    position: absolute !important;
    inset: 0 !important;
    aspect-ratio: unset !important;
    min-height: unset !important;
}

.te-preview-scroll {
    width: 100%;
    max-width: 320px;
    flex-shrink: 0;
    border-radius: 3px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,.12);
}

    .te-preview-scroll > div {
        margin: 0 !important; /* ← remove inv-page margin:0 auto */
        max-width: unset !important;
    }

/* ── JSON output ────────────────────────────────────────────── */
.te-json-output {
    background: #1A0F0C;
    border-top: 1px solid #2E1A1A;
    flex-shrink: 0;
    max-height: 240px;
    overflow-y: auto;
}

.te-json-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    font-size: 10px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: rgba(255,255,255,.4);
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.te-json-header button {
    background: transparent;
    border: none;
    color: rgba(255,255,255,.3);
    cursor: pointer;
    font-size: 12px;
    padding: 0;
}

.te-json-pre {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: rgba(255,255,255,.65);
    padding: 12px 14px;
    margin: 0;
    overflow-x: auto;
    line-height: 1.6;
}

/* ── Typography panel local preview ────────────────────────── */
.ep-font-preview {
    padding: 20px;
    background: #FAF6F1;
    border: 1px solid #E8DDD4;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ep-preview-names {
    font-size: 32px;
    color: #1A0F0C;
    line-height: 1.2;
    margin: 0;
}

.ep-preview-label {
    font-size: 10px;
    color: #C48B9F;
    margin: 0;
    letter-spacing: .2em;
}

.ep-preview-title {
    font-size: 22px;
    color: #3A3230;
    margin: 4px 0 0;
    line-height: 1.2;
}

.ep-preview-body {
    font-size: 13px;
    color: #6B5B54;
    line-height: 1.7;
    margin: 0;
}

/* ── Full invitation preview — ScaleFactor 1.0 ─────────────── */
.te-inv-frame {
    width: 480px;
    flex-shrink: 0;
    border-radius: 3px;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,.12);
    max-height: unset;
    scrollbar-width: thin;
    scrollbar-color: #C48B9F transparent;
}

    .te-inv-frame::-webkit-scrollbar {
        width: 4px;
    }

    .te-inv-frame::-webkit-scrollbar-thumb {
        background: #C48B9F;
        border-radius: 2px;
    }

/* ── Background panel — image uploader ─────────────────────── */

/* Image preview thumbnail */
.ep-img-wrap {
    position: relative;
    width: 100%;
    height: 120px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #D4C4B0;
}

.ep-img-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Dark overlay + remove button on hover */
.ep-img-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
}

.ep-img-wrap:hover .ep-img-overlay {
    background: rgba(0,0,0,.45);
}

.ep-img-remove-btn {
    opacity: 0;
    font-family: 'Jost', sans-serif;
    font-size: 11px;
    letter-spacing: .1em;
    color: #fff;
    background: rgba(192,57,43,.85);
    border: none;
    padding: 7px 14px;
    border-radius: 3px;
    cursor: pointer;
    transition: opacity .2s, background .2s;
}

.ep-img-wrap:hover .ep-img-remove-btn {
    opacity: 1;
}

.ep-img-remove-btn:hover {
    background: #C0392B;
}

/* Upload zone */
.ep-upload-zone {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100px;
    border: 1.5px dashed #C48B9F;
    border-radius: 4px;
    cursor: pointer;
    background: rgba(196,139,159,.04);
    transition: background .2s, border-color .2s;
    overflow: hidden;
}

    .ep-upload-zone:hover {
        background: rgba(196,139,159,.08);
        border-color: #A06070;
    }

/* Hidden file input fills entire zone */
.ep-upload-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
    font-size: 0;
}

/* Idle state */
.ep-upload-idle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    pointer-events: none;
}

.ep-upload-icon {
    font-size: 24px;
    opacity: .6;
}

.ep-upload-text {
    font-family: 'Jost', sans-serif;
    font-size: 12px;
    color: #C48B9F;
    font-weight: 500;
}

.ep-upload-hint {
    font-family: 'Jost', sans-serif;
    font-size: 10px;
    color: #9E8C87;
    letter-spacing: .04em;
}

/* Uploading state */
.ep-upload-uploading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    pointer-events: none;
}

.ep-upload-spinner {
    font-size: 20px;
    animation: epSpin 1s linear infinite;
}

@keyframes epSpin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Error message */
.ep-error {
    font-size: 11px;
    color: #C0392B;
    background: rgba(192,57,43,.08);
    padding: 6px 10px;
    border-radius: 3px;
    border: 1px solid rgba(192,57,43,.2);
    display: block;
}

/* ── Gradient builder ───────────────────────────────────────── */
.ep-gradient-builder {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
    background: #FAF6F1;
    border: 1px solid #E8DDD4;
    border-radius: 4px;
}

.ep-stop-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid #E8DDD4;
}

.ep-color-swatch-sm {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.ep-stop-label {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #6B5B54;
    min-width: 32px;
    flex-shrink: 0;
}

.ep-slider-inline {
    flex: 1;
}

.ep-stop-remove {
    width: 24px;
    height: 24px;
    background: transparent;
    border: 1px solid #D4C4B0;
    border-radius: 3px;
    color: #9E8C87;
    font-size: 9px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all .15s;
}

    .ep-stop-remove:hover {
        background: rgba(196,139,159,.1);
        color: #C48B9F;
    }

.ep-add-stop {
    font-family: 'Jost', sans-serif;
    font-size: 10px;
    letter-spacing: .1em;
    color: #C48B9F;
    background: transparent;
    border: 1px dashed #C48B9F;
    padding: 6px 12px;
    border-radius: 3px;
    cursor: pointer;
    transition: background .15s;
    width: 100%;
    text-align: center;
}

    .ep-add-stop:hover {
        background: rgba(196,139,159,.06);
    }


/* ── Card live preview inside editor panel ──────────────────── */
.ep-card-preview {
    border-radius: 4px;
    transition: all .2s;
}

/* ── Hero style variant tabs ────────────────────────────────── */
.ep-hero-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.ep-hero-tab {
    padding: 5px 12px;
    border: 1px solid #D4C4B0;
    background: transparent;
    color: #9E8C87;
    border-radius: 3px;
    font-family: 'Jost', sans-serif;
    font-size: 11px;
    cursor: pointer;
    transition: all .15s;
}

    .ep-hero-tab:hover {
        border-color: #C48B9F;
        color: #C48B9F;
    }

.ep-hero-tab--active {
    background: #3A3230;
    color: #FAF6F1;
    border-color: #3A3230;
}

.ep-hero-tab--add {
    border-style: dashed;
    color: #C48B9F;
    border-color: #C48B9F;
}

    .ep-hero-tab--add:hover {
        background: rgba(196,139,159,.06);
    }

.ep-btn-danger {
    padding: 6px 10px;
    background: transparent;
    border: 1px solid rgba(192,57,43,.3);
    color: rgba(192,57,43,.7);
    border-radius: 3px;
    font-family: 'Jost', sans-serif;
    font-size: 11px;
    cursor: pointer;
    transition: all .15s;
}

    .ep-btn-danger:hover {
        background: rgba(192,57,43,.08);
        color: #C0392B;
    }

/* ── Nav actions ─────────────────────────────────────────────── */
.te-nav-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px 12px;
}

.te-nav-btn {
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 3px;
    color: rgba(255,255,255,.5);
    font-family: 'Jost', sans-serif;
    font-size: 11px;
    letter-spacing: .08em;
    text-align: left;
    cursor: pointer;
    transition: all .15s;
}

    .te-nav-btn:hover {
        background: rgba(255,255,255,.06);
        color: rgba(255,255,255,.85);
    }

.te-nav-btn--primary {
    background: rgba(196,139,159,.15);
    border-color: rgba(196,139,159,.3);
    color: #C48B9F;
}

    .te-nav-btn--primary:hover {
        background: rgba(196,139,159,.25);
        color: #D4A0B0;
    }

/* ── Unsaved indicator ───────────────────────────────────────── */
.te-preview-label {
    display: flex;
    align-items: center;
    gap: 6px;
}

.te-unsaved-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #C48B9F;
    flex-shrink: 0;
    animation: teUnsavedPulse 2s ease-in-out infinite;
}

@keyframes teUnsavedPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: .4;
        transform: scale(.8);
    }
}


/* ── Draft restore banner ────────────────────────────────────── */
.te-draft-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 10px;
    background: rgba(201,169,110,.15);
    border-bottom: 1px solid rgba(201,169,110,.3);
    font-family: 'Jost', sans-serif;
    font-size: 9px;
    color: #8A6520;
    gap: 10px;
    animation: teBannerIn .3s ease;
}

@keyframes teBannerIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.te-draft-dismiss {
    background: transparent;
    border: 1px solid rgba(201,169,110,.4);
    border-radius: 3px;
    padding: 2px 10px;
    font-family: 'Jost', sans-serif;
    font-size: 9px;
    color: #8A6520;
    cursor: pointer;
    white-space: nowrap;
    transition: all .15s;
    flex-shrink: 0;
}

    .te-draft-dismiss:hover {
        background: rgba(201,169,110,.15);
        border-color: #C9A96E;
    }


/* ── Background style toggle ─────────────────────────────────── */
.ep-toggle-row {
    display: flex;
    gap: 6px;
}

.ep-toggle-btn {
    flex: 1;
    padding: 7px;
    background: transparent;
    border: 1px solid #D4C4B0;
    border-radius: 3px;
    font-family: 'Jost', sans-serif;
    font-size: 11px;
    color: #6B5B54;
    cursor: pointer;
    transition: all .15s;
    text-align: center;
}

    .ep-toggle-btn:hover {
        border-color: #C48B9F;
        color: #C48B9F;
    }

.ep-toggle-btn--active {
    background: #1A0F0C;
    color: #FAF6F1;
    border-color: #1A0F0C;
}

/* ── Gradient preset grid ────────────────────────────────────── */
.ep-gradient-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.ep-gradient-btn {
    height: 56px;
    border-radius: 4px;
    border: 2px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: flex-end;
    padding: 4px;
    transition: all .15s;
    position: relative;
    overflow: hidden;
}

    .ep-gradient-btn:hover {
        border-color: #C48B9F;
    }

.ep-gradient-btn--active {
    border-color: #1A0F0C;
    box-shadow: 0 0 0 1px #1A0F0C;
}

.ep-gradient-label {
    font-family: 'Jost', sans-serif;
    font-size: 8px;
    letter-spacing: .06em;
    color: #1A0F0C;
    background: rgba(255,255,255,.75);
    padding: 2px 5px;
    border-radius: 2px;
    white-space: nowrap;
}