/* ==========================================================================
   PoletCAD — Estilos globais
   Layout responsivo: Desktop (paineis laterais) e Mobile (bottom sheet)
   ========================================================================== */

:root {
    --color-bg: #1e1e1e;
    --color-panel: #252526;
    --color-panel-alt: #2d2d30;
    --color-border: #3c3c3c;
    --color-text: #d4d4d4;
    --color-text-dim: #858585;
    --color-accent: #0e639c;
    --color-accent-hover: #1177bb;
    --color-canvas: #f5f5f5;
    --color-grid: #e0e0e0;
    --color-grid-strong: #c8c8c8;

    --toolbar-height: 48px;
    --status-height: 26px;
    --panel-width: 240px;

    --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font);
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-user-select: none;
    user-select: none;
}

/* Estrutura principal em grade */
.app {
    display: grid;
    grid-template-rows: var(--toolbar-height) 1fr var(--status-height);
    height: 100vh;
    width: 100vw;
}

/* ---------------------------------------------------------------- Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    background: var(--color-panel);
    border-bottom: 1px solid var(--color-border);
    overflow-x: auto;
}

.toolbar .brand {
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-right: 12px;
    color: #fff;
    white-space: nowrap;
}

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

.tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 36px;
    height: 34px;
    padding: 0 10px;
    background: transparent;
    color: var(--color-text);
    border: 1px solid transparent;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
}

.tool-btn:hover {
    background: var(--color-panel-alt);
    border-color: var(--color-border);
}

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

/* ------------------------------------------------------------------- Body */
.body {
    display: grid;
    grid-template-columns: var(--panel-width) 1fr var(--panel-width);
    min-height: 0;
}

.panel {
    background: var(--color-panel);
    overflow-y: auto;
    padding: 10px;
}

.panel-left {
    border-right: 1px solid var(--color-border);
}

.panel-right {
    border-left: 1px solid var(--color-border);
}

.panel h2 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--color-text-dim);
    margin-bottom: 10px;
}

/* ------------------------------------------------------------ Canvas area */
.canvas-area {
    position: relative;
    min-width: 0;
    background: var(--color-canvas);
    overflow: hidden;
}

.canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: crosshair;
}

/* ------------------------------------------------------------- Status bar */
.status-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 12px;
    background: var(--color-accent);
    color: #fff;
    font-size: 12px;
    overflow: hidden;
    white-space: nowrap;
}

.status-bar .status-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ----------------------------------------------------------- Bottom sheet */
.bottom-sheet {
    display: none;
}

/* ------------------------------------------------------ Layers / listagem */
.layer-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 4px;
    border-radius: 4px;
    cursor: pointer;
}

.layer-row:hover {
    background: var(--color-panel-alt);
}

.layer-row.active {
    background: var(--color-accent);
}

.layer-row .swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.layer-row .name {
    flex: 1;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.layer-row .toggle {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 13px;
    opacity: 0.8;
}

/* ------------------------------------------------------ Painel propriedade */
.prop-group {
    margin-bottom: 14px;
}

.prop-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
}

.prop-row .label {
    color: var(--color-text-dim);
}

.prop-row .value {
    font-variant-numeric: tabular-nums;
}

.prop-row input {
    width: 90px;
    background: var(--color-panel-alt);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 13px;
    text-align: right;
}

.empty-hint {
    font-size: 12px;
    color: var(--color-text-dim);
    line-height: 1.5;
}

/* =========================================================== Responsivo === */
@media (max-width: 820px) {
    .app {
        grid-template-rows: var(--toolbar-height) 1fr var(--status-height);
    }

    /* No mobile os paineis laterais somem; usamos o bottom sheet */
    .body {
        grid-template-columns: 1fr;
    }

    .panel-left,
    .panel-right {
        display: none;
    }

    .bottom-sheet {
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        max-height: 45vh;
        background: var(--color-panel);
        border-top: 1px solid var(--color-border);
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.4);
        transform: translateY(calc(100% - 40px));
        transition: transform 0.25s ease;
        z-index: 20;
        overflow: hidden;
    }

    .bottom-sheet.open {
        transform: translateY(0);
    }

    .bottom-sheet .handle {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 40px;
        cursor: pointer;
        font-size: 13px;
        color: var(--color-text-dim);
    }

    .bottom-sheet .sheet-body {
        max-height: calc(45vh - 40px);
        overflow-y: auto;
        padding: 0 12px 16px;
    }
}
