/* Global Styles */
:root {
    --primary-color: #0d6efd;
    --danger-color: #dc3545;
    --success-color: #198754;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --dark-color: #212529;
}

body {
    background-color: #f8f9fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Navigation */
.navbar {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar-brand {
    font-weight: 600;
    font-size: 1.3rem;
}

/* Cards */
.card {
    border: none;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 12px rgba(0,0,0,0.15) !important;
}

.project-card {
    cursor: pointer;
}

.project-card:hover {
    background-color: #f0f6ff;
}

.card-footer {
    padding: 0.75rem;
}

.card-footer .btn {
    margin-right: 0.25rem;
}

/* Tables */
.table {
    margin-bottom: 0;
    border-collapse: collapse;
}

.table thead {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
}

.table tbody tr:hover {
    background-color: #f8f9fa;
}

.table-responsive {
    border-radius: 0.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Buttons */
.btn {
    border-radius: 0.35rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.btn-sm {
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #0b5ed7;
    border-color: #0b5ed7;
}

.btn-danger {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
}

.btn-danger:hover {
    background-color: #bb2d3b;
    border-color: #bb2d3b;
}

/* Forms */
.form-control,
.form-select {
    border-radius: 0.35rem;
    border: 1px solid #dee2e6;
    padding: 0.6rem 0.75rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #212529;
}

/* Modals */
.modal-content {
    border: none;
    border-radius: 0.5rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.modal-title {
    font-weight: 600;
    color: #212529;
}

/* Badges */
.badge {
    padding: 0.4rem 0.6rem;
    border-radius: 0.25rem;
    font-weight: 500;
}

/* Alerts */
.alert {
    border: none;
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
}

.alert-success {
    background-color: #d1e7dd;
    color: #0f5132;
}

.alert-danger {
    background-color: #f8d7da;
    color: #842029;
}

.alert-info {
    background-color: #cfe2ff;
    color: #084298;
}

.alert-warning {
    background-color: #fff3cd;
    color: #664d03;
}

/* Responsive */
@media (max-width: 768px) {
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .row {
        --bs-gutter-x: 0.75rem;
    }
    
    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }
    
    .table {
        font-size: 0.85rem;
    }
    
    .card-title {
        font-size: 1rem;
    }
}

@media (max-width: 576px) {
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    h1 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }
}

/* Utility Classes */
.shadow-sm {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
}

.pt-4 {
    padding-top: 1.5rem !important;
}

.mt-5 {
    margin-top: 3rem !important;
}

.border-top {
    border-top: 1px solid #dee2e6;
}

/* Loading spinner */
.spinner-border {
    width: 1rem;
    height: 1rem;
    border-width: 0.2em;
}

/* Text utilities */
.text-muted {
    color: #6c757d !important;
}

.fw-bold {
    font-weight: 600;
}

/* Color utilities */
.bg-light {
    background-color: #f8f9fa !important;
}

.bg-white {
    background-color: #ffffff !important;
}

/* Timeline Styles */
.timeline-container {
    margin: 20px 0;
    padding: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: auto;
    max-height: 60vh;
    position: relative;
}

.timeline-content {
    display: block;
    padding-bottom: 50px; /* Space for sticky legend */
}

.timeline-header {
    display: flex;
    border-bottom: 2px solid #dee2e6;
    margin-bottom: 5px;
    min-width: 1000px;
    position: sticky;
    top: 0;
    background: white;
    z-index: 30;
}

.timeline-header-label {
    width: 180px;
    font-weight: 600;
    flex-shrink: 0;
    padding: 10px 10px 5px 15px;
    background: white;
    z-index: 35;
    position: sticky;
    left: 0;
    border-right: 1px solid #dee2e6;
}

.timeline-dates-header {
    flex: 1;
    position: relative;
}

.timeline-weeks {
    display: flex;
    border-bottom: 1px solid #dee2e6;
}

.timeline-week {
    flex: 1;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 3px 0;
    border-right: 1px solid #dee2e6;
    background: #f8f9fa;
}

.timeline-week:last-child {
    border-right: none;
}

.timeline-days {
    display: flex;
}

.timeline-day {
    flex: 1;
    text-align: center;
    font-size: 0.65rem;
    padding: 2px 0;
    border-right: 1px solid #eee;
    color: #6c757d;
}

.timeline-day:last-child {
    border-right: none;
}

.timeline-day.weekend {
    background: #fff3cd;
}

.timeline-day.today {
    background: #dc3545;
    color: white;
    font-weight: 600;
}

.timeline-row {
    display: flex;
    align-items: stretch;
    margin: 0;
    min-height: 60px;
    min-width: 1000px;
    border-bottom: 1px solid #eee;
}

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

.timeline-label {
    width: 180px;
    font-weight: 500;
    flex-shrink: 0;
    padding: 8px 10px 8px 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: white;
    z-index: 20;
    position: sticky;
    left: 0;
    border-right: 1px solid #dee2e6;
}

.timeline-label .op-name {
    font-weight: 600;
    color: #212529;
}

.timeline-label .op-info {
    font-size: 0.75rem;
    color: #6c757d;
}

.timeline-label .op-dates {
    font-size: 0.7rem;
    color: #0d6efd;
}

.timeline-bar-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.timeline-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
}

.timeline-grid-cell {
    flex: 1;
    border-right: 1px solid #eee;
}

.timeline-grid-cell.weekend {
    background: rgba(255, 243, 205, 0.3);
}

.timeline-grid-cell:last-child {
    border-right: none;
}

.timeline-bar {
    position: absolute;
    height: 44px;
    border-radius: 6px;
    min-width: 8px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 4px 8px;
    color: white;
    font-size: 0.75rem;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 5;
    overflow: hidden;
}

.timeline-bar:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    z-index: 10;
}

.timeline-bar.project {
    background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
    position: relative;
    overflow: hidden;
}

.timeline-bar.project.completed {
    background: linear-gradient(135deg, #20c997 0%, #1aa179 100%);
}

.timeline-bar.project .bar-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    padding: 2px 8px;
}

.timeline-bar.project .bar-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.5);
    z-index: 1;
    transition: width 0.3s ease;
}

.timeline-bar.operation {
    background: rgba(25, 135, 84, 0.2);
    border: 2px solid #198754;
}

.timeline-bar.operation.completed {
    background: #198754;
    border: 2px solid #146c43;
}

.timeline-bar.operation.no-resource {
    background: rgba(255, 193, 7, 0.25);
    border: 2px solid #ffc107;
    color: #000;
}

.timeline-legend-color.operation.completed {
    background: #198754;
}

.timeline-legend-color.operation.no-resource {
    background: rgba(255, 193, 7, 0.25);
    border: 2px solid #ffc107;
}

.timeline-label.completed .op-name {
    text-decoration: line-through;
    opacity: 0.7;
}

.timeline-bar .bar-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.timeline-bar .bar-workers {
    font-size: 0.65rem;
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.timeline-bar .bar-hours {
    font-size: 0.65rem;
    opacity: 0.85;
}

.timeline-today-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #dc3545;
    z-index: 15;
    box-shadow: 0 0 4px rgba(220, 53, 69, 0.5);
}

.timeline-deadline {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #ffc107;
    z-index: 14;
}

.timeline-legend-wrapper {
    position: sticky;
    bottom: 0;
    left: 0;
    background: white;
    z-index: 25;
    border-top: 1px solid #dee2e6;
}

.timeline-legend {
    display: flex;
    gap: 20px;
    padding: 12px 15px;
    font-size: 0.8rem;
    margin: 0;
}

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

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

.timeline-legend-color.today {
    background: #dc3545;
}

.timeline-legend-color.deadline {
    background: #ffc107;
}

.timeline-legend-color.operation {
    background: rgba(25, 135, 84, 0.2);
    border: 2px solid #198754;
}

/* Timeline zoom controls */
.timeline-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.timeline-controls label {
    font-weight: 500;
    margin-right: 5px;
}

.timeline-zoom-btn {
    padding: 5px 12px;
    font-size: 0.85rem;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.timeline-zoom-btn:hover {
    background: #f8f9fa;
}

.timeline-zoom-btn.active {
    background: #0d6efd;
    color: white;
    border-color: #0d6efd;
}

.timeline-scroll-controls {
    display: flex;
    gap: 5px;
    margin-left: auto;
}

.timeline-scroll-btn {
    padding: 5px 15px;
    font-size: 1rem;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.timeline-scroll-btn:hover {
    background: #e9ecef;
}

.timeline-scroll-btn:active {
    background: #dee2e6;
}

/* Project background highlight */
.timeline-project-bg {
    position: absolute;
    top: 0;
    bottom: 0;
    background: rgba(13, 110, 253, 0.08);
    border-left: 2px solid rgba(13, 110, 253, 0.3);
    border-right: 2px solid rgba(13, 110, 253, 0.3);
    z-index: 1;
}

/* Custom tooltip */
.timeline-tooltip {
    position: fixed;
    background: #212529;
    color: white;
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 0.85rem;
    max-width: 300px;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    opacity: 0;
    transition: opacity 0.2s;
}

.timeline-tooltip.visible {
    opacity: 1;
}

.timeline-tooltip h6 {
    margin: 0 0 8px 0;
    font-size: 0.95rem;
    color: #ffc107;
}

.timeline-tooltip .tooltip-row {
    display: flex;
    margin: 4px 0;
}

.timeline-tooltip .tooltip-label {
    color: #adb5bd;
    min-width: 80px;
}

.timeline-tooltip .tooltip-value {
    color: white;
}

.timeline-tooltip .tooltip-workers {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #495057;
}

.timeline-tooltip .tooltip-workers-title {
    color: #20c997;
    font-weight: 500;
    margin-bottom: 4px;
}

.timeline-tooltip .worker-item {
    padding: 2px 0;
    color: #e9ecef;
}

/* Back button */
.back-button {
    margin-bottom: 20px;
}

.back-button .btn {
    padding: 10px 25px;
    font-size: 1rem;
}
