body {
    background: #f1f5f9;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.page-container {
    max-width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

/* Barra de Título Superior (Central) */
.header-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: #ffffff;
    border-bottom: 2px solid #e2e8f0;
    color: #1e3a8a;
    font-size: 20px;
    font-weight: 800;
}

.header-controls-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    margin-left: 20px;
}

.header-buttons-right {
    display: flex;
    gap: 4px;
}

.layout-btn-custom {
    width: 38px;
    height: 38px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
}

.gear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e2e8f0 !important;
    border-radius: 6px !important;
    padding: 4px 8px !important;
    background: #f1f5f9 !important;
    transition: background 0.2s, border-color 0.2s;
}

.gear-btn:hover {
    background: #dbeafe !important;
    border-color: #2563eb !important;
}

.gear-btn i {
    color: #2563eb;
    font-size: 18px;
    transition: transform 0.2s;
}

.layout-btn-custom:hover {
    background-color: #dbeafe;
    color: #1e40af;
}

.layout-btn-custom.active {
    background-color: #2563eb;
    color: #ffffff;
}

/* Grid de Mapas - Padrão CPTEC Fluído */
.map-container {
    display: grid;
    gap: 16px;
    padding: 16px;
    background-color: #f1f5f9;
    width: 100%;
    box-sizing: border-box;
    align-items: start; /* Garante que comecem no topo */
}

.map-container.grid-1 {
    grid-template-columns: 1fr;
}

.map-container.grid-2 {
    grid-template-columns: 1fr 1fr;
}

.map-container.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.map-container.grid-4 {
    grid-template-columns: 1fr 1fr;
}

/* Janela de Visualização */
.map-view {
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%; /* Força ocupar a coluna toda */
    min-width: 0;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: nowrap; /* Evita quebra de linha para manter compacto */
    gap: 8px;
}

.view-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    position: relative; /* Adicionado para ancorar o menu de configuração */
}

.view-header-right {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
    position: relative; /* Necessário para o painel de horas absolute */
}

.view-info {
    display: flex;
    flex-direction: column;
}

.info-modelo-text {
    font-size: 15px; /* Reduzido de 18px */
    font-weight: bold;
    color: #111111;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.info-data-text {
    font-size: 13px;
    color: #4b5563;
    font-weight: 500;
}

.info-extra-text {
    font-size: 14px;
    color: #2563eb;
    font-weight: 600;
    line-height: 1.2;
}

.info-init-text {
    font-size: 13px;
    color: #1e3a8a;
    font-weight: 700;
    line-height: 1.2;
    margin-top: 2px;
}

.info-update-text {
    font-size: 11px;
    color: #64748b;
    font-style: italic;
    line-height: 1.2;
}

/* Área do Mapa - Foco na Verticalidade */
.map-content {
    padding: 0;
    text-align: center;
    width: 100%;
    min-width: 0;
    height: calc(100vh - 180px); /* Garante o tamanho mesmo sem imagem */
    background-color: #f8fafc; /* Fundo discreto para quadros vazios */
    display: flex;
    align-items: center;
    justify-content: center;
}

.mapa-img {
    width: 100%;
    height: calc(100vh - 180px); /* Altura fixa para alinhar todos os quadros */
    display: block;
    margin: 0 auto;
    object-fit: contain; /* Garante que a imagem caiba toda sem distorcer */
    background-color: #f8fafc; /* Fundo suave para imagens com proporções diferentes */
    border-radius: 4px;
}

/* Ajuste específico para quando houver 4 quadros (2x2) */
.map-container.grid-4 .map-content,
.map-container.grid-4 .mapa-img {
    height: calc(45vh - 90px);
}

/* Componentes de Interface */
.gear-btn i {
    transition: transform 0.2s;
}

.gear-btn:hover i {
    color: #1e3a8a;
}

.media-btn {
    width: 30px;
    height: 30px;
    border: none;
    background-color: transparent;
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 13px;
}

.media-btn:hover {
    background-color: #f1f5f9;
    color: #2563eb;
    border-radius: 50%; /* Faz um círculo sutil ao passar o mouse */
}

.current-hour-display {
    background: #f1f5f9;
    padding: 4px 12px;
    border-radius: 15px;
    font-weight: 700;
    color: #2563eb;
    border: 1px solid #e2e8f0;
}

/* Menus Flutuantes Localizados */
.view-menu { 
    display: none;
    position: fixed;
    width: 260px; 
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border: 1px solid #e2e8f0;
    z-index: 9999;
    padding: 15px;
}

.hour-panel-view { 
    display: none;
    position: fixed;
    width: 260px; 
    max-height: 80vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 10px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border: 1px solid #e2e8f0;
    z-index: 9999;
}

.hour-grid-view {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
}

.hour-grid-view button {
    padding: 3px 0;
    font-size: 10px;
    font-weight: bold;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    background: #fff;
    cursor: pointer;
}

.hour-grid-view button.selected {
    background: #2563eb;
    color: #fff;
}

.view-menu h3 {
    font-size: 15px;
    margin: 0 0 10px 0;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 5px;
    color: #1e3a8a;
}

.view-menu label {
    font-size: 12px;
    font-weight: 700;
    color: #475569;
    display: block;
    margin-top: 10px;
}

.view-menu select {
    width: 100%;
    padding: 6px;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    margin-top: 4px;
}

/* --- Responsividade --- */
@media (max-width: 768px) {
    .header-title-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .header-buttons-right {
        width: 100%;
        display: flex;
        justify-content: flex-end;
        gap: 4px;
    }

    .view-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .view-header-left {
        width: 100%;
    }
    
    .view-header-right {
        width: 100%;
        justify-content: flex-end;
        padding-top: 8px;
        border-top: 1px dashed #e2e8f0;
    }
    
    .info-modelo-text, .info-extra-text, .info-init-text, .info-update-text {
        white-space: normal;
        overflow: visible;
    }

    .map-container.grid-2,
    .map-container.grid-3,
    .map-container.grid-4 {
        grid-template-columns: 1fr;
    }
}

/* Indicador de Alerta na Grade (Ponto Vermelho) */
.hour-btn.has-alert {
    position: relative;
    border-color: #ef4444 !important;
}

.alert-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background-color: #ef4444;
    border-radius: 50%;
    border: 1px solid #fff;
    box-shadow: 0 0 4px rgba(239, 68, 68, 0.6);
    pointer-events: none;
    z-index: 5;
}