/*
 * CDFLABS — Admin Console Style (Operational)
 *
 * Implements a rigid, modular, and dense layout inspired by AdminLTE.
 * Focuses on clarity, squared edges, and high-contrast boundaries.
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Source+Code+Pro:wght@400;500&display=swap');

:root {
    --sidebar-width: 250px;
    --header-height: 56px;
    
    /* AdminLTE-like color palette */
    --main-bg: #f4f6f9;
    --sidebar-bg: #E7F1FF;
    --sidebar-surface: rgba(13, 60, 145, 0.06);
    --sidebar-surface-strong: rgba(13, 60, 145, 0.14);
    --sidebar-hover: #35d7ec;
    --sidebar-active: #35d7ec;
    --sidebar-border: rgba(255, 255, 255, 0.18);
    --header-bg: #ffffff;
    --card-bg: #ffffff;
    --card-border: rgba(0,0,0,.125);
    
    --text-main: #212529;
    --text-muted: #6c757d;

    /* Project dashboard top cards */
    --project-top-row-height: 32px;
    --project-top-visible-rows: 10;
    /* Small allowance for table borders/padding so 10 rows are fully visible */
    --project-top-scroll-fudge: 12px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--main-bg);
    color: var(--text-main);
    overflow-x: hidden;
    margin: 0;
}

/* Pipeline log neon palette (diagnostics) */
.pipeline-log {
  color: #56ccff; /* default informational (sky blue) */
}
.log-neon-green {
  color: #39ff14 !important;
}
.log-neon-blue {
  color: #56ccff !important;
}
.log-neon-yellow {
  color: #f9ff00 !important;
}
.log-neon-red {
  color: #ff3131 !important;
}

.help-tooltip-trigger {
    display: inline-flex;
    align-items: center;
    color: #6c757d;
    cursor: help;
    font-size: 0.9rem;
    line-height: 1;
    vertical-align: middle;
}

.help-tooltip-trigger:hover,
.help-tooltip-trigger:focus {
    color: #495057;
}

/* ----------------------------------------------------------------
   Layout Wrapper
   ---------------------------------------------------------------- */

.wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-header {
    height: var(--header-height);
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--card-border);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    padding: 0 1rem;
}

.header-project-context {
    display: flex;
    align-items: center;
    min-width: 0;
    margin-left: calc(var(--sidebar-width) + 15px);
    gap: 30px;
    flex: 1 1 auto;
}

.header-project-title {
    color: #072161;
    font-size: 1.4rem;
    font-weight: 600;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 30ch;
    margin: 0;
}

.header-project-breadcrumbs {
    min-width: 0;
    overflow: hidden;
}

.header-project-breadcrumbs .breadcrumb {
    margin-bottom: 0;
    float: none !important;
    font-size: 0.9rem;
    flex-wrap: nowrap;
    overflow: hidden;
    white-space: nowrap;
    align-items: center;
}

.header-project-breadcrumbs .breadcrumb-item,
.header-project-breadcrumbs .breadcrumb-item a {
    color: #5b6577;
}

.header-project-breadcrumbs .breadcrumb-item.active {
    color: #072161;
}

.main-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    transition: margin-left .3s ease-in-out, width .3s ease-in-out;
    color: #fff;
    overflow-y: auto;
    border-right: 1px solid #072161;
}

.sidebar-overlay {
    position: fixed;
    inset: var(--header-height) 0 0 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .25s ease, visibility .25s ease;
    z-index: 1035;
}

.content-wrapper {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 1.5rem;
    transition: margin-left .3s ease-in-out;
    flex-grow: 1;
}

/* Sidebar Toggle Logic (JS assisted) */
.sidebar-collapse .main-sidebar {
    margin-left: calc(-1 * var(--sidebar-width));
}
.sidebar-collapse .content-wrapper,
.sidebar-collapse .main-header {
    margin-left: 0;
    left: 0;
}

.sidebar-collapse .header-project-context {
    margin-left: 15px;
}

body.sidebar-mobile-open .sidebar-overlay {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ----------------------------------------------------------------
   Sidebar Menu
   ---------------------------------------------------------------- */

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    font-weight: 700;
    font-size: 1.25rem;
    border-bottom: 1px solid var(--sidebar-border);
    text-decoration: none;
    color: #fff !important;
    background: #35d7ec;
}

.nav-sidebar {
    padding: 0 0 1rem;
}

.nav-sidebar .nav-item {
    width: 100%;
}

.nav-sidebar .nav-link {
    color: rgba(9, 34, 87, 0.95) !important;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: 0;
    transition: background 0.2s;
}

.nav-sidebar .nav-link:hover {
    background-color: var(--sidebar-hover);
    color: #05313b !important;
}

.nav-sidebar .nav-link.active {
    background: var(--sidebar-active);
    color: #05313b !important;
    box-shadow: inset 3px 0 0 var(--sidebar-active);
}

/* ----------------------------------------------------------------
   Sidebar Panels (non-nav content)
   ---------------------------------------------------------------- */

.sidebar-panel {
    padding: 0 0.75rem 1rem;
}

.sidebar-panel-title {
    color: rgba(9, 34, 87, 0.72);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.5rem 0.25rem;
    border-top: 1px solid var(--sidebar-border);
}

.sidebar-panel-items {
    border: 1px solid var(--sidebar-border);
    background: var(--sidebar-surface);
    border-radius: 0.85rem;
    overflow: hidden;
}

.sidebar-panel-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.45rem 0.6rem;
    color: rgba(9, 34, 87, 0.92);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.875rem;
}

.sidebar-panel-item:first-child {
    border-top: 0;
}

.sidebar-panel-item i {
    opacity: 0.9;
}

/* ----------------------------------------------------------------
   Sidebar Project List
   ---------------------------------------------------------------- */

.sidebar-projects {
    max-height: 280px; /* ~10 items */
    overflow-y: auto;
    border-left: 2px solid rgba(255, 255, 255, 0.14);
    margin: 0.25rem 0 0.75rem;
    padding: 0.25rem 0;
}

.sidebar-project-entry {
    margin-bottom: 0.18rem;
}

.sidebar-project-link {
    display: block;
    padding: 0.45rem 0.6rem;
    color: rgba(9, 34, 87, 0.95);
    text-decoration: none;
    font-size: 0.875rem;
    line-height: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-project-link:hover {
    background-color: var(--sidebar-hover);
    color: #fff;
}

.sidebar-project-link.active {
    background: var(--sidebar-surface-strong);
    color: #05313b;
    border-left: 3px solid var(--sidebar-active);
    padding-left: calc(0.6rem - 3px);
}

.sidebar-project-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-project-caret {
    font-size: 0.72rem;
    opacity: 0.85;
}

.sidebar-project-quick-links {
    margin: 0.2rem 0 0.45rem 0.65rem;
    padding-left: 0.4rem;
    border-left: 1px dashed rgba(255, 255, 255, 0.22);
}

.sidebar-project-quick-link {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.36rem 0.65rem;
    margin: 0.08rem 0;
    color: rgba(9, 34, 87, 0.86);
    text-decoration: none;
    font-size: 0.82rem;
    border-radius: 0.65rem;
}

.sidebar-project-quick-link:hover {
    background: var(--sidebar-hover);
    color: #05313b;
}

.sidebar-project-quick-link.active {
    background: var(--sidebar-active);
    color: #05313b;
    box-shadow: inset 2px 0 0 #ffffff;
}

.sidebar-project-quick-group {
    margin: 0.08rem 0;
}

.sidebar-project-quick-link-parent {
    margin-bottom: 0.15rem;
}

.sidebar-project-sub-links {
    margin: 0.1rem 0 0.25rem 1.9rem;
    padding-left: 0.65rem;
    border-left: 1px solid rgba(7, 33, 97, 0.18);
}

.sidebar-project-sub-link {
    display: block;
    padding: 0.28rem 0.55rem;
    margin: 0.06rem 0;
    color: rgba(9, 34, 87, 0.78);
    text-decoration: none;
    font-size: 0.78rem;
    border-radius: 0.55rem;
}

.sidebar-project-sub-link:hover {
    background: rgba(53, 215, 236, 0.45);
    color: #05313b;
}

.sidebar-project-sub-link.active {
    background: rgba(53, 215, 236, 0.75);
    color: #05313b;
    font-weight: 600;
}

.system-health-alert {
    animation: system-health-blink 3s steps(1, end) infinite;
}

@keyframes system-health-blink {
    0%, 66% {
        opacity: 1;
        visibility: visible;
    }
    67%, 100% {
        opacity: 0;
        visibility: hidden;
    }
}

/* ----------------------------------------------------------------
   Project Dashboard Top Lists
   ---------------------------------------------------------------- */

.project-top-list td,
.project-top-list th {
    vertical-align: middle;
}

.project-top-list {
    width: 100%;
    table-layout: fixed;
}

.project-top-list tr {
    height: var(--project-top-row-height);
}

.project-top-list td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-top-list a {
    white-space: nowrap;
}

@media (max-width: 991.98px) {
    .main-sidebar {
        top: var(--header-height);
        height: calc(100vh - var(--header-height));
        transform: translateX(-100%);
        margin-left: 0 !important;
        box-shadow: 0 0.5rem 1rem rgba(0,0,0,.25);
    }

    .content-wrapper {
        margin-left: 0;
        padding: 1rem;
    }

    .content-header {
        margin-bottom: 0.75rem !important;
    }

    .sidebar-collapse .main-sidebar {
        transform: translateX(-100%);
    }

    body.sidebar-mobile-open .main-sidebar {
        transform: translateX(0);
    }

    .main-header {
        left: 0 !important;
        margin-left: 0 !important;
        width: 100%;
    }

    .header-project-context {
        max-width: calc(100vw - 170px);
        margin-left: 15px;
        gap: 12px;
    }

    .header-project-title {
        max-width: 100%;
        font-size: 1rem;
        line-height: 1.1;
    }

    .header-project-breadcrumbs {
        display: none;
    }

    .sidebar-projects {
        max-height: 220px;
    }
}

.project-top-list .badge {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
}

/* Scrollable/paginated top lists (Milestones/Requirements) */
.project-top-scroll {
    height: calc((var(--project-top-row-height) * var(--project-top-visible-rows)) + var(--project-top-scroll-fudge));
    overflow-y: auto;
}

/* ----------------------------------------------------------------
   Cards (Rigid Panels)
   ---------------------------------------------------------------- */

.card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 0; /* Squared edges */
    box-shadow: 0 0 1px rgba(0,0,0,.125), 0 1px 3px rgba(0,0,0,.2);
    margin-bottom: 1.5rem;
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--card-border);
    padding: 0.75rem 1.25rem;
    font-weight: 600;
}

.card-title {
    margin-bottom: 0;
    font-size: 1.1rem;
}

.card-body {
    padding: 1.25rem;
}

/* ----------------------------------------------------------------
   Buttons & Inputs
   ---------------------------------------------------------------- */

.btn {
    border-radius: 2px; /* Minimal rounding */
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
}

.form-control, .form-select {
    border-radius: 0;
    border-color: #ced4da;
}

.form-control:focus {
    border-color: #80bdff;
    box-shadow: none;
}

/* ----------------------------------------------------------------
   Tables
   ---------------------------------------------------------------- */

.table {
    font-size: 0.875rem;
}

.table thead th {
    border-top: 0;
    border-bottom: 2px solid #dee2e6;
    background-color: #f8f9fa;
    color: #495057;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

/* ----------------------------------------------------------------
   Document Viewer (Adapting Phase 4)
   ---------------------------------------------------------------- */

.document-container {
    background: #e9ecef;
    border: 1px solid var(--card-border);
    height: calc(100vh - 200px);
    overflow-y: auto;
    padding: 2rem;
}

.document-page {
    background: #fff;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin: 0 auto 2rem;
    padding: 4rem;
    max-width: 900px;
    min-height: 1100px;
}

.clause-item {
    cursor: pointer;
    transition: background-color 0.15s;
    border-bottom: 1px solid transparent;
}

.clause-item:hover {
    background-color: #fff3cd; /* Minimal operational highlight */
}

.clause-active {
    background-color: #ffeeba !important;
    font-weight: 500;
}

.inspector-filter-link:hover {
    text-decoration: underline !important;
}

.ref-link {
    color: #0d6efd;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.ref-link:hover {
    color: #0a58ca;
}

/* Classification colors (operational markers) */
.clause-milestone { border-left: 3px solid #6f42c1; }
.clause-obligation { border-left: 3px solid #fd7e14; }
.clause-payment { border-left: 3px solid #28a745; }
.clause-liability { border-left: 3px solid #dc3545; }

.inspector-sidebar {
    background: #fff;
    border-left: 1px solid var(--card-border);
    height: calc(100vh - var(--header-height));
    position: sticky;
    top: var(--header-height);
    padding: 1.5rem;
}

/* ----------------------------------------------------------------
   Utilities
   ---------------------------------------------------------------- */

.text-sm { font-size: 0.875rem; }
.text-muted { color: var(--text-muted) !important; }

.elevation-1 { box-shadow: 0 1px 3px rgba(0,0,0,.12),0 1px 2px rgba(0,0,0,.24)!important; }
.elevation-2 { box-shadow: 0 3px 6px rgba(0,0,0,.16),0 3px 6px rgba(0,0,0,.23)!important; }

/* Dashboard Cards (Small boxes) */
.small-box {
    border-radius: 0.25rem;
    box-shadow: 0 0 1px rgba(0,0,0,0.125), 0 1px 3px rgba(0,0,0,0.2);
    display: block;
    margin-bottom: 20px;
    position: relative;
    color: #fff;
    padding: 10px 0;
}

.small-box .inner { padding: 10px; }
.small-box h3 { font-size: 2.2rem; font-weight: 700; margin: 0 0 10px 0; white-space: nowrap; padding: 0; }
.small-box p { font-size: 1rem; }
.small-box .icon {
    color: rgba(0,0,0,0.15);
    z-index: 0;
    position: absolute;
    top: -10px;
    right: 15px;
    font-size: 70px;
}
