:root {
    --primary: #2563eb;
    --danger: #dc2626;
    --bg-color: #f9fafb;
    --text-color: #1f2937;
    --toolbar-height: 60px;
}

body {
    margin: 0;
    font-family: var(--tpl-body-font, 'Inter', sans-serif);
    color: var(--tpl-text, var(--text-color));
    background: var(--bg-color);
    line-height: 1.6;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--tpl-heading-font, var(--tpl-body-font, 'Inter', sans-serif));
    color: var(--tpl-heading-color, inherit);
}
h1 { font-size: var(--tpl-h1-size, 2.5rem); font-weight: var(--tpl-h1-weight, 800); }
h2 { font-size: var(--tpl-h2-size, 2rem); font-weight: var(--tpl-h2-weight, 700); }
h3 { font-size: var(--tpl-h3-size, 1.5rem); font-weight: var(--tpl-h3-weight, 600); }
h4 { font-size: var(--tpl-h4-size, 1.25rem); font-weight: var(--tpl-h4-weight, 600); }

body.edit-mode {
    padding-top: var(--toolbar-height);
}

.container {
    max-width: var(--container-width, 1000px);
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
}

.full-width .container {
    max-width: 100%;
    box-shadow: none;
}

/* =========================================
   1. ADMIN TOOLBAR
   ========================================= */
.admin-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--toolbar-height);
    background: #1e293b;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    gap: 10px;
    box-sizing: border-box;
    z-index: 2000;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 10px;
}
.toolbar-group:first-child,
.toolbar-group:last-child {
    flex: 1;
}
.toolbar-group:last-child {
    justify-content: flex-end;
}

.toolbar-separator {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.25);
    margin: 0 6px;
}

.toolbar-label {
    font-size: 0.85rem;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: bold;
}

.btn-add-widget,
.btn-special,
.btn-ai,
.btn-template,
.btn-seo,
.btn-page {
    border: none;
    color: white;
    padding: 8px 0;
    min-width: 100px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    text-align: center;
    transition: background 0.2s;
}

.btn-page { background: #475569; min-width: 70px; }
.btn-page:hover { background: #334155; }

.btn-add-widget { background: var(--primary); }
.btn-add-widget:hover { background: #1d4ed8; }

/* Save LED indicator */
.save-led { width:10px; height:10px; border-radius:50%; display:inline-block; flex-shrink:0; }
.save-led-green { background:#22c55e; box-shadow:0 0 4px #22c55e; }
.save-led-red { background:#ef4444; box-shadow:0 0 4px #ef4444; }

/* User menu icon + dropdown */
.user-menu-wrapper { position:relative; }
.btn-user-icon { width:32px; height:32px; border-radius:50%; border:none; background:#334155; color:white; font-size:14px; cursor:pointer; display:flex; align-items:center; justify-content:center; }
.btn-user-icon:hover { background:#475569; }
.user-dropdown { display:none; position:absolute; top:100%; right:0; margin-top:8px; background:white; border-radius:8px; box-shadow:0 4px 12px rgba(0,0,0,0.15); min-width:160px; overflow:hidden; z-index:2001; }
.user-dropdown.open { display:block; }
.user-dropdown-item { display:block; width:100%; padding:10px 16px; border:none; background:none; text-align:left; cursor:pointer; font-size:0.85rem; color:#334155; text-decoration:none; }
.user-dropdown-item:hover { background:#f1f5f9; }
.user-dropdown-logout { color:#dc2626; border-top:1px solid #e2e8f0; }

/* Page Manager Buttons */
.btn-mini-tool {
    background: #334155;
    border: 1px solid #475569;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-mini-tool:hover { background: #475569; }

.btn-danger {
    background: #7f1d1d;
    border-color: #991b1b;
}
.btn-danger:hover { background: #991b1b; }

/* Special "Reuse" Button */
.btn-special { background: #d97706; }
.btn-special:hover { background: #b45309; }


/* =========================================
   2. WIDGET WRAPPERS & EDIT CONTROLS
   ========================================= */
.widget-wrapper {
    position: relative;
    transition: all 0.3s ease;
}

.edit-mode .widget-wrapper {
    margin: 20px 0;
    border: 2px dashed transparent;
}

.edit-mode .widget-wrapper:hover {
    border-color: #cbd5e1;
}

/* Alias / Reuse Styles (Alleen in edit mode opvallend) */
.edit-mode .widget-alias {
    border: 2px solid #f59e0b !important;
    background-color: #fffbeb;
}

/* Shared Pill Style for controls */
.editor-controls, 
.menu-item-controls {
    background: #fff; 
    border: 1px solid #e2e8f0; 
    border-radius: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05); 
    padding: 4px 10px; 
    display: flex; 
    gap: 8px; 
    align-items: center;
}

/* Main Widget Controls (Drag/Delete) */
.editor-controls {
    display: none; 
    position: absolute; 
    top: -18px; 
    left: 50%; 
    transform: translateX(-50%);
    z-index: 1500; 
}
.edit-mode .widget-wrapper:hover .editor-controls { display: flex; }

.btn-widget-settings {
    cursor: pointer;
    color: #64748b;
    padding-right: 8px;
    border-right: 1px solid #eee;
    font-weight: 600;
    font-size: 0.85rem;
    transition: color 0.2s;
    white-space: nowrap;
}
.btn-widget-settings:hover { color: var(--primary); }

.drag-handle {
    cursor: grab;
    color: var(--tpl-ui-accent, #2563eb);
    padding-right: 8px;
    border-right: 1px solid #eee;
    font-weight: 600;
    font-size: 0.9rem;
}

.anchor-badge {
    cursor: pointer;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: monospace;
    padding: 1px 6px;
    background: #f1f5f9;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    transition: all 0.2s;
    white-space: nowrap;
}
.anchor-badge:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: #eff6ff;
}

.btn-duplicate-widget {
    cursor: pointer;
    transition: transform 0.2s;
    font-size: 1rem;
}
.btn-duplicate-widget:hover {
    transform: scale(1.2);
    color: var(--primary);
}
.btn-delete-widget {
    cursor: pointer;
    transition: transform 0.2s;
    font-size: 1rem;
}
.btn-delete-widget:hover {
    transform: scale(1.2);
    color: var(--danger);
}

/* Scroll margin for anchored widgets (offset for sticky menus) */
.widget-wrapper[id] {
    scroll-margin-top: 80px;
}


/* =========================================
   3. MENU WIDGET (Layout 2.0)
   ========================================= */
.main-menu {
    display: flex;
    width: 100%;
    align-items: center;
    position: relative;
    z-index: 100;
    box-sizing: border-box;
    min-height: 60px;
}

/* Kolom 1: Logo Gebied */
.menu-col-logo {
    display: flex;
    align-items: center;
    padding: 0 15px;
    flex-shrink: 0; 
}
.menu-logo-img { display: block; height: auto; }
.logo-text { font-weight: 800; font-size: 1.2rem; }

/* Logo overflow: logo visually overlaps the menu bar without increasing its height */
.logo-overflow {
    height: 0;
    overflow: visible;
    position: relative;
    z-index: 10;
}
.logo-overflow .menu-logo-img,
.logo-overflow .logo-text {
    transform: translateY(-50%);
}

/* Kolom 2: Navigatie Gebied */
.menu-col-nav {
    display: flex;
    align-items: center;
    flex-grow: 1;
    padding: 0 15px;
}

/* Top Level List */
.menu-col-nav ul.menu-level-0 {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.menu-item {
    position: relative;
    display: flex;
    align-items: center;
}

.menu-link {
    text-decoration: none;
    padding: 8px 16px;
    display: block;
    border-radius: 4px;
    transition: all 0.2s;
    white-space: nowrap;
}

/* Edit Mode Menu Item Adjustments */
.edit-mode .menu-item {
    border: 1px solid transparent;
    flex-direction: column-reverse; 
    margin-top: 10px;
}
.edit-mode .menu-item:hover {
    border: 1px dashed #ddd; 
    background: rgba(0,0,0,0.02);
}

/* Menu Item Controls (Link/Sub/Del) */
.menu-item-controls {
    display: flex; 
    position: static; 
    margin-bottom: 5px; 
    opacity: 0.3; 
    transition: opacity 0.2s;
    z-index: 10;
}
.edit-mode .menu-item:hover .menu-item-controls { opacity: 1; }

.btn-mini {
    background: none; border: none; cursor: pointer; font-size: 12px; padding: 4px;
    color: #64748b; 
    transition: color 0.2s;
}
.btn-mini:hover { color: var(--primary); }
.btn-mini.btn-delete-link:hover { color: var(--danger); }

/* Submenu arrow - hidden on desktop */
.submenu-arrow { display: none; }

/* --- Submenus (Desktop: Dropdown) --- */
.submenu-container {
    position: absolute;
    top: 100%;
    left: 0;
    background: transparent;
    box-shadow: none;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: visibility 0s 0.3s, opacity 0.15s 0.15s;
    z-index: 1000;
    border-radius: 6px;
    border: none;
    padding: 5px 0;
    margin-top: 5px;
}

/* Vertical bridge: covers gap between menu item and dropdown below */
.submenu-container::before {
    content: ''; position: absolute; top: -10px; left: 0; width: 100%; height: 10px;
}

.menu-item:hover > .submenu-container,
.submenu-container:hover {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transition: visibility 0s, opacity 0.15s;
}

/* Edit mode: preview first submenu branch so styling is visible */
.edit-mode .submenu-preview > .submenu-container {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transition: none;
}

.submenu-container ul {
    list-style: none; padding: 0; margin: 0;
    display: flex; flex-direction: column; gap: 2px;
}
.submenu-container li { width: 100%; }
.submenu-container a { display: block; box-sizing: border-box; border-radius: 4px; }

/* Nested submenus: flyout to the right, flush with parent edge */
.submenu-container .submenu-container {
    top: 0; left: 100%; margin-top: 0;
}
/* Horizontal bridge: covers the gap between parent item and nested flyout */
.submenu-container .submenu-container::before {
    top: 0; left: -30px; width: 30px; height: 100%;
}
/* Flip to left when not enough space (added by JS) */
.submenu-container .submenu-container.flip-left {
    left: auto; right: 100%;
}
.submenu-container .submenu-container.flip-left::before {
    left: auto; right: -30px;
}

/* Add Link Button */
.btn-add-link {
    background: #eff6ff; 
    color: var(--primary); 
    border: 1px dashed var(--primary);
    padding: 6px 12px; 
    font-size: 0.8rem; 
    cursor: pointer; 
    border-radius: 4px;
    margin: 5px 10px;
    display: block;
    text-align: center;
}
.btn-add-link:hover { background: var(--primary); color: white; }


/* Menu settings toolbar - now in editor-controls */


/* =========================================
   4. MOBILE HAMBURGER MENU
   ========================================= */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 200;
}

.hamburger-btn span {
    display: block;
    width: 24px;
    height: 2px;
    margin: 5px 0;
    background-color: #333;
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Mobile overlay backdrop */
.mobile-overlay {
    display: none;
}

/* Submenu arrow hidden on desktop */
.submenu-arrow { display: none; }

@media (max-width: 768px) {
    .hamburger-btn {
        display: block;
        order: 999;
    }

    .menu-lang-switcher {
        order: 998;
        margin-left: auto;
    }

    /* When no lang switcher, hamburger pushes itself right */
    .main-menu:not(:has(.menu-lang-switcher)) .hamburger-btn {
        margin-left: auto;
    }

    /* --- Overlay backdrop --- */
    .mobile-overlay {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0, 0, 0, 0);
        z-index: 190;
        transition: background 0.35s ease;
        pointer-events: none;
    }
    .main-menu.mobile-open .mobile-overlay {
        display: block;
        background: rgba(0, 0, 0, 0.35);
        pointer-events: auto;
    }

    /* --- Slide-in panel from left, 80% width --- */
    .menu-col-nav {
        position: fixed;
        top: 0;
        left: 0;
        width: 80%;
        max-width: 380px;
        height: 100vh;
        height: 100dvh;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        transform: translateX(-100%);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);

        flex-grow: 0;
        flex-direction: column;
        justify-content: flex-start !important;
        padding: 32px 24px;
        box-sizing: border-box;
        z-index: 200;

        background-color: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);

        /* Pixel-based inner width for constraining nested items */
        --menu-panel-w: calc(min(80vw, 380px) - 48px);
    }

    .main-menu.mobile-open .menu-col-nav {
        transform: translateX(0);
    }

    /* --- Menu items: flexbox layout for accordion --- */
    .menu-col-nav ul.menu-level-0 {
        flex-direction: column;
        width: 100%;
        gap: 2px;
    }

    .menu-item {
        display: flex;
        flex-wrap: wrap;
        align-items: stretch;
        box-sizing: border-box;
        max-width: var(--menu-panel-w);
    }

    /* --- Menu links --- */
    .menu-link {
        flex: 1 1 0;
        min-width: 0 !important;
        white-space: normal;
        text-align: var(--mobile-text-align, left);
        padding: 13px 16px;
        font-size: 1rem;
        box-sizing: border-box;
        border-radius: 10px;
        transition: background 0.15s ease;
        cursor: pointer;
    }
    .menu-link:active {
        background: rgba(0, 0, 0, 0.04);
    }

    /* has-submenu: split border-radius between link and arrow */
    .has-submenu > .menu-link {
        border-radius: 10px 0 0 10px;
    }

    /* --- Submenu arrow: fixed 44px, sits next to link --- */
    .menu-item.has-submenu > .submenu-arrow {
        flex: 0 0 44px;
        display: flex !important;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        border-radius: 0 10px 10px 0;
        position: static;
    }
    .submenu-arrow::after {
        content: '';
        display: block;
        width: 8px;
        height: 8px;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: rotate(45deg);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        opacity: 0.5;
    }
    .menu-item.is-open > .submenu-arrow::after {
        transform: rotate(-135deg);
        opacity: 0.8;
    }
    .submenu-arrow:active {
        background: rgba(0, 0, 0, 0.06);
    }

    /* --- Accordion submenus with smooth animation --- */
    .submenu-container {
        flex: 0 0 100%;
        max-width: 100%;
        position: static;
        background: transparent;
        box-shadow: none;
        border: none;
        padding: 0;
        margin-top: 0;
        max-height: 0;
        overflow: hidden;
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
        transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .submenu-container::before {
        display: none;
    }
    .menu-item.is-open > .submenu-container {
        max-height: 600px;
    }

    /* Child items: stacked at same level */
    .submenu-container ul {
        display: flex;
        flex-direction: column;
        padding: 2px 0;
        gap: 0;
        max-width: 100%;
    }
    .submenu-container a {
        display: block;
        padding: 10px 16px;
        font-size: 0.9rem;
        border-radius: 8px;
        transition: background 0.15s ease;
        white-space: normal;
    }
    .submenu-container a:active {
        background: rgba(0, 0, 0, 0.04);
    }

    /* Left accent bar to show hierarchy */
    .submenu-container > ul > .menu-item {
        box-shadow: inset 3px 0 0 rgba(37, 99, 235, 0.3);
    }
    .submenu-container .submenu-container > ul > .menu-item {
        box-shadow: inset 6px 0 0 rgba(37, 99, 235, 0.2);
    }

    /* Nested submenus — reset desktop flyout positioning */
    .submenu-container .submenu-container {
        top: auto; left: auto; margin-top: 0; margin-left: 0;
    }

    /* Editor controls */
    .menu-item-controls {
        flex-basis: 100%;
    }

    /* --- Hamburger animation to X --- */
    .main-menu.mobile-open .hamburger-btn span:nth-child(1) {
        transform: rotate(-45deg) translate(-5px, 6px);
    }
    .main-menu.mobile-open .hamburger-btn span:nth-child(2) {
        opacity: 0;
    }
    .main-menu.mobile-open .hamburger-btn span:nth-child(3) {
        transform: rotate(45deg) translate(-5px, -6px);
    }
}


/* =========================================
   5. CMS SETTINGS MODAL (Professional)
   ========================================= */
.cms-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.08);
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    animation: fadeIn 0.15s ease-out;
    font-family: var(--tpl-editor-font, 'Inter', sans-serif);
}

.cms-modal {
    background: white;
    width: 420px;
    max-width: 90%;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
    max-height: calc(100vh - 90px);
    margin: 75px 0 0 20px;
    border: 1px solid #e2e8f0;
}

.cms-modal-header {
    padding: 16px 24px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.cms-modal-header h3 { margin: 0; font-size: 1.1rem; color: #1e293b; pointer-events: none; }

.cms-modal-close {
    background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #94a3b8;
}
.cms-modal-close:hover { color: #64748b; }

.cms-modal-body {
    padding: 24px;
    overflow-y: auto;
}

.cms-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #94a3b8;
    font-weight: 700;
    letter-spacing: 1px;
    margin: 20px 0 10px 0;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 5px;
}
.cms-section-title:first-child { margin-top: 0; }

/* Collapsible section titles (opt-in via cms-section-collapsible) */
.cms-section-collapsible {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
    padding: 8px 12px;
    border-radius: 6px;
    border-bottom: none;
    margin-bottom: 0;
}
.cms-section-collapsible:not(.collapsed) {
    border-radius: 6px 6px 0 0;
}
.cms-section-collapsible::after {
    content: '▾';
    font-size: 0.65rem;
    transition: transform 0.2s;
}
.cms-section-collapsible.collapsed::after {
    transform: rotate(-90deg);
}
.cms-section-content {
    padding: 12px 0 4px 0;
    border-left: 2px solid #e2e8f0;
    margin-left: 6px;
    padding-left: 12px;
}
.cms-section-content.cms-section-collapsed {
    display: none;
}

.cms-row { display: flex; gap: 15px; margin-bottom: 10px; }
.cms-col { flex: 1; }

.cms-form-group { margin-bottom: 16px; }
.cms-form-group label {
    display: block; font-size: 0.85rem; font-weight: 600; 
    margin-bottom: 6px; color: #475569;
}

.cms-form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.cms-form-control:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Global range input styling */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: linear-gradient(var(--tpl-ui-accent, #2563eb), var(--tpl-ui-accent, #2563eb)) 0/var(--range-fill, 0%) 100% no-repeat #e2e8f0;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--tpl-ui-accent, #2563eb);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--tpl-ui-accent, #2563eb);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
input[type="range"]::-moz-range-progress {
    background: var(--tpl-ui-accent, #2563eb);
    height: 6px;
    border-radius: 3px;
}
/* Global checkbox & radio accent color */
input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--tpl-ui-accent, #2563eb);
}

.preview-box {
    width: 100%; height: 40px; border-radius: 4px; border: 1px solid #ddd;
    display: flex; align-items: center; justify-content: center; font-size: 12px; color: #666;
    background-image: linear-gradient(45deg, #f0f0f0 25%, transparent 25%), linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #f0f0f0 75%), linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
}

.cms-modal-footer {
    padding: 16px 24px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-shrink: 0;
}

.cms-btn {
    padding: 8px 16px; border-radius: 6px; font-weight: 500; font-size: 0.9rem; cursor: pointer; border: none;
}
.cms-btn-secondary { background: white; border: 1px solid #cbd5e1; color: #475569; }
.cms-btn-secondary:hover { background: #f1f5f9; }
.cms-btn-primary { background: var(--tpl-ui-accent, #2563eb); color: white; }
.cms-btn-primary:hover { background: var(--tpl-ui-accent, #2563eb); filter: brightness(0.85); }


/* =========================================
   6. OTHER WIDGETS & UTILS
   ========================================= */
/* =========================================
   HERO WIDGET
   ========================================= */
.hero {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 4rem 2rem;
    text-align: center;
    overflow: hidden;
    box-sizing: border-box;
}

.hero-bg-image {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-size: cover;
    background-position: center;
    z-index: 0;
}

.hero-adjust-btn {
    display: none;
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    background: rgba(0,0,0,0.6);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
}
.edit-mode .hero-settings-open .hero-adjust-btn {
    display: block;
}
.edit-mode header.hero:not(:has(.hero-slide-active .hero-bg-image)):not(:has(.hero-slide-active .hero-bg-video)) .hero-adjust-btn {
    display: none;
}
.hero-adjust-btn:hover {
    background: rgba(0,0,0,0.8);
}
.edit-mode .hero-adjusting .hero-adjust-btn {
    background: rgba(37,99,235,0.8);
    border-color: rgba(255,255,255,0.5);
}
.edit-mode .hero-adjusting .hero-slide:has(.hero-bg-image),
.edit-mode .hero-adjusting .hero-slide:has(.hero-bg-image) .hero-bg-overlay,
.edit-mode .hero-adjusting .hero-slide:has(.hero-bg-image) .hero-content,
.edit-mode .hero-adjusting .hero-slide:has(.hero-bg-image) .hero-content h1,
.edit-mode .hero-adjusting .hero-slide:has(.hero-bg-image) .hero-content p,
.edit-mode .hero-adjusting .hero-slide:has(.hero-bg-image) .hero-content a,
.edit-mode .hero-adjusting .hero-slide:has(.hero-bg-video),
.edit-mode .hero-adjusting .hero-slide:has(.hero-bg-video) .hero-bg-overlay,
.edit-mode .hero-adjusting .hero-slide:has(.hero-bg-video) .hero-content,
.edit-mode .hero-adjusting .hero-slide:has(.hero-bg-video) .hero-content h1,
.edit-mode .hero-adjusting .hero-slide:has(.hero-bg-video) .hero-content p,
.edit-mode .hero-adjusting .hero-slide:has(.hero-bg-video) .hero-content a {
    cursor: grab;
}
.edit-mode .hero-adjusting .hero-slide.hero-dragging,
.edit-mode .hero-adjusting .hero-slide.hero-dragging .hero-bg-overlay,
.edit-mode .hero-adjusting .hero-slide.hero-dragging .hero-content,
.edit-mode .hero-adjusting .hero-slide.hero-dragging .hero-content h1,
.edit-mode .hero-adjusting .hero-slide.hero-dragging .hero-content p,
.edit-mode .hero-adjusting .hero-slide.hero-dragging .hero-content a {
    cursor: grabbing;
}

.hero-bg-controls {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
    transition: opacity 0.3s;
}
.hero-bg-zoom-label {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 0.75rem;
    cursor: default;
}
.hero-bg-zoom-input {
    width: 44px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.75rem;
    text-align: center;
    -moz-appearance: textfield;
}
.hero-bg-zoom-input::-webkit-inner-spin-button,
.hero-bg-zoom-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.hero-bg-zoom-input:focus {
    outline: none;
    border-color: rgba(255,255,255,0.6);
    background: rgba(255,255,255,0.25);
}
.hero-bg-controls button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.7rem;
}
.hero-bg-controls button:hover {
    background: rgba(255,255,255,0.4);
}

/* Device toggle (Desktop / Mobile) */
.hero-device-toggle {
    display: flex;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.3);
    margin-right: 4px;
}
.hero-device-btn {
    border: none !important;
    border-radius: 0 !important;
    padding: 2px 10px !important;
    font-size: 0.7rem !important;
    cursor: pointer;
    background: transparent !important;
    color: rgba(255,255,255,0.7) !important;
    transition: background 0.15s, color 0.15s;
}
.hero-device-btn.hero-device-active {
    background: rgba(59,130,246,0.8) !important;
    color: white !important;
}
.hero-device-btn:hover:not(.hero-device-active) {
    background: rgba(255,255,255,0.15) !important;
}

/* Mobile viewport overlay */
.hero-mobile-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 5;
    pointer-events: none;
}
.hero-mobile-dim {
    position: absolute;
    background: rgba(0,0,0,0.5);
}
.hero-mobile-frame {
    position: absolute;
    top: 0;
    border-left: 2px dashed rgba(255,255,255,0.7);
    border-right: 2px dashed rgba(255,255,255,0.7);
    box-sizing: border-box;
}

.hero-bg-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    width: 100%;
}
.edit-mode .hero-content {
    border: 2px dashed rgba(255,255,255,0.35);
    border-radius: 8px;
    padding: 16px;
}

.hero-content h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0 0 0.5rem 0;
    line-height: 1.2;
}

.hero-content p {
    font-size: 1.2rem;
    margin: 0 0 1.5rem 0;
    opacity: 0.9;
}

/* Hero Text Position (9-point grid) */
.hero-slide[data-text-position] {
    padding: 40px;
    box-sizing: border-box;
}
.hero-slide[data-text-position*="left"]    { justify-content: flex-start; }
.hero-slide[data-text-position*="right"]   { justify-content: flex-end; }
.hero-slide[data-text-position*="-top"]    { align-items: flex-start; }
.hero-slide[data-text-position*="-bottom"] { align-items: flex-end; }

/* Hero slot — floats independently over the hero */
.hero-slot {
    position: absolute;
    z-index: 3;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Slot position presets (format: {horizontal}-{vertical}) */
.hero-slot[data-slot-pos="left-top"]      { top: 20px; left: 20px; }
.hero-slot[data-slot-pos="center-top"]    { top: 20px; left: 50%; transform: translateX(-50%); }
.hero-slot[data-slot-pos="right-top"]     { top: 20px; right: 20px; }
.hero-slot[data-slot-pos="left-center"]   { top: 50%; left: 20px; transform: translateY(-50%); }
.hero-slot[data-slot-pos="center-center"] { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.hero-slot[data-slot-pos="right-center"]  { top: 50%; right: 20px; transform: translateY(-50%); }
.hero-slot[data-slot-pos="left-bottom"]   { bottom: 20px; left: 20px; }
.hero-slot[data-slot-pos="center-bottom"] { bottom: 20px; left: 50%; transform: translateX(-50%); }
.hero-slot[data-slot-pos="right-bottom"]  { bottom: 20px; right: 20px; }
.hero-slot:empty { display: none; }
.hero-slot .widget-wrapper { width: 100%; }
.hero-slot .widget-wrapper .editor-controls { display: none; }
.edit-mode .hero-slot .widget-wrapper .editor-controls { display: flex; }

/* Editor: show slot placeholder when empty */
.edit-mode .hero-slot.hero-slot-empty {
    display: flex;
    min-height: 80px;
    border: 2px dashed rgba(255,255,255,0.3);
    border-radius: 8px;
}
.hero-slot-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: rgba(255,255,255,0.5);
    font-size: 0.85rem;
    padding: 20px;
    width: 100%;
    text-align: center;
}
.hero-slot-placeholder span { font-size: 1.5rem; }
.hero-slot-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.15s;
}
.hero-slot:hover .hero-slot-remove { opacity: 1; }
.hero-slot-remove:hover { background: #ef4444; }

/* Drag hover state for slot */
.hero-slot-drop-hover {
    border: 2px dashed rgba(59, 130, 246, 0.8) !important;
    background: rgba(59, 130, 246, 0.15);
    display: flex !important;
}
.hero-slot-drop-hover .hero-slot-placeholder div {
    color: rgba(255,255,255,0.8);
}

/* Position picker widget in modal */
.hero-position-grid,
.hero-slot-position-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    width: 80px;
    height: 80px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    overflow: hidden;
    background: #e2e8f0;
}
.hero-position-cell {
    background: #f1f5f9;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.hero-position-cell:hover { background: #dbeafe; }
.hero-position-cell.active {
    background: #3b82f6;
}
.hero-position-cell .pos-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #94a3b8;
}
.hero-position-cell.active .pos-dot { background: #fff; }

@media (max-width: 768px) {
    .hero-slide[data-text-position] { padding: 24px; }
    .hero-slide .hero-content { width: 100% !important; }
    .hero-slot { display: none !important; }
}

/* Hero Buttons */
.hero-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

.hero-slide[style*="text-align: left"] .hero-buttons,
.hero-slide[style*="text-align:left"] .hero-buttons { justify-content: flex-start; }
.hero-slide[style*="text-align: right"] .hero-buttons,
.hero-slide[style*="text-align:right"] .hero-buttons { justify-content: flex-end; }

.hero-btn-wrap {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
}

.hero-btn {
    display: inline-block;
    padding: 12px 28px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.hero-btn-primary {
    background: var(--tpl-btn-primary-bg, var(--primary));
    color: var(--tpl-btn-primary-color, #fff);
    border-color: var(--tpl-btn-primary-bg, var(--primary));
    border-radius: var(--tpl-btn-primary-radius, 6px);
    font-size: var(--tpl-btn-primary-size, inherit);
    font-weight: var(--tpl-btn-primary-weight, 600);
    padding: var(--tpl-btn-primary-padding, 12px 28px);
    min-width: var(--tpl-btn-primary-min-width, auto);
    max-width: var(--tpl-btn-primary-max-width, none);
}
.hero-btn-primary:hover {
    opacity: 0.9;
}

.hero-btn-outline {
    background: var(--tpl-btn-outline-bg, transparent);
    color: var(--tpl-btn-outline-color, inherit);
    border: var(--tpl-btn-outline-border, 2px solid currentColor);
    border-radius: var(--tpl-btn-outline-radius, 6px);
    font-size: var(--tpl-btn-outline-size, inherit);
    font-weight: var(--tpl-btn-outline-weight, 600);
    padding: var(--tpl-btn-outline-padding, 12px 28px);
    min-width: var(--tpl-btn-outline-min-width, auto);
    max-width: var(--tpl-btn-outline-max-width, none);
}
.hero-btn-outline:hover {
    opacity: 0.85;
}

/* Hero Button Edit Controls */
.hero-btn-controls {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}
.edit-mode .hero-btn-wrap:hover .hero-btn-controls { opacity: 1; }

.btn-add-hero-btn {
    background: rgba(255,255,255,0.2);
    color: inherit;
    border: 2px dashed currentColor;
    padding: 8px 20px;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 6px;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.btn-add-hero-btn:hover { opacity: 1; }

/* Hero settings toolbar - now in editor-controls */

/* Scroll Effects */
.scroll-fixed {
    position: sticky;
    top: 0;
    z-index: 0;
}
.edit-mode .scroll-fixed {
    position: relative; /* Disable sticky in edit mode to avoid layout issues */
}

.scroll-parallax {
    overflow: hidden;
}

/* Slide-up entrance animation (for future scroll-animate class) */
.scroll-animate {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
.scroll-animate.hero-visible {
    opacity: 1;
    transform: translateY(0);
}

@keyframes heroSlideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 768px) {
    .hero-content h1 { font-size: 1.8rem; }
    .hero-content p { font-size: 1rem; }
    .hero-btn { padding: 10px 20px; font-size: 0.9rem; }
}

/* =========================================
   HERO MULTI-SLIDE & TRANSITIONS
   ========================================= */
.hero-slides-container {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 0;
}

.hero-slide {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.hero-slide-active {
    opacity: 1;
    pointer-events: auto;
    z-index: 1;
}

/* Edit mode: instant slide switching (no transition animations) */
.edit-mode .hero .hero-slide {
    transition: none !important;
    transform: none !important;
}
.edit-mode .hero[data-transition="slide"] .hero-slide:not(.hero-slide-active) {
    opacity: 0;
}

/* Fade transition */
.hero[data-transition="fade"] .hero-slide {
    transition: opacity 0.8s ease;
}

/* Slide (horizontal) transition */
.hero[data-transition="slide"] .hero-slide {
    opacity: 1;
    transform: translateX(100%);
    transition: transform 0.8s ease;
}
.hero[data-transition="slide"] .hero-slide-active {
    transform: translateX(0);
}
.hero[data-transition="slide"] .hero-slide-exit {
    transform: translateX(-100%);
    z-index: 1;
}

/* Zoom transition */
.hero[data-transition="zoom"] .hero-slide {
    transform: scale(1.1);
    transition: opacity 0.8s ease, transform 0.8s ease;
}
.hero[data-transition="zoom"] .hero-slide-active {
    transform: scale(1);
}

/* Video background */
.hero-bg-video {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    z-index: 0;
}

/* Dot navigation */
.hero-dots {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10;
}

.hero-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.8);
    background: transparent;
    cursor: pointer;
    padding: 0;
    transition: background 0.3s, border-color 0.3s;
}

.hero-dot:hover {
    background: rgba(255, 255, 255, 0.5);
}

.hero-dot-active {
    background: rgba(255, 255, 255, 0.9);
    border-color: #fff;
}

/* Editor: Hero slide manager items */
.hero-manage-item {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    overflow: hidden;
    margin-bottom: 8px;
}
.hero-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s;
}
.hero-item-header:hover {
    background: #f8fafc;
}
.hero-item-body {
    display: none;
    padding: 12px;
    border-top: 1px solid #f1f5f9;
    background: #f8fafc;
}
.hero-manage-item.hero-expanded .hero-item-body {
    display: block;
}
.hero-drag-handle {
    cursor: grab;
    color: #94a3b8;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.hero-slide-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: #1e293b;
    flex-grow: 1;
}
.hero-slide-badge {
    font-size: 0.75rem;
    color: #64748b;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
}
.hero-slide-preview {
    width: 40px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.hero-video-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: #f1f5f9;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #475569;
    margin-top: 6px;
}
.hero-video-preview video {
    width: 80px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
}

/* =========================================
   TEXT WIDGET
   ========================================= */
.text-widget {
    position: relative;
    box-sizing: border-box;
}

.text-columns {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    align-items: stretch;
}

.text-column {
    box-sizing: border-box;
    min-height: 40px;
}

.text-column .rich-text {
    outline: none;
    line-height: 1.7;
    word-wrap: break-word;
}

.text-column .rich-text:focus {
    background: rgba(37, 99, 235, 0.03);
    border-radius: 4px;
}

.text-column .rich-text:empty::before {
    content: 'Type here...';
    color: #cbd5e1;
    pointer-events: none;
}

/* Rich text toolbar */
.rich-text-toolbar {
    position: sticky;
    top: 60px;
    z-index: 100;
    background: #1e293b;
    border-radius: 8px;
    padding: 6px 10px;
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.rte-btn {
    background: none;
    border: none;
    color: #cbd5e1;
    padding: 5px 8px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
}

.rte-btn:hover { background: rgba(255,255,255,0.15); color: white; }
.rte-btn.active { background: rgba(255,255,255,0.2); color: white; }

.rte-separator {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.15);
    margin: 0 4px;
}

.rte-select {
    background: #334155;
    border: 1px solid #475569;
    color: #cbd5e1;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    height: 28px;
}

.rte-color-input {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 2px solid #475569;
    border-radius: 4px;
    cursor: pointer;
    background: none;
}


/* =========================================
   SERVICES WIDGET
   ========================================= */
.services-widget {
    position: relative;
    overflow: hidden;
}

.services-viewport {
    overflow: hidden;
}

.services-track {
    display: flex;
    transition: transform 0.5s ease;
}

.service-card {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    flex: 1;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s, box-shadow 0.3s;
}
.service-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
}

.service-card-icon {
    display: flex;
    justify-content: center;
    align-items: center;
}

.service-card-title {
    font-weight: 700;
    text-align: center;
}

.service-card-text {
    text-align: center;
    flex-grow: 1;
    line-height: 1.6;
    color: var(--tpl-text, #64748b);
}

.service-card-btn-wrap {
    text-align: center;
}

.service-card-btn {
    display: inline-block;
    text-decoration: none;
    text-align: center;
    font-weight: var(--tpl-btn-primary-weight, 600);
    cursor: pointer;
    transition: opacity 0.2s;
    padding: var(--tpl-btn-primary-padding, 10px 24px);
    border: none;
    min-width: var(--tpl-btn-primary-min-width, auto);
    max-width: var(--tpl-btn-primary-max-width, none);
}

.service-card-btn:hover {
    opacity: 0.85;
}

/* Carousel arrows */
.services-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.services-widget:hover .services-arrow {
    opacity: 1;
}

.services-arrow-left { left: 12px; }
.services-arrow-right { right: 12px; }
.services-arrow:hover { background: rgba(0,0,0,0.7); }

/* Services settings toolbar - now in editor-controls */

/* Responsive */
@media (max-width: 768px) {
    .services-track {
        flex-wrap: nowrap;
    }
    .service-card-title { font-size: 1rem !important; }
    .service-card-text { font-size: 0.85rem !important; }
    .services-arrow { opacity: 1; }
}

.editable:focus {
    outline: none;
    background: rgba(37, 99, 235, 0.05);
    box-shadow: 0 0 0 2px var(--primary);
    border-radius: 4px;
}

.login-trigger {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    padding: 8px 16px;
    border-radius: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    text-decoration: none;
    color: var(--tpl-text, #555);
    transition: all 0.2s;
    font-size: 0.8rem;
    z-index: 1000;
}
.login-trigger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* =========================================
   TABBED SETTINGS MODAL
   ========================================= */
.cms-tabs {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    padding: 0 16px;
}

.cms-tab {
    background: none;
    border: none;
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.cms-tab:hover { color: #1e293b; }
.cms-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.cms-tab-content {
    display: none;
}

.cms-tab-content.active {
    display: block;
}

/* =========================================
   EDIT TOGGLE BUTTON (floating pencil)
   ========================================= */
.edit-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    transition: all 0.2s;
    z-index: 1000;
}

.edit-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

/* =========================================
   WIDGET PICKER MODAL
   ========================================= */
.widget-picker-overlay { position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.5); z-index:3000; display:flex; justify-content:center; align-items:center; }
.widget-picker { background:white; border-radius:12px; padding:24px; width:480px; max-width:90%; box-shadow:0 10px 25px rgba(0,0,0,0.2); }
.widget-picker h3 { margin:0 0 16px; font-size:1.1rem; color:#1e293b; }
.widget-picker-grid { display:grid; grid-template-columns:1fr 1fr 1fr; gap:8px; }
.widget-picker-divider { grid-column:1/-1; font-size:0.7rem; font-weight:700; text-transform:uppercase; letter-spacing:0.5px; color:#94a3b8; padding:8px 0 4px; margin-top:4px; border-top:1px solid #e2e8f0; }
.widget-picker-item { padding:12px; border:1px solid #e2e8f0; border-radius:8px; cursor:pointer; text-align:center; font-weight:600; font-size:0.85rem; color:#334155; transition:all 0.15s; background:none; }
.widget-picker-item:hover { background:var(--primary); color:white; border-color:var(--primary); }
.widget-picker-item[draggable="true"] { cursor: grab; }
.widget-picker-item[draggable="true"]:active { cursor: grabbing; }

/* =========================================
   FLOATING LIVE TOGGLE BUTTON (green circle)
   ========================================= */
.live-toggle-btn { position:fixed; bottom:20px; right:20px; width:44px; height:44px; background:#059669; color:white; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:1.2rem; text-decoration:none; box-shadow:0 4px 12px rgba(5,150,105,0.3); transition:all 0.2s; z-index:1000; }
.live-toggle-btn:hover { transform:translateY(-2px); box-shadow:0 6px 16px rgba(5,150,105,0.4); }

/* =========================================
   IP TABLE (settings modal)
   ========================================= */
.ip-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.ip-table th {
    text-align: left;
    padding: 6px 8px;
    background: #f1f5f9;
    font-weight: 600;
    color: #475569;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ip-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #f1f5f9;
}

.ip-table tr:hover td { background: #f8fafc; }

/* =========================================
   GRID WIDGET
   ========================================= */
.grid-widget {
    position: relative;
}

.grid-container {
    min-height: 60px;
}

.grid-cell {
    position: relative;
    border-radius: 4px;
    min-height: 40px;
}

.edit-mode .grid-cell-drop {
    min-height: 60px;
    border: 2px dashed #e2e8f0;
    border-radius: 6px;
    transition: border-color 0.2s, background 0.2s;
}

.edit-mode .grid-cell-drop:hover {
    border-color: #cbd5e1;
    background: rgba(37, 99, 235, 0.02);
}

.edit-mode .grid-cell-drop.sortable-drag-over {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

/* "Drop widgets here" hint — CSS pseudo-element so it never interferes
   with drag/drop, auto-hides when cell has widgets, auto-shows when empty */
.edit-mode .grid-cell-drop::before {
    content: "Drop widgets here";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
    font-size: 0.85rem;
    font-style: italic;
    pointer-events: none;
    z-index: 0;
}
.edit-mode .grid-cell-drop:has(.widget-wrapper)::before {
    display: none;
}

.grid-cell .widget-wrapper {
    margin: var(--grid-widget-spacing, 0) 0;
    position: relative;
    z-index: 1;
}

.edit-mode .grid-cell .widget-wrapper {
    margin: max(var(--grid-widget-spacing, 0), 4px) 0;
}
.edit-mode .grid-cell .widget-wrapper:first-child {
    margin-top: 0;
}
.edit-mode .grid-cell .widget-wrapper:last-child {
    margin-bottom: 0;
}

/* Drag: collapsed state */
#widget-container.dragging {
    position: relative;
}
#widget-container.dragging .widget-content {
    display: none;
}
#widget-container.dragging .editor-controls {
    display: none !important;
}
#widget-container.dragging .widget-wrapper {
    padding: 14px 20px;
    background: white;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px;
    margin: 6px 0;
}
#widget-container.dragging .widget-wrapper::before {
    content: attr(data-type);
    text-transform: capitalize;
    font-weight: 600;
    color: #94a3b8;
    font-size: 0.85rem;
}
#widget-container.dragging .sortable-ghost {
    background: #eff6ff !important;
    border: 2px dashed var(--primary) !important;
}
#widget-container.dragging .sortable-ghost::before {
    color: var(--primary);
}

/* Override: Keep grid widgets expanded during drag so cells remain as drop targets */
#widget-container.dragging > .widget-wrapper[data-type="grid"] {
    padding: 0;
    background: transparent;
    border: 2px dashed #cbd5e1 !important;
    border-radius: 8px;
    margin: 20px 0;
}
#widget-container.dragging > .widget-wrapper[data-type="grid"]::before {
    content: "Grid" !important;
    display: block;
    padding: 4px 12px;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 6px 6px 0 0;
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
#widget-container.dragging > .widget-wrapper[data-type="grid"] > .widget-content {
    display: block !important;
}

/* Override: Keep effectbox widgets expanded during drag so cards remain as drop targets */
#widget-container.dragging > .widget-wrapper[data-type="effectbox"] {
    padding: 0;
    background: transparent;
    border: 2px dashed #cbd5e1 !important;
    border-radius: 8px;
    margin: 20px 0;
}
#widget-container.dragging > .widget-wrapper[data-type="effectbox"]::before {
    content: "Effect Box" !important;
    display: block;
    padding: 4px 12px;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 6px 6px 0 0;
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
#widget-container.dragging > .widget-wrapper[data-type="effectbox"] > .widget-content {
    display: block !important;
}

/* Hero drop target: small box appended outside .widget-content, visible only during drag */
.hero-drop-target {
    display: none !important;
}
#widget-container.dragging > .widget-wrapper[data-type="hero"] .hero-drop-target {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    margin: 4px 8px 8px;
    border: 2px dashed #94a3b8;
    border-radius: 6px;
    background: rgba(37, 99, 235, 0.03);
    color: #64748b;
    font-size: 0.8rem;
    position: relative;
    z-index: 10;
}
#widget-container.dragging > .widget-wrapper[data-type="hero"] .hero-drop-target[data-slot-empty="0"] {
    border-color: #e2e8f0;
    color: #cbd5e1;
}
.hero-drop-target.hero-drop-hover {
    border-color: var(--primary) !important;
    background: rgba(37, 99, 235, 0.1) !important;
    color: var(--primary) !important;
}

/* Collapse widgets inside effectbox cards during drag (but keep cards visible) */
#widget-container.dragging .effectbox-card-drop .widget-content {
    display: none;
}
#widget-container.dragging .effectbox-card-drop .widget-wrapper {
    padding: 8px 12px;
    margin: 4px 0;
}
#widget-container.dragging .effectbox-card-drop .widget-wrapper::before {
    font-size: 0.75rem;
}

/* Make effectbox cards look like inviting drop targets during drag */
#widget-container.dragging .effectbox-card-drop {
    border-color: #94a3b8 !important;
    background: rgba(37, 99, 235, 0.03);
    min-height: 50px;
    transition: none !important;
}
#widget-container.dragging .effectbox-card-drop::before {
    color: #94a3b8;
}

/* Keep grid widgets expanded inside effectbox cards during drag */
#widget-container.dragging .effectbox-card-drop .widget-wrapper[data-type="grid"] {
    padding: 0 !important;
    background: transparent;
    border: 2px dashed #cbd5e1 !important;
    border-radius: 8px;
    margin: 8px 0;
}
#widget-container.dragging .effectbox-card-drop .widget-wrapper[data-type="grid"]::before {
    content: "Grid" !important;
    display: block;
    padding: 4px 12px;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 6px 6px 0 0;
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
#widget-container.dragging .effectbox-card-drop .widget-wrapper[data-type="grid"] > .widget-content {
    display: block !important;
}

/* Collapse widgets inside grid cells during drag (but keep cells visible) */
#widget-container.dragging .grid-cell .widget-content {
    display: none;
}
#widget-container.dragging .grid-cell .widget-wrapper {
    padding: 8px 12px;
    margin: 4px 0;
}
#widget-container.dragging .grid-cell .widget-wrapper::before {
    font-size: 0.75rem;
}

/* Make grid cells look like inviting drop targets during drag */
#widget-container.dragging .grid-cell-drop {
    border-color: #94a3b8 !important;
    background: rgba(37, 99, 235, 0.03);
    min-height: 50px;
    transition: none !important;
}
/* Lock grid rows to auto sizing during drag — prevents 1fr equal-height
   redistribution from amplifying layout shifts into oscillation */
#widget-container.dragging .grid-container {
    grid-template-rows: none !important;
    grid-auto-rows: minmax(50px, auto);
}
#widget-container.dragging .grid-cell-drop::before {
    color: #94a3b8;
}

/* Drop indicator line (harmonica insertion point) — absolutely positioned
   so it never causes layout shifts during drag */
.widget-drop-indicator {
    position: absolute;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary);
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(37, 99, 235, 0.5);
    pointer-events: none;
    z-index: 100;
}

/* Grid cell hover during picker drag */
.grid-cell-drop-hover {
    background: rgba(37, 99, 235, 0.08) !important;
    border-color: var(--primary) !important;
}

/* Grid Cell Layout: Column width resize bar */
.col-widths-bar {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
    height: 36px;
}
.col-width-label {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
    background: #f8fafc;
    user-select: none;
}
.col-resize-handle {
    width: 8px;
    flex-shrink: 0;
    height: 100%;
    cursor: col-resize;
    background: #cbd5e1;
    transition: background 0.15s;
    position: relative;
}
.col-resize-handle:hover,
.col-resize-handle:active {
    background: var(--primary);
}

/* Grid Cell Layout: Selection & merge toolbar */
.grid-preview-cell.selected {
    outline: 2px solid var(--primary) !important;
    outline-offset: -2px;
    background: #dbeafe !important;
}
.grid-merge-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.grid-merge-toolbar button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Responsive grid */
@media (max-width: 768px) {
    .grid-container {
        grid-template-columns: 1fr !important;
    }
    .grid-cell {
        grid-column: auto !important;
        grid-row: auto !important;
    }
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Reusable Modal */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 3000;
    display: flex; justify-content: center; align-items: center;
}
.modal-content {
    background: white; padding: 20px; border-radius: 8px;
    width: 400px; max-width: 90%;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.modal-content h3 { margin-top: 0; }
.modal-list {
    max-height: 400px; overflow-y: auto;
    border: 1px solid #eee; margin: 10px 0;
}
.modal-item {
    padding: 10px; border-bottom: 1px solid #eee;
    cursor: pointer; display: flex; justify-content: space-between;
}
.modal-item:hover { background: #f3f4f6; color: var(--primary); }
.modal-close { margin-top: 10px; width: 100%; padding: 10px; cursor: pointer; }

/* Reuse modal: page groups */
.reuse-page-group {
    border-bottom: 1px solid #f1f5f9;
}
.reuse-page-group:last-child {
    border-bottom: none;
}
.reuse-page-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}
.reuse-page-header:hover {
    background: #f8fafc;
}
.reuse-page-header strong {
    font-size: 0.9rem;
    color: #1e293b;
}
.reuse-page-arrow {
    font-size: 0.65rem;
    color: #94a3b8;
    transition: transform 0.2s;
    flex-shrink: 0;
}
/* Reuse modal: widget items with preview */
.reuse-widget-item {
    padding: 10px 12px 10px 32px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.15s;
}
.reuse-widget-item:last-child {
    border-bottom: none;
}
.reuse-widget-item:hover {
    background: #f0f4ff;
}
.reuse-widget-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.85rem;
}
.reuse-widget-preview {
    width: 100%;
    height: 100px;
    overflow: hidden;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: #fff;
    position: relative;
}
.reuse-preview-inner {
    transform: scale(0.25);
    transform-origin: top left;
    width: 400%;
    height: 400%;
    pointer-events: none;
    overflow: hidden;
}
/* Hide editor-only elements inside previews */
.reuse-preview-inner .editor-controls,
.reuse-preview-inner .btn-add-hero-btn,
.reuse-preview-inner .hero-btn-controls,
.reuse-preview-inner .btn-add-link,
.reuse-preview-inner .rich-text-toolbar {
    display: none !important;
}

/* =========================================
   CONTACT FORM WIDGET
   ========================================= */
.contact-widget {
    padding: 30px 20px;
}

.contact-form-container {
    max-width: 600px;
    margin: 0 auto;
}

.contact-form-title {
    font-size: var(--tpl-font-lg, 1.5rem);
    font-weight: 700;
    margin: 0 0 24px 0;
    color: var(--tpl-text, #1e293b);
}

.contact-field-group {
    margin-bottom: 18px;
}

.contact-label {
    display: block;
    font-size: var(--tpl-font-md, 0.9rem);
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--tpl-text, #374151);
}

.contact-required {
    color: #dc2626;
    margin-left: 2px;
}

.contact-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: var(--tpl-font-md, 0.95rem);
    font-family: inherit;
    color: var(--tpl-text, #374151);
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    background: #fff;
}

.contact-input:focus {
    outline: none;
    border-color: var(--tpl-primary, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.contact-textarea {
    resize: vertical;
    min-height: 100px;
}

.contact-radio-group,
.contact-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 0;
}

.contact-radio-label,
.contact-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--tpl-font-md, 0.9rem);
    color: var(--tpl-text, #374151);
    cursor: pointer;
}

.contact-radio-label input,
.contact-checkbox-label input {
    margin: 0;
    accent-color: var(--tpl-primary, #2563eb);
}

.contact-submit-btn {
    display: block;
    margin-left: auto;
    margin-right: auto;
    width: fit-content;
    padding: var(--tpl-btn-primary-padding, 12px 24px);
    border: none;
    border-radius: var(--tpl-btn-primary-radius, 8px);
    font-size: var(--tpl-btn-primary-size, 1rem);
    font-weight: var(--tpl-btn-primary-weight, 600);
    min-width: var(--tpl-btn-primary-min-width, 0);
    max-width: var(--tpl-btn-primary-max-width, none);
    cursor: pointer;
    transition: opacity 0.2s;
    margin-top: 8px;
    font-family: inherit;
}

.contact-submit-btn:hover {
    opacity: 0.9;
}

.contact-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.contact-field-error {
    color: #dc2626;
    font-size: 0.8rem;
    margin-top: 4px;
    min-height: 0;
}

.contact-form-message {
    padding: 0;
    margin: 0;
    border-radius: 8px;
    font-size: var(--tpl-font-md, 0.9rem);
    text-align: center;
    transition: all 0.3s;
}

.contact-form-message.contact-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    padding: 12px 16px;
    margin-bottom: 12px;
}

.contact-form-message.contact-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 12px 16px;
    margin-bottom: 12px;
}

.contact-help-text {
    font-size: 0.8rem;
    color: #9ca3af;
    margin-top: 4px;
}

.contact-file-input {
    padding: 8px;
    font-size: var(--tpl-font-md, 0.85rem);
}

.contact-pdf-group {
    margin-bottom: 18px;
}

/* Contact Editor Styles */
.contact-field-item {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 8px;
    background: #fff;
}

.contact-field-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
}

.contact-drag-handle {
    cursor: grab;
    color: #94a3b8;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.contact-field-type-badge {
    background: #e0e7ff;
    color: #3730a3;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.contact-field-label-text {
    flex-grow: 1;
    font-size: 0.9rem;
    font-weight: 500;
    color: #1e293b;
}

.contact-field-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.contact-field-editor {
    padding: 12px;
    border-top: 1px solid #f1f5f9;
    background: #f8fafc;
}

/* Editor language toggle */
.btn-lang { padding:4px 10px; font-size:12px; font-weight:700; border:1px solid rgba(255,255,255,0.3); border-radius:4px; background:transparent; color:rgba(255,255,255,0.7); cursor:pointer; }
.btn-lang-active { background:#22c55e; color:#fff; border-color:#22c55e; }

/* Menu actions bar (language, cart, user icons) */
.menu-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
}
.menu-action-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s, background 0.2s;
    background: none;
    border: none;
    font-size: inherit;
    padding: 0;
}
.menu-action-icon:hover {
    opacity: 1;
    background: rgba(0,0,0,0.06);
}
.menu-action-icon .material-symbols-outlined { font-size: 22px; }

/* Language dropdown */
.menu-lang-dropdown { position: relative; }
.menu-lang-panel {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    min-width: 120px;
    padding: 4px 0;
    z-index: 1000;
}
.menu-lang-dropdown.open .menu-lang-panel { display: block; }
.lang-option {
    display: block;
    padding: 8px 16px;
    text-decoration: none;
    color: #334155;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s;
}
.lang-option:hover { background: #f1f5f9; }
.lang-option-active { color: #2563eb; font-weight: 700; }

/* Cart badge */
.menu-cart-badge {
    position: absolute;
    top: -2px;
    right: -4px;
    background: #dc2626;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    padding: 0 4px;
}

/* User icon: green when logged in */
.menu-user-icon.logged-in {
    color: #22c55e;
    opacity: 0.9;
}

@media (max-width:768px) {
    .menu-actions {
        margin: auto 0 0 0;
        padding-top: 24px;
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
        justify-content: center;
        width: 100%;
        gap: 8px;
    }
    .menu-actions .menu-action-icon {
        color: inherit;
        opacity: 0.7;
    }
    .menu-actions .menu-action-icon:hover { opacity: 1; }
    /* On mobile, language dropdown opens upward */
    .menu-actions .menu-lang-panel {
        top: auto;
        bottom: 100%;
        margin-top: 0;
        margin-bottom: 6px;
        right: auto;
        left: 50%;
        transform: translateX(-50%);
    }
}

/* =========================================
   GALLERY IMAGE PROCESSING SETTINGS
   ========================================= */
.gallery-processing-group {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
}

.gallery-slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 2px;
}

.gallery-watermark-preview {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 4px;
    background: repeating-conic-gradient(#f0f0f0 0% 25%, #fff 0% 50%) 50% / 12px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* =========================================
   GALLERY LIGHTBOX (Photo Strip + Slideshow)
   ========================================= */
#galleryLightbox {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: #000000;
    z-index: 9999;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    user-select: none;
}

/* Close button */
.lb-close {
    position: absolute;
    top: 20px; right: 20px;
    background: none; border: none;
    color: white;
    font-size: 40px;
    cursor: pointer;
    z-index: 10;
    opacity: 1;
    transition: opacity 0.4s;
}

/* Main image area */
.lb-content {
    position: relative;
    width: 90%; height: 70%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Crossfade images */
.lb-image {
    position: absolute;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    opacity: 0;
    transition: opacity 0.5s;
}
.lb-image.lb-image-active {
    opacity: 1;
}

/* Caption */
.lb-caption {
    color: white;
    font-size: 1.1rem;
    text-align: center;
    width: 80%;
    font-weight: 300;
    padding: 12px 0 8px;
    opacity: 1;
    transition: opacity 0.4s;
}

/* Strip bar (bottom) */
.lb-strip-bar {
    display: flex;
    align-items: center;
    width: 100%;
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 0;
    position: absolute;
    bottom: 0; left: 0;
    opacity: 1;
    transition: opacity 0.4s;
}

/* Strip arrows */
.lb-strip-arrow {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 4px 16px;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.lb-strip-arrow:hover {
    opacity: 1;
}

/* Play/Pause button (centered on screen) */
.lb-play-pause {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: white;
    font-size: 28px;
    cursor: pointer;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    opacity: 0.85;
    transition: opacity 0.4s, background 0.2s, transform 0.2s;
}
.lb-play-pause:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.8);
    transform: translate(-50%, -50%) scale(1.08);
}

/* Strip scroll container */
.lb-strip-scroll {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    flex: 1;
    padding: 4px 8px;
    scrollbar-width: none;
    align-items: center;
    justify-content: center;
}
.lb-strip-scroll::-webkit-scrollbar {
    display: none;
}

/* Strip thumbnails */
.lb-strip-thumb {
    height: 60px;
    width: auto;
    aspect-ratio: auto;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    opacity: 0.6;
    transition: opacity 0.2s, border-color 0.2s;
    flex-shrink: 0;
}
.lb-strip-thumb:hover {
    opacity: 1;
}
.lb-strip-thumb.active {
    border-color: white;
    opacity: 1;
}

/* Photo frame effect */
#galleryLightbox.lb-photoframe .lb-image {
    border: 12px solid #fff;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}

/* Idle state: hide controls */
#galleryLightbox.lb-idle .lb-strip-bar,
#galleryLightbox.lb-idle .lb-close,
#galleryLightbox.lb-idle .lb-caption,
#galleryLightbox.lb-idle .lb-play-pause {
    opacity: 0;
    pointer-events: none;
}
/* Always show captions during slideshow */
#galleryLightbox.lb-always-captions.lb-idle .lb-caption {
    opacity: 1;
    pointer-events: auto;
}

/* Responsive */
@media (max-width: 768px) {
    .lb-content {
        width: 100%;
        height: 65%;
    }
    .lb-image {
        max-width: calc(100% - 24px);
        box-sizing: border-box;
    }
    .lb-strip-thumb {
        height: 44px;
    }
    .lb-close {
        top: 10px;
        right: 10px;
        font-size: 32px;
    }
    .lb-strip-arrow {
        padding: 10px 16px;
        min-height: 44px;
    }
}

/* =========================================
   EMPLOYEE WIDGET
   ========================================= */

/* --- Cards --- */
.emp-card {
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
}
.emp-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
}

.emp-image-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #f1f5f9;
}
.emp-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s;
}
.emp-card:hover .emp-image {
    transform: scale(1.05);
}
.emp-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
}

.emp-info {
    padding: 20px;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.emp-name {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--tpl-heading-color, #1e293b);
}
.emp-title {
    margin: 4px 0 0;
    font-size: 0.9rem;
    color: var(--tpl-text, #64748b);
    flex: 1;
}
.emp-btn {
    display: inline-block;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
    margin-top: 14px;
    align-self: center;
}
.emp-btn:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}

/* --- Mobile carousel (hidden on desktop) --- */
.emp-carousel {
    display: none;
    position: relative;
    overflow: hidden;
}
.emp-carousel-track {
    display: flex;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.emp-carousel-slide {
    flex: 0 0 100%;
    min-width: 0;
}
.emp-carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.4);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.emp-carousel-arrow:hover {
    background: rgba(0, 0, 0, 0.6);
}
.emp-carousel-prev { left: 10px; }
.emp-carousel-next { right: 10px; }
.emp-carousel-indicator {
    text-align: center;
    padding: 12px 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #64748b;
}

@media (max-width: 768px) {
    .emp-grid { display: none !important; }
    .emp-carousel { display: block; }
    .emp-carousel-slide .emp-image-wrap {
        aspect-ratio: 3 / 4;
    }
}

/* --- Bio modal --- */
.emp-bio-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}
.emp-bio-overlay.emp-bio-visible {
    background: rgba(0, 0, 0, 0.6);
}
.emp-bio-modal {
    background: white;
    border-radius: 16px;
    width: 520px;
    max-width: 92%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    position: relative;
    transform: translateY(30px);
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
}
.emp-bio-visible .emp-bio-modal {
    transform: translateY(0);
    opacity: 1;
}
.emp-bio-close {
    position: absolute;
    top: 12px; right: 16px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    font-size: 24px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.emp-bio-close:hover {
    background: rgba(0, 0, 0, 0.7);
}
.emp-bio-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 16px 16px 0 0;
    display: block;
}
.emp-bio-modal-content {
    padding: 0 0 28px;
}
.emp-bio-name {
    margin: 20px 28px 0;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--tpl-heading-color, #1e293b);
}
.emp-bio-title {
    margin: 4px 28px 0;
    font-size: 0.95rem;
    color: var(--tpl-text, #64748b);
    font-weight: 500;
}
.emp-bio-text {
    margin: 20px 28px 0;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--tpl-text, #374151);
}

/* --- Editor: Employee manage items --- */
.emp-manage-item {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    overflow: hidden;
}
.emp-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s;
}
.emp-item-header:hover {
    background: #f8fafc;
}
.emp-item-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: #1e293b;
}
.emp-item-title-badge {
    font-size: 0.75rem;
    color: #64748b;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
}
.emp-item-body {
    display: none;
    padding: 12px;
    border-top: 1px solid #f1f5f9;
    background: #f8fafc;
}
.emp-manage-item.emp-expanded .emp-item-body {
    display: block;
}

/* --- Photo Cropper Modal --- */
.emp-crop-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.25s;
}
.emp-crop-overlay.emp-crop-visible {
    background: rgba(0, 0, 0, 0.7);
}
.emp-crop-modal {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: scale(0.95);
    opacity: 0;
    transition: transform 0.25s, opacity 0.25s;
}
.emp-crop-visible .emp-crop-modal {
    transform: scale(1);
    opacity: 1;
}
.emp-crop-viewport {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    background: #f1f5f9;
    cursor: grab;
}
.emp-crop-viewport:active {
    cursor: grabbing;
}
.emp-crop-image {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    user-select: none;
}

/* Coloris color picker — render above CMS modals */
.clr-picker { z-index: 10000 !important; }
/* Shared: color picker row */
.cms-color-row { display: flex; gap: 8px; align-items: center; }

/* Shared: sortable item card (services, etc.) */
.cms-manage-item {
    display: flex; align-items: center; gap: 8px;
    padding: 12px; margin-bottom: 8px;
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px;
}
.cms-manage-item .cms-drag-handle {
    cursor: grab; color: #94a3b8; font-size: 1.2rem; flex-shrink: 0;
}
.cms-manage-item .cms-delete-btn {
    background: none; border: none; cursor: pointer;
    font-size: 1.1rem; color: #dc2626; padding: 4px; flex-shrink: 0;
}

.cms-color-swatch {
    width: 38px; min-width: 38px;
    align-self: stretch;
    padding: 4px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    box-sizing: border-box;
    cursor: pointer;
}
.cms-color-swatch input {
    width: 100%; height: 100%;
    padding: 0; margin: 0;
    border: 1px solid #999;
    border-radius: 2px;
    cursor: pointer;
    color: transparent;
    font-size: 0;
    display: block;
    box-sizing: border-box;
}

/* Button Styler — reset button */
.btn-styler-reset {
    background: none; border: 1px solid #e2e8f0; border-radius: 3px;
    color: #94a3b8; cursor: pointer; font-size: 0.75rem; padding: 1px 5px;
    line-height: 1; flex-shrink: 0;
}
.btn-styler-reset:hover { color: #dc2626; border-color: #dc2626; }

/* ==========================================
   GRADIENT BUILDER
   ========================================== */
.gradient-preview-bar { position: relative; }
.gradient-stop-marker {
    transition: border-color 0.15s;
    z-index: 2;
}
.gradient-stop-marker:hover, .gradient-stop-marker.selected {
    z-index: 3;
}
/* BG type selector */
.bg-type-btn { transition: all 0.15s; }
.bg-type-btn.active { background: var(--primary) !important; color: #fff !important; border-color: var(--primary) !important; }

/* ==========================================
   IMAGE WIDGET
   ========================================== */

/* Widget display */
.image-widget {
    position: relative;
    width: 100%;
    box-sizing: border-box;
}
.image-widget-inner {
    position: relative;
    line-height: 0;
}
.image-widget-img {
    width: 100%;
    display: block;
    transition: filter 0.2s ease;
}
.image-widget-caption {
    margin: 8px 0 0;
    font-size: 0.85rem;
    color: #64748b;
    text-align: center;
    line-height: 1.4;
}
.image-widget-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 20px;
    border: 2px dashed #e2e8f0;
    border-radius: 8px;
    color: #94a3b8;
    font-size: 0.9rem;
    min-height: 120px;
    cursor: default;
}
/* Image lightbox */
.image-lightbox-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.92);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.image-lightbox-overlay.visible { opacity: 1; }
.image-lightbox-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    cursor: default;
}
.image-lightbox-close {
    position: absolute;
    top: 16px; right: 16px;
    background: none;
    border: none;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    z-index: 1;
}
.image-lightbox-close:hover { opacity: 1; }

/* ── Button Widget ── */
.button-widget { padding: 10px 0; }
.button-widget-btn { display: inline-block; text-decoration: none; text-align: center; cursor: pointer; transition: background 0.2s, color 0.2s; }


/* Collage arrange button — overlay style like hero adjust */
.collage-arrange-btn {
    display: none;
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    background: rgba(0,0,0,0.6);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
}
.edit-mode .collage-arrange-btn { display: block; }
.collage-arrange-btn:hover { background: rgba(0,0,0,0.8); }
.collage-arranging .collage-arrange-btn {
    background: rgba(37,99,235,0.8);
    border-color: rgba(255,255,255,0.5);
}
.collage-cancel-btn {
    display: none;
    position: absolute;
    top: 12px;
    right: 140px;
    z-index: 10;
    background: rgba(0,0,0,0.6);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
}
.collage-cancel-btn:hover { background: rgba(220,38,38,0.7); }
.collage-arranging .collage-cancel-btn { display: block; }

/* Collage resize controls — hidden by default, visible in arrange mode */
.collage-resize-controls {
    position: absolute;
    bottom: 6px;
    right: 6px;
    display: none;
    gap: 2px;
    align-items: center;
    background: rgba(0,0,0,0.7);
    border-radius: 6px;
    padding: 3px 6px;
    z-index: 5;
}
.collage-arranging .collage-resize-controls { display: flex; }
.collage-arranging .gallery-item { transform: none !important; transition: none !important; }
.collage-arranging .gallery-item.sortable-chosen { cursor: grabbing; opacity: 0.8; }
.collage-arranging .gallery-item.sortable-ghost { opacity: 0.3; }
/* Image wrapper — clips zoom/pan overflow within card */
.collage-img-wrap {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    position: relative;
}
/* Unified controls bar — drag + info + reset, floats over image top */
.collage-img-controls {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 6;
    display: none;
    align-items: center;
    gap: 6px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    padding: 4px 8px;
    font-size: 0.7rem;
    white-space: nowrap;
    border-radius: inherit;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}
.collage-arranging .collage-img-controls {
    display: flex;
    cursor: grab;
}
.collage-arranging .collage-img-controls:active { cursor: grabbing; }
.collage-img-info { flex: 1; font-size: 0.7rem; opacity: 0.85; cursor: default; }
.collage-drag-icon {
    font-size: 0.85rem;
    padding: 0 4px;
    user-select: none;
    opacity: 0.8;
    color: var(--tpl-ui-accent, #2563eb);
}
/* Prevent images from being natively dragged outside the gallery */
.collage-img-wrap img { -webkit-user-drag: none; user-select: none; }
.collage-reset-img {
    background: rgba(255,255,255,0.15) !important;
    border: none !important;
    border-radius: 3px !important;
    padding: 2px 8px !important;
    font-size: 0.65rem !important;
    margin-left: auto;
}
.collage-reset-img:hover { background: rgba(255,255,255,0.35) !important; }
/* Image drag cursor in arrange mode */
.collage-arranging .gallery-item img { cursor: move; }
.collage-size-label {
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 28px;
    text-align: center;
    user-select: none;
}
.collage-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 10px;
    padding: 2px 4px;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.15s;
}
.collage-btn:hover { opacity: 1; }

/* ==========================================
   ADVANCED IMAGE EDITOR
   ========================================== */
.img-editor-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.img-editor-overlay.visible {
    opacity: 1;
}
.img-editor-container {
    background: #fff;
    width: 95vw;
    height: 90vh;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0,0,0,0.4);
}
.img-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.img-editor-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #1e293b;
}
.img-editor-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #64748b;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
}
.img-editor-close:hover {
    background: #f1f5f9;
    color: #1e293b;
}
.img-editor-main {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.img-editor-preview {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
        linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    position: relative;
    overflow: hidden;
    padding: 20px;
}
.img-editor-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    transition: filter 0.15s ease;
}
.img-editor-sidebar {
    width: 280px;
    flex-shrink: 0;
    border-left: 1px solid #e2e8f0;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
}
.img-editor-sidebar h4 {
    margin: 0 0 14px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}
.img-adj-group {
    margin-bottom: 14px;
}
.img-adj-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: #475569;
    margin-bottom: 4px;
}
.img-adj-group label span {
    color: #94a3b8;
    font-size: 0.75rem;
}
.img-adj-group input[type="range"] {
    width: 100%;
    margin: 0;
    cursor: pointer;
}
.img-editor-reset-btn {
    width: 100%;
    padding: 8px;
    margin-top: 8px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #475569;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}
.img-editor-reset-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
}
.img-editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}
.img-editor-toolbar button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #475569;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}
.img-editor-toolbar button:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #1e293b;
}
.img-editor-toolbar button.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}
.img-tool-separator {
    width: 1px;
    height: 24px;
    background: #e2e8f0;
    margin: 0 4px;
}
.img-zoom-label {
    font-size: 0.8rem;
    color: #475569;
    min-width: 42px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.img-editor-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

/* ==========================================
   CROP UI
   ========================================== */
.img-crop-container {
    position: absolute;
    inset: 0;
}
.img-crop-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.img-crop-darken {
    position: absolute;
    background: rgba(0,0,0,0.5);
}
.img-crop-box {
    position: absolute;
    border: 2px dashed #fff;
    box-sizing: border-box;
    cursor: move;
    pointer-events: auto;
}
.img-crop-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #fff;
    border: 1px solid #999;
    box-sizing: border-box;
    pointer-events: auto;
}
.img-crop-handle.nw { top: -5px; left: -5px; cursor: nw-resize; }
.img-crop-handle.ne { top: -5px; right: -5px; cursor: ne-resize; }
.img-crop-handle.sw { bottom: -5px; left: -5px; cursor: sw-resize; }
.img-crop-handle.se { bottom: -5px; right: -5px; cursor: se-resize; }
.img-crop-handle.n  { top: -5px; left: 50%; margin-left: -5px; cursor: n-resize; }
.img-crop-handle.s  { bottom: -5px; left: 50%; margin-left: -5px; cursor: s-resize; }
.img-crop-handle.w  { top: 50%; margin-top: -5px; left: -5px; cursor: w-resize; }
.img-crop-handle.e  { top: 50%; margin-top: -5px; right: -5px; cursor: e-resize; }
.img-crop-aspect-bar {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-right: auto;
}
.img-crop-aspect-bar span {
    font-size: 0.8rem;
    color: #64748b;
    margin-right: 4px;
}
.img-crop-aspect-btn {
    padding: 4px 10px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 0.78rem;
    color: #475569;
    cursor: pointer;
}
.img-crop-aspect-btn:hover {
    background: #f1f5f9;
}
.img-crop-aspect-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

/* Save Mode Dialog (Overwrite / Copy / Cancel) */
.img-save-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 10010;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.img-save-dialog-overlay.visible { opacity: 1; }
.img-save-dialog {
    background: #fff;
    border-radius: 12px;
    padding: 24px 28px;
    max-width: 440px;
    width: 90%;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.15);
    text-align: center;
}
.img-save-dialog h4 {
    margin: 0 0 8px;
    font-size: 1.1rem;
    color: #1e293b;
}
.img-save-dialog p {
    margin: 0 0 20px;
    color: #64748b;
    font-size: 0.9rem;
    line-height: 1.4;
}
.img-save-dialog-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* =========================================
   TEMPLATE EDITOR
   ========================================= */

/* Toolbar button */
.btn-template { background: #7c3aed; }
.btn-template:hover { background: #6d28d9; }

/* Modal layout */
.template-editor-modal {
    display: flex;
    flex-direction: column;
}

.template-editor {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Sidebar */
.template-sidebar {
    width: 200px;
    flex-shrink: 0;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    background: #f8fafc;
}

.template-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.template-list-item {
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: #475569;
    transition: all 0.15s;
    margin-bottom: 2px;
}
.template-list-item:hover {
    background: #e2e8f0;
}
.template-list-item.active {
    background: var(--primary);
    color: white;
}

.template-sidebar-actions {
    padding: 8px;
    border-top: 1px solid #e2e8f0;
}

/* Content area */
.template-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.template-tabs {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    padding: 0 16px;
    flex-shrink: 0;
}

.template-tab-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Colors grid */
.tpl-colors-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Footer */
.template-footer {
    padding: 12px 20px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.template-footer-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Button preview */
.tpl-btn-preview {
    font-family: inherit;
    transition: all 0.15s;
}

/* =========================================
   SEO — Toolbar Button & Preview
   ========================================= */
.btn-seo { background: #059669; }
.btn-seo:hover { background: #047857; }

/* =========================================
   AI — Toolbar Button & Spinner
   ========================================= */
.btn-ai {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    min-width: 100px;
}
.btn-ai:hover { opacity: 0.85; }
.ai-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: ai-spin 0.8s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }

.seo-counter { font-size: 0.75rem; color: #6b7280; text-align: right; margin-top: 4px; transition: color 0.2s; }
.seo-preview { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px; font-family: Arial, sans-serif; }
.seo-preview-title { color: #1a0dab; font-size: 1.1rem; line-height: 1.3; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seo-preview-url { color: #006621; font-size: 0.8rem; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seo-preview-desc { color: #545454; font-size: 0.8rem; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* =========================================
   SOCIALS BAR — Fixed Position Bar
   ========================================= */
.socials-bar {
    position: fixed;
    z-index: 999;
    display: flex;
    gap: var(--social-icon-gap, 8px);
    padding: 8px;
    transition: opacity 0.4s, transform 0.4s;
}
.socials-bar:empty { display: none; }
.socials-bar.socials-hidden { opacity: 0; pointer-events: none; }

/* Position variants */
.socials-right-bottom { right: var(--social-offset-h, 20px); bottom: var(--social-offset-v, 20px); }
.socials-right-top { right: var(--social-offset-h, 20px); top: var(--social-offset-v, 20px); }
.socials-left-bottom { left: var(--social-offset-h, 20px); bottom: var(--social-offset-v, 20px); }
.socials-left-top { left: var(--social-offset-h, 20px); top: var(--social-offset-v, 20px); }
.socials-right-center { right: var(--social-offset-h, 20px); top: calc(50% + var(--social-offset-v, 0px)); transform: translateY(-50%); }
.socials-left-center { left: var(--social-offset-h, 20px); top: calc(50% + var(--social-offset-v, 0px)); transform: translateY(-50%); }

/* Auto-hide fade directions */
.socials-right-bottom.socials-hidden  { transform: translateX(20px); }
.socials-right-top.socials-hidden     { transform: translateX(20px); }
.socials-right-center.socials-hidden  { transform: translateY(-50%) translateX(20px); }
.socials-left-bottom.socials-hidden   { transform: translateX(-20px); }
.socials-left-top.socials-hidden      { transform: translateX(-20px); }
.socials-left-center.socials-hidden   { transform: translateY(-50%) translateX(-20px); }

/* Adjust for edit mode toolbar */
body.edit-mode .socials-left-top,
body.edit-mode .socials-right-top { top: calc(var(--toolbar-height) + var(--social-offset-v, 20px)); }
body.edit-mode .socials-right-center { top: calc(50% + var(--toolbar-height) / 2 + var(--social-offset-v, 0px)); }
body.edit-mode .socials-left-center { top: calc(50% + var(--toolbar-height) / 2 + var(--social-offset-v, 0px)); }

/* Direction variants */
.socials-vertical { flex-direction: column; }
.socials-horizontal { flex-direction: row; }

/* Inline mode (in page flow) */
.socials-inline {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--social-icon-gap, 8px);
    padding: 16px;
}

/* Floating mode editor notice */
.socials-floating-notice {
    border: 2px solid #ef4444;
    background: #fef2f2;
    color: #991b1b;
    padding: 14px 20px;
    text-align: center;
    font-size: 0.85rem;
    border-radius: 6px;
}

/* Individual icon */
.social-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--social-icon-size, 32px);
    height: var(--social-icon-size, 32px);
    filter: drop-shadow(0 calc(var(--social-icon-shadow, 0) * 0.5px) calc(var(--social-icon-shadow, 0) * 1px) rgba(0,0,0,0.35));
    border-radius: 50%;
    color: var(--social-icon-color, #334155);
    opacity: 0.85;
    transition: transform 0.2s, opacity 0.2s;
    text-decoration: none;
}
.social-icon:hover {
    transform: scale(1.15);
    opacity: 1;
}
.social-icon svg {
    width: 100%;
    height: 100%;
}

/* Brand colors (only when .socials-colored is on parent) */
.socials-colored .social-icon-facebook  { color: #1877F2; }
.socials-colored .social-icon-instagram { color: #E4405F; }
.socials-colored .social-icon-x         { color: #000000; }
.socials-colored .social-icon-linkedin  { color: #0A66C2; }
.socials-colored .social-icon-youtube   { color: #FF0000; }
.socials-colored .social-icon-tiktok    { color: #000000; }
.socials-colored .social-icon-pinterest { color: #BD081C; }
.socials-colored .social-icon-snapchat  { color: #FFFC00; }
.socials-colored .social-icon-whatsapp  { color: #25D366; }
.socials-colored .social-icon-telegram  { color: #26A5E4; }
.socials-colored .social-icon-github    { color: #181717; }
.socials-colored .social-icon-dribbble  { color: #EA4C89; }
.socials-colored .social-icon-behance   { color: #1769FF; }
.socials-colored .social-icon-vimeo     { color: #1AB7EA; }
.socials-colored .social-icon-discord   { color: #5865F2; }

/* =========================================
   SOCIALS MODAL
   ========================================= */
.socials-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--tpl-editor-font, 'Inter', sans-serif);
}
.socials-modal {
    background: white;
    width: 520px;
    max-width: 95%;
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.socials-modal-header {
    padding: 16px 24px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.socials-modal-header h3 { margin: 0; font-size: 1.1rem; color: #1e293b; }
.socials-modal-close {
    background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #94a3b8;
}
.socials-modal-close:hover { color: #64748b; }
.socials-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}
.socials-modal-footer {
    padding: 16px 24px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-shrink: 0;
}

/* Links list */
.socials-list {
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
}
.socials-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 8px;
    background: #fff;
}
.socials-list-item .drag-handle-social {
    cursor: grab;
    color: #94a3b8;
    font-size: 1.1rem;
    flex-shrink: 0;
    padding: 0 4px;
}
.socials-list-item .social-platform-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    color: #334155;
}
.socials-list-item .social-platform-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}
.socials-list-item .social-platform-name {
    font-weight: 600;
    font-size: 0.8rem;
    color: #334155;
    min-width: 70px;
    flex-shrink: 0;
}
.socials-list-item input[type="url"] {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.85rem;
    min-width: 0;
}
.socials-list-item input[type="url"]:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.1);
}
.socials-list-item .btn-remove-social {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px;
    flex-shrink: 0;
    transition: color 0.15s;
}
.socials-list-item .btn-remove-social:hover { color: #dc2626; }

/* Platform picker grid */
.socials-picker-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}
.socials-picker-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 4px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    background: none;
    transition: all 0.15s;
    font-size: 0.7rem;
    color: #475569;
    font-weight: 500;
}
.socials-picker-item:hover {
    background: #0ea5e9;
    color: white;
    border-color: #0ea5e9;
}
.socials-picker-item svg {
    width: 24px;
    height: 24px;
}
.socials-picker-item.disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* Settings row */
.socials-settings {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}
.socials-setting-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.socials-setting-row label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
    min-width: 80px;
}
.socials-setting-row select,
.socials-setting-row input[type="range"] {
    flex: 1;
}
.socials-setting-row select {
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.85rem;
}
.socials-size-value {
    font-size: 0.8rem;
    color: #64748b;
    min-width: 35px;
    text-align: right;
}

/* Enable toggle */
.socials-enable-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}
.socials-enable-row label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
}
.socials-toggle {
    position: relative;
    width: 44px;
    min-width: 44px;
    height: 24px;
    flex-shrink: 0;
    display: inline-block;
}
.socials-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.socials-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #cbd5e1;
    border-radius: 24px;
    transition: background 0.2s;
}
.socials-toggle-slider:before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}
.socials-toggle input:checked + .socials-toggle-slider {
    background: #22c55e;
}
.socials-toggle input:checked + .socials-toggle-slider:before {
    transform: translateX(20px);
}

/* ============================================
   EFFECT BOX WIDGET
   ============================================ */

/* --- Stacking Mode --- */
.effectbox-widget {
    position: relative;
    width: 100%;
}
.effectbox-stacking {
    position: relative;
}
.effectbox-card {
    position: sticky;
    top: 0;
    width: 100%;
    box-sizing: border-box;
}
.effectbox-card-inner {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    background: var(--tpl-background);
    will-change: transform, filter, opacity;
}

/* --- Sticky Reveal Mode --- */
.effectbox-sticky-wrapper {
    position: relative;
}
.effectbox-sticky-container {
    position: sticky;
    top: 0;
    width: 100%;
    overflow: hidden;
    background: var(--tpl-background);
}
.effectbox-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
    background: var(--tpl-background);
    will-change: transform, opacity;
}

/* --- Editor Mode Overrides --- */
.edit-mode .effectbox-card {
    position: relative !important;
    height: auto !important;
    margin-bottom: 12px;
}
.edit-mode .effectbox-card-inner {
    height: auto;
    min-height: 120px;
    transform: none !important;
    filter: none !important;
    opacity: 1 !important;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    background: var(--tpl-background);
}
.edit-mode .effectbox-sticky-wrapper {
    height: auto !important;
}
.edit-mode .effectbox-sticky-container {
    position: relative !important;
    height: auto !important;
    overflow: visible !important;
}
.edit-mode .effectbox-panel {
    position: relative !important;
    height: auto !important;
    min-height: 120px;
    transform: none !important;
    opacity: 1 !important;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    margin-bottom: 12px;
    background: var(--tpl-background);
}

/* Drop zone empty hint */
.edit-mode .effectbox-card-drop::before {
    content: "Drop widgets here";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
    font-size: 0.85rem;
    font-style: italic;
    pointer-events: none;
    z-index: 0;
}
.edit-mode .effectbox-card-drop:has(.widget-wrapper)::before {
    display: none;
}

/* Child widgets above drop hint */
.effectbox-card-drop .widget-wrapper {
    position: relative;
    z-index: 1;
}

/* Drop hover highlight */
.effectbox-card-drop-hover {
    background: #dbeafe !important;
    border-color: #3b82f6 !important;
}

/* --- Settings Modal: Card List --- */
.effectbox-card-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.effectbox-card-item {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
}
.effectbox-card-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    cursor: default;
}
.effectbox-card-drag-handle {
    cursor: grab;
    color: #94a3b8;
    font-size: 1.1rem;
}
.effectbox-card-toggle {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: #64748b;
    font-size: 0.8rem;
    padding: 2px 6px;
}
.effectbox-card-delete {
    background: none;
    border: none;
    cursor: pointer;
    color: #dc2626;
    font-size: 1rem;
    padding: 2px 6px;
}
.effectbox-card-item-body {
    padding: 12px;
}

/* ===== MEDIA BROWSER ===== */
.media-browser-modal {
    width: 95vw !important;
    height: 90vh;
    max-width: 95vw !important;
    display: flex;
    flex-direction: column;
}
.media-browser-modal .cms-modal-body {
    flex: 1;
    min-height: 0;
    padding: 0 !important;
    display: flex;
    flex-direction: row;
    overflow: hidden;
}
/* Left panel */
.mb-left-panel {
    width: 280px;
    min-width: 280px;
    border-right: 1px solid #e2e8f0;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 4px;
}
.mb-left-section {
    border-top: 1px solid #e2e8f0;
    margin: 8px 0 4px;
    padding-top: 8px;
}
.mb-left-section:first-child {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}
/* Tabs row in left panel */
.media-browser-tabs {
    display: flex;
    gap: 4px;
}
.mb-tab {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    color: #475569;
    transition: all 0.15s;
    text-align: center;
    white-space: nowrap;
}
.mb-tab:hover { background: #f1f5f9; }
.mb-tab.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
/* Search in left panel */
.mb-search {
    width: 100%;
    padding: 7px 10px !important;
    font-size: 0.85rem !important;
    box-sizing: border-box;
    margin-top: 8px;
}
/* Type filter buttons */
.media-browser-type-filter {
    display: flex;
    gap: 4px;
}
.mb-type-btn {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    color: #64748b;
    text-align: center;
}
.mb-type-btn:hover { background: #f1f5f9; }
.mb-type-btn.active {
    background: #1e293b;
    color: #fff;
    border-color: #1e293b;
}
/* Orphan checkbox */
.mb-orphan-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #475569;
    padding: 2px 0;
}
/* Upload button */
.mb-upload-btn {
    width: 100%;
    white-space: nowrap;
    font-size: 0.85rem !important;
    padding: 7px 14px !important;
}
/* Processing options in left panel */
.mb-left-panel .gallery-processing-group {
    margin-bottom: 6px;
}
/* Sub-list area (pages / galleries) */
.mb-sublist {
    flex: 1 1 0;
    min-height: 150px;
    overflow-y: auto;
    margin: 0 -16px;
}
.mb-sidebar-item {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.15s;
}
.mb-sidebar-item:hover { background: #e2e8f0; }
.mb-sidebar-item.active {
    background: #dbeafe;
    color: var(--primary);
    font-weight: 600;
}
.mb-sidebar-item.drag-over {
    background: #bbf7d0;
    outline: 2px dashed #16a34a;
}
.mb-sidebar-count {
    background: #e2e8f0;
    color: #64748b;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 0.75rem;
    font-weight: 600;
}
.mb-sidebar-loading, .mb-sidebar-empty {
    padding: 20px 16px;
    text-align: center;
    color: #94a3b8;
    font-size: 0.85rem;
}
/* Right side: image grid area */
.media-browser-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-y: auto;
    padding: 12px;
}
.media-browser-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    align-content: start;
}
.media-browser-item {
    cursor: pointer;
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.15s;
    overflow: hidden;
    background: #f8fafc;
}
.media-browser-item:hover {
    border-color: #cbd5e1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.media-browser-item.selected {
    border-color: var(--primary);
    background: #eff6ff;
}
.media-browser-item.current {
    outline: 2px dashed #f59e0b;
    outline-offset: -2px;
}
.media-browser-item.dragging {
    opacity: 0.5;
}
.mb-item-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mb-item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.mb-video-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.mb-video-badge {
    position: absolute;
    bottom: 6px;
    left: 6px;
    background: rgba(0,0,0,0.6);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    pointer-events: none;
}
.mb-item-check {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255,255,255,0.85);
    border: 2px solid #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: transparent;
    transition: all 0.15s;
}
.media-browser-item.selected .mb-item-check {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.mb-item-name {
    padding: 4px 6px 0;
    font-size: 0.75rem;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mb-item-meta {
    padding: 0 6px 6px;
    font-size: 0.65rem;
    color: #94a3b8;
}
.media-browser-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 10px;
    font-size: 0.8rem;
    color: #64748b;
}
.mb-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
    font-size: 0.9rem;
}
.mb-load-more {
    font-size: 0.8rem !important;
    padding: 4px 14px !important;
}
/* Delete button */
.mb-delete-btn {
    background: #fff !important;
    color: #dc2626 !important;
    border: 1px solid #fca5a5 !important;
}
.mb-delete-btn:hover:not(:disabled) {
    background: #fef2f2 !important;
    border-color: #dc2626 !important;
}
.mb-delete-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.mb-edit-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
/* Context menu */
.mb-context-menu {
    position: fixed;
    z-index: 100001;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    min-width: 180px;
    overflow: hidden;
}
.mb-ctx-item {
    padding: 8px 14px;
    font-size: 0.8rem;
    color: #334155;
}
.mb-ctx-info {
    border-bottom: 1px solid #f1f5f9;
    line-height: 1.5;
}
.mb-ctx-delete:hover {
    background: #fef2f2;
}
/* Browse library button used in widget settings */
.mb-browse-btn {
    white-space: nowrap;
}

/* ====================================================================
   SHOP ADMIN PANEL
   ==================================================================== */
.shop-admin-overlay {
    position: fixed; inset: 0; z-index: 9990;
    background: rgba(0,0,0,0.5);
    display: flex; opacity: 0; transition: opacity 0.2s;
}
.shop-admin-overlay.visible { opacity: 1; }
.shop-admin-panel {
    display: flex; width: 100%; height: 100%;
    background: #fff;
}
.shop-admin-sidebar {
    width: 220px; background: #0f172a; color: #e2e8f0;
    display: flex; flex-direction: column; flex-shrink: 0;
}
.shop-admin-sidebar-header {
    padding: 20px; font-size: 18px; font-weight: 700;
    border-bottom: 1px solid #1e293b;
    display: flex; align-items: center; gap: 8px;
}
.shop-admin-sidebar-header span { color: #10b981; }
.shop-admin-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.shop-admin-nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px; color: #94a3b8; text-decoration: none;
    font-size: 14px; transition: all 0.15s;
}
.shop-admin-nav a:hover { color: #e2e8f0; background: #1e293b; }
.shop-admin-nav a.active { color: #fff; background: #10b981; }
.shop-admin-nav a .nav-icon { width: 18px; text-align: center; }
.shop-admin-close {
    margin: 16px 20px; padding: 10px;
    background: #1e293b; border: none; border-radius: 6px;
    color: #94a3b8; cursor: pointer; font-size: 13px;
}
.shop-admin-close:hover { background: #334155; color: #fff; }
.shop-admin-content {
    flex: 1; overflow-y: auto; padding: 28px 32px;
    background: #f8fafc;
}
.shop-admin-content h2 {
    font-size: 22px; font-weight: 700; color: #0f172a; margin-bottom: 20px;
}

/* Shop admin cards */
.sa-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.sa-stat-card {
    background: #fff; border-radius: 8px; padding: 20px;
    border: 1px solid #e2e8f0;
}
.sa-stat-card .label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: #64748b; margin-bottom: 4px; }
.sa-stat-card .value { font-size: 28px; font-weight: 700; color: #0f172a; }
.sa-stat-card .sub { font-size: 12px; color: #94a3b8; margin-top: 4px; }

/* Shop admin tables */
.sa-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; border: 1px solid #e2e8f0; }
.sa-table th { background: #f8fafc; text-align: left; padding: 10px 14px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: #64748b; font-weight: 600; border-bottom: 1px solid #e2e8f0; }
.sa-table td { padding: 10px 14px; border-bottom: 1px solid #f1f5f9; font-size: 14px; color: #334155; }
.sa-table tr:last-child td { border-bottom: none; }
.sa-table tr:hover td { background: #f8fafc; }
.ba-ev-row:hover, .ba-res-row:hover { background: #f0f4ff !important; }
.sa-table .sa-thumb { width: 40px; height: 40px; border-radius: 4px; object-fit: cover; background: #f1f5f9; }

/* Shop admin buttons */
.sa-btn { padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; border: 1px solid transparent; display: inline-flex; align-items: center; gap: 6px; }
.sa-btn-primary { background: #10b981; color: #fff; }
.sa-btn-primary:hover { background: #059669; }
.sa-btn-secondary { background: #f1f5f9; color: #475569; border-color: #d1d5db; }
.sa-btn-secondary:hover { background: #e2e8f0; }
.sa-btn-danger { background: #dc2626; color: #fff; }
.sa-btn-danger:hover { background: #b91c1c; }
.sa-btn-sm { padding: 5px 10px; font-size: 12px; }

/* Shop admin forms */
.sa-form-group { margin-bottom: 16px; }
.sa-form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: #374151; }
.sa-form-control { width: 100%; padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; background: #fff; box-sizing: border-box; }
.sa-form-control:focus { outline: none; border-color: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,0.1); }
.sa-form-row { display: flex; gap: 16px; }
.sa-form-row .sa-form-group { flex: 1; }
.sa-form-hint { font-size: 12px; color: #94a3b8; margin-top: 4px; }

/* Shop admin toolbar */
.sa-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.sa-search { padding: 8px 14px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; min-width: 250px; }
.sa-search:focus { outline: none; border-color: #10b981; }

/* Shop admin tabs */
.sa-tabs { display: flex; gap: 0; border-bottom: 2px solid #e2e8f0; margin-bottom: 20px; }
.sa-tab { padding: 10px 20px; font-size: 14px; color: #64748b; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; background: none; border-top: none; border-left: none; border-right: none; }
.sa-tab:hover { color: #0f172a; }
.sa-tab.active { color: #10b981; border-bottom-color: #10b981; font-weight: 600; }

/* Shop admin status badges */
.sa-status { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.sa-status-paid, .sa-status-completed, .sa-status-in_stock, .sa-status-active { background: #dcfce7; color: #166534; }
.sa-status-pending, .sa-status-processing, .sa-status-backorder { background: #fef3c7; color: #92400e; }
.sa-status-cancelled, .sa-status-refunded, .sa-status-out_of_stock, .sa-status-inactive { background: #fef2f2; color: #dc2626; }
.sa-status-shipped { background: #dbeafe; color: #1e40af; }
.sa-status-partially_refunded, .sa-status-returned { background: #f3e8ff; color: #7c3aed; }

/* Shop admin modal (for sub-dialogs) */
.sa-modal-overlay {
    position: fixed; inset: 0; z-index: 9995;
    background: rgba(0,0,0,0.4);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.2s;
}
.sa-modal-overlay.visible { opacity: 1; }
.sa-modal {
    background: #fff; border-radius: 10px; width: 90%; max-width: 600px;
    max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    box-sizing: border-box;
}
.sa-modal-header { padding: 16px 20px; border-bottom: 1px solid #e2e8f0; display: flex; justify-content: space-between; align-items: center; }
.sa-modal-header h3 { font-size: 16px; font-weight: 600; }
.sa-modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: #64748b; padding: 0; line-height: 1; }
.sa-modal-body { padding: 20px; overflow-x: hidden; }
.sa-modal-footer { padding: 12px 20px; border-top: 1px solid #e2e8f0; display: flex; justify-content: flex-end; gap: 8px; }

/* Shop admin pagination */
.sa-pagination { display: flex; justify-content: center; gap: 4px; margin-top: 20px; }
.sa-pagination button {
    padding: 6px 12px; border: 1px solid #d1d5db; border-radius: 4px;
    background: #fff; cursor: pointer; font-size: 13px; color: #475569;
}
.sa-pagination button.active { background: #10b981; color: #fff; border-color: #10b981; }
.sa-pagination button:disabled { opacity: 0.4; cursor: default; }

/* Shop admin responsive */
@media (max-width: 700px) {
    /* Modals */
    .sa-modal { width: 96%; max-width: none !important; }
    .sa-modal-body { padding: 16px; }
    .sa-modal-header { padding: 12px 16px; }
    .sa-modal-footer { padding: 10px 16px; }
    /* Form rows stack vertically */
    .sa-form-row { flex-direction: column; gap: 0; }
    .sa-form-row .sa-form-group { max-width: none !important; }
    /* Tabs wrap */
    .sa-tabs { flex-wrap: wrap; gap: 0; }
    .sa-tab { padding: 8px 12px; font-size: 13px; }
    /* Inputs stay within bounds */
    .sa-form-control { box-sizing: border-box; max-width: 100% !important; width: 100% !important; }
    .sa-form-control[style*="width:80px"],
    .sa-form-control[style*="width:120px"],
    .sa-form-control[style*="width:130px"] { width: 100% !important; }
    /* Variation rows */
    .sp-var-row .sa-form-row { gap: 0; }
    /* Order detail inline grids */
    [style*="grid-template-columns:1fr 1fr"],
    [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
    /* Tracking row flex wrap */
    [style*="display:flex;gap:8px"] { flex-wrap: wrap; }
    /* Status select inline */
    .sa-form-control[style*="width:auto"] { width: auto !important; }
}

/* ====================================================================
   SHOP FRONTEND WIDGETS
   ==================================================================== */

/* Product grid */
.shop-grid-widget { padding: 20px 0; }
.shop-grid-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.shop-grid-sort select { padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; }
.shop-grid-count { font-size: 14px; color: #64748b; }
.shop-product-grid {
    display: grid;
    grid-template-columns: repeat(var(--shop-grid-cols, 3), 1fr);
    gap: 24px;
}
.shop-product-card {
    background: #fff; border-radius: 8px; overflow: hidden;
    border: 1px solid #e2e8f0; transition: box-shadow 0.2s;
    cursor: pointer;
}
.shop-product-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
.shop-product-card-img {
    width: 100%; aspect-ratio: var(--shop-grid-aspect, 1);
    object-fit: cover; display: block; background: #f8fafc;
}
.shop-product-card-body { padding: 14px 16px; }
.shop-product-card-name { font-size: 15px; font-weight: 600; color: #0f172a; margin-bottom: 6px; }
.shop-product-card-price { font-size: 16px; font-weight: 700; color: #059669; }
.shop-product-card-compare { font-size: 13px; color: #94a3b8; text-decoration: line-through; margin-left: 8px; }
.shop-product-card-desc { font-size: 13px; color: #64748b; margin-top: 6px; line-height: 1.4; }

/* Product grid pagination */
.shop-grid-pagination { display: flex; justify-content: center; gap: 4px; margin-top: 28px; }
.shop-grid-pagination button {
    padding: 8px 14px; border: 1px solid #d1d5db; border-radius: 6px;
    background: #fff; cursor: pointer; font-size: 14px; color: #475569;
}
.shop-grid-pagination button.active { background: #2563eb; color: #fff; border-color: #2563eb; }

/* Filter widget */
.shop-filter-widget { padding: 16px 0; }
.shop-filter-section { margin-bottom: 20px; }
.shop-filter-section-title { font-size: 14px; font-weight: 600; color: #0f172a; margin-bottom: 10px; }
.shop-filter-option { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; font-size: 14px; color: #475569; }
.shop-filter-option input[type="checkbox"] { accent-color: var(--tpl-ui-accent, #2563eb); }
.shop-filter-count { font-size: 12px; color: #94a3b8; margin-left: auto; }
.shop-filter-swatch {
    width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent;
    cursor: pointer; transition: border-color 0.15s;
}
.shop-filter-swatch.active { border-color: #2563eb; }
.shop-price-range { padding: 8px 0; }
.shop-price-range input[type="range"] { width: 100%; }
.shop-price-range-values { display: flex; justify-content: space-between; font-size: 12px; color: #64748b; margin-top: 4px; }

/* Product detail */
.shop-product-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; padding: 20px 0; }
.shop-product-gallery { position: relative; }
.shop-product-main-img { width: 100%; border-radius: 8px; aspect-ratio: 1; object-fit: cover; background: #f8fafc; }
.shop-product-thumbs { display: flex; gap: 8px; margin-top: 12px; overflow-x: auto; }
.shop-product-thumb {
    width: 64px; height: 64px; border-radius: 4px; object-fit: cover;
    cursor: pointer; border: 2px solid transparent; opacity: 0.6; transition: all 0.15s;
}
.shop-product-thumb.active, .shop-product-thumb:hover { border-color: #2563eb; opacity: 1; }
.shop-product-info h1 { font-size: 28px; font-weight: 700; color: #0f172a; margin-bottom: 8px; }
.shop-product-price-box { margin-bottom: 20px; }
.shop-product-current-price { font-size: 28px; font-weight: 700; color: #059669; }
.shop-product-was-price { font-size: 18px; color: #94a3b8; text-decoration: line-through; margin-left: 12px; }
.shop-product-stock { font-size: 14px; margin-bottom: 16px; }
.shop-product-stock.in-stock { color: #16a34a; }
.shop-product-stock.out-of-stock { color: #dc2626; }
.shop-product-variations { margin-bottom: 20px; }
.shop-product-variation-group { margin-bottom: 12px; }
.shop-product-variation-group label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.shop-product-variation-group select { padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; min-width: 150px; }
.shop-add-to-cart-row { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
.shop-qty-input { width: 60px; padding: 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; text-align: center; }
.shop-add-to-cart-btn {
    padding: 12px 28px; border-radius: 6px; font-size: 16px; font-weight: 600;
    border: none; cursor: pointer; color: #fff; transition: background 0.15s;
}
.shop-add-to-cart-btn:disabled { opacity: 0.5; cursor: default; }
.shop-product-description { margin-top: 24px; line-height: 1.7; color: #475569; font-size: 15px; }

/* Cart sidebar */
.shop-cart-overlay {
    position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,0.4);
    opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.shop-cart-overlay.open { opacity: 1; pointer-events: auto; }
.shop-cart-panel {
    position: fixed; top: 0; right: -420px; width: 400px; max-width: 90vw;
    height: 100vh; background: #fff; z-index: 10000;
    display: flex; flex-direction: column;
    box-shadow: -4px 0 20px rgba(0,0,0,0.1);
    transition: right 0.3s ease;
}
.shop-cart-panel.open { right: 0; }
.shop-cart-header {
    padding: 16px 20px; border-bottom: 1px solid #e2e8f0;
    display: flex; justify-content: space-between; align-items: center;
}
.shop-cart-header h3 { font-size: 18px; font-weight: 600; margin: 0; }
.shop-cart-close { background: none; border: none; font-size: 28px; cursor: pointer; color: #64748b; line-height: 1; padding: 0; }
.shop-cart-items { flex: 1; overflow-y: auto; padding: 16px 20px; }
.shop-cart-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f1f5f9; }
.shop-cart-item-img { width: 64px; height: 64px; border-radius: 6px; object-fit: cover; background: #f8fafc; }
.shop-cart-item-info { flex: 1; }
.shop-cart-item-name { font-size: 14px; font-weight: 600; color: #0f172a; }
.shop-cart-item-variant { font-size: 12px; color: #64748b; }
.shop-cart-item-price { font-size: 14px; color: #059669; font-weight: 600; margin-top: 4px; }
.shop-cart-item-qty { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.shop-cart-item-qty button { width: 28px; height: 28px; border: 1px solid #d1d5db; border-radius: 4px; background: #fff; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; }
.shop-cart-item-qty span { font-size: 14px; min-width: 20px; text-align: center; }
.shop-cart-item-remove { background: none; border: none; color: #dc2626; font-size: 12px; cursor: pointer; margin-top: 4px; padding: 0; }
.shop-cart-footer { padding: 16px 20px; border-top: 1px solid #e2e8f0; background: #f8fafc; }
.shop-cart-total { display: flex; justify-content: space-between; font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.shop-cart-checkout-btn {
    width: 100%; padding: 14px; border-radius: 6px; font-size: 16px; font-weight: 600;
    background: #2563eb; color: #fff; border: none; cursor: pointer;
}
.shop-cart-checkout-btn:hover { background: #1d4ed8; }
.shop-cart-empty { text-align: center; padding: 40px 20px; color: #94a3b8; }
.shop-cart-badge {
    position: fixed; bottom: 24px; right: 24px; z-index: 9998;
    width: 56px; height: 56px; border-radius: 50%;
    background: #2563eb; color: #fff; border: none; cursor: pointer;
    font-size: 24px; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 16px rgba(37,99,235,0.3);
}
.shop-cart-badge-count {
    position: absolute; top: -4px; right: -4px;
    background: #dc2626; color: #fff; font-size: 12px; font-weight: 700;
    min-width: 20px; height: 20px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* Checkout */
.shop-checkout { max-width: 800px; margin: 0 auto; padding: 20px 0; }
.shop-checkout-steps { display: flex; gap: 0; margin-bottom: 32px; border-bottom: 2px solid #e2e8f0; }
.shop-checkout-step {
    padding: 12px 24px; font-size: 14px; font-weight: 500; color: #94a3b8;
    border-bottom: 2px solid transparent; margin-bottom: -2px; cursor: pointer;
}
.shop-checkout-step.active { color: #2563eb; border-bottom-color: #2563eb; }
.shop-checkout-step.completed { color: #16a34a; }
.shop-checkout-section { display: none; }
.shop-checkout-section.active { display: block; }

/* Order confirmed */
.shop-order-confirmed { max-width: 700px; margin: 40px auto; text-align: center; padding: 0 20px; }
.shop-order-confirmed-icon { font-size: 64px; margin-bottom: 16px; }
.shop-order-confirmed h1 { font-size: 28px; color: #0f172a; margin-bottom: 8px; }
.shop-order-confirmed .order-number { font-size: 16px; color: #64748b; margin-bottom: 32px; }

/* Widget editor placeholders */
.shop-widget-placeholder {
    border: 2px dashed #d1d5db; border-radius: 8px;
    padding: 40px 20px; text-align: center; color: #94a3b8;
    background: #f8fafc;
}
.shop-widget-placeholder .icon { font-size: 32px; margin-bottom: 8px; }
.shop-widget-placeholder .label { font-size: 14px; font-weight: 500; }
.shop-widget-placeholder .hint { font-size: 12px; margin-top: 4px; }

/* =========================================
   Location Widget
   ========================================= */
.location-widget { position: relative; width: 100%; }
.location-map { width: 100%; min-height: 150px; background: #e5e7eb; }

/* Responsive */
@media (max-width: 768px) {
    .shop-product-detail { grid-template-columns: 1fr; gap: 24px; }
    .shop-product-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 12px; }
    .shop-admin-sidebar { width: 60px; }
    .shop-admin-nav a span:not(.nav-icon) { display: none; }
    .shop-admin-sidebar-header span:last-child { display: none; }
}
