/* ==========================================================================
   NextXen Designer – Frontend Designer UI
   ========================================================================== */

/* ── Reset inside overlay ─────────────────────────────────────────────────── */
#nxd-designer-overlay *,
#nxd-designer-overlay *::before,
#nxd-designer-overlay *::after {
    box-sizing: border-box;
}

/* ── Overlay ─────────────────────────────────────────────────────────────── */
#nxd-designer-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: stretch;
    justify-content: center;
    background: rgba(0, 0, 0, .65);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.nxd-designer-wrap {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1280px;
    max-height: 100vh;
    background: #f9fafb;
    border-radius: 0;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0,0,0,.4);
}

@media (min-width: 768px) {
    #nxd-designer-overlay {
        padding: 16px;
        align-items: center;
    }
    .nxd-designer-wrap {
        border-radius: 12px;
        max-height: calc(100vh - 32px);
    }
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.nxd-designer-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #1e293b;
    color: #f1f5f9;
    flex-shrink: 0;
}

.nxd-product-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #f1f5f9;
}

.nxd-surface-tabs {
    display: flex;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
}

.nxd-surface-tab {
    padding: 5px 14px;
    border: 1px solid #475569;
    border-radius: 20px;
    background: transparent;
    color: #cbd5e1;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: all .15s;
}
.nxd-surface-tab.is-active,
.nxd-surface-tab:hover {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}

.nxd-close-btn {
    margin-left: auto;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,.1);
    color: #f1f5f9;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.nxd-close-btn:hover { background: rgba(255,255,255,.25); }

/* ── Body ────────────────────────────────────────────────────────────────── */
.nxd-designer-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Sidebars ────────────────────────────────────────────────────────────── */
.nxd-sidebar {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.nxd-tools-sidebar {
    width: 82px;
    background: #1e293b;
    padding: 8px 6px;
    gap: 4px;
    align-items: center;
}

.nxd-props-sidebar {
    width: 220px;
    background: #fff;
    border-left: 1px solid #e2e8f0;
    padding: 12px;
    gap: 0;
}

@media (max-width: 640px) {
    .nxd-tools-sidebar { width: 60px; }
    .nxd-props-sidebar { display: none; }
}

/* ── Tool buttons ────────────────────────────────────────────────────────── */
.nxd-tool-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
}
.nxd-tool-group + .nxd-tool-group {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #334155;
}

.nxd-tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    width: 100%;
    padding: 8px 4px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #94a3b8;
    font-size: 10px;
    cursor: pointer;
    transition: all .15s;
}
.nxd-tool-btn svg { width: 22px; height: 22px; }
.nxd-tool-btn:hover,
.nxd-tool-btn.is-active {
    background: rgba(59,130,246,.15);
    border-color: #3b82f6;
    color: #93c5fd;
}

.nxd-pro-locked {
    text-align: center;
    padding: 8px 4px;
}
.nxd-pro-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #64748b;
    margin: 0 0 4px;
}
.nxd-upgrade-link {
    font-size: 10px;
    color: #f59e0b;
    text-decoration: none;
    line-height: 1.3;
}
.nxd-upgrade-link:hover { text-decoration: underline; }

/* ── Canvas container ────────────────────────────────────────────────────── */
.nxd-canvas-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #e2e8f0;
    overflow: hidden;
    position: relative;
}

/* Canvas action toolbar */
.nxd-canvas-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 6px 10px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.nxd-action-btn {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .12s, color .12s;
}
.nxd-action-btn svg { width: 16px; height: 16px; }
.nxd-action-btn:hover:not(:disabled) { background: #f1f5f9; color: #1e293b; }
.nxd-action-btn:disabled { opacity: .35; cursor: default; }

.nxd-toolbar-sep {
    width: 1px;
    height: 20px;
    background: #e2e8f0;
    margin: 0 4px;
}

/* Canvas wrapper */
.nxd-canvas-wrapper {
    flex: 1;
    overflow: hidden;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    position: relative;
}

/* Target only Fabric's rendering canvas, not the transparent upper-canvas event layer */
.nxd-canvas-wrapper .lower-canvas {
    border: 1px solid #cbd5e1;
    box-shadow: 0 4px 20px rgba(0,0,0,.12);
    background: #fff;
}

/* ── Floating panels ─────────────────────────────────────────────────────── */
.nxd-floating-panel {
    position: absolute;
    top: 50px;
    left: 90px;
    width: 260px;
    max-height: calc(100% - 70px);
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    padding: 14px;
    overflow-y: auto;
    z-index: 100;
}
.nxd-floating-panel h4 {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}

.nxd-shapes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}
.nxd-shape-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    color: #475569;
    transition: all .12s;
}
.nxd-shape-option svg {
    width: 32px;
    height: 28px;
    color: #3b82f6;
    flex-shrink: 0;
}
.nxd-shape-option:hover { background: #eff6ff; border-color: #3b82f6; color: #1d4ed8; }
.nxd-shape-option:hover svg { color: #1d4ed8; }

.nxd-asset-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-top: 8px;
}
.nxd-asset-item {
    padding: 4px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    background: #f8fafc;
    text-align: center;
    font-size: 10px;
    transition: border-color .12s;
}
.nxd-asset-item img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; }
.nxd-asset-item span { display: block; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nxd-asset-item:hover { border-color: #3b82f6; }

.nxd-category-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.nxd-category-tab {
    padding: 2px 8px;
    font-size: 11px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: transparent;
    cursor: pointer;
}
.nxd-category-tab.is-active { background: #3b82f6; color: #fff; border-color: #3b82f6; }

.nxd-loading { color: #94a3b8; font-size: 12px; }

/* ── Properties sidebar ──────────────────────────────────────────────────── */
.nxd-prop-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 16px 8px;
    color: #94a3b8;
    gap: 8px;
}
.nxd-hint-icon { width: 28px; height: 28px; opacity: .5; }
.nxd-prop-hint p { margin: 0; font-size: 12px; line-height: 1.5; }

.nxd-prop-section { padding-bottom: 8px; }

.nxd-prop-heading {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #64748b;
}

.nxd-prop-row {
    margin-bottom: 10px;
}
.nxd-prop-row label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 3px;
}
.nxd-prop-row--two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.nxd-prop-row--checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
}
.nxd-prop-row--checkbox label { margin: 0; }
.nxd-prop-row--checkbox input[type="checkbox"] { margin: 0; }

.nxd-prop-divider {
    height: 1px;
    background: #f1f5f9;
    margin: 12px 0;
}

/* Inputs */
.nxd-input {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: 13px;
    color: #1e293b;
    background: #f8fafc;
}
.nxd-input--sm { max-width: 70px; }
.nxd-input:focus { outline: none; border-color: #3b82f6; background: #fff; }

.nxd-select {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: 12px;
    color: #1e293b;
    background: #f8fafc;
    cursor: pointer;
}
.nxd-select:focus { outline: none; border-color: #3b82f6; }

.nxd-color {
    width: 40px;
    height: 32px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    cursor: pointer;
    padding: 2px;
    background: #f8fafc;
}

/* Button groups */
.nxd-btn-group {
    display: flex;
    gap: 4px;
}
.nxd-style-btn, .nxd-align-btn {
    width: 30px;
    height: 30px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    background: #f8fafc;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all .12s;
}
.nxd-align-btn svg { width: 14px; height: 14px; }
.nxd-style-btn:hover, .nxd-align-btn:hover,
.nxd-style-btn.is-active { background: #eff6ff; border-color: #3b82f6; color: #1d4ed8; }

/* Range inputs */
.nxd-range-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}
.nxd-range-wrap input[type="range"] { flex: 1; }
.nxd-range-val {
    font-size: 11px;
    color: #64748b;
    min-width: 30px;
    text-align: right;
}

.nxd-sub-opts {
    padding-left: 8px;
    border-left: 2px solid #e2e8f0;
    margin-top: 4px;
    margin-bottom: 8px;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.nxd-designer-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
    gap: 10px;
}
.nxd-footer-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.nxd-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 18px;
    border: none;
    border-radius: 7px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    white-space: nowrap;
}
.nxd-btn-sm { padding: 5px 12px; font-size: 12px; }

.nxd-btn-primary    { background: #3b82f6; color: #fff; }
.nxd-btn-primary:hover { background: #2563eb; }

.nxd-btn-secondary  { background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; }
.nxd-btn-secondary:hover { background: #e2e8f0; }

.nxd-btn-ghost      { background: transparent; color: #64748b; border: 1px solid transparent; }
.nxd-btn-ghost:hover { background: #f1f5f9; border-color: #e2e8f0; color: #1e293b; }

.nxd-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Customize button (product page) ─────────────────────────────────────── */
.nxd-customize-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 11px 24px;
    background: #1e293b;
    color: #fff;
    border: none;
    border-radius: 7px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
    width: 100%;
    justify-content: center;
}
.nxd-customize-btn:hover { background: #334155; }

/* ── Cart thumbnail ──────────────────────────────────────────────────────── */
.nxd-cart-thumbnail {
    max-width: 80px;
    display: block;
    margin-top: 4px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
}

.nxd-cart-design-thumb-inline {
    display: block;
    margin-top: 8px;
}

/* ── Order design ────────────────────────────────────────────────────────── */
.nxd-order-design { margin: 6px 0; }
.nxd-order-thumb {
    max-width: 120px;
    display: block;
    margin-top: 4px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
}

/* ── My Account: saved designs ───────────────────────────────────────────── */
.nxd-my-designs { }
.nxd-designs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 16px;
}
.nxd-design-card {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    transition: box-shadow .15s;
}
.nxd-design-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.nxd-design-thumb {
    aspect-ratio: 1;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.nxd-design-thumb img { width: 100%; height: 100%; object-fit: contain; }
.nxd-no-thumb { font-size: 12px; color: #94a3b8; }
.nxd-design-info { padding: 10px 12px; }
.nxd-design-name { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.nxd-design-product, .nxd-design-date { margin: 0 0 2px; font-size: 12px; color: #64748b; }
.nxd-design-actions { padding: 8px 12px; display: flex; gap: 6px; border-top: 1px solid #f1f5f9; }

.nxd-empty { color: #94a3b8; }

/* ── Empty-canvas hint ──────────────────────────────────────────────────── */
.nxd-canvas-hint {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    pointer-events: none;
    user-select: none;
    padding: 24px;
    text-align: center;
}
.nxd-canvas-hint.is-hidden { display: none; }

.nxd-hint-arrow {
    width: 36px;
    height: 36px;
    color: #94a3b8;
    transform: rotate(180deg);  /* points left toward the sidebar */
    flex-shrink: 0;
}

.nxd-hint-headline {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #64748b;
    letter-spacing: .01em;
}

.nxd-hint-steps {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.nxd-hint-steps li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #94a3b8;
}

.nxd-hint-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #f1f5f9;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #475569;
    flex-shrink: 0;
}

.nxd-hint-icon svg {
    width: 14px;
    height: 14px;
    fill: #475569;
}
