/* Mapas de Planeamento: layout igual ao planeamento da Inox, com as cores da paleta da Vitroglass
   (MudBlazor), para seguir o tema claro e escuro.
   Usado em: MapasPlaneamento, CalendarioPlanComponent, StatsPlanComponent, MobiscrollTimelineComponent
   e os dialogs dos mapas. */

/* Barra de filtros e painéis */
.filter-bar,
.list-panel {
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.list-panel-header {
    padding: 4px 4px 0 4px;
}

.list-panel-divider {
    margin: 10px -12px;
    border: 0;
    border-top: 1px solid var(--mud-palette-lines-default);
}

.list-panel-content {
    padding-top: 4px;
}

.filter-input {
    flex: 1 1 180px;
    min-width: 180px;
}

.filter-button {
    height: 40px;
    min-width: 130px;
    font-weight: 600;
    text-transform: none;
    border-radius: 8px;
    letter-spacing: 0.02em;
}

/* Colunas de altura fixa: o conteúdo faz scroll quando excede (3 linhas de caixas de fase). */
.coluna-fixa-scroll {
    height: calc(100vh - 280px);
    min-height: 660px;
    max-height: 660px;
    display: flex;
    flex-direction: column;
}

    .coluna-fixa-scroll .list-panel-content {
        overflow-y: auto;
        overflow-x: hidden;
        flex: 1 1 auto;
        min-height: 0;
    }

/* Caixas de estatística por fase */
/* Quantas caixas couberem na largura do painel, centradas (nunca cortadas). */
.boxs-grid {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(auto-fill, 170px);
    gap: 16px;
    justify-content: center;
}

.stats-box-clickable {
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

    .stats-box-clickable:hover {
        transform: translateY(-3px);
        filter: brightness(1.05);
    }

/* Timeline (Mobiscroll) */
.timeline-wrapper .mbsc-timeline-resource-col {
    width: 188px !important;
    min-width: 188px !important;
    max-width: 188px !important;
}

.timeline-wrapper .mbsc-timeline-resource-title {
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    padding-right: 6px;
}

/* Riscas alternadas por recurso, alinhadas entre os nomes e a grelha (a linha vazia final fica de fora). */
.timeline-wrapper .mbsc-timeline-row:not(.mbsc-timeline-empty-row):nth-child(odd) {
    background-color: var(--mud-palette-background-gray) !important;
}

.timeline-wrapper .mbsc-timeline-row:not(.mbsc-timeline-empty-row):nth-child(even) {
    background-color: var(--mud-palette-surface) !important;
}

/* Altura base da linha sem !important, para as linhas com barras empilhadas continuarem a crescer. */
.timeline-wrapper .mbsc-timeline-row {
    height: 4.5em;
}

/* Botões de vista no cabeçalho do timeline (Semana, Mês, Trimestre, Agenda) */
.md-work-week-picker {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 10px;
    padding: 6px 10px;
}

    .md-work-week-picker label {
        position: relative;
        cursor: pointer;
        background: var(--mud-palette-surface);
        border: 1px solid var(--mud-palette-primary);
        border-radius: 6px;
        padding: 6px 14px;
        font-size: 14px;
        color: var(--mud-palette-primary);
        font-weight: 500;
        transition: all 0.25s ease;
    }

        .md-work-week-picker label:hover {
            background: var(--mud-palette-action-default-hover);
        }

    .md-work-week-picker input[type="radio"] {
        display: none;
    }

        .md-work-week-picker input[type="radio"]:checked + label {
            background: var(--mud-palette-primary);
            color: var(--mud-palette-primary-text);
            border-color: var(--mud-palette-primary);
        }

@media (max-width: 600px) {
    .md-work-week-picker {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* Barra focada pela pesquisa */
.mbsc-schedule-event-selected {
    outline: 3px solid var(--mud-palette-error) !important;
    z-index: 9999 !important;
    border-radius: 6px;
}

/* Nome do recurso: título e segunda linha; clicável abre o detalhe (ex.: a obra). */
.timeline-resource-titulo {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.timeline-resource-sub {
    font-size: 0.75rem;
    opacity: 0.7;
    overflow-wrap: anywhere;
}

.timeline-resource-clicavel {
    cursor: pointer;
}

    .timeline-resource-clicavel:hover .timeline-resource-titulo {
        text-decoration: underline;
        color: var(--mud-palette-primary);
    }

/* Tooltip ao passar o rato numa barra */
.md-tooltip, .md-tooltip * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.md-tooltip {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    width: 340px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--mud-palette-text-primary);
    background-color: var(--mud-palette-surface);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--mud-palette-lines-default);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    animation: fadeInTooltip 0.2s ease-out;
}

.md-tooltip-header {
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    padding: 12px 16px;
    width: 100%;
}

.md-tooltip-time {
    font-size: 0.9rem;
    opacity: 0.9;
    display: block;
    margin-bottom: 4px;
}

.md-tooltip-header-title {
    font-size: 0.98rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.md-tooltip-info {
    padding: 14px 16px;
    line-height: 1.5;
}

.md-tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
    border-bottom: 1px dashed var(--mud-palette-lines-default);
    padding-bottom: 3px;
}

    .md-tooltip-row:last-child {
        border-bottom: none;
        margin-bottom: 0;
    }

    .md-tooltip-row .label {
        color: var(--mud-palette-text-secondary);
        font-weight: 600;
    }

@keyframes fadeInTooltip {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Cartões de resultado da pesquisa, por cima do timeline */
.timeline-grid-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 8px;
}

.search-results-scroll {
    display: flex;
    flex-direction: row;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 0 6px 4px;
    scroll-behavior: smooth;
}

    .search-results-scroll::-webkit-scrollbar {
        height: 6px;
    }

    .search-results-scroll::-webkit-scrollbar-thumb {
        background-color: var(--mud-palette-primary);
        border-radius: 4px;
    }

.result-card {
    min-width: 248px;
    max-width: 248px;
    border: 2px solid transparent;
    border-radius: 8px;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.25s ease;
}

    .result-card:hover {
        transform: translateY(-2px);
    }

.selected-card {
    border: 2px solid var(--mud-palette-primary);
}

/* Sem largura mínima: em ecrãs estreitos a grelha do Mobiscroll faz scroll por dentro, não a página. */
.timeline-wrapper {
    flex: 1;
    min-width: 0;
    width: 100%;
    height: 100%;
}

.timeline-grid-container {
    min-width: 0;
}

/* Telemóvel: cabeçalho do calendário (título, vistas, setas) em várias linhas e coluna dos nomes mais estreita. */
@media (max-width: 600px) {
    .timeline-wrapper .mbsc-calendar-header,
    .timeline-wrapper .mbsc-calendar-controls {
        flex-wrap: wrap !important;
        gap: 8px;
        height: auto !important;
    }

    .md-work-week-picker {
        margin-left: 0 !important;
        padding: 4px 6px;
        gap: 4px;
        flex-wrap: wrap;
    }

        .md-work-week-picker label {
            padding: 4px 8px;
            font-size: 13px;
        }

    .timeline-wrapper .mbsc-timeline-resource-col {
        width: 120px !important;
        min-width: 120px !important;
        max-width: 120px !important;
    }
}

/* <input type="time"> sem o ícone do browser: o picker abre pelo adornment do campo. */
.time-picker-icon-start input[type="time"]::-webkit-calendar-picker-indicator {
    display: none;
    -webkit-appearance: none;
}

.time-picker-icon-start input[type="time"] {
    -moz-appearance: textfield;
}
