/* canvas_editor.css */

.canvas-editor-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: none;
    flex-direction: column;
    color: #e0e0e0;
    font-family: 'Inter', sans-serif;
    backdrop-filter: blur(5px);
}

.canvas-editor-overlay.active {
    display: flex;
}

/* Header */
.ce-header {
    height: 50px;
    background: #1e1e1e;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    border-bottom: 1px solid #333;
}

.ce-header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
}

.ce-header-center {
    display: flex;
    align-items: center;
    gap: 20px;
}

.ce-zoom-bar {
    display: flex;
    align-items: center;
    background: #2a2a2a;
    border-radius: 6px;
    padding: 2px;
}

.ce-zoom-btn {
    background: transparent;
    border: none;
    color: #ccc;
    width: 28px;
    height: 28px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.ce-zoom-btn:hover {
    background: #3a3a3a;
    color: #fff;
}

.ce-zoom-val {
    min-width: 45px;
    text-align: center;
    font-size: 12px;
    color: #bbb;
}

.ce-history-btns {
    display: flex;
    gap: 5px;
}

.ce-history-btn {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.2s;
}

.ce-history-btn.active {
    opacity: 1;
    pointer-events: auto;
}

.ce-header-title {
    font-size: 16px;
    font-weight: 600;
}

.ce-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.ce-btn {
    background: #333;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}

.ce-btn:hover {
    background: #444;
}

.ce-btn-primary {
    background: #00e5a0;
    color: #000;
}

.ce-btn-primary:hover {
    background: #00c98c;
}

/* Main Body */
.ce-body {
    display: flex;
    flex: 1;
    flex-direction: column; /* Vertical stack: Toolbar -> (Sidebar + Workspace) */
    overflow: hidden;
}

.ce-editor-container {
    display: flex;
    flex: 1;
    height: calc(100vh - 100px); /* 50px header + 50px toolbar */
    overflow: hidden;
    background: #121212;
}

.ce-right-col {
    display: grid;
    grid-template-rows: 1fr auto;
    height: 100%;
    overflow: hidden;
}

/* Sidebar / Thumbnails */
.ce-sidebar {
    width: 220px;
    background: #1a1a1a;
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
}
.ce-workspace {
    flex: 1;
    display: block;       /* NOT flex — we scroll instead of flex-center */
    overflow: auto;
    background: #111;
    background-image: radial-gradient(circle, #2a2a2a 1px, transparent 1px);
    background-size: 20px 20px;
    position: relative;
    /* padding set dynamically by applyZoom() */
}

.ce-canvas-wrapper {
    display: inline-block;   /* shrink to canvas size only */
    background: white;
    box-shadow: 0 8px 40px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.05);
    transform-origin: top left;  /* top-left so scroll math is simple */
    /* width/height set via JS to CANVAS_WIDTH x CANVAS_HEIGHT */
    border-radius: 2px;
}

.ce-fabric-canvas {
    display: block;
}
.ce-properties-panel {
    width: 260px;
    background: #1a1a1a;
    border-left: 1px solid #333;
    display: flex;
    flex-direction: column;
}
.ce-layer-panel {
    border-top: 1px solid #333;
    display: flex;
    flex-direction: column;
    background: #151515;
    min-height: 40px;
    overflow: hidden;
    resize: vertical; /* Enable vertical resize */
    height: 300px; /* Default height */
}
#ce-layer-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    min-height: 20px;
}

.ce-prop-section {
    padding: 15px;
    border-bottom: 1px solid #2a2a2a;
}

.ce-prop-title {
    font-size: 11px;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 12px;
    letter-spacing: 0.05em;
    font-weight: 700;
}

.ce-prop-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.ce-prop-row:last-child {
    margin-bottom: 0;
}

.ce-prop-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ce-prop-label {
    font-size: 11px;
    color: #aaa;
}

.ce-prop-input {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    color: #fff;
    padding: 6px 8px;
    font-size: 12px;
    width: 100%;
    outline: none;
}

.ce-prop-input:focus {
    border-color: #00e5a0;
}

.ce-btn-icon-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.ce-prop-btn {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    color: #ccc;
    border-radius: 4px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ce-prop-btn:hover {
    background: #333;
    color: #fff;
}

.ce-prop-btn.active {
    background: rgba(0, 229, 160, 0.1);
    border-color: #00e5a0;
    color: #00e5a0;
}

.ce-color-preview {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    border: 1px solid #3a3a3a;
    cursor: pointer;
    background: #fff;
}

/* Context Menu */
.ce-context-menu {
    position: fixed;
    background: #222;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 6px 0;
    z-index: 20000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    min-width: 180px;
    display: none;
}

.ce-context-item {
    padding: 8px 15px;
    color: #eee;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ce-context-item:hover {
    background: #333;
}

.ce-context-divider {
    height: 1px;
    background: #444;
    margin: 6px 0;
}

.ce-context-shortcut {
    color: #666;
    font-size: 11px;
    margin-left: 20px;
}

.ce-sidebar-header {
    padding: 15px;
    font-size: 14px;
    font-weight: 600;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#ce-prop-content {
    flex: 1;
    overflow-y: auto !important;
    padding: 15px;
    background: #1a1a1a;
    direction: ltr; /* Force scrollbar to the right */
    scrollbar-width: auto; 
    scrollbar-color: #666 #141414;
    min-height: 0;
}
#ce-prop-content::-webkit-scrollbar { width: 12px; }
#ce-prop-content::-webkit-scrollbar-track { background: #141414; border-left: 1px solid #222; }
#ce-prop-content::-webkit-scrollbar-thumb { background: #444; border-radius: 6px; border: 3px solid #141414; }
#ce-prop-content::-webkit-scrollbar-thumb:hover { background: #00e5a0; }

.ce-thumbnails {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.ce-thumbnail-item {
    background: #333;
    border-radius: 4px;
    padding: 10px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border 0.2s;
}

.ce-thumbnail-item.active {
    border-color: #00e5a0;
}

.ce-thumbnail-item-header {
    font-size: 11px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #888;
}

.ce-thumbnail-actions {
    display: flex;
    gap: 5px;
}

.ce-thumb-action {
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 14px;
    padding: 2px;
    line-height: 1;
    border-radius: 2px;
}

.ce-thumb-action:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.ce-thumbnail-preview {
    width: 100%;
    aspect-ratio: 210 / 297; /* A4 aspect ratio */
    background: #fff;
    border-radius: 2px;
}

/* Horizontal Toolbar */
.ce-toolbar {
    height: 50px;
    width: 100%;
    background: #252525;
    border-bottom: 1px solid #333;
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 0 15px;
    gap: 15px;
    z-index: 10;
}

.ce-tool-group {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #1a1a1a;
    padding: 3px;
    border-radius: 6px;
    border: 1px solid #333;
}

.ce-tool-btn {
    height: 34px;
    padding: 0 12px;
    border-radius: 4px;
    background: #333;
    border: none;
    color: #e0e0e0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}

.ce-tool-btn:hover {
    background: #444;
}

.ce-tool-btn.active {
    background: #00e5a0;
    color: #000;
}

.ce-tool-icon {
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
}

/* Canvas Area — duplicate definition removed, handled above */

/* Floating Toolbar (Context Menu) */
.ce-floating-toolbar {
    position: absolute;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    gap: 15px;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    z-index: 100;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s, visibility 0.2s;
}

.ce-floating-toolbar.active {
    visibility: visible;
    opacity: 1;
}

.ce-floating-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.ce-floating-divider {
    width: 1px;
    height: 20px;
    background: #333;
}

.ce-floating-label {
    font-size: 11px;
    color: #aaa;
}

.ce-color-picker {
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.ce-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.ce-color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.ce-floating-icon-btn {
    background: transparent;
    border: none;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 14px;
    padding: 5px;
    border-radius: 4px;
}

.ce-floating-icon-btn:hover {
    background: #333;
}

/* Fabric.js custom selection styling (injected via JS usually, but kept clean here) */
.ce-canvas-wrapper .canvas-container {
    margin: 0 auto;
}

/* Modals */
.ce-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    display: none; /* Controlled by JS */
    align-items: center;
    justify-content: center;
    z-index: 10001; /* Higher than editor overlay */
}

.ce-modal {
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 12px;
    width: 600px;
    max-width: 90vw;
    padding: 24px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
}

.ce-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
}

.ce-modal-close {
    background: transparent;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
}

.ce-modal-close:hover {
    color: #fff;
}

/* Layout Grid */
.ce-layout-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
    max-height: 400px;
    overflow-y: auto;
}

.ce-layout-card {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, background 0.2s;
}

.ce-layout-card:hover {
    transform: translateY(-2px);
    border-color: #00e5a0;
    background: #333;
}

.ce-layout-icon {
    font-size: 32px;
}

.ce-layout-name {
    font-size: 12px;
    font-weight: 500;
    color: #bbb;
    text-align: center;
}

/* Tool Overrides & Align */
/* Page Builder Button Premium Style */
.canvas-builder-btn {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%) !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2) !important;
    padding: 14px !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 13px !important;
}

.canvas-builder-btn:hover {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3) !important;
    border-color: rgba(255,255,255,0.2) !important;
}

.canvas-builder-btn:active {
    transform: translateY(0);
}

select#ce-ft-font-family {
    background: #252525;
    color: #fff;
    border: 1px solid #333;
    border-radius: 4px;
    outline: none;
}


/* Grid Overlay */
.ce-grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-image: 
        linear-gradient(to right, rgba(0,0,0,0.08) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0,0,0,0.08) 1px, transparent 1px);
    background-size: 20px 20px;
    display: none;
    z-index: 5;
}

.ce-grid-overlay.active {
    display: block;
}

/* Library Modal Styles */
.ce-lib-nav:hover { color: #00e5a0 !important; }
.ce-lib-nav.active { color: #00e5a0 !important; font-weight: bold; background: rgba(0,229,160,0.1); border-radius: 4px; }
.ce-lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 15px; }
.ce-lib-item { background: #1e1e1e; border: 1px solid #333; border-radius: 8px; padding: 15px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 10px; transition: all 0.2s; }
.ce-lib-item:hover { border-color: #00e5a0; background: #2a2a2a; transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
.ce-lib-item svg { width: 40px; height: 40px; color: #fff; }
.ce-lib-item span { font-size: 11px; color: #aaa; text-align: center; }
.ce-lib-item:hover span { color: #fff; }

.ce-tool-btn.active .ce-tool-icon {
    color: #00e5a0;
}

/* ── Field Library Sidebar Cards ─────────────────────────────── */
.ce-field-group { border-bottom: 1px solid #2a2a2a; }
.ce-field-group-header {
    padding: 10px 15px; background: #1e1e1e; border-bottom: 1px solid #2a2a2a;
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; color: #777; display: flex; align-items: center; gap: 8px;
    cursor: pointer; user-select: none;
}
.ce-field-items {
    padding: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.ce-field-item {
    padding: 10px 6px; background: #252525; border: 1px solid #333;
    border-radius: 6px; cursor: pointer; text-align: center;
    transition: all 0.15s ease; display: flex; flex-direction: column;
    align-items: center; gap: 4px;
}
.ce-field-item:hover {
    background: #2e2e2e; border-color: #00e5a0;
    transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,229,160,0.15);
}
.ce-field-item div:first-child { font-size: 18px; line-height: 1; }
.ce-field-item div:last-child {
    font-size: 10px; color: #bbb; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; max-width: 90px;
}
#ce-field-search {
    width: 100%; padding: 6px 10px; background: #222;
    border: 1px solid #444; color: #eee; border-radius: 4px;
    font-size: 12px; outline: none; box-sizing: border-box;
}
#ce-field-search:focus { border-color: #00e5a0; }
select.ce-prop-input { background: #2a2a2a; color: #fff; }

/* ── PREMIUM TOOLBAR UPGRADES ─── */
.ce-header {
    background: #141414;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.ce-btn-primary {
    background: linear-gradient(135deg, #00e5a0, #00c98c);
    color: #000;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 2px 8px rgba(0,229,160,0.3);
}
.ce-btn-primary:hover {
    background: linear-gradient(135deg, #00f0aa, #00d898);
    box-shadow: 0 3px 12px rgba(0,229,160,0.5);
}

/* Header preview button */
#ce-preview-btn {
    background: #1e1e2e;
    border: 1px solid #444;
    color: #aaa;
    transition: all 0.2s;
}
#ce-preview-btn:hover { border-color: #00e5a0; color: #00e5a0; }

/* Toolbar improvements */
.ce-toolbar {
    background: #191919;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    height: 48px;
    gap: 8px;
    padding: 0 12px;
}
.ce-tool-group {
    background: #222;
    border: 1px solid #2e2e2e;
    border-radius: 6px;
    gap: 2px;
    padding: 2px;
}
.ce-tool-btn {
    background: transparent;
    border-radius: 5px;
    transition: all 0.15s;
}
.ce-tool-btn:hover {
    background: #333;
    color: #fff;
}
.ce-tool-btn.active {
    background: rgba(0,229,160,0.15);
    color: #00e5a0;
}
.ce-tool-btn.active .ce-tool-icon { color: #00e5a0; }

/* ── LAYER PANEL ─ improved ─── */
.ce-layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    font-size: 12px;
    color: #bbb;
    cursor: pointer;
    border-radius: 5px;
    margin-bottom: 2px;
    border: 1px solid transparent;
    transition: all 0.15s;
}
.ce-layer-item:hover {
    background: #2a2a2a;
    border-color: #333;
    color: #fff;
}
.ce-layer-item.active-layer {
    background: rgba(0,229,160,0.08);
    border-color: rgba(0,229,160,0.25);
    color: #00e5a0;
}
.ce-layer-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 12px;
    opacity: 0.6;
    transition: opacity 0.15s, background 0.15s;
}
.ce-layer-toggle:hover { opacity: 1; background: #333; }

/* ── SIDEBAR HEADER ─── */
.ce-sidebar-header {
    padding: 12px 15px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #555;
    border-bottom: 1px solid #222;
    background: #161616;
}

/* ── FIELD LIBRARY UPGRADES ─── */
.ce-field-group { border-bottom: 1px solid #1e1e1e; }
.ce-field-group-header {
    padding: 9px 12px;
    background: #1a1a1a;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #666;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}
.ce-field-group-header:hover { background: #202020; color: #999; }
.ce-field-items {
    padding: 8px;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    background: #141414;
}
.ce-field-item {
    padding: 9px 5px;
    background: #1e1e1e;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    cursor: grab;
    text-align: center;
    transition: all 0.15s;
}
.ce-field-item:active { cursor: grabbing; transform: scale(0.96); }
.ce-field-item:hover {
    background: #252525;
    border-color: rgba(0,229,160,0.4);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,229,160,0.12);
}

/* ── WORKSPACE CANVAS AREA ─── */
.ce-workspace {
    background: #111;
    background-image: radial-gradient(circle, #2a2a2a 1px, transparent 1px);
    background-size: 20px 20px;
}

/* ── CANVAS WRAPPER ─── */
.ce-canvas-wrapper {
    box-shadow: 0 8px 40px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.05);
    border-radius: 2px;
}

/* ── PROPERTIES PANEL ─── */
.ce-properties-panel {
    background: #161616;
    border-left: 1px solid #222;
}
.ce-prop-section { border-bottom: 1px solid #222; }
.ce-prop-input {
    background: #1e1e1e;
    border: 1px solid #2e2e2e;
    color: #ddd;
}
.ce-prop-input:focus { border-color: #00e5a0; outline: none; }

/* ── RIGHT COLUMN (Properties + Layers stacked) ─── */
#ce-right-col {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

/* Layer Panel */
#ce-layer-panel {
    background: #151515;
    border-top: 1px solid #2a2a2a;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 250px; /* Default height */
    min-height: 40px;
}

/* Vertical Resizer */
.ce-resizer-v {
    height: 6px;
    background: #1e1e1e;
    border-top: 1px solid #333;
    border-bottom: 1px solid #000;
    cursor: ns-resize;
    flex-shrink: 0;
    transition: all 0.2s;
    z-index: 100;
    position: relative;
}

.ce-resizer-v::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 2px;
    background: #444;
    border-radius: 1px;
}

.ce-resizer-v:hover, .ce-resizer-v.resizing {
    background: #222;
    border-color: #00e5a0;
}

.ce-resizer-v:hover::after, .ce-resizer-v.resizing::after {
    background: #00e5a0;
    width: 40px;
}

/* Toggle bar */
#ce-layer-toggle-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    background: #161616;
    border-bottom: 1px solid #222;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}
#ce-layer-toggle-bar:hover { background: #1c1c1c; }

#ce-layer-toggle-btn {
    background: none;
    border: none;
    color: #555;
    cursor: pointer;
    padding: 2px 5px;
    font-size: 11px;
    border-radius: 3px;
    transition: color 0.2s, background 0.2s;
    line-height: 1;
}
#ce-layer-toggle-btn:hover {
    color: #00e5a0;
    background: rgba(0,229,160,0.08);
}

/* Layer list — height animated via JS */
#ce-layer-list {
    padding: 5px;
    overflow-y: auto;
    transition: height 0.25s ease, min-height 0.25s ease;
    flex-shrink: 0;
}

/* ── ANIMATING ACCORDION CHEVRON ─── */
.ce-accordion-chevron { transition: transform 0.2s; }

/* ── SCROLLBAR STYLING ─── */
.ce-field-groups::-webkit-scrollbar,
#ce-layer-list::-webkit-scrollbar,
.ce-properties-panel::-webkit-scrollbar { width: 4px; }
.ce-field-groups::-webkit-scrollbar-track,
#ce-layer-list::-webkit-scrollbar-track,
.ce-properties-panel::-webkit-scrollbar-track { background: transparent; }
.ce-field-groups::-webkit-scrollbar-thumb,
#ce-layer-list::-webkit-scrollbar-thumb,
.ce-properties-panel::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

/* ── SEARCH BOX ─── */
#ce-field-search {
    background: #1a1a1a;
    border: 1px solid #2e2e2e;
    color: #ddd;
    border-radius: 6px;
}
#ce-field-search:focus { border-color: rgba(0,229,160,0.5); box-shadow: 0 0 0 3px rgba(0,229,160,0.08); }

/* Thumbnail previews */
/* ── PHOTOMETRIC ANALYSIS PREMIUM STYLING ─── */
.p-item-analysis-strip {
    display: flex;
    gap: 15px;
    padding: 12px 15px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(30, 64, 175, 0.05));
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 10px;
    margin-top: 12px;
    backdrop-filter: blur(8px);
    box-shadow: inset 0 1px 1px rgba(255,255,255,0.05);
}

.p-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.p-stat strong {
    color: #60a5fa;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 800;
}

.p-stat span {
    font-weight: 700;
    color: #fff;
    font-size: 14px;
    font-family: 'Montserrat', sans-serif;
    text-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

.p-empty-placeholder {
    padding: 40px 20px;
    text-align: center;
    color: #64748b;
    font-size: 13px;
    border: 2px dashed #333;
    border-radius: 12px;
    margin: 10px;
}

/* Ensure Library Sidebar has scrolling */
.ce-field-groups {
    overflow-y: auto !important;
    max-height: calc(100vh - 200px);
}

/* ═══════════════════════════════════════════════════════════════
   PREMIUM UI/UX OVERHAUL — Phase 2
   Addresses all 7 identified issues from screenshot analysis
   ═══════════════════════════════════════════════════════════════ */

/* ── 1. PREMIUM HEADER ──────────────────────────────────────── */
.ce-header {
    background: linear-gradient(180deg, #0f1420 0%, #0a0e15 100%) !important;
    border-bottom: 1px solid #1e2938 !important;
    height: 52px !important;
}

.ce-header-logo span:first-child {
    color: #f8fafc;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* Template name pill */
#ce-template-name {
    margin-left: 16px !important;
    padding: 4px 12px !important;
    border-left: 1px solid #1e2938 !important;
    background: #111827;
    border-radius: 20px;
    color: #00e5a0 !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    letter-spacing: 0.01em;
}

/* ── 2. TOOLBAR DIVIDERS ─────────────────────────────────────── */
.ce-toolbar {
    background: #0d1117 !important;
    border-bottom: 1px solid #1e2938 !important;
    height: 46px !important;
    padding: 0 14px !important;
    gap: 4px !important;
    position: relative;
}

/* Vertical divider between tool groups */
.ce-toolbar-divider {
    width: 1px;
    height: 22px;
    background: #1e2938;
    flex-shrink: 0;
    margin: 0 4px;
}

/* Tool group label on hover */
.ce-tool-group[data-label] {
    position: relative;
}

.ce-tool-group {
    background: transparent !important;
    border: none !important;
    border-radius: 6px;
    padding: 2px !important;
    gap: 1px !important;
}

.ce-tool-group:hover {
    background: #111827 !important;
}

.ce-tool-btn {
    height: 32px !important;
    padding: 0 9px !important;
    border-radius: 5px !important;
    transition: all 0.12s ease !important;
    color: #94a3b8 !important;
    font-size: 14px !important;
}

.ce-tool-btn:hover {
    background: #1e2938 !important;
    color: #f1f5f9 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.ce-tool-btn.active {
    background: rgba(0, 229, 160, 0.12) !important;
    color: #00e5a0 !important;
    border: 1px solid rgba(0, 229, 160, 0.25) !important;
}

/* ── 3. WORKSPACE — better canvas environment ─────────────────── */
.ce-workspace,
#ce-workspace {
    background: #080c12 !important;
    background-image: 
        radial-gradient(circle, rgba(255,255,255,0.04) 1px, transparent 1px) !important;
    background-size: 24px 24px !important;
}

/* Stronger page shadow — makes the canvas feel grounded */
.ce-canvas-wrapper,
#ce-canvas-wrapper {
    box-shadow: 
        0 0 0 1px rgba(255,255,255,0.06),
        0 8px 24px rgba(0,0,0,0.6),
        0 24px 64px rgba(0,0,0,0.5) !important;
    border-radius: 2px !important;
}

/* ── 4. LEFT SIDEBAR (Pages) ─────────────────────────────────── */
.ce-sidebar {
    background: #0a0e15 !important;
    border-right: 1px solid #1e2938 !important;
}

.ce-sidebar-header {
    background: #0a0e15 !important;
    border-bottom: 1px solid #1e2938 !important;
    font-size: 10px !important;
    font-weight: 800 !important;
    letter-spacing: 0.1em !important;
    color: #475569 !important;
    text-transform: uppercase;
    padding: 12px 14px !important;
}

/* Page thumbnails */
.ce-thumbnail-item {
    background: #111827 !important;
    border: 1px solid #1e2938 !important;
    border-radius: 6px !important;
    padding: 8px !important;
    transition: all 0.15s;
}

.ce-thumbnail-item:hover {
    border-color: #374151 !important;
}

.ce-thumbnail-item.active {
    border-color: #00e5a0 !important;
    background: #0f2033 !important;
}

/* ── 5. RIGHT PANEL — Properties ─────────────────────────────── */
.ce-properties-panel,
#ce-properties-panel {
    background: #0a0e15 !important;
    border-left: 1px solid #1e2938 !important;
}

/* Prop tab active state (JS may override, CSS provides fallback) */
.ce-prop-tab.active {
    background: rgba(0, 229, 160, 0.12) !important;
    border: 1px solid rgba(0, 229, 160, 0.25) !important;
    border-radius: 6px !important;
    color: #00e5a0 !important;
}

/* Property section borders */
.ce-prop-section {
    border-bottom: 1px solid #111827 !important;
}

.ce-prop-title {
    color: #475569 !important;
    font-size: 10px !important;
    letter-spacing: 0.08em !important;
}

.ce-prop-input {
    background: #111827 !important;
    border: 1px solid #1e2938 !important;
    color: #e2e8f0 !important;
    border-radius: 5px !important;
}

.ce-prop-input:focus {
    border-color: #00e5a0 !important;
    box-shadow: 0 0 0 3px rgba(0, 229, 160, 0.08) !important;
}

/* ── 6. LAYER PANEL ──────────────────────────────────────────── */
#ce-layer-panel {
    background: #080c12 !important;
    border-top: 1px solid #1e2938 !important;
}

#ce-layer-toggle-bar {
    background: #0a0e15 !important;
    border-bottom: 1px solid #1e2938 !important;
    padding: 10px 14px !important;
}

.ce-layer-item {
    padding: 8px 12px !important;
    border-radius: 6px !important;
    border: 1px solid transparent !important;
    color: #94a3b8 !important;
    font-size: 11px !important;
}

.ce-layer-item:hover {
    background: #111827 !important;
    border-color: #1e2938 !important;
    color: #e2e8f0 !important;
}

.ce-layer-item.active-layer {
    background: rgba(0, 229, 160, 0.06) !important;
    border-color: rgba(0, 229, 160, 0.2) !important;
    color: #00e5a0 !important;
}

.ce-layer-toggle {
    width: 22px !important;
    height: 22px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 4px !important;
    font-size: 12px !important;
}

/* ── 7. FIELD LIBRARY — better visual hierarchy ───────────────── */
.ce-sidebar.ce-field-library,
#ce-field-library {
    background: #0a0e15 !important;
    border-right: 1px solid #1e2938 !important;
}

.ce-field-group-header {
    background: #0d1117 !important;
    border-bottom: 1px solid #111827 !important;
    color: #64748b !important;
    padding: 10px 14px !important;
    font-size: 10px !important;
    letter-spacing: 0.08em !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
}

.ce-field-group-header:hover {
    background: #111827 !important;
    color: #94a3b8 !important;
}

.ce-field-item {
    background: #111827 !important;
    border: 1px solid #1e2938 !important;
    border-radius: 7px !important;
    transition: all 0.12s ease !important;
}

.ce-field-item:hover {
    background: #0f2033 !important;
    border-color: rgba(0, 229, 160, 0.35) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 16px rgba(0, 229, 160, 0.1) !important;
}

/* ── 8. HEADER BUTTONS ────────────────────────────────────────── */
.ce-btn {
    background: #111827 !important;
    border: 1px solid #1e2938 !important;
    color: #94a3b8 !important;
    font-size: 12px !important;
    border-radius: 6px !important;
    padding: 7px 14px !important;
    transition: all 0.15s !important;
}

.ce-btn:hover {
    background: #1e2938 !important;
    color: #f1f5f9 !important;
    border-color: #374151 !important;
}

.ce-btn-primary {
    background: linear-gradient(135deg, #00e5a0, #00b87d) !important;
    color: #000 !important;
    border: none !important;
    font-weight: 700 !important;
    letter-spacing: 0.03em !important;
    box-shadow: 0 2px 12px rgba(0, 229, 160, 0.3) !important;
}

.ce-btn-primary:hover {
    background: linear-gradient(135deg, #00f0aa, #00d898) !important;
    box-shadow: 0 4px 20px rgba(0, 229, 160, 0.45) !important;
    transform: translateY(-1px);
}

/* ── 9. CONTEXT MENU ─────────────────────────────────────────── */
.ce-context-menu {
    background: #0d1117 !important;
    border: 1px solid #1e2938 !important;
    border-radius: 10px !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6) !important;
}

.ce-context-item {
    color: #cbd5e1 !important;
    font-size: 12px !important;
    padding: 9px 16px !important;
}

.ce-context-item:hover {
    background: #111827 !important;
    color: #f1f5f9 !important;
}

.ce-context-divider {
    background: #1e2938 !important;
    margin: 4px 8px !important;
}

/* ── 10. SEARCH INPUT ──────────────────────────────────────────── */
#ce-field-search {
    background: #111827 !important;
    border: 1px solid #1e2938 !important;
    color: #e2e8f0 !important;
    border-radius: 7px !important;
    padding: 8px 12px !important;
    font-size: 12px !important;
}

#ce-field-search:focus {
    border-color: rgba(0, 229, 160, 0.4) !important;
    box-shadow: 0 0 0 3px rgba(0,229,160,0.06) !important;
    outline: none !important;
}

/* ── 11. SCHEMA PANEL scrollbar ────────────────────────────────── */
#ce-sp-sections::-webkit-scrollbar { width: 4px; }
#ce-sp-sections::-webkit-scrollbar-track { background: transparent; }
#ce-sp-sections::-webkit-scrollbar-thumb { background: #1e2938; border-radius: 4px; }
#ce-sp-sections::-webkit-scrollbar-thumb:hover { background: #00e5a0; }

/* ── 12. Floating toolbar polish ───────────────────────────────── */
.ce-floating-toolbar {
    background: #0d1117 !important;
    border: 1px solid #1e2938 !important;
    border-radius: 10px !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5) !important;
}

/* ═══════════════════════════════════════════════════════════════
   ── 13. Floating Panels ──────────────────────────────────────
   ═══════════════════════════════════════════════════════════════ */

.ce-floating-panel {
    position: fixed;
    background: #1a1a1a;
    border: 1px solid #2e2e2e;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.04);
    min-width: 300px;
    width: 300px;
    z-index: 12000;
    overflow: hidden;
    animation: ce-panel-appear 0.15s cubic-bezier(0.4,0,0.2,1);
}
@keyframes ce-panel-appear {
    from { opacity:0; transform:translateY(-6px); }
    to   { opacity:1; transform:translateY(0); }
}
.ce-fp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px 10px;
    border-bottom: 1px solid #2a2a2a;
}
.ce-fp-tabs {
    display: flex;
    padding: 8px 10px;
    gap: 4px;
    background: #141414;
    border-bottom: 1px solid #2a2a2a;
}
.ce-fp-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: #777;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.ce-fp-tab:hover { background: #222; color: #ccc; }
.ce-fp-tab.active {
    background: rgba(0,229,160,0.12);
    color: #00e5a0;
    border: 1px solid rgba(0,229,160,0.25);
}
.ce-fp-content { padding: 0; }
.ce-fp-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #00e5a0;
    color: #000;
    border: none;
    border-radius: 7px;
    padding: 9px 16px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
}
.ce-fp-action-btn:hover {
    background: #00f0aa;
    box-shadow: 0 4px 14px rgba(0,229,160,0.4);
}
.ce-drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 14px;
    padding: 28px 16px;
    border: 2px dashed #2e2e2e;
    border-radius: 10px;
    background: #111;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 130px;
}
.ce-drop-zone:hover, .ce-drop-zone.dragging {
    border-color: #00e5a0;
    background: rgba(0,229,160,0.05);
}
.ce-ip-assets-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 10px;
    max-height: 240px;
    overflow-y: auto;
}
.ce-ip-asset-tile {
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    aspect-ratio: 1;
    background: #111;
    transition: border-color 0.15s, transform 0.15s;
}
.ce-ip-asset-tile:hover { border-color: #00e5a0; transform: scale(1.03); }
.ce-ip-asset-tile img { width:100%; height:100%; object-fit:cover; display:block; }
#ce-diagram-panel { width: 320px; }
.ce-dp-section {
    padding: 12px 14px 8px;
    border-bottom: 1px solid #222;
}
.ce-dp-section-title {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #555;
    margin-bottom: 10px;
}
.ce-dp-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}
.ce-dp-shape-btn {
    background: #111;
    border: 1px solid #2e2e2e;
    border-radius: 8px;
    padding: 8px 4px 6px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    transition: all 0.15s;
    color: #aaa;
}
.ce-dp-shape-btn:hover {
    background: #1e2030;
    border-color: #00e5a0;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0,229,160,0.15);
}
.ce-dp-shape-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 68px;
    height: 44px;
}
.ce-dp-shape-btn span {
    font-size: 9px;
    font-weight: 600;
    color: #666;
    text-align: center;
}
.ce-dp-shape-btn:hover span { color: #ccc; }
.ce-dp-template-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #111;
    border: 1px solid #2e2e2e;
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: all 0.15s;
}
.ce-dp-template-btn:hover {
    background: #1a1f2e;
    border-color: #00e5a0;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,229,160,0.12);
}

