/* ============================================================
   V2 Builder — Public Stylesheet
   ============================================================ */

/* ---- Reset / Base ----------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #1a1a1a;
    background: #fff;
}

img { max-width: 100%; height: auto; display: block; }

a { text-decoration: none; }

#v2-page { min-height: 100vh; }

/* ---- Container -------------------------------------------- */
.v2-container {
    max-width: 1140px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 24px;
    padding-right: 24px;
}

/* ---- Button ----------------------------------------------- */
.v2-btn {
    display: inline-block;
    padding: 14px 32px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity 0.2s ease, transform 0.15s ease;
    letter-spacing: 0.01em;
}
.v2-btn:hover { opacity: 0.88; transform: translateY(-1px); }

/* ---- Section header (shared title/subtitle block) --------- */
.v2-section-header {
    text-align: center;
    margin-bottom: 56px;
}
.v2-section-header h2 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 12px;
}
.v2-section-header p {
    font-size: 1.1rem;
}

/* ---- Header ----------------------------------------------- */
.v2-header {
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 8px rgba(0,0,0,.07);
}
.v2-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 68px;
    gap: 24px;
}
.v2-logo {
    font-size: 1.4rem;
    font-weight: 700;
    flex-shrink: 0;
}
.v2-logo-img {
    max-height: 44px;
    width: auto;
    display: block;
}
.v2-nav {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}
.v2-nav a {
    font-size: 0.95rem;
    font-weight: 500;
    opacity: 0.85;
    transition: opacity 0.15s;
}
.v2-nav a:hover { opacity: 1; }
.v2-nav-btn {
    padding: 9px 22px !important;
    border-radius: 5px !important;
    font-weight: 600 !important;
    opacity: 1 !important;
    transition: opacity 0.2s ease !important;
}
.v2-nav-btn:hover { opacity: 0.88 !important; }
.v2-nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

/* ---- Hero ------------------------------------------------- */
.v2-hero {
    padding: 100px 0;
}
.v2-hero-inner {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 48px;
}
.v2-hero-inner.v2-hero--with-image {
    flex-direction: row;
    align-items: center;
}
.v2-hero-text {
    flex: 1;
}
.v2-hero-headline {
    font-size: 3.2rem;
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 20px;
    letter-spacing: -0.02em;
}
.v2-hero-sub {
    font-size: 1.2rem;
    line-height: 1.7;
    margin-bottom: 36px;
    max-width: 520px;
}
.v2-hero-image {
    flex: 1;
    text-align: center;
}
.v2-hero-image img {
    border-radius: 12px;
    margin: 0 auto;
    max-height: 480px;
    object-fit: cover;
}

/* ---- About ------------------------------------------------ */
.v2-about {
    padding: 80px 0;
}
.v2-about-inner {
    display: flex;
    align-items: center;
    gap: 64px;
}
.v2-about-image {
    flex: 1;
}
.v2-about-image img {
    border-radius: 12px;
    width: 100%;
    object-fit: cover;
}
.v2-about-text {
    flex: 1;
}
.v2-about-text h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 16px;
}
.v2-about-text p {
    font-size: 1.05rem;
    line-height: 1.75;
    margin-bottom: 28px;
}

/* ---- Features --------------------------------------------- */
.v2-features {
    padding: 80px 0;
}
.v2-features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
}
.v2-feature-card {
    background: #fff;
    border-radius: 12px;
    padding: 36px 28px;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.v2-feature-card:hover {
    box-shadow: 0 8px 32px rgba(0,0,0,.12);
    transform: translateY(-4px);
}
.v2-feature-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin-bottom: 20px;
}
.v2-feature-card h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 10px;
}
.v2-feature-card p {
    font-size: 0.95rem;
    line-height: 1.65;
}

/* ---- CTA -------------------------------------------------- */
.v2-cta {
    padding: 90px 0;
    text-align: center;
}
.v2-cta h2 {
    font-size: 2.4rem;
    font-weight: 800;
    margin-bottom: 16px;
}
.v2-cta p {
    font-size: 1.15rem;
    margin-bottom: 36px;
    opacity: 0.9;
}

/* ---- Footer ----------------------------------------------- */
.v2-footer {
    padding: 32px 0;
    text-align: center;
}
.v2-footer p {
    font-size: 0.9rem;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
    .v2-features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    /* Header */
    .v2-nav-toggle { display: block; }
    .v2-nav {
        display: none;
        flex-direction: column;
        align-items: flex-start;
        position: absolute;
        top: 68px;
        left: 0;
        right: 0;
        background: inherit;
        padding: 16px 24px 20px;
        gap: 14px;
        box-shadow: 0 4px 12px rgba(0,0,0,.1);
        z-index: 99;
    }
    .v2-nav.v2-nav--open { display: flex; }
    .v2-header { position: relative; }

    /* Hero */
    .v2-hero { padding: 60px 0; }
    .v2-hero-inner.v2-hero--with-image { flex-direction: column; }
    .v2-hero-headline { font-size: 2.2rem; }
    .v2-hero-sub { font-size: 1.05rem; }

    /* About */
    .v2-about { padding: 56px 0; }
    .v2-about-inner { flex-direction: column; gap: 32px; }

    /* Features */
    .v2-features { padding: 56px 0; }
    .v2-features-grid { grid-template-columns: 1fr; }

    /* CTA */
    .v2-cta { padding: 60px 0; }
    .v2-cta h2 { font-size: 1.8rem; }

    /* Section header */
    .v2-section-header h2 { font-size: 1.7rem; }
}

/* ============================================================
   Editor-mode styles  (only active when is_edit=true,
   because the elements they target only exist in edit mode)
   ============================================================ */

/* Toolbar */
#v2-toolbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: #1a1a2e;
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 20px;
    z-index: 9000;
    box-shadow: 0 -2px 12px rgba(0,0,0,.25);
}
#v2-toolbar-brand {
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.04em;
    color: #a78bfa;
    margin-right: auto;
}
#v2-add-section-btn {
    background: #448c74;
    color: #fff;
    border: none;
    padding: 9px 20px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
}
#v2-add-section-btn:hover { background: #376d5c; }
#v2-save-status {
    font-size: 0.85rem;
    color: #86efac;
    min-width: 120px;
}

/* Section wrapper in edit mode */
.v2-section-wrap {
    position: relative;
}
.v2-section-controls {
    position: absolute;
    top: 10px;
    right: 12px;
    display: none;
    gap: 6px;
    z-index: 200;
    background: rgba(26,26,46,.88);
    border-radius: 8px;
    padding: 6px 8px;
    align-items: center;
}
.v2-section-wrap:hover > .v2-section-controls {
    display: flex;
}
.v2-ctrl-btn {
    background: none;
    border: 1px solid rgba(255,255,255,.25);
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
}
.v2-ctrl-btn:hover { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.5); }
.v2-ctrl-btn--edit  { color: #7dd3fc; }
.v2-ctrl-btn--delete{ color: #fca5a5; }
.v2-ctrl-btn--drag  { cursor: grab; color: #d1d5db; }
.v2-section-wrap.v2-dragging { opacity: 0.4; }
.v2-section-wrap.v2-drag-over { outline: 2px dashed #448c74; outline-offset: -2px; }

/* Backdrop */
#v2-editor-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 8000;
    backdrop-filter: blur(2px);
}
#v2-editor-backdrop.active { display: block; }

/* Sidebar */
#v2-sidebar {
    position: fixed;
    top: 0;
    right: -380px;
    width: 360px;
    height: 100%;
    background: #fff;
    z-index: 8500;
    box-shadow: -4px 0 24px rgba(0,0,0,.15);
    transition: right 0.28s cubic-bezier(.4,0,.2,1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#v2-sidebar.active { right: 0; }
#v2-sidebar-inner {
    flex: 1;
    overflow-y: auto;
    padding: 0 0 60px 0;
}

/* Sidebar header */
.v2-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    position: sticky;
    top: 0;
    z-index: 1;
}
.v2-sidebar-head h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #1a1a2e;
}
.v2-sidebar-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: #6b7280;
    line-height: 1;
    padding: 4px;
}
.v2-sidebar-close:hover { color: #1a1a1a; }

/* Sidebar form fields */
.v2-fields-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.v2-field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.v2-field-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.v2-field-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #1a1a1a;
    background: #fff;
    transition: border-color 0.15s;
    font-family: inherit;
}
.v2-field-input:focus {
    outline: none;
    border-color: #448c74;
    box-shadow: 0 0 0 2px rgba(68,140,116,.15);
}
textarea.v2-field-input {
    resize: vertical;
    min-height: 90px;
}
.v2-field-color {
    display: flex;
    align-items: center;
    gap: 10px;
}
.v2-field-color input[type="color"] {
    width: 44px;
    height: 36px;
    padding: 2px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    background: none;
}
.v2-field-color input[type="text"] {
    flex: 1;
}
.v2-image-preview {
    width: 100%;
    max-height: 120px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    display: block;
    margin-bottom: 8px;
}
.v2-image-empty {
    width: 100%;
    height: 80px;
    background: #f3f4f6;
    border: 2px dashed #d1d5db;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 0.85rem;
    margin-bottom: 8px;
}
.v2-change-image-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    background: #f9fafb;
    color: #374151;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.v2-change-image-btn:hover {
    border-color: #448c74;
    background: #f0faf6;
    color: #448c74;
}

/* Sidebar save bar */
.v2-sidebar-footer {
    position: sticky;
    bottom: 0;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    padding: 14px 20px;
    display: flex;
    gap: 10px;
}
.v2-save-btn {
    flex: 1;
    padding: 11px;
    background: #448c74;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.v2-save-btn:hover { background: #376d5c; }
.v2-save-btn:disabled { background: #9ca3af; cursor: not-allowed; }
.v2-cancel-btn {
    padding: 11px 20px;
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s;
}
.v2-cancel-btn:hover { background: #e5e7eb; }

/* Add Section Modal */
#v2-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 9500;
    align-items: center;
    justify-content: center;
}
#v2-modal-overlay.active { display: flex; }
#v2-modal {
    background: #fff;
    border-radius: 12px;
    width: 560px;
    max-width: 95vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    overflow: hidden;
}
#v2-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}
#v2-modal-header span {
    font-weight: 700;
    font-size: 1rem;
    color: #1a1a2e;
}
#v2-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6b7280;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
}
#v2-modal-close:hover { background: #e5e7eb; color: #1a1a1a; }
#v2-modal-body {
    overflow-y: auto;
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    align-content: start;
}
.v2-template-card {
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    padding: 18px 16px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
    background: #fff;
}
.v2-template-card:hover {
    border-color: #448c74;
    box-shadow: 0 4px 16px rgba(68,140,116,.15);
    transform: translateY(-2px);
}
.v2-template-card-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: #1a1a2e;
    margin-bottom: 4px;
}
.v2-template-card-cat {
    font-size: 0.78rem;
    color: #6b7280;
    text-transform: capitalize;
    font-weight: 500;
    background: #f3f4f6;
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
}

/* Bottom padding for toolbar */
#v2-page { padding-bottom: 0; }
