/* ============================================
   CMMS Industrial - Gantt Chart Styles
   Renderização Dinâmica - Estilo MS-Project
   OTIMIZADO: Layout responsivo + Mobile melhorado
   ============================================ */

.gantt-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

/* ===== HEADER ===== */
.gantt-header {
    padding: 16px 20px;
    background: var(--bg-tertiary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    border-bottom: 1px solid var(--border-color);
}

.gantt-header h2 {
    font-size: 16px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.gantt-header h2 i {
    color: var(--accent-blue);
}

/* ===== LEGENDA ===== */
.gantt-legend {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.legend-color {
    width: 20px;
    height: 12px;
    border-radius: 4px;
}

.legend-color.planejada { background: var(--status-planejada); }
.legend-color.executando { background: var(--status-executando); }
.legend-color.atrasada { background: var(--status-atrasada); }
.legend-color.concluida { background: var(--status-concluida); }

/* ===== TABELA ===== */
.gantt-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

.gantt-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
    font-size: 12px;
}

.gantt-table th,
.gantt-table td {
    border: 1px solid var(--border-color);
    padding: 10px 8px;
    vertical-align: middle;
}

.gantt-table th {
    background: var(--bg-secondary);
    color: var(--text-muted);
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Colunas fixas */
.gantt-col-id {
    width: 85px;
    text-align: center;
}

.gantt-col-equipamento {
    width: 180px;
    text-align: left;
}

.gantt-col-status {
    width: 100px;
    text-align: center;
}

    .gantt-day-header {
        min-width: 32px;
        padding: 10px 4px;
        font-size: 10px;
    }

/* Linhas */
.gantt-row {
    transition: background var(--transition-fast);
}

.gantt-row:hover {
    background: var(--bg-hover);
}

/* Dia da semana no cabeçalho */
.gantt-dia-semana {
    display: block;
    font-size: 8px;
    text-transform: uppercase;
    opacity: 0.5;
    line-height: 1;
    margin-bottom: 2px;
}

/* Marcadores de hoje e fim de semana */
.gantt-day-header.gantt-today,
.gantt-cell.gantt-today {
    background: rgba(52, 152, 219, 0.08);
    box-shadow: inset 0 0 0 1px rgba(52, 152, 219, 0.3);
}

.gantt-day-header.gantt-weekend,
.gantt-cell.gantt-weekend {
    background: rgba(0, 0, 0, 0.03);
}

.gantt-cell.gantt-today.gantt-weekend {
    background: rgba(52, 152, 219, 0.06);
    box-shadow: inset 0 0 0 1px rgba(52, 152, 219, 0.3);
}

/* Células */
.gantt-cell {
    min-width: 32px;
    height: 44px;
    text-align: center;
    vertical-align: middle;
    padding: 4px;
}

/* Barras do Gantt */
.gantt-bar {
    width: 100%;
    height: 20px;
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-fast);
    opacity: 0.85;
    position: relative;
}

.gantt-bar:hover {
    transform: translateY(-1px);
    opacity: 1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.gantt-bar.planejada { background: var(--status-planejada); }
.gantt-bar.executando { background: var(--status-executando); }
.gantt-bar.atrasada { background: var(--status-atrasada); }
.gantt-bar.concluida { background: var(--status-concluida); }

/* Label dentro da barra */
.gantt-bar-label {
    display: block;
    padding: 0 6px;
    color: white;
    font-size: 10px;
    font-weight: 600;
    line-height: 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    pointer-events: none;
}

/* ===== TOOLTIP ===== */
.gantt-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    pointer-events: none;
    min-width: 200px;
    white-space: normal;
    font-size: 12px;
    color: var(--text-primary);
}

.gantt-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 7px solid transparent;
    border-top-color: var(--bg-primary);
}

.gantt-bar:hover .gantt-tooltip {
    display: block;
    animation: gantt-fadeIn var(--transition-fast) ease;
}

@keyframes gantt-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== RESPONSIVO ===== */

/* Tablet (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .gantt-header {
        padding: 12px 16px;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .gantt-legend {
        gap: 12px;
    }
    
    .gantt-table {
        min-width: 700px;
        font-size: 11px;
    }
    
    .gantt-table th,
    .gantt-table td {
        padding: 8px 6px;
    }
    
    .gantt-col-equipamento {
        width: 150px;
    }
    
    .gantt-bar {
        height: 18px;
    }
    
    .gantt-bar-label {
        font-size: 9px;
        line-height: 18px;
    }
}

/* Mobile (< 480px) */
@media (max-width: 480px) {
    .gantt-container {
        border-radius: var(--radius-md);
    }
    
    .gantt-header {
        padding: 10px 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .gantt-header h2 {
        font-size: 14px;
    }
    
    .gantt-legend {
        gap: 10px;
        width: 100%;
        justify-content: flex-start;
    }
    
    .legend-item {
        font-size: 9px;
        gap: 4px;
    }
    
    .legend-color {
        width: 16px;
        height: 10px;
    }
    
    .gantt-table-container {
        margin: 0 -1px;
    }
    
    .gantt-table {
        min-width: 600px;
        font-size: 10px;
    }
    
    .gantt-table th,
    .gantt-table td {
        padding: 6px 4px;
    }
    
    .gantt-col-id {
        width: 60px;
    }
    
    .gantt-col-equipamento {
        width: 120px;
    }
    
    .gantt-col-status {
        width: 80px;
    }
    
    .gantt-day-header {
        min-width: 26px;
        padding: 6px 2px;
        font-size: 9px;
    }
    
    .gantt-cell {
        min-width: 26px;
        height: 36px;
    }
    
    .gantt-bar {
        height: 16px;
    }
    
    .gantt-bar-label {
        font-size: 8px;
        line-height: 16px;
        padding: 0 4px;
    }
    
    .gantt-tooltip {
        min-width: 160px;
        padding: 8px 12px;
        font-size: 11px;
    }
}

/* Desktop (> 768px) */
@media (min-width: 769px) {
    .gantt-table {
        min-width: 100%;
    }
    
    .gantt-table th,
    .gantt-table td {
        padding: 12px 10px;
    }
    
    .gantt-bar:hover {
        transform: translateY(-2px);
    }
}

/* Large Desktop (> 1200px) */
@media (min-width: 1201px) {
    .gantt-table th,
    .gantt-table td {
        padding: 14px 12px;
    }
    
    .gantt-col-id {
        width: 100px;
    }
    
    .gantt-col-equipamento {
        width: 220px;
    }
    
    .gantt-col-status {
        width: 120px;
    }
    
    .gantt-bar {
        height: 22px;
    }
    
    .gantt-bar-label {
        font-size: 11px;
        line-height: 22px;
    }
}

/* ===== TOUCH OTIMIZAÇÕES ===== */
@media (hover: none) and (pointer: coarse) {
    .gantt-bar:active {
        transform: scale(0.98);
        transition: transform 0.05s ease;
    }
    
    .gantt-bar:hover {
        transform: none;
    }
}

/* ===== SCROLLBAR PERSONALIZADA ===== */
.gantt-table-container::-webkit-scrollbar {
    height: 6px;
}

.gantt-table-container::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 3px;
}

.gantt-table-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.gantt-table-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    .gantt-bar,
    .gantt-row {
        transition: none;
    }
    
    .gantt-bar:hover {
        transform: none;
    }
    
    .gantt-tooltip {
        animation: none;
    }
}

/* ===== PRINT ===== */
@media print {
    .gantt-container {
        border: 1px solid #ccc;
        background: white;
    }
    
    .gantt-header {
        background: #f0f0f0;
    }
    
    .gantt-table th {
        background: #e0e0e0;
        color: #000;
    }
    
    .gantt-table td {
        border: 1px solid #ccc;
    }
    
    .gantt-bar {
        opacity: 1;
        border: 1px solid #333;
    }
    
    .gantt-bar.planejada { background: #3498db; }
    .gantt-bar.executando { background: #f1c40f; }
    .gantt-bar.atrasada { background: #e74c3c; }
    .gantt-bar.concluida { background: #2ecc71; }
    
    .gantt-tooltip {
        display: none;
    }
}
