/* =========================================================================
   Vida Dupla — Coordenadas do Grid
   ========================================================================= */

:root {
    --bg:        #0a0e14;
    --bg-2:      #111722;
    --panel:     #151c28;
    --panel-2:   #1b2433;
    --line:      #263043;
    --text:      #e7ecf3;
    --muted:     #8b97aa;
    --brand:     #f39200;   /* laranja do logo */
    --brand-2:   #1e5c99;   /* azul do logo */

    --c-free:    #2fa860;
    --c-single:  #e5484d;
    --c-var:     #f08cb4;
    --c-main:    #3b8ee8;

    --cell: 18px;
    --gap: 2px;
    --radius: 12px;
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}

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

html, body { margin: 0; min-height: 100%; }

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background:
        radial-gradient(1200px 500px at 85% -10%, rgba(243,146,0,.10), transparent 60%),
        radial-gradient(900px 500px at -10% 0%, rgba(30,92,153,.22), transparent 60%),
        var(--bg);
    background-attachment: fixed;
    display: flex;
    flex-direction: column;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Topo ---------- */
.topbar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 18px clamp(16px, 3vw, 40px);
    border-bottom: 1px solid var(--line);
    background: rgba(10,14,20,.6);
    backdrop-filter: blur(8px);
}
.brand img { height: 64px; width: auto; display: block; }
.topbar h1 { margin: 0; font-size: clamp(20px, 2.4vw, 28px); font-weight: 700; letter-spacing: -.01em; }
.topbar p  { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

/* ---------- Estrutura ---------- */
.page { flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; padding: 24px clamp(16px, 3vw, 40px); }

.layout {
    display: grid;
    grid-template-columns: 270px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.sidebar { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 16px; }

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
}
.card h2 {
    margin: 0 0 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
}
.hint { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

/* ---------- Direcional ---------- */
.dpad {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 48px);
    grid-template-rows: repeat(3, 48px);
    gap: 6px;
    justify-content: center;
    width: max-content;
    margin: 0 auto;
    padding: 18px 26px;
}
.dpad-btn {
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    transition: background .15s, border-color .15s, transform .1s;
}
.dpad-btn svg { width: 22px; height: 22px; fill: var(--text); stroke: var(--text); }
.dpad-btn:hover { background: var(--brand); border-color: var(--brand); text-decoration: none; }
.dpad-btn:hover svg { fill: #111; stroke: #111; }
.dpad-btn:active { transform: scale(.94); }
.dpad-btn.up    { grid-area: 1 / 2; }
.dpad-btn.left  { grid-area: 2 / 1; }
.dpad-btn.mid   { grid-area: 2 / 2; background: var(--brand-2); border-color: var(--brand-2); }
.dpad-btn.right { grid-area: 2 / 3; }
.dpad-btn.down  { grid-area: 3 / 2; }
.dpad span { position: absolute; font: 600 10px var(--mono); color: var(--muted); }
.dpad-n { top: 0; left: 50%; transform: translateX(-50%); }
.dpad-s { bottom: 0; left: 50%; transform: translateX(-50%); }
.dpad-w { left: 6px; top: 50%; transform: translateY(-50%); }
.dpad-e { right: 6px; top: 50%; transform: translateY(-50%); }

/* ---------- Formulário ---------- */
.coord-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
.coord-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.coord-form input {
    width: 100%;
    padding: 8px 10px;
    font: 500 14px var(--mono);
    color: var(--text);
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    -moz-appearance: textfield;
}
.coord-form input::-webkit-outer-spin-button,
.coord-form input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.coord-form input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(243,146,0,.25); }
.coord-form button, .copy-btn {
    padding: 8px 14px;
    font: 600 14px var(--font);
    color: #111;
    background: var(--brand);
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: filter .15s;
}
.coord-form button:hover, .copy-btn:hover { filter: brightness(1.1); }

/* ---------- Estatísticas ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; text-align: center; padding: 14px; }
.stats div + div { border-left: 1px solid var(--line); }
.stats strong { display: block; font: 700 26px var(--mono); }
.stats span { font-size: 12px; color: var(--muted); }
.free-txt { color: var(--c-free); }
.occ-txt  { color: var(--c-single); }

/* ---------- Detalhes ---------- */
.details dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 13px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 500; word-break: break-word; }
.copy-btn { width: 100%; margin-top: 12px; }

/* ---------- Legenda ---------- */
.legend ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.legend li { display: flex; align-items: center; gap: 10px; }
.sw { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.sw.free   { background: var(--c-free); }
.sw.single { background: var(--c-single); }
.sw.var    { background: var(--c-var); }
.sw.main   { background: var(--c-main); }

/* ---------- Mapa ---------- */
.map-wrap {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    min-width: 0;
}
.map-scroll { overflow-x: auto; padding-bottom: 4px; position: relative; }
.map {
    display: grid;
    grid-template-columns: 44px repeat(var(--cols), var(--cell));
    grid-template-rows: 46px;
    grid-auto-rows: var(--cell);
    gap: var(--gap);
    width: max-content;
    margin: 0 auto;
}
.corner { font: 600 9px var(--mono); color: var(--muted); align-self: end; }
.map .corner { display: flex; align-items: flex-end; padding-bottom: 4px; position: sticky; left: 0; z-index: 3; background: var(--panel); }

.axis-x, .axis-y {
    font: 500 10px var(--mono);
    color: #566174;
    display: flex;
    user-select: none;
}
.axis-x {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    align-items: center;
    justify-content: flex-start;
    padding-top: 4px;
}
.axis-y { align-items: center; justify-content: flex-end; padding-right: 6px; position: sticky; left: 0; z-index: 3; background: var(--panel); }
.axis-x.major, .axis-y.major { color: var(--muted); }
.axis-x.focus, .axis-y.focus { color: var(--brand); font-weight: 700; }

.cell {
    width: var(--cell);
    height: var(--cell);
    padding: 0;
    border: 0;
    border-radius: 3px;
    cursor: pointer;
    transition: transform .1s, box-shadow .1s, filter .1s;
}
.cell.free   { background: var(--c-free); opacity: .7; }
.cell.single { background: var(--c-single); }
.cell.var    { background: var(--c-var); }
.cell.main   { background: var(--c-main); }
.cell:hover, .cell:focus-visible {
    transform: scale(1.35);
    position: relative;
    z-index: 2;
    opacity: 1;
    outline: none;
    box-shadow: 0 0 0 2px #fff, 0 4px 12px rgba(0,0,0,.6);
}
.cell.target { box-shadow: 0 0 0 2px var(--brand); }
.cell.pinned { box-shadow: 0 0 0 2px #fff; transform: scale(1.2); position: relative; z-index: 1; }

.alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 8px;
    background: rgba(229,72,77,.12);
    border: 1px solid rgba(229,72,77,.4);
    color: #ffb3b5;
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translate(-50%, 20px);
    padding: 10px 16px;
    border-radius: 8px;
    background: var(--brand);
    color: #111;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Rodapé ---------- */
.footer {
    padding: 18px;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    border-top: 1px solid var(--line);
}
.footer .sep { margin: 0 8px; }

/* ---------- Responsivo ---------- */
@media (min-width: 1400px) { :root { --cell: 21px; } }
@media (max-width: 960px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar {
        position: static;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }
    .map-wrap { order: -1; }
}
@media (max-width: 560px) {
    :root { --cell: 16px; }
    .brand img { height: 44px; }
    .topbar { gap: 12px; }
    .map-wrap { padding: 10px; }
}
