/**
 * Ekeka Customizer CSS — Modern green SaaS product customizer.
 *
 * Primary: #37B65B   Layout: left preview + right tools
 *
 * @package Ekeka
 */

/* ============================================================
   CSS Custom Properties
   ============================================================ */
:root {
    --ek-primary: #37B65B;
    --ek-primary-hover: #2ea34f;
    --ek-primary-light: #e8f7ed;
    --ek-primary-glow: rgba(55, 182, 91, 0.25);
    --ek-bg: #f5f7fa;
    --ek-surface: #ffffff;
    --ek-text: #1a1a2e;
    --ek-text-muted: #6b7280;
    --ek-border: #e5e7eb;
    --ek-border-light: #f0f1f3;
    --ek-danger: #ef4444;
    --ek-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --ek-shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);
    --ek-shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.1);
    --ek-radius: 10px;
    --ek-radius-lg: 14px;
    --ek-transition: 0.2s ease;
}

/* ============================================================
   Reset
   ============================================================ */
.ekeka-customizer-body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--ek-text);
    background: var(--ek-bg);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    -webkit-font-smoothing: antialiased;
}

.ekeka-customizer-body * {
    box-sizing: border-box;
}

#ekeka-customizer-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* ============================================================
   Header Bar
   ============================================================ */
.ekeka-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    padding: 0 20px;
    background: var(--ek-surface);
    border-bottom: 1px solid var(--ek-border);
    flex-shrink: 0;
    z-index: 100;
}

.ekeka-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.ekeka-logo {
    height: 36px;
    width: auto;
    display: block;
}

.ekeka-header-divider {
    width: 1px;
    height: 28px;
    background: var(--ek-border);
}

.ekeka-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Icon buttons (undo / redo) */
.ekeka-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--ek-border);
    background: var(--ek-surface);
    cursor: pointer;
    border-radius: var(--ek-radius);
    color: var(--ek-text-muted);
    transition: all var(--ek-transition);
}

.ekeka-icon-btn:hover:not(:disabled) {
    background: var(--ek-primary-light);
    color: var(--ek-primary);
    border-color: var(--ek-primary);
}

.ekeka-icon-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.ekeka-header-center {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Variations selector */
.ekeka-variations {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 8px;
}

.ekeka-variation-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid white;
    background-size: cover;
    background-position: center;
    cursor: pointer;
    transition: all var(--ek-transition);
    padding: 0;
    box-shadow: 0 0 0 1px var(--ek-border);
}

.ekeka-variation-btn:hover {
    box-shadow: 0 0 0 1px var(--ek-text-muted);
}

.ekeka-variation-btn.active {
    box-shadow: 0 0 0 2px var(--ek-primary);
    transform: scale(1.05);
}

/* Mode toggle (Edit / Preview) */
.ekeka-mode-toggle {
    display: flex;
    background: var(--ek-bg);
    border-radius: 22px;
    padding: 3px;
    border: 1px solid var(--ek-border);
}

.ekeka-mode-btn {
    padding: 7px 18px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ek-text-muted);
    transition: all var(--ek-transition);
}

.ekeka-mode-btn.active {
    background: var(--ek-primary);
    color: white;
    box-shadow: 0 2px 8px var(--ek-primary-glow);
}

.ekeka-mode-btn:hover:not(.active) {
    color: var(--ek-text);
}

.ekeka-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Primary CTA button */
.ekeka-save-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border: none;
    border-radius: 22px;
    background: var(--ek-primary);
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--ek-transition);
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.ekeka-save-btn:hover {
    background: var(--ek-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--ek-primary-glow);
}

.ekeka-save-btn:active {
    transform: translateY(0);
}

.ekeka-save-btn svg {
    flex-shrink: 0;
}

/* Back button */
.ekeka-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--ek-border);
    background: none;
    cursor: pointer;
    border-radius: var(--ek-radius);
    color: var(--ek-text);
    transition: all var(--ek-transition);
}

.ekeka-back-btn:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: var(--ek-danger);
}

/* ============================================================
   Main Body — Left Preview + Right Tools
   ============================================================ */
.ekeka-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

/* ============================================================
   Canvas Area (Left — main preview)
   ============================================================ */
.ekeka-canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--ek-bg);
    position: relative;
    min-width: 0;
    padding: 16px;
}

.ekeka-canvas-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    min-height: 0;
}

.ekeka-canvas-container {
    position: relative;
    box-shadow: var(--ek-shadow-lg);
    border-radius: var(--ek-radius-lg);
    overflow: hidden;
    background: white;
    max-width: 100%;
}

.ekeka-canvas-container canvas {
    display: block;
}

/* Bottom controls bar (zoom) */
.ekeka-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 0 0;
    flex-shrink: 0;
}

.ekeka-zoom-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--ek-surface);
    border-radius: 22px;
    padding: 5px 12px;
    box-shadow: var(--ek-shadow-sm);
    border: 1px solid var(--ek-border);
}

.ekeka-zoom-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--ek-text);
    border-radius: 50%;
    transition: all var(--ek-transition);
}

.ekeka-zoom-btn:hover {
    background: var(--ek-primary-light);
    color: var(--ek-primary);
}

#zoom-level {
    font-size: 12px;
    font-weight: 600;
    color: var(--ek-text-muted);
    min-width: 40px;
    text-align: center;
}

.ekeka-element-count {
    font-size: 12px;
    color: var(--ek-text-muted);
    background: var(--ek-surface);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--ek-border);
}

/* ============================================================
   Right Panel — Tools + Properties
   ============================================================ */
.ekeka-right-panel {
    width: 300px;
    min-width: 300px;
    background: var(--ek-surface);
    border-left: 1px solid var(--ek-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
}

/* Tool buttons row */
.ekeka-tools-section {
    padding: 16px;
    border-bottom: 1px solid var(--ek-border-light);
}

.ekeka-tools-title {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--ek-text-muted);
    font-weight: 700;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
}

.ekeka-tools-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.ekeka-tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 18px 10px;
    border: 2px dashed var(--ek-border);
    border-radius: var(--ek-radius-lg);
    background: var(--ek-bg);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--ek-text-muted);
    transition: all var(--ek-transition);
}

.ekeka-tool-btn:hover {
    border-color: var(--ek-primary);
    background: var(--ek-primary-light);
    color: var(--ek-primary);
    transform: translateY(-2px);
    box-shadow: var(--ek-shadow-sm);
}

.ekeka-tool-btn:active {
    transform: translateY(0);
}

.ekeka-tool-btn svg {
    stroke: currentColor;
    width: 28px;
    height: 28px;
}

/* Properties sections */
.ekeka-props-section {
    padding: 16px;
    border-bottom: 1px solid var(--ek-border-light);
}

.ekeka-props-title {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--ek-text-muted);
    font-weight: 700;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
}

.ekeka-prop-row {
    margin-bottom: 10px;
}

.ekeka-prop-row label {
    display: block;
    font-size: 12px;
    color: var(--ek-text-muted);
    margin-bottom: 4px;
    font-weight: 500;
}

.ekeka-prop-row-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ekeka-prop-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--ek-border);
    border-radius: var(--ek-radius);
    font-size: 13px;
    font-family: inherit;
    background: var(--ek-surface);
    color: var(--ek-text);
    transition: border-color var(--ek-transition);
}

.ekeka-prop-select:focus {
    border-color: var(--ek-primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--ek-primary-glow);
}

.ekeka-prop-input {
    width: 70px;
    padding: 8px 10px;
    border: 1px solid var(--ek-border);
    border-radius: var(--ek-radius);
    font-size: 13px;
    font-family: inherit;
    text-align: center;
    background: var(--ek-surface);
    transition: border-color var(--ek-transition);
}

.ekeka-prop-input:focus {
    border-color: var(--ek-primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--ek-primary-glow);
}

.ekeka-prop-color {
    width: 38px;
    height: 38px;
    border: 2px solid var(--ek-border);
    border-radius: var(--ek-radius);
    cursor: pointer;
    padding: 2px;
    transition: border-color var(--ek-transition);
}

.ekeka-prop-color:hover {
    border-color: var(--ek-primary);
}

.ekeka-prop-range {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--ek-border);
    border-radius: 2px;
    outline: none;
    margin: 6px 0;
}

.ekeka-prop-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--ek-primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 4px var(--ek-primary-glow);
}

.ekeka-range-value {
    font-size: 12px;
    color: var(--ek-text-muted);
    min-width: 35px;
    text-align: right;
    font-weight: 600;
}

/* Style Buttons (Bold, Italic, Align) */
.ekeka-style-btns {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

.ekeka-style-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--ek-border);
    background: var(--ek-surface);
    cursor: pointer;
    border-radius: var(--ek-radius);
    color: var(--ek-text-muted);
    font-size: 14px;
    transition: all var(--ek-transition);
}

.ekeka-style-btn:hover {
    background: var(--ek-primary-light);
    border-color: var(--ek-primary);
    color: var(--ek-primary);
}

.ekeka-style-btn.active {
    background: var(--ek-primary);
    border-color: var(--ek-primary);
    color: white;
}

.ekeka-style-separator {
    width: 1px;
    height: 24px;
    background: var(--ek-border);
    margin: 0 4px;
}

/* Delete button */
.ekeka-delete-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    width: 100%;
    justify-content: center;
    border: 1px solid #fecaca;
    background: #fef2f2;
    border-radius: var(--ek-radius);
    color: var(--ek-danger);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--ek-transition);
}

.ekeka-delete-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    transform: translateY(-1px);
}

/* ============================================================
   Layers
   ============================================================ */
.ekeka-layers-section {
    border-bottom: none;
}

.ekeka-layers-list {
    max-height: 200px;
    overflow-y: auto;
}

.ekeka-empty-layers {
    text-align: center;
    color: var(--ek-text-muted);
    font-size: 12px;
    padding: 16px 0;
    margin: 0;
}

.ekeka-layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--ek-radius);
    cursor: pointer;
    font-size: 12px;
    color: var(--ek-text);
    transition: background var(--ek-transition);
}

.ekeka-layer-item:hover {
    background: var(--ek-bg);
}

.ekeka-layer-item.active {
    background: var(--ek-primary-light);
    color: var(--ek-primary);
    font-weight: 600;
}

.ekeka-layer-icon {
    color: var(--ek-text-muted);
    flex-shrink: 0;
}

.ekeka-layer-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================
   Toast
   ============================================================ */
.ekeka-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 22px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10000;
    animation: ek-toast-in 0.3s ease;
    max-width: 400px;
    box-shadow: var(--ek-shadow-lg);
}

.ekeka-toast.success {
    background: var(--ek-primary);
    color: white;
}

.ekeka-toast.error {
    background: #dc2626;
    color: white;
}

.ekeka-toast.warning {
    background: #d97706;
    color: white;
}

@keyframes ek-toast-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ============================================================
   Modal (product page iframe)
   ============================================================ */
.ekeka-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999990;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    backdrop-filter: blur(4px);
}

.ekeka-modal-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    background: var(--ek-bg);
}

.ekeka-modal-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.ekeka-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.08);
    color: var(--ek-text);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--ek-transition);
}

.ekeka-modal-close:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--ek-danger);
}

/* ============================================================
   Customize Button (Product Page)
   ============================================================ */
.ekeka-customize-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    border: none;
    border-radius: 26px;
    background: var(--ek-primary);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--ek-transition);
    text-decoration: none;
}

.ekeka-customize-button:hover {
    background: var(--ek-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--ek-primary-glow);
    color: white;
    text-decoration: none;
}

.ekeka-customize-button svg {
    flex-shrink: 0;
}

/* ============================================================
   Responsive — Tablet (≤ 900px)
   ============================================================ */
@media (max-width: 900px) {
    .ekeka-right-panel {
        width: 260px;
        min-width: 260px;
    }

    .ekeka-header {
        padding: 0 12px;
    }

    .ekeka-save-btn {
        padding: 9px 16px;
        font-size: 14px;
    }

    .ekeka-mode-btn {
        padding: 6px 14px;
        font-size: 12px;
    }

    .ekeka-tool-btn {
        padding: 16px 8px;
    }
}

/* ============================================================
   Responsive — Mobile (≤ 640px)
   ============================================================ */
@media (max-width: 640px) {
    .ekeka-body {
        flex-direction: column;
    }

    /* Canvas gets most of the space */
    .ekeka-canvas-area {
        padding: 6px;
        flex: 1;
        min-height: 0;
    }

    .ekeka-canvas-container {
        border-radius: 8px;
    }

    /* Right panel becomes bottom sheet */
    .ekeka-right-panel {
        width: 100%;
        min-width: 100%;
        max-height: 40vh;
        border-left: none;
        border-top: 2px solid var(--ek-border);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Compact header */
    .ekeka-header {
        height: 50px;
        padding: 0 10px;
        gap: 8px;
    }

    .ekeka-header-left {
        gap: 8px;
    }

    .ekeka-logo {
        height: 26px;
    }

    .ekeka-header-divider {
        display: none;
    }

    .ekeka-header-actions {
        gap: 4px;
    }

    /* Hide edit/preview toggle on mobile — use full width for buttons */
    .ekeka-mode-toggle {
        display: none;
    }

    /* Keep variations centered/visible */
    .ekeka-header-center {
        flex: 1;
        justify-content: flex-end;
    }

    /* Compact CTA */
    .ekeka-save-btn {
        padding: 8px 14px;
        font-size: 13px;
        border-radius: 20px;
        gap: 6px;
    }

    .ekeka-save-btn svg {
        width: 16px;
        height: 16px;
    }

    /* Larger touch targets for icon buttons */
    .ekeka-icon-btn {
        width: 36px;
        height: 36px;
    }

    .ekeka-back-btn {
        width: 36px;
        height: 36px;
    }

    /* Tools section — large tap targets */
    .ekeka-tools-section {
        padding: 12px;
    }

    .ekeka-tools-title {
        margin-bottom: 8px;
    }

    .ekeka-tools-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .ekeka-tool-btn {
        padding: 16px 8px;
        font-size: 13px;
        font-weight: 700;
        border-width: 2px;
        min-height: 70px;
        border-radius: var(--ek-radius);
    }

    .ekeka-tool-btn svg {
        width: 26px;
        height: 26px;
    }

    /* Properties — compact */
    .ekeka-props-section {
        padding: 12px;
    }

    .ekeka-prop-select {
        padding: 10px 12px;
        font-size: 14px;
    }

    .ekeka-prop-input {
        padding: 10px;
        font-size: 14px;
        width: 80px;
    }

    .ekeka-prop-color {
        width: 42px;
        height: 42px;
    }

    .ekeka-style-btn {
        width: 40px;
        height: 40px;
        font-size: 15px;
    }

    .ekeka-delete-btn {
        padding: 12px;
        font-size: 14px;
    }

    /* Zoom controls — compact */
    .ekeka-bottom-bar {
        padding: 4px 0 0;
    }

    .ekeka-zoom-controls {
        padding: 3px 8px;
    }

    .ekeka-zoom-btn {
        width: 28px;
        height: 28px;
    }

    .ekeka-element-count {
        font-size: 11px;
        padding: 4px 10px;
    }

    /* Layers compact */
    .ekeka-layers-list {
        max-height: 120px;
    }

    /* Toast */
    .ekeka-toast {
        bottom: 16px;
        font-size: 13px;
        padding: 10px 20px;
        max-width: 90vw;
    }
}

/* ============================================================
   Responsive — Small Mobile (≤ 380px)
   ============================================================ */
@media (max-width: 380px) {
    .ekeka-header {
        height: 46px;
        padding: 0 8px;
    }

    .ekeka-logo {
        height: 22px;
    }

    .ekeka-save-btn {
        padding: 7px 10px;
        font-size: 12px;
    }

    .ekeka-save-btn svg {
        display: none;
    }

    .ekeka-icon-btn {
        width: 32px;
        height: 32px;
    }

    .ekeka-back-btn {
        width: 32px;
        height: 32px;
    }

    .ekeka-tool-btn {
        min-height: 60px;
        padding: 12px 6px;
    }
}