﻿/* =========================================================
   CLICKABLE DASHBOARD ROW
   ========================================================= */

.trace-table-row {
    transition: background-color .18s ease;
}

    .trace-table-row:hover {
        background: #f8fafc;
    }

.trace-kavling-button,
.trace-status-button,
.trace-progress-button,
.trace-percentage-button {
    border: 0;
    background: transparent;
    font: inherit;
}

.trace-kavling-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 4px 6px;
    color: #0f172a;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
}

    .trace-kavling-button:hover {
        background: #eff6ff;
        color: #2563eb;
    }

    .trace-kavling-button span:last-child {
        display: flex;
        flex-direction: column;
        gap: 1px;
    }

    .trace-kavling-button strong {
        font-size: 14px;
        font-weight: 700;
    }

    .trace-kavling-button small {
        color: #64748b;
        font-size: 11px;
        font-weight: 500;
    }

.trace-home-icon {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 9px;
    background: #eff6ff;
    color: #2563eb;
}

.trace-status-button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px;
    cursor: pointer;
    border-radius: 8px;
}

    .trace-status-button > i {
        color: #94a3b8;
        font-size: 11px;
        transition: transform .18s ease;
    }

    .trace-status-button:hover > i {
        color: #2563eb;
        transform: translateX(2px);
    }

.trace-progress-button {
    display: block;
    width: 100%;
    min-width: 210px;
    padding: 6px 4px;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
}

    .trace-progress-button:hover {
        background: #f1f5f9;
    }

.trace-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
    font-size: 11px;
    color: #64748b;
}

    .trace-progress-header strong {
        color: #0f172a;
        font-size: 12px;
    }

.trace-progress-track {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}

.trace-percentage-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 78px;
    padding: 7px 10px;
    border-radius: 8px;
    color: #2563eb;
    font-weight: 700;
    cursor: pointer;
}

    .trace-percentage-button:hover {
        background: #eff6ff;
    }

/* =========================================================
   MODAL
   ========================================================= */

.trace-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10550;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, .58);
    backdrop-filter: blur(3px);
}

.trace-modal {
    width: min(1100px, 100%);
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f8fafc;
    border-radius: 18px;
    box-shadow: 0 30px 80px rgba(15, 23, 42, .3);
    animation: traceModalIn .2s ease;
}

@keyframes traceModalIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(.985);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.trace-modal-header {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 22px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}

.trace-modal-heading {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 0;
}

.trace-modal-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 12px;
    background: #eff6ff;
    color: #2563eb;
    font-size: 18px;
}

.trace-modal-heading h4 {
    margin: 0 0 3px;
    color: #0f172a;
    font-size: 18px;
    font-weight: 750;
}

.trace-modal-heading p {
    margin: 0;
    color: #64748b;
    font-size: 12px;
}

    .trace-modal-heading p strong {
        color: #334155;
    }

.trace-modal-close {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: 0;
    border-radius: 10px;
    background: #f1f5f9;
    color: #64748b;
    cursor: pointer;
    transition: .18s ease;
}

    .trace-modal-close:hover {
        background: #fee2e2;
        color: #dc2626;
    }

.trace-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.trace-modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 13px 20px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
}

.trace-close-button {
    min-width: 100px;
    height: 38px;
    padding: 0 18px;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: #fff;
    color: #334155;
    font-weight: 650;
    cursor: pointer;
}

    .trace-close-button:hover {
        background: #f8fafc;
        border-color: #94a3b8;
    }

/* =========================================================
   LOADING
   ========================================================= */

.trace-loading {
    min-height: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: #334155;
}

    .trace-loading span {
        color: #94a3b8;
        font-size: 12px;
    }

.trace-spinner {
    width: 40px;
    height: 40px;
    margin-bottom: 8px;
    border: 4px solid #dbeafe;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: traceSpin .75s linear infinite;
}

@keyframes traceSpin {
    to {
        transform: rotate(360deg);
    }
}

/* =========================================================
   SUMMARY
   ========================================================= */

.trace-summary-section {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.trace-summary-main,
.trace-summary-card,
.trace-current-information,
.trace-content-section {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
}

.trace-summary-main {
    padding: 20px;
}

.trace-summary-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 16px;
}

.trace-section-label {
    display: block;
    margin-bottom: 4px;
    color: #64748b;
    font-size: 11px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.trace-summary-top h3 {
    margin: 0;
    color: #0f172a;
    font-size: 23px;
    font-weight: 800;
}

.trace-total-percentage {
    color: #2563eb;
    font-size: 27px;
    font-weight: 800;
}

.trace-main-progress {
    height: 13px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}

.trace-main-progress-bar {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #3b82f6, #2563eb);
    transition: width .4s ease;
}

.trace-progress-caption {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-top: 10px;
    color: #64748b;
    font-size: 11px;
}

    .trace-progress-caption i {
        margin-right: 4px;
        color: #2563eb;
    }

.trace-summary-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
}

.trace-summary-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 15px;
}

.trace-card-icon {
    width: 39px;
    height: 39px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 10px;
}

    .trace-card-icon.success {
        background: #dcfce7;
        color: #16a34a;
    }

    .trace-card-icon.warning {
        background: #fef3c7;
        color: #d97706;
    }

    .trace-card-icon.muted {
        background: #f1f5f9;
        color: #64748b;
    }

.trace-summary-card > div:last-child {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    width: 100%;
    column-gap: 10px;
}

.trace-summary-card span {
    color: #475569;
    font-size: 12px;
    font-weight: 650;
}

.trace-summary-card strong {
    grid-row: span 2;
    color: #0f172a;
    font-size: 21px;
}

.trace-summary-card small {
    color: #94a3b8;
    font-size: 10px;
}

/* =========================================================
   CURRENT INFORMATION
   ========================================================= */

.trace-current-information {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 14px;
    margin-bottom: 16px;
}

.trace-info-item {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    min-width: 0;
    padding: 12px;
    border-radius: 11px;
    background: #f8fafc;
}

    .trace-info-item.constraint {
        background: #fff7ed;
    }

.trace-info-icon {
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 9px;
}

    .trace-info-icon.current {
        background: #dbeafe;
        color: #2563eb;
    }

    .trace-info-icon.danger {
        background: #ffedd5;
        color: #ea580c;
    }

.trace-info-item > div:last-child {
    min-width: 0;
}

.trace-info-item span {
    display: block;
    margin-bottom: 3px;
    color: #64748b;
    font-size: 10px;
    font-weight: 650;
    text-transform: uppercase;
}

.trace-info-item strong {
    display: block;
    color: #1e293b;
    font-size: 12px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

/* =========================================================
   TIMELINE CONTENT
   ========================================================= */

.trace-content-section {
    padding: 18px;
}

.trace-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 15px;
    margin-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
}

    .trace-section-header h5 {
        margin: 0 0 3px;
        color: #0f172a;
        font-size: 15px;
        font-weight: 750;
    }

        .trace-section-header h5 i {
            margin-right: 7px;
            color: #2563eb;
        }

    .trace-section-header p {
        margin: 0;
        color: #64748b;
        font-size: 11px;
    }

.trace-record-count {
    flex-shrink: 0;
    padding: 6px 10px;
    border-radius: 999px;
    background: #eff6ff;
    color: #2563eb;
    font-size: 11px;
    font-weight: 700;
}

.trace-timeline {
    width: 100%;
}

.trace-timeline-item {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 13px;
}

.trace-timeline-marker-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.trace-timeline-marker {
    position: relative;
    z-index: 2;
    width: 31px;
    height: 31px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px #e2e8f0;
    font-size: 10px;
}

    .trace-timeline-marker.completed {
        background: #22c55e;
        color: #fff;
    }

    .trace-timeline-marker.active {
        background: #f59e0b;
        color: #fff;
    }

    .trace-timeline-marker.pending {
        background: #e2e8f0;
        color: #64748b;
    }

.trace-timeline-line {
    width: 2px;
    flex: 1;
    min-height: 24px;
    background: #e2e8f0;
}

    .trace-timeline-line.completed {
        background: #86efac;
    }

.trace-work-card {
    min-width: 0;
    padding: 15px;
    margin-bottom: 14px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    transition: border-color .18s ease, box-shadow .18s ease;
}

    .trace-work-card:hover {
        border-color: #bfdbfe;
        box-shadow: 0 8px 22px rgba(15, 23, 42, .06);
    }

.trace-work-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 13px;
}

.trace-work-title {
    min-width: 0;
}

.trace-work-code {
    display: inline-block;
    margin-bottom: 4px;
    color: #2563eb;
    font-size: 10px;
    font-weight: 750;
    text-transform: uppercase;
}

.trace-work-title h6 {
    margin: 0;
    color: #0f172a;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.45;
}

.trace-work-status {
    flex-shrink: 0;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
}

    .trace-work-status.completed {
        background: #dcfce7;
        color: #15803d;
    }

    .trace-work-status.active {
        background: #fef3c7;
        color: #b45309;
    }

    .trace-work-status.pending {
        background: #f1f5f9;
        color: #64748b;
    }

.trace-work-progress-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 52px;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.trace-work-progress {
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}

.trace-work-progress-bar {
    height: 100%;
    border-radius: inherit;
    background: #3b82f6;
}

.trace-work-progress-row strong {
    color: #334155;
    font-size: 11px;
    text-align: right;
}

.trace-work-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

.trace-metric {
    min-width: 0;
    padding: 10px 12px;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
}

    .trace-metric:last-child {
        border-right: 0;
    }

    .trace-metric span {
        display: block;
        margin-bottom: 4px;
        color: #94a3b8;
        font-size: 9px;
        font-weight: 650;
        text-transform: uppercase;
    }

    .trace-metric strong {
        display: block;
        color: #334155;
        font-size: 11px;
        line-height: 1.45;
        overflow-wrap: anywhere;
    }

.trace-work-notes {
    display: grid;
    gap: 8px;
    margin-top: 11px;
}

.trace-note {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 9px 11px;
    border-radius: 9px;
    background: #eff6ff;
    color: #1d4ed8;
}

    .trace-note.constraint {
        background: #fff7ed;
        color: #c2410c;
    }

    .trace-note > i {
        margin-top: 3px;
        flex-shrink: 0;
    }

    .trace-note span {
        display: block;
        margin-bottom: 2px;
        font-size: 10px;
        font-weight: 750;
    }

    .trace-note p {
        margin: 0;
        color: #475569;
        font-size: 11px;
        line-height: 1.5;
    }

.trace-work-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding-top: 11px;
    margin-top: 12px;
    border-top: 1px dashed #e2e8f0;
}

.trace-update-information {
    display: flex;
    flex-wrap: wrap;
    gap: 13px;
    color: #64748b;
    font-size: 10px;
}

    .trace-update-information i {
        margin-right: 4px;
        color: #94a3b8;
    }

.trace-photo-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 31px;
    padding: 0 11px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
    color: #2563eb;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
}

    .trace-photo-button:hover {
        background: #dbeafe;
    }

/* =========================================================
   EMPTY
   ========================================================= */

.trace-empty {
    min-height: 250px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    text-align: center;
}

.trace-empty-icon {
    width: 55px;
    height: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 11px;
    border-radius: 15px;
    background: #f1f5f9;
    color: #94a3b8;
    font-size: 20px;
}

.trace-empty h5 {
    margin: 0 0 5px;
    color: #334155;
    font-size: 14px;
}

.trace-empty p {
    max-width: 360px;
    margin: 0;
    color: #94a3b8;
    font-size: 11px;
    line-height: 1.55;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 900px) {
    .trace-modal-backdrop {
        padding: 12px;
    }

    .trace-modal {
        max-height: calc(100vh - 24px);
        border-radius: 14px;
    }

    .trace-summary-section {
        grid-template-columns: 1fr;
    }

    .trace-summary-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .trace-summary-card {
        align-items: flex-start;
        padding: 12px;
    }

        .trace-summary-card > div:last-child {
            display: block;
        }

        .trace-summary-card strong {
            display: block;
            margin: 2px 0;
        }

    .trace-current-information {
        grid-template-columns: 1fr;
    }

    .trace-work-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .trace-metric:nth-child(2) {
        border-right: 0;
    }

    .trace-metric:nth-child(-n+2) {
        border-bottom: 1px solid #e2e8f0;
    }
}

@media (max-width: 600px) {
    .trace-modal-backdrop {
        align-items: flex-end;
        padding: 0;
    }

    .trace-modal {
        width: 100%;
        max-height: 94vh;
        border-radius: 18px 18px 0 0;
    }

    .trace-modal-header {
        min-height: 66px;
        padding: 13px 15px;
    }

    .trace-modal-icon {
        width: 38px;
        height: 38px;
        border-radius: 10px;
    }

    .trace-modal-heading h4 {
        font-size: 15px;
    }

    .trace-modal-heading p {
        font-size: 10px;
    }

    .trace-modal-body {
        padding: 12px;
    }

    .trace-summary-main {
        padding: 15px;
    }

    .trace-summary-grid {
        grid-template-columns: 1fr;
    }

    .trace-summary-card {
        align-items: center;
    }

        .trace-summary-card > div:last-child {
            display: grid;
        }

    .trace-summary-top h3 {
        font-size: 19px;
    }

    .trace-total-percentage {
        font-size: 22px;
    }

    .trace-progress-caption {
        flex-direction: column;
        gap: 4px;
    }

    .trace-content-section {
        padding: 13px;
    }

    .trace-section-header {
        align-items: center;
    }

        .trace-section-header p {
            display: none;
        }

    .trace-timeline-item {
        grid-template-columns: 29px minmax(0, 1fr);
        gap: 8px;
    }

    .trace-timeline-marker {
        width: 27px;
        height: 27px;
    }

    .trace-work-card {
        padding: 12px;
    }

    .trace-work-header {
        flex-direction: column;
        gap: 7px;
    }

    .trace-work-status {
        align-self: flex-start;
    }

    .trace-work-metrics {
        grid-template-columns: 1fr;
    }

    .trace-metric {
        border-right: 0;
        border-bottom: 1px solid #e2e8f0;
    }

        .trace-metric:last-child {
            border-bottom: 0;
        }

    .trace-work-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .trace-photo-button {
        width: 100%;
        justify-content: center;
    }

    .trace-close-button {
        width: 100%;
    }
}
