/* ============================================================
   Ressourcenverwaltung — Application Styles
   ============================================================ */

/* Layout */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f0f2f5;
    color: #212529;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1 0 auto;
}

.with-navbar {
    padding-top: 56px;
}

main > .container-fluid {
    max-width: 1600px;
}

.footer {
    background: #fff;
    font-size: .8rem;
    margin-top: 2rem;
}

/* Login page */
.login-page {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
}

.login-card {
    width: 100%;
    max-width: 420px;
    border: 0;
    border-radius: 12px;
    overflow: hidden;
}

/* Stats cards */
.stat-card .card-body {
    padding: 1.25rem;
}

.stat-number {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    font-size: .85rem;
    opacity: .9;
    margin-top: .25rem;
}

/* Construction site cards */
.site-card {
    border-radius: 8px;
    transition: box-shadow .15s ease;
}

.site-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,.12) !important;
}

.site-color-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
    flex-shrink: 0;
}

.site-color-dot.small {
    width: 10px;
    height: 10px;
}

/* Employee dots */
.employee-color-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
    flex-shrink: 0;
}

.employee-color-dot.large {
    width: 18px;
    height: 18px;
}

/* Buttons xs */
.btn-xs {
    padding: .15rem .4rem;
    font-size: .75rem;
    border-radius: .2rem;
}

/* Gap utility (Bootstrap 4 compat) */
.gap-2 { gap: .5rem !important; }
.gap-3 { gap: 1rem !important; }
.ms-1  { margin-left: .25rem !important; }
.ms-2  { margin-left: .5rem !important; }

/* Card adjustments */
.card-header h5 { margin-bottom: 0; }

/* Gantt controls */
.gantt-controls .btn {
    white-space: nowrap;
}

/* Legend */
.legend-item {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .8rem;
    color: #666;
}

.legend-box {
    display: inline-block;
    width: 18px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-box-milestone {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: #333;
    transform: rotate(45deg);
    flex-shrink: 0;
}

/* ============================================================
   Gantt Chart Styles
   ============================================================ */

#gantt-chart-wrapper {
    overflow: hidden;
    position: relative;
    border-radius: 0 0 .25rem .25rem;
}

.gantt-root {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 70vh;
    background: #fff;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

.gantt-scroll-wrapper {
    position: relative;
    display: inline-block;
    min-width: 100%;
}

.gantt-empty {
    padding: 2rem;
    text-align: center;
    color: #888;
}

/* Header */
.gantt-header {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 20;
    background: #fff;
    border-bottom: 2px solid #dee2e6;
    user-select: none;
}

.gantt-corner {
    position: sticky;
    left: 0;
    z-index: 30;
    background: #343a40;
    color: #fff;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0 8px 4px;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    border-right: 2px solid #dee2e6;
    flex-shrink: 0;
}

.gantt-date-area {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.gantt-month-row,
.gantt-week-row,
.gantt-day-row {
    display: flex;
    flex-shrink: 0;
}

.gantt-month-cell {
    height: 20px;
    line-height: 20px;
    font-size: .7rem;
    font-weight: 600;
    color: #fff;
    background: #495057;
    text-align: center;
    border-right: 1px solid #6c757d;
    overflow: hidden;
    white-space: nowrap;
    flex-shrink: 0;
}

.gantt-week-cell {
    height: 22px;
    line-height: 22px;
    font-size: .68rem;
    color: #fff;
    background: #6c757d;
    text-align: center;
    border-right: 1px solid #adb5bd;
    overflow: hidden;
    flex-shrink: 0;
}

.gantt-day-cell {
    height: 22px;
    line-height: 22px;
    font-size: .7rem;
    color: #495057;
    background: #f8f9fa;
    text-align: center;
    border-right: 1px solid #dee2e6;
    flex-shrink: 0;
    overflow: hidden;
}

.gantt-day-cell.weekend {
    background: #e9ecef;
    color: #adb5bd;
}

.gantt-day-cell.today {
    background: #fff3cd;
    color: #856404;
    font-weight: 700;
}

.gantt-day-cell.holiday {
    background: #fef3cd;
    color: #856404;
    font-weight: 600;
}

.gantt-bg-cell.holiday {
    background: rgba(254, 243, 205, 0.45);
}

/* Body */
.gantt-body {
    display: flex;
    flex-direction: column;
}

.gantt-row {
    display: flex;
    flex-shrink: 0;
    border-bottom: 1px solid #dee2e6;
    position: relative;
}

.gantt-row.even { background: #fff; }
.gantt-row.odd  { background: #f8f9fa; }

.gantt-label {
    position: sticky;
    left: 0;
    z-index: 10;
    background: inherit;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4px 10px 4px 8px;
    font-size: .82rem;
    font-weight: 500;
    border-right: 2px solid #dee2e6;
    flex-shrink: 0;
    overflow: hidden;
    white-space: nowrap;
}

.gantt-emp-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    flex-shrink: 0;
    vertical-align: middle;
}

.gantt-emp-name {
    vertical-align: middle;
}

.gantt-emp-pos {
    color: #6c757d;
    font-size: .72rem;
    font-weight: 400;
}

/* Timeline area */
.gantt-timeline {
    position: relative;
    display: flex;
    align-items: center;
    flex-grow: 1;
    overflow: hidden;
}

.gantt-bg-cell {
    position: absolute;
    top: 0;
    height: 100%;
    border-right: 1px solid #f0f0f0;
}

.gantt-bg-cell.weekend {
    background: rgba(0,0,0,.025);
}

/* Bars */
.gantt-bar {
    position: absolute;
    height: 22px;
    border-radius: 3px;
    top: 3px;
    cursor: default;
    display: flex;
    align-items: center;
    overflow: hidden;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    transition: opacity .15s;
    z-index: 5;
}

.gantt-bar:hover {
    opacity: .85;
    z-index: 6;
}

.gantt-bar-clickable {
    cursor: pointer;
}

.gantt-bar-clickable:hover {
    opacity: .8;
    box-shadow: 0 2px 8px rgba(0,0,0,.35);
    transform: translateY(-1px);
    transition: opacity .1s, box-shadow .1s, transform .1s;
}

.gantt-bar-assignment {
    top: 3px;
    height: 24px;
}

.gantt-bar-absence {
    top: 29px;
    height: 10px;
    border-radius: 2px;
    opacity: .75;
    box-shadow: none;
}

.gantt-bar-absence:hover {
    opacity: .9;
}

.gantt-bar-label {
    padding: 0 5px;
    font-size: .7rem;
    color: #fff;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 1px rgba(0,0,0,.3);
    pointer-events: none;
}

.gantt-bar-vehicle {
    top: 2px;
    height: 18px;
    border-radius: 2px;
    opacity: 0.9;
}

.gantt-track-divider {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: #dee2e6;
    z-index: 4;
    pointer-events: none;
}

/* Today line — z-index below sticky .gantt-label (10) so it clips behind the label on scroll */
.gantt-today-line {
    position: absolute;
    top: 0;
    width: 2px;
    background: #e74c3c;
    z-index: 7;
    pointer-events: none;
    opacity: .7;
}

.gantt-today-label {
    position: absolute;
    /* top is set dynamically in JS relative to headerHeight */
    font-size: .6rem;
    font-weight: 700;
    color: #e74c3c;
    background: rgba(255,255,255,.85);
    padding: 0 2px;
    border-radius: 2px;
    z-index: 8;
    pointer-events: none;
    white-space: nowrap;
}

/* Milestone line — z-index below sticky .gantt-label (10) so it clips behind the label on scroll */
.gantt-milestone-line {
    position: absolute;
    top: 0;
    width: 0;
    border-left: 2px dashed #555;
    z-index: 6;
    pointer-events: none;
    opacity: .65;
}

.gantt-milestone-row-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 2px dashed;
    opacity: 0.35;
    pointer-events: none;
    z-index: 4;
}

.gantt-milestone-diamond {
    position: absolute;
    /* top is set dynamically in JS relative to headerHeight */
    width: 12px;
    height: 12px;
    transform: rotate(45deg);
    z-index: 9;   /* below sticky .gantt-label (10) so it clips behind the label column on scroll */
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,.3);
}

/* Tooltip */
.gantt-tooltip {
    position: fixed;
    z-index: 9999;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,.15);
    pointer-events: none;
    max-width: 260px;
    font-size: .8rem;
    overflow: hidden;
}

.gantt-tooltip-header {
    height: 6px;
}

.gantt-tooltip-body {
    padding: 8px 10px;
    line-height: 1.6;
}

.gantt-tt-icon-row {
    display: flex;
    align-items: center;
    gap: 2px;
}

.gantt-label-link {
    display: block;
    color: inherit;
    text-decoration: none;
}
.gantt-label-link:hover {
    text-decoration: underline;
    color: inherit;
}

/* Drag & drop */
/* Stat tile detail panel */
.stat-card[id] { user-select: none; }
.stat-card.tile-active { box-shadow: 0 0 0 3px rgba(255,255,255,.55) inset, 0 4px 16px rgba(0,0,0,.18) !important; }

#tile-detail-content ul { padding-left: 0; }
#tile-detail-content li { list-style: none; font-size: .84rem; }
#tile-detail-content li:last-child { border-bottom: none !important; }

/* Admin: crosshair on empty timeline space, preserved bar cursors */
.gantt-timeline-create {
    cursor: cell;
}

.gantt-timeline-create .gantt-bar        { cursor: default; }
.gantt-timeline-create .gantt-bar-clickable { cursor: pointer; }
.gantt-timeline-create .gantt-resize-handle { cursor: ew-resize; }

.gantt-resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    width: 8px;
    height: 100%;
    cursor: ew-resize;
    z-index: 2;
}

.gantt-resize-handle-left {
    right: auto;
    left: 0;
}

.gantt-bar-dragging {
    opacity: .7 !important;
    box-shadow: 0 4px 16px rgba(0,0,0,.4) !important;
    z-index: 50 !important;
    transition: none !important;
}

.gantt-bar-saving {
    animation: gantt-pulse .6s ease-in-out infinite alternate;
}

@keyframes gantt-pulse {
    from { opacity: .9; }
    to   { opacity: .45; }
}

body.gantt-cursor-grabbing,
body.gantt-cursor-grabbing * {
    cursor: grabbing !important;
}

body.gantt-cursor-resize,
body.gantt-cursor-resize * {
    cursor: ew-resize !important;
}

/* Toast notifications */
.gantt-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 99999;
    padding: .55rem 1rem;
    border-radius: 6px;
    font-size: .82rem;
    font-weight: 500;
    color: #fff;
    box-shadow: 0 4px 16px rgba(0,0,0,.2);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .2s, transform .2s;
    pointer-events: none;
    max-width: 320px;
}

.gantt-toast.gantt-toast-show {
    opacity: 1;
    transform: translateY(0);
}

.gantt-toast-success { background: #28a745; }
.gantt-toast-error   { background: #dc3545; }

/* Cross-row drag — drop target highlight */
.gantt-row-drop-target {
    background: rgba(0,123,255,0.08) !important;
    outline: 2px solid rgba(0,123,255,0.35);
    outline-offset: -2px;
}

/* Ghost bar for cross-row drag — positioned via JS inline style */
.gantt-bar-ghost {
    border-radius: 3px;
    pointer-events: none;
}

/* Responsive */
@media (max-width: 768px) {
    .gantt-controls {
        flex-wrap: wrap;
    }
    .stat-number {
        font-size: 1.6rem;
    }
    .gantt-label {
        font-size: .75rem;
    }
}
