/* Variables CSS para mejor rendimiento */
:root {
    --weeks-count: 4;
    --animation-duration: 0.3s;
    --border-radius: 12px;
    --shadow-light: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-heavy: 0 8px 32px rgba(0,0,0,0.15);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease-out;
}

.roadmap-container {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-heavy);
    overflow: hidden;
    margin: 0 auto;
    will-change: transform;
}

.roadmap-header {
    background: linear-gradient(135deg, #2C5F41, #4A90B8);
    color: white;
    padding: 20px;
    text-align: center;
}

.roadmap-weeks-header {
    display: grid;
    grid-template-columns: 200px repeat(var(--weeks-count), 1fr);
    background: #495057;
    color: white;
    min-width: 800px;
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
}

.roadmap-week-cell {
    padding: 15px 10px;
    text-align: center;
    border-right: 1px solid #6c757d;
    font-weight: 600;
    font-size: 0.85rem;
    transition: var(--transition-fast);
}

.roadmap-week-cell:hover {
    background: rgba(255,255,255,0.1);
}

.roadmap-week-cell:last-child {
    border-right: none;
}

.roadmap-category-label {
    background: #6c757d;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
}

.roadmap-week-dates {
    font-size: 0.75rem;
    opacity: 0.9;
    margin-top: 3px;
}

.roadmap-grid {
    display: grid;
    grid-template-columns: 200px repeat(var(--weeks-count), 1fr);
    min-width: 800px;
    position: relative;
    transform: translateZ(0);
    width: 100%;
    overflow-x: visible;
}

.roadmap-category-row {
    display: contents;
}

.roadmap-category-header {
    padding: 20px 15px;
    color: white;
    font-weight: 600;
    border-right: 1px solid rgba(255,255,255,0.2);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.9rem;
    min-height: 120px;
    position: relative;
    transition: var(--transition-fast);
}

.roadmap-week-content {
    padding: 15px 8px;
    border-right: 1px solid #dee2e6;
    border-bottom: 1px solid #dee2e6;
    min-height: 120px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-content: flex-start;
    overflow: visible;
    transition: var(--transition-fast);
    will-change: background-color, border-color;
    width: 100%;
    max-width: 100%;
}

.roadmap-week-content:last-child {
    border-right: none;
}

.roadmap-week-content.drop-zone-active {
    background: linear-gradient(135deg, #e3f2fd, #f0f8ff);
    border: 2px dashed #1976d2;
    transform: scale(1.02);
}

.roadmap-week-content.drop-zone-highlight {
    background: rgba(25, 118, 210, 0.05);
    border-color: #1976d2;
}

.roadmap-week-content.horizontal-drop-target {
    background: linear-gradient(135deg, #fff3e0, #ffe0b2);
    border: 2px dashed #ff9800;
    transform: scale(1.05);
}

/* Category Colors */
.roadmap-milestone { background: linear-gradient(135deg, #3498db, #2980b9); }
.roadmap-revenue { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.roadmap-operations { background: linear-gradient(135deg, #2ecc71, #27ae60); }
.roadmap-development { background: linear-gradient(135deg, #f39c12, #e67e22); }
.roadmap-customer { background: linear-gradient(135deg, #9b59b6, #8e44ad); }
.roadmap-strategic { background: linear-gradient(135deg, #1abc9c, #16a085); }
.roadmap-default { background: linear-gradient(135deg, #3498db, #2980b9); }

/* Enhanced multi-week objective styling */
.roadmap-objective-item.multi-week {
    position: absolute;
    z-index: 2; /* Reducido de 5 a 2 para que esté debajo de objetivos normales */
    left: 8px;
    min-width: 140px;
    backdrop-filter: none; /* Eliminado para mejor visibilidad */
    pointer-events: auto;
    box-shadow: var(--shadow-light); /* Sombra más sutil */
    border-width: 2px;
    background: rgba(255, 255, 255, 0.85) !important; /* Más transparente */
    opacity: 0.9; /* Ligeramente transparente */
}

.roadmap-objective-item.multi-week::before {
    content: '';
    position: absolute;
    top: -1px;
    bottom: -1px;
    left: -1px;
    right: -1px;
    background: inherit;
    border-radius: inherit;
    z-index: -1;
    opacity: 0.05; /* Muy sutil */
}

.roadmap-objective-item.multi-week:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2); /* Sombra reducida */
    z-index: 8; /* Solo al hover sube el z-index */
    background: rgba(255, 255, 255, 0.95) !important;
    opacity: 1;
}

/* Objetivos normales (cortos) tienen prioridad visual */
.roadmap-objective-item:not(.multi-week) {
    z-index: 5; /* Mayor que multi-week */
    position: relative;
}

.roadmap-objective-item:not(.multi-week):hover {
    z-index: 10;
}

/* Sistema de capas por duración */
.roadmap-objective-item.duration-1 { z-index: 6; } /* 1 día/semana */
.roadmap-objective-item.duration-2 { z-index: 5; } /* 2 días/semanas */
.roadmap-objective-item.duration-3 { z-index: 4; } /* 3 días/semanas */
.roadmap-objective-item.duration-4-plus { z-index: 3; } /* 4+ días/semanas */

/* Al hacer hover, todos suben temporalmente */
.roadmap-objective-item.duration-1:hover { z-index: 15; }
.roadmap-objective-item.duration-2:hover { z-index: 14; }
.roadmap-objective-item.duration-3:hover { z-index: 13; }
.roadmap-objective-item.duration-4-plus:hover { z-index: 12; }

/* Mejor visibilidad de objetivos superpuestos */
.roadmap-objective-item {
    border: 2px solid;
    border-radius: var(--border-radius);
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: move;
    transition: var(--transition-smooth);
    position: relative;
    box-shadow: var(--shadow-light);
    flex-shrink: 0;
    line-height: 1.3;
    user-select: none;
    min-height: 36px;
    display: flex;
    align-items: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    will-change: transform, box-shadow;
    /* Mejor contraste */
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(2px);
}

.roadmap-objective-item .objective-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
    padding-right: 20px;
}

.roadmap-objective-item:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: var(--shadow-heavy);
    z-index: 10;
}

.roadmap-objective-item.dragging {
    opacity: 0.8;
    transform: rotate(3deg) scale(1.05);
    z-index: 1000;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.roadmap-objective-item.moving-horizontal {
    opacity: 0.9;
    transform: scale(1.1);
    z-index: 999;
    box-shadow: 0 8px 30px rgba(255, 152, 0, 0.4);
    border-color: #ff9800 !important;
}




/* Ensure week boundaries remain visible */
.roadmap-week-content::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 1px;
    background: #dee2e6;
    z-index: 3;
    pointer-events: none;
}

.roadmap-week-content:last-child::after {
    display: none;
}

.roadmap-objective-item.resizing {
    border-style: dashed;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.3);
    cursor: ew-resize;
}

.roadmap-objective-item.resize-preview {
    opacity: 0.7;
    border-style: dashed;
    background: rgba(255,255,255,0.9);
}

.roadmap-objective-item.saving {
    position: relative;
    opacity: 0.8;
}

.roadmap-objective-item.saving::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 8px;
    width: 12px;
    height: 12px;
    border: 2px solid #007bff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
    transform: translateY(-50%);
}

@keyframes spin {
    to { transform: translateY(-50%) rotate(360deg); }
}

.roadmap-objective-item.error {
    border-color: #dc3545 !important;
    background: rgba(220, 53, 69, 0.1) !important;
}

.roadmap-objective-item.success {
    border-color: #28a745 !important;
    animation: successPulse 0.6s ease-out;
}

@keyframes successPulse {
    0% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(40, 167, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0); }
}

/* Objective Colors */
.roadmap-obj-milestone { border-color: #3498db; color: #2980b9; background: rgba(52, 152, 219, 0.05); }
.roadmap-obj-revenue { border-color: #e74c3c; color: #c0392b; background: rgba(231, 76, 60, 0.05); }
.roadmap-obj-operations { border-color: #2ecc71; color: #27ae60; background: rgba(46, 204, 113, 0.05); }
.roadmap-obj-development { border-color: #f39c12; color: #e67e22; background: rgba(243, 156, 18, 0.05); }
.roadmap-obj-customer { border-color: #9b59b6; color: #8e44ad; background: rgba(155, 89, 182, 0.05); }
.roadmap-obj-strategic { border-color: #1abc9c; color: #16a085; background: rgba(26, 188, 156, 0.05); }

/* Enhanced resize handles */
.roadmap-resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 12px;
    cursor: ew-resize;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
}

.roadmap-resize-handle.left {
    left: -6px;
    border-radius: var(--border-radius) 0 0 var(--border-radius);
}

.roadmap-resize-handle.right {
    right: -6px;
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.roadmap-resize-handle::before {
    content: '⋮';
    font-size: 12px;
    color: rgba(0,123,255,0.7);
    transform: rotate(90deg);
}

.roadmap-objective-item:hover .roadmap-resize-handle {
    opacity: 1;
    background: rgba(0,123,255,0.1);
}

.roadmap-resize-handle:hover {
    background: rgba(0,123,255,0.2) !important;
    opacity: 1 !important;
}

.roadmap-resize-handle:hover::before {
    color: rgba(0,123,255,1);
}

/* Progress indicators */
.roadmap-progress-indicator {
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 85%;
    height: 3px;
    background: rgba(0,0,0,0.1);
    border-radius: 2px;
    overflow: hidden;
}

.roadmap-progress-fill {
    height: 100%;
    border-radius: 2px;
    transition: width var(--animation-duration) ease-out;
    position: relative;
}

.roadmap-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.roadmap-controls {
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-bottom: 1px solid #dee2e6;
}

.roadmap-date-controls .form-group {
    margin-bottom: 0;
    vertical-align: top;
}

.roadmap-date-controls .form-label {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 1px;
    display: block;
}

.roadmap-legend {
    border-top: 1px solid #ddd;
}

.roadmap-legend-item {
    display: inline-block;
    margin-right: 15px;
    margin-bottom: 10px;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(255,255,255,0.7);
    transition: var(--transition-fast);
    font-size: 0.8rem;
}

.roadmap-legend-item:hover {
    background: rgba(255,255,255,0.9);
    transform: translateY(-1px);
}

.roadmap-legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    box-shadow: var(--shadow-light);
    display: inline-block;
    margin-right: 8px;
    vertical-align: middle;
}

.roadmap-employee-info {
    text-align: center;
    margin-bottom: 15px;
}

.roadmap-employee-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.roadmap-employee-role {
    font-size: 0.95rem;
    color: rgba(255,255,255,0.9);
}

.roadmap-stats-summary {
    background: rgba(255,255,255,0.15);
    border-radius: 10px;
    padding: 12px 20px;
    margin-top: 12px;
    text-align: center;
    font-size: 0.85rem;
    backdrop-filter: blur(10px);
}

.roadmap-stat-item {
    display: inline-block;
    margin: 0 12px;
    text-align: center;
    transition: var(--transition-fast);
}

.roadmap-stat-item:hover {
    transform: scale(1.05);
}

.roadmap-stat-number {
    font-weight: 700;
    font-size: 1.2rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    display: block;
}

.roadmap-objective-priority {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.roadmap-priority-high { background: linear-gradient(135deg, #dc3545, #c82333); }
.roadmap-priority-medium { background: linear-gradient(135deg, #ffc107, #e0a800); }
.roadmap-priority-low { background: linear-gradient(135deg, #28a745, #1e7e34); }

.roadmap-empty-week {
    color: #adb5bd;
    font-style: italic;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    text-align: center;
    opacity: 0.7;
}

.roadmap-week-indicator {
    background: rgba(255,255,255,0.95);
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 0.7rem;
    color: #495057;
    margin-bottom: 6px;
    text-align: center;
    font-weight: 600;
    box-shadow: var(--shadow-light);
}

/* Notifications */
.roadmap-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: var(--shadow-heavy);
    z-index: 2000;
    opacity: 0;
    transform: translateX(100%) scale(0.8);
    transition: var(--transition-smooth);
    backdrop-filter: blur(10px);
    max-width: 300px;
}

.roadmap-notification.show {
    opacity: 1;
    transform: translateX(0) scale(1);
}

.roadmap-notification.error {
    background: linear-gradient(135deg, #dc3545, #c82333);
}

.roadmap-notification.warning {
    background: linear-gradient(135deg, #ffc107, #e0a800);
    color: #212529;
}

.roadmap-notification.info {
    background: linear-gradient(135deg, #17a2b8, #138496);
}

/* Connection status indicator */
.roadmap-connection-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 1500;
    transition: var(--transition-smooth);
}

.roadmap-connection-status.online {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
}

.roadmap-connection-status.offline {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
}

.roadmap-connection-status.syncing {
    background: linear-gradient(135deg, #ffc107, #e0a800);
    color: #212529;
}

/* Scroll container */
.roadmap-scroll-container {
    overflow-x: auto;
    scroll-behavior: smooth;
}

.roadmap-scroll-container::-webkit-scrollbar {
    height: 8px;
}

.roadmap-scroll-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.roadmap-scroll-container::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #6c757d, #495057);
    border-radius: 4px;
}

.roadmap-scroll-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #495057, #343a40);
}

/* Loading states */
.roadmap-loading {
    opacity: 0.6;
    pointer-events: none;
}

.roadmap-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* Modal header styling */
.roadmap-modal-header {
    background: linear-gradient(135deg, #2C5F41, #4A90B8);
    color: white;
    border-radius: 15px 15px 0 0;
}

.roadmap-modal-header .close {
    color: white;
    opacity: 0.8;
}

/* Responsive */
@media (max-width: 768px) {
    .roadmap-objective-item {
        font-size: 0.7rem;
        padding: 6px 10px;
        min-height: 32px;
    }
    
    .roadmap-category-header {
        padding: 15px 8px;
        font-size: 0.8rem;
    }
    
    .roadmap-week-cell {
        padding: 12px 5px;
        font-size: 0.75rem;
    }

    .roadmap-stats-summary {
        padding: 10px 15px;
    }

    .roadmap-stat-item {
        margin: 0 8px;
    }

    .roadmap-controls {
        padding: 15px;
    }

    .roadmap-date-controls .form-group {
        display: block;
        margin-bottom: 10px;
    }
}

/* Accessibility */
.roadmap-objective-item:focus {
    outline: 3px solid rgba(0,123,255,0.5);
    outline-offset: 2px;
}

.roadmap-resize-handle:focus {
    outline: 2px solid rgba(0,123,255,0.8);
    outline-offset: 1px;
}

/* Print styles */
@media print {
    .roadmap-controls {
        display: none;
    }
    
    .roadmap-notification {
        display: none;
    }
    
    .roadmap-container {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }
}

/* Mejores bordes para objetivos superpuestos */
.roadmap-objective-item {
    border-width: 2px !important;
    border-style: solid !important;
}

/* Objetivos largos con bordes más sutiles */
.roadmap-objective-item.multi-week.duration-4-plus {
    border-style: dashed !important;
    border-width: 1px !important;
}

/* Efecto de elevación para objetivos al hover */
.roadmap-objective-item:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
    border-width: 3px !important;
}

/* Indicador visual de superposición */
.roadmap-week-content {
    position: relative;
}

.roadmap-week-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: 20px 20px;
    pointer-events: none;
    z-index: 1;
}