/* Custom styles for Task Optimization Dashboard */

:root {
    --primary-color: #0d6efd;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --light-bg: #f8f9fa;
    --border-color: #dee2e6;
}

body {
    background-color: var(--light-bg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    background-color: #ffffff;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    z-index: 10;
}

/* Ensure child elements don't block events */
.upload-area * {
    pointer-events: none;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background-color: rgba(13, 110, 253, 0.05);
}

.upload-area.drag-over {
    border-color: var(--primary-color);
    background-color: rgba(13, 110, 253, 0.1);
    transform: scale(1.02);
}

/* Metrics */
.metric {
    padding: 1rem;
}

.metric-value {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.metric-label {
    font-size: 0.875rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Table Customization */
.tabulator {
    background-color: #fff;
    font-size: 0.875rem;
}

.tabulator-row {
    transition: background-color 0.2s ease;
}

.tabulator-row.improved {
    background-color: rgba(25, 135, 84, 0.1) !important;
}

.tabulator-row.delayed {
    background-color: rgba(220, 53, 69, 0.1) !important;
}

.tabulator-row.resource-changed {
    background-color: rgba(255, 193, 7, 0.1) !important;
}

.tabulator-cell {
    padding: 0.75rem 0.5rem;
}

/* Delta indicators */
.delta-positive {
    color: var(--success-color);
    font-weight: 600;
}

.delta-negative {
    color: var(--danger-color);
    font-weight: 600;
}

.delta-neutral {
    color: #6c757d;
}

/* Status badges */
.status-improved {
    background-color: var(--success-color) !important;
}

.status-delayed {
    background-color: var(--danger-color) !important;
}

.status-resource-changed {
    background-color: var(--warning-color) !important;
    color: #000 !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .metric-value {
        font-size: 1.5rem;
    }
    
    .metric-label {
        font-size: 0.75rem;
    }
    
    .upload-area {
        padding: 2rem !important;
    }
    
    .upload-area h4 {
        font-size: 1.25rem;
    }
}

/* Card enhancements */
.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    margin-bottom: 1.5rem;
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
}

/* Button states */
.btn {
    transition: all 0.2s ease;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Progress bar */
.progress {
    height: 1.5rem;
}

.progress-bar {
    transition: width 0.3s ease;
}

/* Tooltips */
.tooltip-inner {
    max-width: 300px;
    text-align: left;
}

/* Gantt Chart Styles */
#ganttChart {
    height: 100%;
    width: 100%;
    position: relative;
}

/* DHTMLX Gantt customization */
.gantt_task_line {
    border-radius: 3px;
    opacity: 0.8;
}

/* Original task bar styling */
.gantt_task_line.gantt_task_inline_color {
    background-color: #6c757d;
    border-color: #5a6268;
}

/* Baseline bar styling */
.baseline-bar {
    position: absolute;
    background-color: rgba(13, 110, 253, 0.7);
    border: 1px solid rgba(13, 110, 253, 0.9);
    border-radius: 3px;
    z-index: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.baseline-bar.baseline-improved {
    background-color: rgba(25, 135, 84, 0.7);
    border-color: rgba(25, 135, 84, 0.9);
}

.baseline-bar.baseline-delayed {
    background-color: rgba(220, 53, 69, 0.7);
    border-color: rgba(220, 53, 69, 0.9);
}

.baseline-bar.baseline-resource-changed {
    background-color: rgba(255, 193, 7, 0.7);
    border-color: rgba(255, 193, 7, 0.9);
}

.baseline-content {
    color: white;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 5px;
    text-align: center;
    line-height: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Gantt grid styling */
.gantt_grid_head_cell {
    font-weight: 600;
    background-color: #f8f9fa;
}

.gantt_tree_content {
    font-size: 13px;
}

/* Tooltip styling */
.gantt_tooltip {
    background-color: rgba(33, 37, 41, 0.95);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 10px;
    font-size: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Scale styling */
.gantt_scale_line {
    border-top: 1px solid #dee2e6;
}

.gantt_scale_cell {
    font-size: 12px;
    color: #495057;
}

/* Simple Gantt Implementation */
.simple-gantt-wrapper {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.gantt-legend {
    padding: 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    margin-right: 20px;
    font-size: 13px;
}

.legend-box {
    width: 20px;
    height: 12px;
    margin-right: 5px;
    border-radius: 2px;
}

.gantt-container {
    display: flex;
    height: calc(100% - 60px);
    overflow: hidden;
}

.gantt-grid {
    width: 250px;
    min-width: 250px;
    background: #f8f9fa;
    border-right: 2px solid #dee2e6;
    overflow-y: auto;
    overflow-x: hidden;
}

.gantt-grid-row {
    height: 40px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    padding: 0 10px;
}

.task-name {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gantt-chart {
    flex: 1;
    overflow: auto;
    position: relative;
    background: #fff;
}

.gantt-time-header {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 10;
    border-bottom: 2px solid #dee2e6;
}

.gantt-day-row {
    display: flex;
    height: 30px;
}

.gantt-day-cell {
    text-align: center;
    line-height: 30px;
    font-size: 12px;
    border-right: 1px solid #e9ecef;
    flex-shrink: 0;
}

.gantt-day-cell.weekend {
    background: #f8f9fa;
}

.gantt-tasks {
    position: relative;
}

.gantt-chart-row {
    height: 40px;
    border-bottom: 1px solid #e9ecef;
    position: relative;
}

.gantt-bar {
    position: absolute;
    height: 24px;
    top: 8px;
    border-radius: 3px;
    cursor: pointer;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    padding: 0 5px;
    font-size: 11px;
    color: white;
    overflow: hidden;
}

.gantt-bar:hover {
    opacity: 0.9 !important;
    z-index: 5;
}

.original-bar {
    background: rgba(108, 117, 125, 0.6);
    border: 1px solid rgba(108, 117, 125, 0.8);
}

.optimized-bar {
    background: rgba(13, 110, 253, 0.8);
    border: 1px solid rgba(13, 110, 253, 1);
    top: 14px;
    height: 20px;
}

.optimized-bar.improved {
    background: rgba(25, 135, 84, 0.8);
    border: 1px solid rgba(25, 135, 84, 1);
}

.optimized-bar.delayed {
    background: rgba(220, 53, 69, 0.8);
    border: 1px solid rgba(220, 53, 69, 1);
}

.optimized-bar.resource-changed {
    background: rgba(255, 193, 7, 0.8);
    border: 1px solid rgba(255, 193, 7, 1);
}

.bar-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Tab navigation */
.nav-tabs .nav-link {
    color: #6c757d;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.5rem 1rem;
}

.nav-tabs .nav-link:hover {
    border-color: transparent;
    border-bottom-color: #dee2e6;
}

.nav-tabs .nav-link.active {
    color: var(--primary-color);
    background-color: transparent;
    border-color: transparent;
    border-bottom-color: var(--primary-color);
}

/* Print styles */
@media print {
    .navbar,
    .btn-group,
    #uploadArea,
    #clearBtn {
        display: none !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
    }
}

/* ===========================================
   DHTMLX Gantt Interactive Features Styles
   ========================================= */

/* Locked tasks (do_not_optimise) */
.gantt_task_line.locked-task {
    background-color: #6c757d !important;
    border: 2px solid #495057 !important;
    opacity: 0.7;
}

.gantt_task_line.locked-task .gantt_task_content {
    color: white;
    font-weight: bold;
}

.gantt_task_line.locked-task::before {
    content: '🔒';
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translateY(-50%);
}

/* Critical path tasks */
.gantt_task_line.critical-task {
    background-color: #dc3545 !important;
    border: 2px solid #bd2130 !important;
    box-shadow: 0 2px 6px rgba(220, 53, 69, 0.4);
}

.gantt_task_line.critical-task .gantt_task_content {
    color: white;
    font-weight: bold;
}

/* Milestone tasks */
.gantt_task_line.milestone-task {
    width: 0 !important;
    height: 0 !important;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 20px solid #ffc107;
    background-color: transparent !important;
    border-radius: 0 !important;
    transform: translateY(-5px);
}

.gantt_task_line.milestone-task::after {
    content: '🎯';
    position: absolute;
    top: -25px;
    left: -8px;
    font-size: 16px;
}

/* Summary tasks (parent tasks with children) */
.gantt_task_line.summary-task {
    background-color: #6610f2 !important;
    border: 2px solid #520dc2 !important;
    height: 18px !important;
    border-radius: 2px !important;
    opacity: 0.85;
}

.gantt_task_line.summary-task .gantt_task_content {
    color: white;
    font-weight: bold;
    font-size: 13px;
}

/* Summary task end caps (triangle decorations) */
.gantt_task_line.summary-task::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 0;
    width: 0;
    height: 0;
    border-top: 9px solid transparent;
    border-bottom: 9px solid transparent;
    border-right: 8px solid #6610f2;
}

.gantt_task_line.summary-task::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 0;
    width: 0;
    height: 0;
    border-top: 9px solid transparent;
    border-bottom: 9px solid transparent;
    border-left: 8px solid #6610f2;
}

/* Baseline bars (existing styles enhanced) */
.baseline-bar {
    position: absolute;
    height: 18px;
    background: rgba(108, 117, 125, 0.5);
    border: 1px solid #6c757d;
    border-radius: 3px;
    z-index: 1;
    pointer-events: none;
}

.baseline-bar.baseline-improved {
    background: rgba(40, 167, 69, 0.5);
    border-color: #28a745;
}

.baseline-bar.baseline-delayed {
    background: rgba(220, 53, 69, 0.5);
    border-color: #dc3545;
}

.baseline-bar.baseline-resource-changed {
    background: rgba(255, 193, 7, 0.5);
    border-color: #ffc107;
}

.baseline-content {
    font-size: 10px;
    padding: 2px 5px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Dependency links styling */
.gantt_link_arrow {
    border-color: #0275d8;
}

.gantt_line_wrapper div {
    background-color: #0275d8;
}

/* Different link types */
.link-fs .gantt_line_wrapper div {
    background-color: #0275d8; /* Finish-to-Start - Blue */
}

.link-ss .gantt_line_wrapper div {
    background-color: #5cb85c; /* Start-to-Start - Green */
}

.link-ff .gantt_line_wrapper div {
    background-color: #f0ad4e; /* Finish-to-Finish - Orange */
}

.link-sf .gantt_line_wrapper div {
    background-color: #d9534f; /* Start-to-Finish - Red */
}

/* Gantt context menu */
.gantt-context-menu {
    position: absolute;
    background: white;
    border: 1px solid #ccc;
    box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    padding: 5px 0;
    min-width: 180px;
    border-radius: 4px;
}

.gantt-context-menu > div {
    padding: 8px 15px;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
}

.gantt-context-menu > div:hover {
    background-color: #f0f0f0;
}

/* Task hover effects */
.gantt_task_line:hover {
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    transform: scale(1.02);
    transition: all 0.2s ease;
}

/* Drag and drop feedback */
.gantt_task_drag {
    opacity: 0.6;
    cursor: move;
}

.gantt_task_line.gantt_drag_marker {
    opacity: 0.5;
    border: 2px dashed #0275d8 !important;
}

/* Link creation feedback */
.gantt_link_direction {
    background-color: rgba(2, 117, 216, 0.3);
}

.gantt_link_control {
    background-color: #0275d8;
    border-radius: 50%;
}

.gantt_link_control:hover {
    background-color: #025aa5;
    transform: scale(1.2);
    transition: all 0.2s ease;
}

/* Tree grid (parent/child) styling */
.gantt_tree_content {
    overflow: visible;
}

.gantt_tree_icon {
    cursor: pointer;
    opacity: 0.7;
}

.gantt_tree_icon:hover {
    opacity: 1;
}

.gantt_tree_icon.gantt_open {
    transform: rotate(90deg);
}

/* Parent task styling */
.gantt_row.gantt_row_parent {
    background-color: rgba(0, 123, 255, 0.05);
}

.gantt_task_line.gantt_project {
    background-color: #0275d8;
    border: 2px solid #025aa5;
}

.gantt_task_line.gantt_project .gantt_task_content {
    color: white;
    font-weight: bold;
}

/* Lightbox (edit dialog) custom styles */
.gantt_popup_title {
    background-color: var(--primary-color);
    color: white;
}

.gantt_cal_light_wide {
    width: 600px;
}

/* Zoom controls (if added) */
.gantt-zoom-controls {
    display: flex;
    gap: 5px;
    margin: 10px 0;
}

.gantt-zoom-controls button {
    padding: 5px 15px;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    border-radius: 3px;
}

.gantt-zoom-controls button:hover {
    background-color: #f0f0f0;
}

.gantt-zoom-controls button.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Loading overlay for Gantt operations */
.gantt_loading {
    background-color: rgba(255, 255, 255, 0.9);
    z-index: 9999;
}

/* Message notifications */
.gantt_message_area {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10001;
}

.gantt_message_success {
    background-color: #28a745;
    color: white;
}

.gantt_message_error {
    background-color: #dc3545;
    color: white;
}

.gantt_message_warning {
    background-color: #ffc107;
    color: #333;
}

/* Tooltip enhancements */
.gantt_tooltip {
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 10px;
    border-radius: 4px;
    max-width: 300px;
    font-size: 13px;
    line-height: 1.5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Performance optimization for large datasets */
.gantt_data_area {
    will-change: transform;
}

.gantt_task {
    will-change: transform;
}