* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 95%;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 20px;
}

.header h1 {
    font-size: 1.5em;
    margin-bottom: 5px;
}

.nav {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.nav a {
    color: white;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.2);
    transition: all 0.2s;
    font-weight: 500;
    font-size: 0.9em;
}

.nav a:hover {
    background: rgba(255, 255, 255, 0.3);
}

.nav a.active {
    background: white;
    color: #667eea;
}

.stats {
    padding: 20px 30px;
    display: flex;
    justify-content: space-around;
    border-bottom: 2px solid #f0f0f0;
}

.stat-item {
    text-align: center;
}

.stat-number {
    font-size: 2em;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    color: #6c757d;
    font-size: 0.9em;
    margin-top: 5px;
}

.gantt-container {
    display: flex;
    height: calc(100vh - 200px);
    min-height: 500px;
}

.left-pane {
    width: 400px;
    border-right: 2px solid #dee2e6;
    overflow-y: auto;
    flex-shrink: 0;
}

/* Left header spacer to align with right timeline header */
.left-header {
    position: sticky;
    top: 0;
    height: 100px; /* match combined timeline headers (months + days) */
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px 10px;
}

/* Summary section in left header */
.gantt-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: 100%;
    padding: 0 8px;
}

.summary-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 6px;
    background: white;
    border-radius: 4px;
    border: 1px solid #dee2e6;
}

.summary-label {
    color: #6c757d;
    font-size: 0.65em;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 1px;
}

.summary-value {
    color: #667eea;
    font-weight: 700;
    font-size: 1.1em;
    line-height: 1;
}

.right-pane {
    flex: 1;
    overflow-x: auto;
    overflow-y: auto;
    position: relative;
    box-sizing: border-box;
}

.timeline-header {
    position: sticky;
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    z-index: 1000; /* keep headers above bars */
    display: flex;
    height: 50px;
    left: 0;
    right: 0;
}

/* Freeze month and day headers separately */
.timeline-header.months { top: 0; }
.timeline-header.days { top: 50px; }

.day-marker {
    min-width: 30px;
    text-align: center;
    padding: 10px 5px;
    border-right: 1px solid #dee2e6;
    font-size: 0.75em;
    color: #6c757d;
    font-weight: 600;
}

.day-marker.non-working {
    background: #ffe5e5;
    color: #dc3545;
    font-weight: 700;
}

.item-row {
    display: flex;
    border-bottom: 1px solid #f0f0f0;
    height: 40px; /* fixed height to match left labels */
    align-items: center;
    position: relative; /* Ensure bars position within their own row */
}

.item-row:hover {
    background: #f8f9fa;
}

.item-label {
    padding: 8px 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
    border-bottom: 1px solid #f0f0f0;
    height: 40px; /* fixed height to align with right rows */
}

.item-label.component {
    background: repeating-linear-gradient(
        135deg,
        #667eea,
        #667eea 5px,
        rgba(93, 111, 216, 0.95) 5px,
        rgba(93, 111, 216, 0.95) 10px
    );
    color: white;
    font-weight: 700;
    font-size: 1em;
    padding-left: 10px;
    position: relative;
}

.item-label.component::after {
    content: '📦';
    position: absolute;
    right: 10px;
    opacity: 0.3;
    font-size: 0.85em;
}

.item-label.module {
    background: repeating-linear-gradient(
        135deg,
        #f8f9fa,
        #f8f9fa 4px,
        rgba(233, 236, 239, 0.8) 4px,
        rgba(233, 236, 239, 0.8) 8px
    );
    font-weight: 600;
    padding-left: 25px;
    color: #667eea;
    position: relative;
}

.item-label.module::after {
    content: '📁';
    position: absolute;
    right: 10px;
    opacity: 0.25;
    font-size: 0.85em;
}

.item-label.task {
    padding-left: 45px;
    color: #495057;
}

.item-id {
    background: rgba(255, 255, 255, 0.3);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.8em;
    font-weight: bold;
}

.component .item-id {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

.module .item-id {
    background: #667eea;
    color: white;
}

.task .item-id {
    background: #dee2e6;
    color: #495057;
}

.item-label.editable {
    cursor: pointer;
}

.item-label.editable:hover {
    background: #e9ecef !important;
}

/* Action buttons for CRUD operations */
.action-buttons {
    margin-left: auto;
    display: none;
    gap: 4px;
}

.item-label:hover .action-buttons {
    display: flex;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    font-size: 1em;
    border-radius: 3px;
    transition: all 0.2s;
    opacity: 0.7;
}

.btn-icon:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.3);
}

.btn-icon.btn-danger:hover {
    background: rgba(220, 53, 69, 0.2);
}

/* Drag handle for task reordering */
.drag-handle {
    cursor: grab;
    padding: 0 4px;
    color: #999;
    font-size: 0.9em;
    user-select: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.item-label.draggable {
    transition: background-color 0.2s;
}

.item-label.dragging {
    opacity: 0.5;
    background: #e7f3ff !important;
}

.item-label.task[draggable="true"] {
    cursor: move;
}

/* Edit mode toggle button */
.btn-edit {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-edit:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.item-name-input {
    flex: 1;
    border: 1px solid #667eea;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9em;
    outline: none;
}

.relations-badge {
    background: #ffc107;
    color: #856404;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7em;
    font-weight: bold;
    cursor: help;
}

.edit-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.edit-modal-content {
    background: white;
    border-radius: 8px;
    padding: 24px;
    min-width: 500px;
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.edit-modal h2 {
    margin-bottom: 20px;
    color: #667eea;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #495057;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 0.9em;
}

.form-group textarea {
    resize: vertical;
    font-family: inherit;
}

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

.relation-item select, .relation-item input {
    flex: 1;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
}

.btn-danger {
    background: #dc3545;
    color: white;
    padding: 4px 8px;
    font-size: 0.8em;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-success {
    background: #28a745;
    color: white;
    padding: 4px 12px;
    font-size: 0.85em;
}

.btn-success:hover {
    background: #218838;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.gantt-bars {
    position: relative;
    display: flex;
}

.timeline-cell {
    min-width: 30px;
    border-right: 1px solid #f0f0f0;
    position: relative;
}

.timeline-cell.non-working {
    background: #ffe5e5;
}

.gantt-bar {
    position: absolute;
    height: 24px;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-size: 0.75em;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s;
    z-index: 1;
}

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

.gantt-bar.component {
    background: repeating-linear-gradient(
        45deg,
        #667eea,
        #667eea 4px,
        rgba(86, 105, 211, 0.9) 4px,
        rgba(86, 105, 211, 0.9) 8px
    );
    color: white;
    height: 28px;
    font-weight: 700;
    border: 1px solid rgba(74, 90, 184, 0.3);
}

.gantt-bar.module {
    background: repeating-linear-gradient(
        135deg,
        #8b9cfa,
        #8b9cfa 5px,
        #7a8ce9 5px,
        #7a8ce9 10px
    );
    color: white;
    height: 26px;
    border: 1px solid rgba(102, 126, 234, 0.3);
}

.gantt-bar.task {
    background: #e7f3ff;
    color: #0066cc;
    border: 1px solid #0066cc;
}

.gantt-bar.milestone {
    background: #ffd700;
    color: #856404;
    border: 2px solid #856404;
    width: 20px !important;
    height: 20px;
    padding: 0;
    border-radius: 4px;
    transform: translateY(-50%) rotate(45deg);
}

.gantt-bar.milestone:hover {
    transform: translateY(-50%) rotate(45deg) scale(1.2);
}

.duration-label {
    margin-left: auto;
    opacity: 0.9;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.legend {
    padding: 8px 20px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    display: flex;
    gap: 15px;
    align-items: center;
    font-size: 0.8em;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-color {
    width: 30px;
    height: 16px;
    border-radius: 3px;
}

.legend-color.component {
    background: repeating-linear-gradient(
        45deg,
        #667eea,
        #667eea 4px,
        rgba(86, 105, 211, 0.9) 4px,
        rgba(86, 105, 211, 0.9) 8px
    );
    border: 1px solid rgba(74, 90, 184, 0.3);
}

.legend-color.module {
    background: repeating-linear-gradient(
        135deg,
        #8b9cfa,
        #8b9cfa 5px,
        #7a8ce9 5px,
        #7a8ce9 10px
    );
    border: 1px solid rgba(102, 126, 234, 0.3);
}

.legend-color.task {
    background: #e7f3ff;
    border: 1px solid #0066cc;
}

.legend-color.milestone {
    width: 16px;
    height: 16px;
    background: #ffd700;
    border: 2px solid #856404;
    transform: rotate(45deg);
}

/* Scrollbar styling */
.right-pane::-webkit-scrollbar,
.left-pane::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.right-pane::-webkit-scrollbar-track,
.left-pane::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.right-pane::-webkit-scrollbar-thumb,
.left-pane::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 5px;
}

.right-pane::-webkit-scrollbar-thumb:hover,
.left-pane::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.timeline-content {
    position: relative;
    z-index: 1;
}
