/* ── MagnetShop Designer Styles ─────────────────────────────────────────── */

:root {
    --toolbar-h: 48px;
    --footer-h: 56px;
    --sidebar-w: 200px;
    --panel-w: 320px;
    --accent: #6c63ff;
    --accent-hover: #5a52d5;
    --text-primary: #212529;
    --text-muted: #6c757d;
    --border: #dee2e6;
    --radius: 8px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    height: 100%; overflow: hidden;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: #f0f0f5;
}

/* ── Designer Root Layout ─────────────────────────────────────────────── */

.designer-root {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ── Toolbar ──────────────────────────────────────────────────────────── */

.designer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--toolbar-h);
    padding: 0 16px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 10;
}

.toolbar-brand {
    font-weight: 700;
    font-size: 16px;
    color: var(--accent);
}

.toolbar-center {
    display: flex;
    gap: 6px;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Body (templates | canvas | panels) ───────────────────────────────── */

.designer-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Template Sidebar ─────────────────────────────────────────────────── */

.designer-templates {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 12px;
}

.template-picker .panel-title {
    margin: 0 0 10px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.template-category {
    margin-bottom: 12px;
}

.template-category > small {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.template-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
    margin-bottom: 4px;
}

.template-card:hover {
    background: #f0f0f5;
}

.template-card.selected {
    background: #e8e6ff;
    outline: 2px solid var(--accent);
}

.template-preview {
    width: 48px;
    min-height: 20px;
    border: 1px solid #ccc;
    flex-shrink: 0;
}

.template-info {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.template-name {
    font-size: 12px;
    font-weight: 600;
}

.template-size {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Canvas Area ──────────────────────────────────────────────────────── */

.designer-canvas-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e8e8f0;
    padding: 20px;
    overflow: hidden;
    position: relative;
}

.canvas-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.canvas-container canvas {
    border-radius: 4px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
}

/* ── Right Panels ─────────────────────────────────────────────────────── */

.designer-panels {
    width: var(--panel-w);
    flex-shrink: 0;
    background: #fff;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.tab-btn {
    flex: 1;
    padding: 10px 4px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    border-bottom: 2px solid transparent;
    text-align: center;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.property-panel .panel-title {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 700;
}

.property-panel .panel-subtitle {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

/* ── Shape Items ──────────────────────────────────────────────────────── */

.shape-item {
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.shape-item:hover {
    background: #f8f8fc;
}

.shape-item.selected {
    background: #f0eeff;
    border-color: var(--accent);
}

.shape-item-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.shape-type-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--accent);
    color: #fff;
    padding: 1px 6px;
    border-radius: 3px;
    flex-shrink: 0;
}

.shape-content {
    flex: 1;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shape-editor {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

/* ── Export Section ────────────────────────────────────────────────────── */

.export-section {
    margin-bottom: 16px;
}

/* ── Footer ───────────────────────────────────────────────────────────── */

.designer-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--footer-h);
    padding: 0 16px;
    background: #fff;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.footer-info {
    display: flex;
    gap: 20px;
    font-size: 12px;
    color: var(--text-muted);
}

.footer-actions {
    display: flex;
    gap: 8px;
}

/* ── Utilities ────────────────────────────────────────────────────────── */

.form-control-color {
    width: 40px;
    height: 32px;
    padding: 2px;
}

/* ── Loading / Error ──────────────────────────────────────────────────── */

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

/* ── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 960px) {
    .designer-templates { width: 160px; }
    .designer-panels { width: 260px; }
}

@media (max-width: 720px) {
    .designer-body { flex-direction: column; }
    .designer-templates,
    .designer-panels {
        width: 100%;
        max-height: 200px;
        border: none;
        border-bottom: 1px solid var(--border);
    }
    .designer-canvas-area { min-height: 300px; }
}