/* ============================================================
   map-ui.css — Territory dialog, minimap, map canvas,
   biome legend, floating actions, menu icon bar, map overlay
   ============================================================ */

/* DIALOGO DE TERRITORIO */
#territory-dialog-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 1000;
    pointer-events: none; /* Permitir cliques através do overlay */
}

#territory-dialog {
    background: rgba(10, 10, 30, 0.90);
    border: 3px solid rgba(240, 192, 64, 0.4);
    border-radius: 12px;
    padding: 15px;
    margin: 10px;
    min-width: auto;
    max-width: 280px;
    overflow-y: auto;
    box-shadow: none;
    position: fixed;
    top: 49px; /* Embaixo do player panel */
    left: 5px;
    pointer-events: auto; /* Ativar cliques no diálogo */
}

#territory-dialog-close {
    width: 30px;
    height: 30px;
}

#territory-dialog h3 {
    color: #f0c040;
    margin-bottom: 5px;
    font-size: 16px;
    padding-right: 30px;
    word-break: break-word;
    overflow-wrap: break-word;
}

.owned-badge-inline {
    background: #2d6e2d;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#territory-dialog .territory-id {
    color: #888;
    font-size: 12px;
    margin-bottom: 4px;
}

#territory-dialog .info-row {
    display: flex;
    justify-content: space-between;
    margin: 6px 0;
    font-size: 12px;
    gap: 8px;
}

#territory-dialog .info-label {
    color: #888;
    flex-shrink: 0;
}

#territory-dialog .info-value {
    color: #e0e0e0;
    font-weight: 500;
    text-align: right;
    word-break: break-word;
    overflow-wrap: break-word;
    min-width: 0;
}

#territory-dialog .action-btn {
    white-space: normal;
}

/* MINIMAP */
#minimap {
    position: fixed;
    bottom: 10px;
    left: 10px;
    width: 200px;
    height: 140px;
    border: 1px solid rgba(240, 192, 64, 0.3);
    border-radius: 8px;
    background: rgba(10, 10, 30, 0.92);
    z-index: 10;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.3s ease;
}

#minimap.expanded {
    z-index: 150;
    border: 2px solid rgba(240, 192, 64, 0.6);
    box-shadow: 0 8px 60px rgba(0, 0, 0, 0.9);
    cursor: crosshair;
    opacity: 1;
}

#minimap.expanded canvas {
    width: 100% !important;
    height: 100% !important;
}

#minimap-close {
    display: none;
    position: absolute;
    top: 10px;
    right: 10px;
    width: 20px;
    height: 20px;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 151;
    padding: 0;
    transition: opacity 0.2s;
}

#minimap-close:hover {
    opacity: 0.8;
}

#minimap.expanded #minimap-close {
    display: block;
}

#minimap-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 140;
}

#minimap-canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#minimap-viewport {
    position: absolute;
    border: 2px solid #f0c040;
    pointer-events: none;
}

/* Loading screen antigo removido - novo splash tem barra de progresso propria */

canvas#map-canvas {
    display: block;
    cursor: grab;
    touch-action: pinch-zoom pan-x pan-y; /* Permite zoom e pan APENAS no mapa */
}

canvas#map-canvas:active {
    cursor: grabbing;
}

#biome-legend {
    position: fixed;
    top: 50px;
    left: 20px;
    background: rgba(10, 10, 30, 0.92);
    border: 1px solid rgba(240, 192, 64, 0.3);
    border-radius: 8px;
    padding: 10px 15px;
    z-index: 10;
    font-size: 11px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

#biome-legend h4 {
    color: #f0c040;
    margin-bottom: 6px;
    font-size: 12px;
}

/* BOTAO FLUTUANTE DE ACOES */
#floating-actions {
    position: fixed;
    bottom: 10px;
    right: 10px;
    z-index: 15;
    display: flex;
    align-items: center;
    gap: 8px;

}

#actions-menu {
    position: relative;
    display: inline-block;
}

#action-timer-menu {
    position: relative;
    display: inline-block;
}

.actions-toggle-btn {
    background: linear-gradient(135deg, #c09030, #f0c040);
    color: #1a1a2e;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 26px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    box-shadow: 0 4px 15px rgba(240, 192, 64, 0.4);
}

.actions-toggle-btn:hover {
    transform: scale(1.1);
}

.actions-toggle-btn.open {
    transform: rotate(45deg);
}

.actions-dropdown {
    position: absolute;
    bottom: 0;
    right: calc(100% + 8px);
    display: none;
    flex-direction: column;
    gap: 5px;
    background: rgba(10, 10, 30, 0.98);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(240, 192, 64, 0.4);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    min-width: 180px;
    z-index: 100;
}

.actions-dropdown.open {
    display: flex;
}

.actions-dropdown .action-btn {
    white-space: nowrap;
    width: 100%;
    text-align: center;
    padding: 10px 15px;
}

/* MENU DE ÍCONES LATERAL */
#menu-icon-bar {
    position: fixed;
    top: 52px;
    right: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    z-index: 998;
}

.menu-icon-btn {
    background: rgba(240, 192, 64, 0.7);
    border: 1px solid rgba(200, 160, 48, 0.85);
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    transition: background 0.15s, border-color 0.15s;
    position: relative;
}

.menu-icon-btn img {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.menu-icon-btn:hover {
    background: rgba(255, 212, 84, 0.85);
    border-color: rgba(212, 170, 64, 0.95);
}

.menu-icon-btn--lottery {
    background: rgba(30, 10, 60, 0.9);
    border-color: rgba(180, 80, 255, 0.8);
    font-size: 16px;
    box-shadow: 0 0 8px rgba(180, 80, 255, 0.5);
    animation: lottery-pulse 2.5s ease-in-out infinite;
}
.menu-icon-btn--lottery.lottery-pulse {
    animation: lottery-pulse-alert 1.2s ease-in-out infinite !important;
}

.menu-icon-btn--lottery:hover {
    background: rgba(60, 20, 100, 0.95);
    border-color: rgba(200, 120, 255, 1);
    box-shadow: 0 0 14px rgba(180, 80, 255, 0.8);
}

@keyframes lottery-pulse {
    0%, 100% { box-shadow: 0 0 8px rgba(180, 80, 255, 0.5); }
    50% { box-shadow: 0 0 16px rgba(180, 80, 255, 0.9); }
}
@keyframes lottery-pulse-alert {
    0%   { transform: scale(1);    box-shadow: 0 0 10px rgba(240,192,64,0.8),  0 0 0 0 rgba(240,192,64,0.9);   border-color: #f0c040;  background: rgba(60,40,0,0.95); }
    25%  { transform: scale(1.3);  box-shadow: 0 0 28px rgba(255,60,60,1),     0 0 0 20px rgba(255,60,60,0);    border-color: #ff3c3c;  background: rgba(60,0,0,0.95); }
    50%  { transform: scale(1);    box-shadow: 0 0 10px rgba(80,200,255,0.8),  0 0 0 0 rgba(80,200,255,0.9);   border-color: #50c8ff;  background: rgba(0,30,60,0.95); }
    75%  { transform: scale(1.3);  box-shadow: 0 0 28px rgba(160,80,255,1),    0 0 0 20px rgba(160,80,255,0);   border-color: #a050ff;  background: rgba(30,0,60,0.95); }
    100% { transform: scale(1);    box-shadow: 0 0 10px rgba(240,192,64,0.8),  0 0 0 0 rgba(240,192,64,0.9);   border-color: #f0c040;  background: rgba(60,40,0,0.95); }
}

/* BOTÕES DE AÇÃO COM ÍCONE NO DIÁLOGO DE TERRITÓRIO */
.territory-action-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
    justify-content: center;
}

.territory-action-icon-btn {
    background: rgba(240, 192, 64, 0.12);
    border: 1px solid rgba(200, 160, 48, 0.5);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    padding: 10px 14px;
    min-width: 68px;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
    color: #f0c040;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
}

.territory-action-icon-btn img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

@media (max-width: 768px) {
    .territory-action-grid {
        gap: 6px;
        flex-wrap: nowrap;
    }
    .territory-action-icon-btn {
        padding: 7px 8px;
        min-width: 0;
        flex: 1;
        font-size: 9px;
        gap: 3px;
    }
    .territory-action-icon-btn img {
        width: 20px;
        height: 20px;
    }
}

.territory-action-icon-btn:hover:not(:disabled) {
    background: rgba(240, 192, 64, 0.22);
    border-color: rgba(200, 160, 48, 0.85);
}

.territory-action-icon-btn:disabled,
.territory-action-icon-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Recrutar — verde */
.territory-action-icon-btn.recruit {
    color: #4ade80;
    background: rgba(74, 222, 128, 0.08);
    border-color: #4ade80;
}
.territory-action-icon-btn.recruit img {
    filter: brightness(0) saturate(100%) invert(75%) sepia(40%) saturate(500%) hue-rotate(90deg) brightness(105%);
}
.territory-action-icon-btn.recruit:hover:not(:disabled) {
    background: rgba(74, 222, 128, 0.2);
    border-color: #4ade80;
}

/* Navios — azul */
.territory-action-icon-btn.ship {
    color: #7db8f7;
    background: rgba(30, 100, 180, 0.12);
    border-color: #2a6db5;
}
.territory-action-icon-btn.ship img {
    filter: brightness(0) saturate(100%) invert(65%) sepia(40%) saturate(500%) hue-rotate(185deg) brightness(110%);
}
.territory-action-icon-btn.ship:hover:not(:disabled) {
    background: rgba(30, 100, 180, 0.25);
    border-color: #7db8f7;
}

/* Muralha — bege/dourado escuro */
.territory-action-icon-btn.wall {
    color: #c0a060;
    background: rgba(192, 160, 96, 0.08);
    border-color: #c0a060;
}
.territory-action-icon-btn.wall img {
    filter: brightness(0) saturate(100%) invert(68%) sepia(30%) saturate(500%) hue-rotate(20deg) brightness(95%);
}
.territory-action-icon-btn.wall:hover:not(:disabled) {
    background: rgba(192, 160, 96, 0.2);
    border-color: #c0a060;
}

/* Renunciar — vermelho escuro */
.territory-action-icon-btn.renounce {
    color: #f87171;
    background: rgba(248, 113, 113, 0.08);
    border-color: #f87171;
}
.territory-action-icon-btn.renounce img {
    filter: brightness(0) saturate(100%) invert(58%) sepia(60%) saturate(600%) hue-rotate(310deg) brightness(110%);
}
.territory-action-icon-btn.renounce:hover:not(:disabled) {
    background: rgba(248, 113, 113, 0.2);
    border-color: #f87171;
}

/* Atacar — vermelho */
.territory-action-icon-btn.attack {
    color: #f87171;
    background: rgba(248, 113, 113, 0.08);
    border-color: #f87171;
}
.territory-action-icon-btn.attack img {
    filter: brightness(0) saturate(100%) invert(58%) sepia(60%) saturate(600%) hue-rotate(310deg) brightness(110%);
}
.territory-action-icon-btn.attack:hover:not(:disabled) {
    background: rgba(248, 113, 113, 0.2);
    border-color: #f87171;
}

/* Denunciar — laranja */
.territory-action-icon-btn.danger {
    color: #fb923c;
    background: rgba(251, 146, 60, 0.08);
    border-color: #fb923c;
}
.territory-action-icon-btn.danger img {
    filter: brightness(0) saturate(100%) invert(65%) sepia(70%) saturate(700%) hue-rotate(340deg) brightness(105%);
}
.territory-action-icon-btn.danger:hover:not(:disabled) {
    background: rgba(251, 146, 60, 0.2);
    border-color: #fb923c;
}

/* Pacto — branco */
.territory-action-icon-btn.pact {
    color: #e5e7eb;
    background: rgba(229, 231, 235, 0.08);
    border-color: #e5e7eb;
}
.territory-action-icon-btn.pact img {
    filter: brightness(0) invert(1);
}
.territory-action-icon-btn.pact:hover:not(:disabled) {
    background: rgba(229, 231, 235, 0.18);
    border-color: #fff;
}

/* Comprar — dourado */
.territory-action-icon-btn.buy {
    color: #f0c040;
    background: rgba(240, 192, 64, 0.08);
    border-color: #f0c040;
}
.territory-action-icon-btn.buy img {
    filter: brightness(0) saturate(100%) invert(78%) sepia(50%) saturate(600%) hue-rotate(5deg) brightness(105%);
}
.territory-action-icon-btn.buy:hover:not(:disabled) {
    background: rgba(240, 192, 64, 0.2);
    border-color: #f0c040;
}

/* ================================================
   EFEITO CLAREAMENTO DO MAPA
   ================================================ */

#map-fade-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    opacity: 1;
    transition: opacity 5s ease;
    z-index: 5;
    pointer-events: none;
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {
    /* Minimap mobile */
    #minimap {
        width: 120px;
        height: 85px;
        left: 10px;
        bottom: 10px;
        margin-bottom: 10px;
    }

    #minimap canvas {
        width: 120px;
        height: 85px;
    }

    #minimap.expanded canvas {
        width: 100% !important;
        height: 100% !important;
    }

    /* Botao flutuante mobile */
    #floating-actions {
        bottom: 20px;
        right: 10px;
    }

    .actions-toggle-btn {
        width: 42px;
        height: 42px;
        font-size: 22px;

    }

    /* Menu dropdown mobile */
    .actions-dropdown {
        bottom: 0;
        right: calc(100% + 8px);
        min-width: 150px;
    }

    .actions-dropdown .action-btn {
        padding: 8px 12px;
        font-size: 11px;
    }
}
