/* ================================================================
   criscuolo.online — Criador de Fluxograma
   ================================================================ */

:root {
    --brand-gold: #D4A843;
    --brand-gold-light: #E0BE6A;
    --brand-gold-dark: #B8922F;
    --brand-gradient: linear-gradient(135deg, #D4A843, #E0BE6A, #D4A843);
    --cta-gradient: linear-gradient(135deg, #D4A843, #B8922F);

    --bg-primary: #16161E;
    --bg-secondary: #1C1C26;
    --bg-card: rgba(24, 24, 32, 0.88);
    --bg-card-border: rgba(212, 168, 67, 0.12);
    --bg-card-border-hover: rgba(212, 168, 67, 0.3);
    --bg-input: #141420;

    --text-primary: #F2F0EB;
    --text-secondary: #9B978E;
    --text-muted: #6B6760;
    --text-accent: #D4A843;

    --color-success: #22C55E;
    --color-error: #EF4444;

    --border-radius: 16px;
    --border-radius-sm: 10px;
    --border-radius-xs: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-glow: 0 0 40px rgba(212, 168, 67, 0.1);
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-button: 0 4px 15px rgba(212, 168, 67, 0.25);
    --shadow-button-hover: 0 6px 25px rgba(212, 168, 67, 0.35);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

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

html {
    font-size: 16px;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; }
textarea, select, input { font-family: var(--font); }

/* ================================================================
   Fundo decorativo
   ================================================================ */
.bg-effects {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.35;
}
.orb-1 { width: 600px; height: 600px; background: radial-gradient(circle, rgba(212,168,67,0.18) 0%, transparent 70%); top: -200px; right: -100px; }
.orb-2 { width: 500px; height: 500px; background: radial-gradient(circle, rgba(184,146,47,0.12) 0%, transparent 70%); bottom: -150px; left: -100px; }
.orb-3 { width: 400px; height: 400px; background: radial-gradient(circle, rgba(212,168,67,0.08) 0%, transparent 70%); top: 40%; left: 30%; }
.orb-4 { width: 300px; height: 300px; background: radial-gradient(circle, rgba(224,190,106,0.1) 0%, transparent 70%); bottom: 10%; right: 20%; }

.grid-overlay {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(212,168,67,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(212,168,67,0.03) 1px, transparent 1px);
    background-size: 40px 40px;
}

/* ================================================================
   Mouse Glow
   ================================================================ */
.mouse-glow {
    position: fixed;
    width: 700px;
    height: 700px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(212,168,67,0.06) 0%, rgba(212,168,67,0.02) 40%, transparent 70%);
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.5s ease;
}
.mouse-glow.visible { opacity: 1; }

/* ================================================================
   Header
   ================================================================ */
.header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    padding: 0 24px;
    background: rgba(22,22,30,.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(212,168,67,.08);
    transition: var(--transition);
}
.header.scrolled { background: rgba(22,22,30,.95); border-bottom-color: rgba(212,168,67,.15); }

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    flex-shrink: 0;
}

.logo-img-wrapper {
    width: 44px; height: 44px;
    background: radial-gradient(circle,rgba(255,255,255,.95) 60%,rgba(255,255,255,.6) 80%,transparent 100%);
    border-radius: 50%; padding: 5px;
    box-shadow: 0 0 16px rgba(212,168,67,.15);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    transition: var(--transition);
}
.logo-img-wrapper:hover { box-shadow: 0 0 24px rgba(212,168,67,.25); }

.logo-img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; }

.logo-text-group { display: flex; align-items: baseline; }
.logo-text { font-size: 1.25rem; font-weight: 800; color: var(--text-primary); letter-spacing: -0.02em; }
.logo-text-accent { font-size: 1.25rem; font-weight: 800; color: var(--brand-gold); letter-spacing: -0.02em; }

.nav { display: flex; align-items: center; gap: 8px; }
.nav-link { font-size: .9rem; font-weight: 600; color: var(--text-secondary); padding: 8px 14px; border-radius: var(--border-radius-xs); transition: var(--transition); }
.nav-link:hover { color: var(--text-primary); background: var(--bg-hover); }
.nav-link-active { color: var(--brand-gold) !important; background: rgba(212,168,67,.08); }
.nav-cta { font-size: .9rem; font-weight: 700; color: #0C0C0E; background: var(--cta-gradient); padding: 9px 18px; border-radius: var(--border-radius-sm); box-shadow: var(--shadow-button); transition: var(--transition); margin-left: 8px; }
.nav-cta:hover { transform: translateY(-1px); box-shadow: var(--shadow-button-hover); }

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}
.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
}

/* ================================================================
   Utilities
   ================================================================ */
.gradient-text {
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.breadcrumb {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
    transition: var(--transition);
}
.breadcrumb:hover { color: var(--text-secondary); }

/* ================================================================
   Layout principal
   ================================================================ */
.flowchart-main {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Hero compacto */
.page-hero-compact {
    flex-shrink: 0;
    padding: 68px 20px 12px;
    border-bottom: 1px solid var(--bg-card-border);
    background: rgba(22, 22, 30, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.page-hero-inner { max-width: 1400px; margin: 0 auto; }

.hero-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.hero-left { display: flex; flex-direction: column; }

.page-title {
    font-size: clamp(1.2rem, 2.5vw, 1.7rem);
    font-weight: 900;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.page-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ================================================================
   Toolbar
   ================================================================ */
.flowchart-toolbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-card-border);
    overflow-x: auto;
    scrollbar-width: none;
}
.flowchart-toolbar::-webkit-scrollbar { display: none; }

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.toolbar-group-right { margin-left: auto; }

.toolbar-sep {
    width: 1px;
    height: 22px;
    background: var(--bg-card-border);
    margin: 0 8px;
    flex-shrink: 0;
}

.btn-tool {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 9px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--border-radius-xs);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-tool:hover {
    background: var(--bg-card);
    border-color: var(--bg-card-border);
    color: var(--text-primary);
}

.btn-tool.active {
    background: rgba(212,168,67,0.12);
    border-color: rgba(212,168,67,0.3);
    color: var(--brand-gold);
}

.btn-tool:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.btn-tool:disabled:hover {
    background: transparent;
    border-color: transparent;
    transform: none;
}

.btn-export {
    color: var(--text-secondary);
}
.btn-export:hover { color: var(--brand-gold); }

.btn-danger {
    color: var(--color-error);
}
.btn-danger:hover {
    background: rgba(239,68,68,0.1);
    border-color: rgba(239,68,68,0.3);
    color: var(--color-error);
}

.btn-danger-soft:hover {
    background: rgba(239,68,68,0.08);
    border-color: rgba(239,68,68,0.2);
    color: var(--color-error);
}

.zoom-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 38px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

/* ================================================================
   Workspace
   ================================================================ */
.flowchart-workspace {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
}

/* ================================================================
   Sidebar esquerda
   ================================================================ */
.flowchart-sidebar {
    flex-shrink: 0;
    width: 168px;
    background: rgba(22, 22, 30, 0.85);
    border-right: 1px solid var(--bg-card-border);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-card-border) transparent;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sidebar-section {}

.sidebar-title {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding-left: 2px;
}

/* Paleta de formas */
.shape-palette {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
}

.shape-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: var(--border-radius-xs);
    border: 1px solid transparent;
    cursor: grab;
    transition: var(--transition);
    width: 100%;
    background: rgba(28,28,38,0.6);
}
.shape-item:hover {
    border-color: var(--bg-card-border-hover);
    background: rgba(212,168,67,0.06);
    transform: translateX(2px);
}
.shape-item:active { cursor: grabbing; }

.shape-item-sm { width: auto; }

/* Legenda */
.legend-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.legend-shape-rect,
.legend-shape-diamond,
.legend-shape-terminal,
.legend-shape-para,
.legend-shape-circle {
    display: inline-block;
    flex-shrink: 0;
    border: 1.5px solid var(--brand-gold);
}

.legend-shape-rect { width: 18px; height: 10px; border-radius: 1px; }
.legend-shape-diamond {
    width: 12px; height: 12px;
    transform: rotate(45deg);
    border-radius: 1px;
}
.legend-shape-terminal { width: 18px; height: 10px; border-radius: 6px; }
.legend-shape-para { width: 18px; height: 10px; transform: skewX(-15deg); }
.legend-shape-circle { width: 11px; height: 11px; border-radius: 50%; }

/* Atalhos */
.shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.shortcut {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.shortcut kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1px 5px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ================================================================
   Canvas principal
   ================================================================ */
.flowchart-canvas-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-width: 0;
    background: #12121a;
}

#canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.grid-bg { pointer-events: all; }

/* Estado vazio */
.canvas-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    pointer-events: none;
    transition: opacity 0.3s;
}

.canvas-empty.hidden { opacity: 0; }

.canvas-empty-icon { font-size: 2.5rem; opacity: 0.4; }

.canvas-empty-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-muted);
}

.canvas-empty-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
    max-width: 300px;
    line-height: 1.5;
    opacity: 0.7;
}

.canvas-empty-desc kbd {
    display: inline;
    padding: 1px 5px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
}

/* ================================================================
   Painel de propriedades (direita)
   ================================================================ */
.flowchart-props {
    flex-shrink: 0;
    width: 200px;
    background: rgba(22, 22, 30, 0.85);
    border-left: 1px solid var(--bg-card-border);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-card-border) transparent;
    padding: 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.props-section {}

.props-title {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.props-empty {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    padding: 4px 0;
}

.props-content { display: flex; flex-direction: column; gap: 8px; }

.prop-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.prop-label {
    font-size: 0.73rem;
    color: var(--text-secondary);
    flex: 1;
    line-height: 1.3;
}

.prop-color {
    width: 32px;
    height: 24px;
    border: 1px solid var(--bg-card-border);
    border-radius: 5px;
    cursor: pointer;
    padding: 1px;
    background: transparent;
    flex-shrink: 0;
}
.prop-color::-webkit-color-swatch-wrapper { padding: 0; }
.prop-color::-webkit-color-swatch { border: none; border-radius: 4px; }

.prop-number {
    width: 52px;
    padding: 3px 6px;
    background: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: 5px;
    color: var(--text-primary);
    font-size: 0.78rem;
    font-weight: 500;
    text-align: right;
    outline: none;
    flex-shrink: 0;
}
.prop-number:focus { border-color: var(--brand-gold-dark); }

.prop-select {
    width: 100%;
    padding: 4px 6px;
    background: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: 5px;
    color: var(--text-primary);
    font-size: 0.78rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
}
.prop-select:focus { border-color: var(--brand-gold-dark); }
.prop-select option { background: var(--bg-secondary); }

/* Paleta de cores rápida */
.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.palette-color {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    border: 1.5px solid transparent;
}
.palette-color:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

.btn-edge-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--border-radius-xs);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 4px;
}
.btn-edge-label:hover {
    border-color: var(--bg-card-border-hover);
    color: var(--text-primary);
}

/* ================================================================
   SVG: Nós e arestas
   ================================================================ */
.node-group { cursor: move; }
.node-group:hover .node-shape { filter: brightness(1.15); }

.node-shape {
    transition: filter 0.15s;
}

.edge-group { cursor: pointer; }
.edge-hit { pointer-events: stroke; }

/* Portas de conexão */
.port {
    cursor: crosshair;
    opacity: 0;
    transition: opacity 0.15s;
}
.port.visible { opacity: 1; }
.port:hover { transform-box: fill-box; transform-origin: center; }

/* Handles de seleção / redimensionamento */
.resize-handle {
    cursor: nw-resize;
}
.resize-handle[data-pos="n"],
.resize-handle[data-pos="s"] { cursor: ns-resize; }
.resize-handle[data-pos="e"],
.resize-handle[data-pos="w"] { cursor: ew-resize; }
.resize-handle[data-pos="ne"],
.resize-handle[data-pos="sw"] { cursor: nesw-resize; }
.resize-handle[data-pos="nw"],
.resize-handle[data-pos="se"] { cursor: nwse-resize; }

/* ================================================================
   Textarea flutuante (edição de texto)
   ================================================================ */
.text-editor-overlay {
    position: fixed;
    display: none;
    z-index: 200;
    background: rgba(22, 22, 30, 0.96);
    border: 2px solid var(--brand-gold);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font);
    font-weight: 500;
    text-align: center;
    padding: 6px 8px;
    resize: none;
    outline: none;
    overflow: hidden;
    line-height: 1.4;
    box-shadow: 0 0 0 4px rgba(212,168,67,0.15);
}

/* ================================================================
   Toast
   ================================================================ */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    background: rgba(30, 30, 40, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--bg-card-border);
    border-radius: 40px;
    padding: 9px 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--text-primary);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 999;
    white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast svg { color: var(--color-success); flex-shrink: 0; }

/* ================================================================
   Responsivo
   ================================================================ */
@media (max-width: 1024px) {
    .flowchart-props { width: 176px; }
}

@media (max-width: 860px) {
    .flowchart-sidebar { width: 140px; }
    .flowchart-props { display: none; }
    .page-subtitle { display: none; }
}

@media (max-width: 640px) {
    .nav {
        display: none;
        flex-direction: column;
        position: fixed;
        top: 64px; left: 0; right: 0;
        background: rgba(22,22,30,.97);
        backdrop-filter: blur(20px);
        padding: 16px;
        border-bottom: 1px solid var(--bg-card-border);
        z-index: 99;
    }
    .nav.open { display: flex; }
    .nav-toggle { display: flex; }

    .flowchart-sidebar { display: none; }
    .page-hero-compact { padding: 68px 14px 10px; }
    .page-title { font-size: 1.15rem; }
    .btn-label { display: none; }
    .flowchart-toolbar { padding: 5px 8px; }
}
