:root {
    --bg-app: #0d0d0d;
    --bg-sidebar: #141414;
    --bg-panel: #1a1a1a;
    --bg-workspace: #121212;
    --bg-canvas: #121212;
    --bg-editor-canvas: #1b1b1b;
    --bg-input: #222222;
    --border: #2a2a2a;
    --border-light: #333333;
    --text: #f0f0f0;
    --text-muted: #888888;
    --text-dim: #555555;
    --accent: #d4ff00;
    --accent-dim: rgba(212, 255, 0, 0.15);
    --accent-glow: rgba(212, 255, 0, 0.4);
    --radius: 10px;
    --radius-sm: 6px;
    --radius-canvas: 18px;
    --font: 'Exo 2', 'Segoe UI', sans-serif;
    --canvas-size: clamp(700px, min(78vmin, 820px), 820px);
    --shadow-canvas:
        0 24px 48px rgba(0, 0, 0, 0.42),
        0 8px 20px rgba(0, 0, 0, 0.28);
    --shadow-canvas-inset:
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        inset 0 0 80px rgba(0, 0, 0, 0.22);
}

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

body.mockup-app {
    font-family: var(--font);
    background: var(--bg-app);
    color: var(--text);
    min-height: 100vh;
    overflow: hidden;
}

.app-shell {
    display: grid;
    grid-template-columns: 300px 1fr;
    height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 0 0 1rem;
}

.sidebar-header {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.brand-logo {
    width: 36px;
    height: 36px;
    background: var(--accent);
    color: #000;
    font-weight: 800;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.brand-title {
    font-size: 0.72rem;
    font-weight: 800;
    font-style: italic;
    letter-spacing: 0.04em;
    line-height: 1.3;
    color: var(--text);
}

.brand-sub {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.panel {
    padding: 1rem 1.25rem 0;
}

.panel-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
    text-transform: uppercase;
}

/* Upload zone */
.upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: 1.5px dashed var(--border-light);
    border-radius: var(--radius);
    padding: 1.25rem 1rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: var(--bg-panel);
    min-height: 90px;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.upload-icon {
    font-size: 1.1rem;
    color: var(--text-muted);
}

.upload-text {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.5;
}

.upload-text kbd {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 3px;
    padding: 0 4px;
    font-size: 0.65rem;
    color: var(--text);
}

.design-slots {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.6rem;
    flex-wrap: wrap;
}

.slot-btn {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.3rem 0.65rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.slot-btn.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

.slot-btn.has-design::after {
    content: ' ●';
    color: var(--accent);
}

.slot-clear {
    background: none;
    border: none;
    color: var(--text-dim);
    font-family: var(--font);
    font-size: 0.65rem;
    cursor: pointer;
    margin-left: auto;
    transition: color 0.15s;
}

.slot-clear:hover { color: #ff5555; }

.download-design-btn {
    width: 100%;
    margin-top: 0.65rem;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    color: var(--accent);
    font-family: var(--font);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.download-design-btn:hover:not(:disabled) {
    background: var(--accent);
    color: #000;
}

.download-design-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.download-hint {
    margin-top: 0.45rem;
    font-size: 0.62rem;
    line-height: 1.4;
    color: var(--text-dim);
}

/* Selects */
.dark-select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.78rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23888' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    cursor: pointer;
}

.dark-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Size buttons */
.size-row {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.size-btn {
    flex: 1;
    min-width: 36px;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.45rem 0.2rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}

.size-btn:hover {
    border-color: var(--accent);
    color: var(--text);
}

.size-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
}

.size-dims {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 0.55rem;
    letter-spacing: 0.03em;
}

/* Color picker */
.color-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-picker {
    width: 36px;
    height: 36px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 2px;
    cursor: pointer;
    background: none;
}

.color-hex {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.78rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
}

.color-hex:focus {
    outline: none;
    border-color: var(--accent);
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem 1.25rem 0;
}

.link-back {
    font-size: 0.68rem;
    color: var(--text-dim);
    text-decoration: none;
    transition: color 0.15s;
}

.link-back:hover { color: var(--accent); }

/* ── Workspace / Canvas area (estilo editor) ── */
.canvas-area {
    display: flex;
    flex-direction: column;
    background: var(--bg-workspace);
    overflow: hidden;
    min-width: 0;
}

.canvas-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: rgba(18, 18, 18, 0.92);
    backdrop-filter: blur(8px);
    flex-shrink: 0;
    z-index: 2;
}

.view-tabs {
    display: flex;
    gap: 0.4rem;
}

.view-tab {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 0.45rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}

.view-tab:hover:not(:disabled) {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.view-tab .tab-icon { font-size: 0.85rem; }

.view-tab.active {
    background: rgba(212, 255, 0, 0.12);
    border-color: rgba(212, 255, 0, 0.35);
    color: var(--accent);
}

.view-tab:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.live-badge {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--accent);
}

/* Workspace: ocupa el área restante y centra el canvas */
.canvas-wrapper {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.editor-workspace {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background: var(--bg-workspace);
    padding: 1.5rem;
    gap: 1rem;
}

.size-badge {
    position: absolute;
    top: 1.25rem;
    right: 1.5rem;
    z-index: 10;
    background: rgba(27, 27, 27, 0.92);
    border: 1px solid rgba(212, 255, 0, 0.35);
    color: var(--accent);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 0.5rem 0.9rem;
    border-radius: 10px;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    line-height: 1.35;
    text-align: right;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.badge-row { white-space: nowrap; }

.badge-design {
    font-size: 0.62rem;
    font-weight: 600;
    color: #e8ff80;
    border-top: 1px solid rgba(212, 255, 0, 0.2);
    padding-top: 0.3rem;
}

.badge-dot { font-size: 0.5rem; vertical-align: middle; }

/* Canvas central (tarjeta del mockup) */
.editor-canvas {
    width: var(--canvas-size);
    height: var(--canvas-size);
    max-width: calc(100% - 1rem);
    max-height: calc(100% - 5rem);
    flex-shrink: 0;
    background: var(--bg-editor-canvas);
    border: 1px solid var(--border);
    border-radius: var(--radius-canvas);
    box-shadow: var(--shadow-canvas);
    overflow: hidden;
    position: relative;
}

.editor-canvas-inner {
    width: 100%;
    height: 100%;
    padding: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: var(--shadow-canvas-inset);
    background:
        radial-gradient(ellipse 70% 60% at 50% 42%, rgba(255, 255, 255, 0.025) 0%, transparent 72%),
        var(--bg-editor-canvas);
}

.mockup-workspace {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

.mockup-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transform-origin: center center;
    will-change: transform;
}

.shirt-container {
    position: relative;
    display: block;
    line-height: 0;
    user-select: none;
    flex-shrink: 0;
}

.shirt-render-stack {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.shirt-mask[hidden],
.shirt-svg-inline[hidden] {
    display: none !important;
}

.shirt-mask {
    width: 100%;
    height: 100%;
    background-color: var(--shirt-color, #ffffff);
    -webkit-mask-image: var(--shirt-url);
    mask-image: var(--shirt-url);
    -webkit-mask-size: 100% 100%;
    mask-size: 100% 100%;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.5));
}

.shirt-svg-inline {
    width: 100%;
    height: 100%;
    line-height: 0;
}

.shirt-svg-inline svg {
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.5));
}

.shirt-svg-inline .shirt-garment-part {
    color: var(--shirt-garment-color, #ffffff);
}

.shirt-svg-inline .shirt-outline-part {
    color: var(--shirt-outline-color, #575757);
}

.shirt-style-row {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.shirt-style-btn {
    flex: 1;
    min-width: 0;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.45rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.shirt-style-btn:hover {
    border-color: var(--accent);
    color: var(--text);
}

.shirt-style-btn.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

/* Empty state */
.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    z-index: 1;
    width: 60%;
}

.empty-state.hidden { display: none; }

.empty-icon {
    font-size: 1.5rem;
    opacity: 0.3;
    margin-bottom: 0.5rem;
}

.empty-title {
    font-size: 0.72rem;
    font-weight: 800;
    font-style: italic;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    margin-bottom: 0.3rem;
}

.empty-sub {
    font-size: 0.65rem;
    color: var(--text-dim);
    line-height: 1.4;
}

/* Capa del diseño — libre sobre la playera */
.design-layer {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
}

.design-box {
    position: absolute;
    box-sizing: border-box;
    pointer-events: all;
    display: none;
    touch-action: none;
}

.design-box.visible {
    display: block;
}

.design-box.dragging {
    cursor: grabbing;
}

.design-crop-wrap {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.design-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center center;
    cursor: grab;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

.design-box.dragging .design-image {
    cursor: grabbing;
}

.design-box:not(.selected) .design-image {
    cursor: pointer;
}

/* Marco morado estilo editor — solo visible con selección activa */
.design-frame-border {
    position: absolute;
    inset: -1px;
    border: 2px solid #b060ff;
    box-shadow: 0 0 0 1px rgba(176, 96, 255, 0.35);
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.design-box.selected .design-frame-border {
    opacity: 1;
}

/* Handles de transformación */
.tf-handle {
    position: absolute;
    z-index: 6;
    transform: translate(-50%, -50%);
    box-sizing: border-box;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.design-box.selected .tf-handle {
    opacity: 1;
    pointer-events: all;
}

.tf-corner {
    width: 14px;
    height: 14px;
    background: #ffffff;
    border: 2.5px solid #b060ff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.tf-edge {
    width: 24px;
    height: 11px;
    background: #ffffff;
    border: 2px solid #b060ff;
    border-radius: 999px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.tf-nw { top: 0; left: 0; cursor: nwse-resize; }
.tf-ne { top: 0; left: 100%; cursor: nesw-resize; }
.tf-sw { top: 100%; left: 0; cursor: nesw-resize; }
.tf-se { top: 100%; left: 100%; cursor: nwse-resize; }
.tf-n  { top: 0; left: 50%; cursor: ns-resize; }
.tf-s  { top: 100%; left: 50%; cursor: ns-resize; }
.tf-e  { top: 50%; left: 100%; cursor: ew-resize; }
.tf-w  { top: 50%; left: 0; cursor: ew-resize; }

.tf-handle:hover {
    background: #f3e8ff;
    transform: translate(-50%, -50%) scale(1.12);
}

/* Toolbar flotante bajo el canvas */
.canvas-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    pointer-events: none;
    z-index: 10;
    flex-shrink: 0;
}

.tool-btn {
    pointer-events: all;
    width: 38px;
    height: 38px;
    background: rgba(27, 27, 27, 0.95);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    font-size: 1rem;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.tool-btn:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(212, 255, 0, 0.08);
}

.tool-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.design-info {
    font-size: 0.65rem;
    color: var(--text-dim);
    pointer-events: none;
    z-index: 9;
    text-align: center;
    flex-shrink: 0;
    min-height: 1rem;
}

/* Scrollbar */
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

@media (max-width: 768px) {
    .app-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: auto;
        min-height: 100vh;
    }

    .sidebar { max-height: 50vh; }

    body.mockup-app { overflow: auto; }

    .editor-workspace {
        padding: 1rem;
    }

    .editor-canvas {
        width: min(100%, 700px);
        height: min(calc(100vh - 280px), 700px);
        max-height: none;
    }

    .editor-canvas-inner {
        padding: 1.75rem;
    }

    .size-badge {
        position: static;
        align-self: flex-end;
        order: -1;
    }
}
