/* ==========================================================================
   Milestone Matrix Styles (Eisenhower Matrix)
   ========================================================================== */

/* Milestone Matrix Table */
.milestone-matrix-table {
    border: 3px solid #495057 !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    background: white;
}

.milestone-matrix-table th,
.milestone-matrix-table td {
    border: 2px solid #495057 !important;
    padding: 15px !important;
    position: relative;
}

.milestone-matrix-table th {
    background: #343a40 !important;
    color: white !important;
    font-weight: 600;
}

/* Milestone Matrix Cells */
.milestone-matrix-cell {
    position: relative;
    min-height: 300px;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    overflow-y: auto;
}

/* Matrix Cell Colors */
.milestone-matrix-cell.do-first-cell {
    background: linear-gradient(135deg, #fff5f5, #ffffff);
    border-left: 4px solid #dc3545 !important;
    border-top: 4px solid #dc3545 !important;
}

.milestone-matrix-cell.schedule-cell {
    background: linear-gradient(135deg, #f0f8ff, #ffffff);
    border-right: 4px solid #0d6efd !important;
    border-top: 4px solid #0d6efd !important;
}

.milestone-matrix-cell.delegate-cell {
    background: linear-gradient(135deg, #fffbf0, #ffffff);
    border-left: 4px solid #ffc107 !important;
    border-bottom: 4px solid #ffc107 !important;
}

.milestone-matrix-cell.eliminate-cell {
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    border-right: 4px solid #6c757d !important;
    border-bottom: 4px solid #6c757d !important;
}

/* Milestone Badges Container */
.milestone-badges-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 5px;
}

.milestone-badges-container::-webkit-scrollbar {
    width: 4px;
}

.milestone-badges-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
}

.milestone-badges-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

.milestone-badges-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ==========================================================================
   Badge Styles (Shared between Milestone and Initiative)
   ========================================================================== */

.milestone-badge,
.initiative-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 500;
    color: white;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.milestone-badge:hover,
.initiative-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
}

.milestone-badge a,
.initiative-badge a {
    color: white !important;
    text-decoration: none !important;
}

.milestone-badge a:hover,
.initiative-badge a:hover {
    color: white !important;
}

.initiative-badge {
    color: white !important;
}

/* Priority Colors (Shared) */
.milestone-badge.milestone-priority-1,
.initiative-badge.priority-1 {
    background: #dc3545;
}

.milestone-badge.milestone-priority-2,
.initiative-badge.priority-2 {
    background: #fd7e14;
}

.milestone-badge.milestone-priority-3,
.initiative-badge.priority-3 {
    background: #ffc107;
    color: #212529 !important;
}

.milestone-badge.milestone-priority-4,
.initiative-badge.priority-4 {
    background: #20c997;
}

.milestone-badge.milestone-priority-5,
.initiative-badge.priority-5 {
    background: #0dcaf0;
    color: #212529 !important;
}

.milestone-badge.milestone-priority-6,
.initiative-badge.priority-6 {
    background: #6f42c1;
}

/* Text contrast fixes for priority-3 and priority-5 */
.milestone-badge.milestone-priority-3,
.milestone-badge.milestone-priority-5,
.initiative-badge.priority-3,
.initiative-badge.priority-5 {
    color: #212529 !important;
}

.initiative-badge.priority-3 a,
.initiative-badge.priority-5 a {
    color: #212529 !important;
}

/* Badge States */
.milestone-badge.milestone-completed {
    opacity: 0.7;
    text-decoration: line-through;
}

.milestone-badge.milestone-overdue {
    animation: pulse 2s infinite;
    box-shadow: 0 0 10px rgba(220, 53, 69, 0.5);
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 10px rgba(220, 53, 69, 0.5); }
    50% { box-shadow: 0 0 20px rgba(220, 53, 69, 0.8); }
}

/* ==========================================================================
   Table Styles
   ========================================================================== */

/* Matrix Table */
.matrix-table {
    border: 2px solid #495057 !important;
}

.matrix-table th,
.matrix-table td {
    border: 1px solid #495057 !important;
    vertical-align: middle;
}

.matrix-cell-content {
    min-height: 80px;
    background: #f8f9fa;
}

/* RACI Matrix Table */
.raci-matrix-table {
    font-size: 0.875rem;
    width: 100% !important;
    table-layout: auto;
}

.raci-matrix-table th,
.raci-matrix-table td {
    padding: 10px 8px;
}

.raci-matrix-table th {
    white-space: nowrap;
    padding: 12px 8px;
    border-right: 2px solid #495057 !important;
}

.raci-matrix-table th:last-child {
    border-right: none !important;
}

/* RACI Column Layout */
.raci-matrix-table td.initiative-info,
.raci-matrix-table td.milestone-info {
    text-align: left;
    white-space: normal;
    word-wrap: break-word;
}

.raci-matrix-table td.initiative-info {
    width: 20%;
    min-width: 180px;
    max-width: 250px;
}

.raci-matrix-table td.milestone-info {
    width: 25%;
    min-width: 200px;
    max-width: 300px;
}

.raci-matrix-table td.date-info,
.raci-matrix-table td.status-info {
    white-space: nowrap;
}

.raci-matrix-table td.date-info {
    width: 10%;
    min-width: 110px;
}

.raci-matrix-table td.status-info {
    width: 8%;
    min-width: 100px;
}

.raci-matrix-table td.dept-cell {
    white-space: nowrap;
    width: auto;
    min-width: 80px;
    padding: 10px 6px;
    text-align: center;
}

.raci-matrix-table th.dept-header {
    writing-mode: vertical-lr;
    text-orientation: mixed;
    width: auto;
    min-width: 80px;
    padding: 12px 6px;
}

/* Table General Styles */
.table th {
    color: white !important;
}

.table td {
    color: #212529 !important;
    background-color: white !important;
}

.table-responsive {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* DataTables wrapper fix */
.dataTables_wrapper .table-responsive {
    border: none;
}

/* RACI table header styling */
#raci-matrix-table thead.table-dark th {
    background-color: #212529 !important;
    border-color: #495057 !important;
    color: #fff !important;
}

/* ==========================================================================
   Links and Text Styling
   ========================================================================== */

.initiative-link,
.milestone-link {
    color: #0d6efd;
    text-decoration: none;
    font-weight: 500;
}

.initiative-link:hover,
.milestone-link:hover {
    color: #0a58ca;
    text-decoration: underline;
}

.initiative-code {
    font-weight: 600;
    color: #495057;
}

.initiative-title {
    font-size: 0.85em;
    color: #6c757d;
    margin-top: 2px;
}

.initiative-info .d-flex {
    align-items: flex-start;
}

/* ==========================================================================
   RACI Role Color Coding
   ========================================================================== */

.raci-r, .legend-badge.responsible,
.raci-a, .legend-badge.accountable,
.raci-c, .legend-badge.consulted,
.raci-i, .legend-badge.informed {
    color: white !important;
    font-weight: bold;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
}

.raci-r, .legend-badge.responsible {
    background-color: #dc3545 !important;
}

.raci-a, .legend-badge.accountable {
    background-color: #fd7e14 !important;
}

.raci-c, .legend-badge.consulted {
    background-color: #198754 !important;
}

.raci-i, .legend-badge.informed {
    background-color: #0dcaf0 !important;
}

.legend-badge {
    margin: 0 0.25rem;
}

/* Individual (person-level) RACI badge — half the size of department badge */
.raci-person-badge {
    width: 14px !important;
    height: 14px !important;
    font-size: 0.65em !important;
    vertical-align: middle;
    opacity: 0.85;
}

.legend-badge.person-badge {
    width: 14px !important;
    height: 14px !important;
    font-size: 0.65em !important;
    vertical-align: middle;
}

.raci-legend {
    font-size: 0.9em;
}

.raci-legend strong {
    margin-right: 0.5rem;
}

/* ==========================================================================
   Interactive Elements
   ========================================================================== */

.fas.fa-info-circle {
    transition: color 0.2s ease-in-out, transform 0.2s ease-in-out;
}

.fas.fa-info-circle:hover {
    color: #0d6efd !important;
    transform: scale(1.1);
}

.tooltip {
    font-size: 0.875rem;
    max-width: 300px;
}

.tooltip-inner {
    text-align: left;
}

/* ==========================================================================
   Layout and Spacing
   ========================================================================== */

body {
    padding-top: 70px;
}

.container-fluid {
    padding-top: 0;
}

.alert,
.card {
    border-radius: 0.375rem;
}

.card {
    border: 1px solid #dee2e6;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 1200px) {
    .raci-matrix-table td.initiative-info {
        width: 18%;
        min-width: 150px;
    }

    .raci-matrix-table td.milestone-info {
        width: 22%;
        min-width: 180px;
    }

    .raci-matrix-table th.dept-header,
    .raci-matrix-table td.dept-cell {
        min-width: 70px;
    }
}

@media (max-width: 768px) {
    .milestone-matrix-table th,
    .milestone-matrix-table td {
        padding: 10px !important;
    }

    .milestone-matrix-cell {
        min-height: 200px;
        padding: 10px;
    }

    .milestone-badges-container {
        max-height: 150px;
    }

    .milestone-badge,
    .initiative-badge {
        font-size: 0.7rem;
        padding: 3px 6px;
    }

    .raci-matrix-table {
        font-size: 0.75rem;
    }

    .raci-matrix-table td.initiative-info {
        width: 25%;
        min-width: 120px;
    }

    .raci-matrix-table td.milestone-info {
        width: 30%;
        min-width: 120px;
    }

    .raci-matrix-table th.dept-header {
        min-width: 60px;
        font-size: 0.7rem;
    }

    .raci-matrix-table td.dept-cell {
        min-width: 60px;
    }

    .raci-r, .raci-a, .raci-c, .raci-i,
    .legend-badge.responsible, .legend-badge.accountable,
    .legend-badge.consulted, .legend-badge.informed {
        width: 20px;
        height: 20px;
        font-size: 0.7em;
    }

    .raci-person-badge,
    .legend-badge.person-badge {
        width: 12px !important;
        height: 12px !important;
        font-size: 0.6em !important;
    }
}

/* Gantt Chart Styles */
.gantt-container {
    overflow-x: auto;
    overflow-y: visible;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 100%;
}

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

.gantt-header .d-flex {
    display: flex;
    align-items: stretch;
}

.gantt-timeline {
    display: flex;
    height: 60px;
    flex: 1;
}

.gantt-month-header {
    background: linear-gradient(135deg, #343a40, #495057);
    border-right: 1px solid #dee2e6;
    padding: 12px 8px;
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    flex-shrink: 0;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.gantt-month-header:last-child {
    border-right: none;
}

.gantt-body {
    position: relative;
    min-height: 200px;
}

.gantt-row {
    display: flex;
    border-bottom: 1px solid #e9ecef;
    min-height: 80px;
    align-items: stretch;
}

.gantt-row:nth-child(even) {
    background-color: #f8f9fa;
}

.gantt-row:hover {
    background-color: #e3f2fd;
    box-shadow: inset 0 0 0 1px #2196f3;
}

.gantt-row-label {
    width: 450px;
    min-width: 450px;
    max-width: 450px;
    padding: 16px;
    background: #ffffff;
    border-right: 3px solid #dee2e6;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    flex-shrink: 0;
}

.gantt-row:nth-child(even) .gantt-row-label {
    background: #f8f9fa;
}

.gantt-row-label .flex-1 {
    min-width: 0;
    flex: 1;
}

.gantt-row-label .fw-semibold {
    margin-bottom: 6px;
    line-height: 1.3;
    display: block;
    font-size: 0.95rem;
    color: #212529;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.gantt-row-label small {
    display: block;
    line-height: 1.2;
    color: #6c757d;
    font-size: 0.8rem;
}

.gantt-row-timeline {
    flex: 1;
    position: relative;
    min-height: 80px;
    box-sizing: border-box;
}

/* Base bar styling - NO clip-path here */
.gantt-bar {
    position: absolute;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
    box-sizing: border-box;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    min-width: 8px;
    border: 2px solid rgba(255,255,255,0.2);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.gantt-bar:hover {
    transform: translateY(-50%) scale(1.03);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 6;
}

.gantt-bar-text {
    padding: 0 8px;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    height: 100%;
    overflow: hidden;
}

.gantt-bar-progress {
    margin-left: auto;
    margin-right: 8px;
    font-size: 0.7rem;
    background: rgba(255,255,255,0.2);
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 700;
}

/* Initiative Status Colors - Professional scheme */
.gantt-initiative {
    background: linear-gradient(135deg, #28a745, #20c997);
    border-color: #1e7e34;
}

.gantt-initiative.planning {
    background: linear-gradient(135deg, #17a2b8, #20c997);
    border-color: #117a8b;
}

.gantt-initiative.in_progress {
    background: linear-gradient(135deg, #007bff, #17a2b8);
    border-color: #0056b3;
}

.gantt-initiative.on_hold {
    background: linear-gradient(135deg, #ffc107, #fd7e14);
    border-color: #e0a800;
    color: #212529;
    text-shadow: none;
}

.gantt-initiative.completed {
    background: linear-gradient(135deg, #28a745, #20c997);
    border-color: #1e7e34;
}

.gantt-initiative.cancelled {
    background: linear-gradient(135deg, #6c757d, #495057);
    border-color: #495057;
}

/* Delayed/Overdue - Red for actual problems */
.gantt-overdue {
    background: linear-gradient(135deg, #dc3545, #c82333) !important;
    border-color: #bd2130 !important;
    animation: pulse-warning 3s infinite;
}

@keyframes pulse-warning {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; box-shadow: 0 0 0 4px rgba(220, 53, 69, 0.3); }
}

/* Milestone styles - Simple rectangle, half row height */
.gantt-bar.gantt-milestone,
.gantt-milestone {
    background: linear-gradient(135deg, #ffc107, #ffeb3b) !important;
    border-color: #f39c12 !important;
    height: 40px;
    margin-top: 20px;
    border-radius: 4px;
    justify-content: center;
    color: #212529;
    font-weight: 600;
}

/* Completed milestones - green */
.gantt-bar.gantt-milestone.completed,
.gantt-milestone.completed {
    background: linear-gradient(135deg, #28a745, #20c997) !important;
    border-color: #20a745 !important;
}

/* Overdue milestones - red */
.gantt-bar.gantt-milestone.gantt-overdue,
.gantt-milestone.gantt-overdue {
    background: linear-gradient(135deg, #dc3545, #fd7e14) !important;
    border-color: #c82333 !important;
}

/* Make sure milestone text is centered */
.gantt-bar.gantt-milestone .gantt-bar-text {
    justify-content: center;
    padding: 0 6px;
    font-size: 0.75rem;
}

/* Today line - more prominent */
.gantt-today-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, #dc3545, #c82333);
    z-index: 8;
    box-shadow: 0 0 8px rgba(220, 53, 69, 0.6);
}

.gantt-today-line::before {
    content: 'TODAY';
    position: absolute;
    top: -25px;
    left: -20px;
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Level indentation with better visual hierarchy */
.gantt-level-0 .gantt-row-label {
    padding-left: 16px;
    border-left: 4px solid #007bff;
}

.gantt-level-1 .gantt-row-label {
    padding-left: 40px;
    background: linear-gradient(90deg, #f8f9fa, #ffffff);
    border-left: 4px solid #6c757d;
}

.gantt-level-1 .gantt-row-label::before {
    content: '└─';
    position: absolute;
    left: 24px;
    color: #6c757d;
    font-family: monospace;
    font-weight: bold;
}

.gantt-extension-left {
    position: absolute;
    left: 8px; /* Move 50% inward from the left edge */
    top: 50%;
    transform: translate(-50%, -50%);
    background: rgba(23, 162, 184, 0.9);
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.gantt-extension-right {
    position: absolute;
    right: 8px; /* Move 5% inward from the right edge */
    top: 50%;
    transform: translate(50%, -50%);
    background: rgba(23, 162, 184, 0.9);
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.gantt-extension-left-alt {
    position: absolute;
    left: 8px; /* Fixed 8px from left edge */
    top: 50%;
    transform: translateY(-50%);
    /* rest of styles same as above */
}

.gantt-extension-right-alt {
    position: absolute;
    right: 8px; /* Fixed 8px from right edge */
    top: 50%;
    transform: translateY(-50%);
    /* rest of styles same as above */
}

/*.gantt-extension-left {*/
/*    left: -10px;*/
/*}*/

/*.gantt-extension-right {*/
/*    right: -10px;*/
/*}*/

/* Better contrast for extended bars */
.gantt-bar.extends-before {
    border-left: 4px solid #007bff;
    border-radius: 0 6px 6px 0;
}

.gantt-bar.extends-after {
    border-right: 4px solid #007bff;
    border-radius: 6px 0 0 6px;
}

.gantt-bar.extends-before.extends-after {
    border-radius: 0;
}

/* Enhanced Legend */
.gantt-legend {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.legend-color {
    width: 32px;
    height: 20px;
    border-radius: 4px;
    margin-right: 12px;
    border: 1px solid rgba(0,0,0,0.1);
}

/* Status badges in left column */
.status-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 8px;
}

.status-planning { background: #17a2b8; color: white; }
.status-in-progress { background: #007bff; color: white; }
.status-on-hold { background: #ffc107; color: #212529; }
.status-completed { background: #28a745; color: white; }
.status-cancelled { background: #6c757d; color: white; }

/* Progress information */
.progress-info {
    font-size: 0.75rem;
    color: #495057;
    margin-top: 4px;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .gantt-row-label {
        width: 400px;
        min-width: 400px;
        max-width: 400px;
    }
}

@media (max-width: 992px) {
    .gantt-row-label {
        width: 350px;
        min-width: 350px;
        max-width: 350px;
        font-size: 0.85rem;
        padding: 12px;
    }

    .gantt-bar {
        height: 28px;
        font-size: 0.75rem;
    }

    .gantt-bar.gantt-milestone {
        height: 20px;
        margin-top: 24px;
    }
}

@media (max-width: 768px) {
    .gantt-row-label {
        width: 300px;
        min-width: 300px;
        max-width: 300px;
        font-size: 0.8rem;
        padding: 10px;
    }

    .gantt-month-header {
        font-size: 0.75rem;
        padding: 8px 4px;
    }

    .gantt-bar {
        height: 24px;
        font-size: 0.7rem;
    }

    .gantt-bar.gantt-milestone {
        height: 16px;
        margin-top: 20px;
    }
}

/* Scrollbar styling */
.gantt-container::-webkit-scrollbar {
    height: 12px;
}

.gantt-container::-webkit-scrollbar-track {
    background: #f1f3f4;
    border-radius: 6px;
}

.gantt-container::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #6c757d, #495057);
    border-radius: 6px;
}

.gantt-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #495057, #343a40);
}
/* Priority Level Colors for Legend */
.col-md-6 .legend-item .legend-color.priority-1,
.col-md-6 div:nth-child(5) .legend-color.priority-1 {
    background: linear-gradient(135deg, #dc3545, #fd7e14) !important;
    border: 1px solid #dc3545 !important;
}

.col-md-6 .legend-item .legend-color.priority-2,
.col-md-6 div:nth-child(6) .legend-color.priority-2 {
    background: linear-gradient(135deg, #fd7e14, #ffc107) !important;
    border: 1px solid #fd7e14 !important;
}

.col-md-6 .legend-item .legend-color.priority-3,
.col-md-6 div:nth-child(7) .legend-color.priority-3 {
    background: linear-gradient(135deg, #ffc107, #28a745) !important;
    border: 1px solid #ffc107 !important;
}

.col-md-6 .legend-item .legend-color.priority-4,
.col-md-6 div:nth-child(8) .legend-color.priority-4 {
    background: linear-gradient(135deg, #28a745, #20c997) !important;
    border: 1px solid #28a745 !important;
}

.legend-color {
    width: 20px !important;
    height: 20px !important;
    border-radius: 4px !important;
    display: inline-block !important;
    margin-right: 8px !important;
    vertical-align: middle !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2) !important;
}
