/* ═══════════════════════════════════════════════════════════
   WC Ticket Map — Frontend  v2
   Abordagem SVG: totalmente responsivo, sem canvas
   ═══════════════════════════════════════════════════════════ */

/* ── Reset box ──────────────────────────────────────────── */
.tm-wrap *,
.tm-wrap *::before,
.tm-wrap *::after { box-sizing: border-box; }

/* ── Wrapper externo ────────────────────────────────────── */
.tm-wrap {
    --tm-radius: 12px;
    --tm-border: #e2e8f0;
    --tm-bg: #ffffff;
    --tm-bg-panel: #f8fafc;
    --tm-text: #1a202c;
    --tm-muted: #718096;
    --tm-accent: #ff6600;
    --tm-shadow: 0 4px 24px rgba(0,0,0,.09);

    background: var(--tm-bg);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius);
    overflow: hidden;
    box-shadow: var(--tm-shadow);
    margin-bottom: 32px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Cabeçalho ───────────────────────────────────────────── */
.tm-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: var(--tm-text);
    color: #fff;
    font-size: .95rem;
    font-weight: 600;
    letter-spacing: .02em;
}

.tm-header-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: .85;
}

/* ── Body: mapa + painel ─────────────────────────────────── */
.tm-body {
    display: grid;
    grid-template-columns: 1fr 240px;
    min-height: 0;
}

/* ── Mapa ────────────────────────────────────────────────── */
.tm-map-outer {
    position: relative;
    border-right: 1px solid var(--tm-border);
    background: #f0f0f0;
}

/* Inner = relativo para o SVG overlay ficar em cima */
.tm-map-inner {
    position: relative;
    width: 100%;
    line-height: 0;   /* remove espaço extra do inline */
}

#tm-map-img {
    display: block;
    width: 100%;
    height: auto;
}

/* SVG overlay: cobre exatamente a imagem */
#tm-svg-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
}

/* ── Zonas SVG ───────────────────────────────────────────── */
.tm-zone {
    transition: opacity .15s;
    outline: none;
}

.tm-zone-rect {
    transition: fill-opacity .18s, stroke-width .18s;
}

.tm-zone-label {
    fill: #fff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 700;
    paint-order: stroke;
    stroke: rgba(0,0,0,.65);
    stroke-width: 24px;
    stroke-linejoin: round;
    pointer-events: none;
    user-select: none;
}

/* ── Painel lateral ──────────────────────────────────────── */
.tm-panel {
    display: flex;
    flex-direction: column;
    background: var(--tm-bg-panel);
    padding: 16px;
    gap: 16px;
    min-width: 0;
}

/* Card de seleção */
.tm-selected-card {
    border: 1.5px solid var(--tm-border);
    border-radius: 10px;
    background: #fff;
    padding: 14px;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tm-selected-placeholder {
    text-align: center;
    color: var(--tm-muted);
}

.tm-selected-placeholder svg {
    width: 28px; height: 28px;
    margin: 0 auto 6px;
    display: block;
    opacity: .45;
}

.tm-selected-placeholder p {
    margin: 0;
    font-size: .78rem;
    line-height: 1.4;
}

.tm-selected-content {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
}

.tm-selected-dot {
    width: 14px; height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 3px;
    box-shadow: 0 0 0 3px rgba(0,0,0,.08);
}

.tm-selected-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.tm-selected-tag {
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--tm-muted);
}

.tm-selected-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--tm-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tm-selected-price {
    font-size: .9rem;
    color: var(--tm-text);
    font-weight: 600;
}

.tm-selected-price .amount {
    color: var(--tm-accent);
}

.tm-disponivel {
    font-size: .75rem;
    font-weight: 600;
    color: #22863a;
}

.tm-esgotado {
    font-size: .75rem;
    font-weight: 600;
    color: #cb2431;
}

/* ── Legenda ─────────────────────────────────────────────── */
.tm-legend-title {
    margin: 0 0 8px;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--tm-muted);
}

.tm-legend-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tm-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 8px;
    cursor: pointer;
    border: 1.5px solid transparent;
    background: #fff;
    transition: all .15s;
    font-size: .83rem;
    color: var(--tm-text);
}

.tm-legend-item:hover {
    border-color: var(--tm-border);
    transform: translateX(2px);
}

.tm-legend-item.tm-active {
    border-color: currentColor;
    background: #fff;
    font-weight: 600;
}

.tm-legend-swatch {
    width: 10px; height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

.tm-legend-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tm-legend-check {
    width: 14px; height: 14px;
    color: #22863a;
    opacity: 0;
    flex-shrink: 0;
    transition: opacity .15s;
}

.tm-legend-item.tm-active .tm-legend-check {
    opacity: 1;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVO
   ═══════════════════════════════════════════════════════════ */

/* Tablet: painel embaixo */
@media (max-width: 900px) {
    .tm-body {
        grid-template-columns: 1fr;
    }

    .tm-map-outer {
        border-right: none;
        border-bottom: 1px solid var(--tm-border);
    }

    .tm-panel {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 12px;
        padding: 14px;
    }

    .tm-selected-card {
        flex: 1 1 200px;
        min-height: 70px;
    }

    .tm-legend {
        flex: 1 1 200px;
    }

    .tm-legend-list {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }

    .tm-legend-item {
        flex: 0 0 auto;
    }
}

/* Mobile pequeno */
@media (max-width: 480px) {
    .tm-header {
        padding: 12px 14px;
        font-size: .85rem;
    }

    .tm-panel {
        padding: 12px;
        flex-direction: column;
    }

    .tm-legend-list {
        flex-direction: column;
    }

    .tm-legend-item {
        padding: 9px 12px;
        font-size: .88rem;
    }

    .tm-selected-name {
        font-size: .95rem;
    }
}

/* ── Lock styles ─────────────────────────────────────────── */
.tm-legend-item.tm-locked {
    opacity: .5;
    cursor: not-allowed;
    text-decoration: line-through;
}

.tm-legend-item.tm-locked::after {
    content: ' 🔒';
    font-size: .7em;
}

.tm-legend-item.tm-mine {
    border-style: dashed;
    font-weight: 600;
}

.tm-legend-item.tm-mine::after {
    content: ' ✓ no carrinho';
    font-size: .7em;
    color: #22863a;
}

.tm-lock-notice {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-left: 4px solid #ffc107;
    color: #856404;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: .88rem;
    margin-bottom: 12px;
}
