/* ============================================================================
 * CTP Oceanic Slot Management - Styles
 * Split-pane layout: Map (top) / Table (bottom) with resize handle
 * ============================================================================ */

/* -- Navbar Override (solid dark, matching NOD pattern) -------------------- */
.cs-header.navbar-floating {
    background: rgba(26, 26, 46, 0.98) !important;
    border-bottom: 1px solid #333;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
}

.cs-header.navbar-floating .nav-link {
    color: rgba(255,255,255,0.8) !important;
}

.cs-header.navbar-floating .nav-link:hover {
    color: #fff !important;
}

/* -- Container ------------------------------------------------------------ */
.ctp-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding-top: var(--navbar-height, 76px);
    overflow: hidden;
}

/* Hide footer on full-screen app layout */
.ctp-container ~ footer.cs-footer {
    display: none !important;
}

/* -- Top Bar -------------------------------------------------------------- */
.ctp-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 4px 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    min-height: 38px;
    gap: 4px;
    flex-shrink: 0;
}

.ctp-session-selector select {
    min-width: 200px;
    font-size: 0.82rem;
}

/* Action buttons: compact sizing */
#ctp_session_actions .btn {
    font-size: 0.72rem;
    padding: 2px 8px;
}

.ctp-status-badge {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ctp-direction-badge {
    font-size: 0.7rem;
    text-transform: uppercase;
}

/* -- Stats Bar ------------------------------------------------------------ */
.ctp-stats-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.8rem;
}

.ctp-stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #495057;
}

.ctp-stat i {
    font-size: 0.75rem;
    opacity: 0.7;
}

.ctp-stat-value {
    font-weight: 700;
}

.ctp-stat-slotted .ctp-stat-value { color: #28a745; }
.ctp-stat-modified .ctp-stat-value { color: #007bff; }
.ctp-stat-excluded .ctp-stat-value { color: #dc3545; }

/* -- Map Section ---------------------------------------------------------- */
.ctp-map-section {
    position: relative;
    flex: 0 0 35%;
    min-height: 80px;
}

.ctp-map {
    width: 100%;
    height: 100%;
}

.ctp-map-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #1a1a2e;
    z-index: 1;
}

.ctp-map .maplibregl-popup-content {
    background: rgba(30, 30, 50, 0.95);
    color: #e0e0e0;
    font-size: 0.78rem;
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid rgba(0, 188, 212, 0.3);
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.ctp-map .maplibregl-popup-tip {
    border-top-color: rgba(30, 30, 50, 0.95);
}

.ctp-map .maplibregl-ctrl-group {
    background: rgba(30, 30, 50, 0.85);
    border: 1px solid rgba(255,255,255,0.1);
}

.ctp-map .maplibregl-ctrl-group button {
    filter: invert(0.85);
}

/* -- Resize Handle -------------------------------------------------------- */
.ctp-resize-handle {
    flex: 0 0 6px;
    background: #dee2e6;
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    z-index: 10;
}

.ctp-resize-handle i {
    font-size: 0.6rem;
    color: #6c757d;
}

.ctp-resize-handle:hover {
    background: #ced4da;
}

/* -- Table Section -------------------------------------------------------- */
.ctp-table-section {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 100px;
}

/* -- Filter Bar ----------------------------------------------------------- */
.ctp-filter-bar {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    flex-shrink: 0;
}

.ctp-search-group {
    max-width: 360px;
}

.ctp-filter-dropdown {
    min-width: 280px;
}

.ctp-filter-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 12px;
}

.ctp-filter-check {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    margin-bottom: 0;
    cursor: pointer;
    white-space: nowrap;
}

.ctp-filter-check input {
    margin: 0;
}

/* -- Perspective Tabs ----------------------------------------------------- */
#ctp_perspective_tabs .btn {
    font-size: 0.75rem;
    padding: 2px 10px;
}

#ctp_perspective_tabs .btn.active {
    font-weight: 600;
}

/* -- Flight Table --------------------------------------------------------- */
.ctp-table-wrapper {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: auto;
}

.ctp-flight-table {
    font-size: 0.8rem;
    margin-bottom: 0;
    table-layout: fixed;
    width: 100%;
}

.ctp-flight-table thead th {
    position: sticky;
    top: 0;
    background: #f8f9fa;
    z-index: 5;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    padding: 4px 6px;
    white-space: nowrap;
}

.ctp-flight-table tbody td {
    padding: 3px 6px;
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ctp-flight-table tbody tr {
    cursor: pointer;
}

.ctp-flight-table tbody tr:hover {
    background-color: rgba(0, 123, 255, 0.06);
}

.ctp-flight-table tbody tr.ctp-row-selected {
    background-color: rgba(0, 123, 255, 0.12);
}

.ctp-flight-table tbody tr.ctp-row-excluded {
    opacity: 0.4;
}

.ctp-flight-table tbody tr.ctp-row-priority {
    border-left: 3px solid #ffc107;
}

/* Column widths */
.ctp-col-check { width: 30px; text-align: center; }
.ctp-col-cs    { width: 80px; }
.ctp-col-apt   { width: 52px; text-align: center; }
.ctp-col-type  { width: 52px; text-align: center; }
.ctp-col-fix   { width: 70px; }
.ctp-col-time  { width: 60px; text-align: center; }
.ctp-col-seg   { width: 36px; text-align: center; }
.ctp-col-status { width: 72px; }

/* Sortable columns */
.ctp-sortable {
    cursor: pointer;
    user-select: none;
}

.ctp-sortable:hover {
    color: #007bff;
}

.ctp-sortable::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 4px;
    vertical-align: middle;
}

.ctp-sortable.sort-asc::after {
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 4px solid #495057;
}

.ctp-sortable.sort-desc::after {
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid #495057;
}

/* -- Segment Status Indicators -------------------------------------------- */
.ctp-seg-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid #ccc;
}

.ctp-seg-dot.seg-filed     { background: #adb5bd; border-color: #868e96; }
.ctp-seg-dot.seg-modified  { background: #007bff; border-color: #0056b3; }
.ctp-seg-dot.seg-validated { background: #28a745; border-color: #1e7e34; }

/* -- Status Badges -------------------------------------------------------- */
.ctp-badge {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
}

.badge-filed       { background: #e9ecef; color: #495057; }
.badge-modified    { background: #cce5ff; color: #004085; }
.badge-validated   { background: #d4edda; color: #155724; }
.badge-rejected    { background: #f8d7da; color: #721c24; }
.badge-assigned    { background: #d1ecf1; color: #0c5460; }
.badge-delivered   { background: #c3e6cb; color: #155724; }
.badge-compliant   { background: #28a745; color: #fff; }
.badge-non-compliant { background: #dc3545; color: #fff; }
.badge-late        { background: #dc3545; color: #fff; }
.badge-early       { background: #ffc107; color: #212529; }
.badge-none        { background: #6c757d; color: #fff; }
.badge-no-show     { background: #6c757d; color: #fff; }

/* Status badge colors for session status */
.badge-status-draft      { background: #e2e3e5; color: #383d41; }
.badge-status-active     { background: #28a745; color: #fff; }
.badge-status-monitoring { background: #17a2b8; color: #fff; }
.badge-status-completed  { background: #6c757d; color: #fff; }
.badge-status-cancelled  { background: #dc3545; color: #fff; }

/* -- Pagination ----------------------------------------------------------- */
.ctp-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-top: 1px solid #e9ecef;
    flex-shrink: 0;
    background: #f8f9fa;
}

.ctp-page-label {
    font-size: 0.8rem;
    color: #495057;
}

/* -- Expandable Row ------------------------------------------------------- */
.ctp-expand-row td {
    padding: 8px 12px;
    background: #f8f9fa;
    border-top: none;
}

.ctp-expand-content {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    font-size: 0.78rem;
}

.ctp-expand-section h6 {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    color: #6c757d;
    margin-bottom: 4px;
}

.ctp-expand-field {
    display: flex;
    justify-content: space-between;
    padding: 1px 0;
}

.ctp-expand-field .field-label {
    color: #6c757d;
}

.ctp-expand-field .field-value {
    font-weight: 600;
    font-family: 'Inconsolata', monospace;
}

/* -- Route Suggestions ---------------------------------------------------- */
.ctp-route-suggestions {
    max-height: 240px;
    overflow-y: auto;
}

.ctp-suggestion-card {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 6px 8px;
    margin-bottom: 4px;
    background: #f8f9fa;
    cursor: pointer;
    transition: border-color 0.15s;
}

.ctp-suggestion-card:hover {
    border-color: #007bff;
    background: #eef5ff;
}

.ctp-suggestion-route {
    font-family: 'Inconsolata', monospace;
    font-size: 0.72rem;
    color: #495057;
    word-break: break-all;
    line-height: 1.3;
    max-height: 36px;
    overflow: hidden;
}

.ctp-suggestion-card .btn-sm {
    font-size: 0.65rem;
    padding: 1px 6px;
}

/* -- Route Editor Tabs ---------------------------------------------------- */
#ctp_route_tabs .nav-link {
    font-size: 0.78rem;
    padding: 4px 12px;
}

#ctp_route_tabs .nav-link.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* -- Sidebar (Phase 2+) -------------------------------------------------- */
.ctp-sidebar {
    position: fixed;
    right: 0;
    top: var(--navbar-height, 76px);
    bottom: 0;
    width: 420px;
    background: #fff;
    box-shadow: -2px 0 8px rgba(0,0,0,0.1);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ctp-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
}

.ctp-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

/* -- Map Collapse Toggle -------------------------------------------------- */
.ctp-map-toggle {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    background: rgba(30, 30, 50, 0.7);
    color: rgba(255,255,255,0.7);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 3px;
    padding: 1px 10px;
    font-size: 0.65rem;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.ctp-map-toggle:hover {
    opacity: 1;
    color: #fff;
    background: rgba(30, 30, 50, 0.9);
}

.ctp-map-section.ctp-map-collapsed {
    flex: 0 0 auto !important;
    min-height: 0 !important;
    overflow: visible;
}

.ctp-map-section.ctp-map-collapsed .ctp-map,
.ctp-map-section.ctp-map-collapsed .ctp-map-placeholder {
    display: none;
}

.ctp-map-section.ctp-map-collapsed .ctp-map-toggle {
    position: static;
    transform: none;
    display: block;
    width: 100%;
    border-radius: 0;
    padding: 2px 10px;
    opacity: 1;
    background: #e9ecef;
    color: #495057;
    border: none;
    border-bottom: 1px solid #dee2e6;
    font-size: 0.72rem;
}

.ctp-map-section.ctp-map-collapsed + .ctp-resize-handle {
    display: none;
}

/* -- Bottom Tabs Resize Handle -------------------------------------------- */
.ctp-bottom-resize-handle {
    flex: 0 0 5px;
    background: #dee2e6;
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    z-index: 10;
    border-top: 1px solid #ced4da;
}

.ctp-bottom-resize-handle:hover {
    background: #ced4da;
}

/* -- Bottom Tabs (own flex area outside table section) -------------------- */
.ctp-bottom-tabs {
    flex: 0 1 auto;
    border-top: 2px solid #dee2e6;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    min-height: 34px;
    max-height: 75vh;
    overflow: hidden;
}

.ctp-bottom-tabs-header {
    display: flex;
    align-items: center;
    background: #f0f1f3;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
}

.ctp-bottom-tabs-header .nav-tabs {
    font-size: 0.78rem;
    border-bottom: none;
    flex: 1;
}

.ctp-bottom-tabs-header .nav-link {
    padding: 4px 12px;
    font-size: 0.78rem;
}

.ctp-panel-toggle {
    padding: 2px 8px;
    color: #6c757d;
    flex-shrink: 0;
}

.ctp-panel-toggle:hover {
    color: #212529;
}

.ctp-bottom-tabs-body {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
}

.ctp-bottom-tabs.ctp-panel-collapsed .ctp-bottom-tabs-body {
    display: none;
}

.ctp-bottom-tabs.ctp-panel-collapsed {
    max-height: none;
}

/* -- Demand Chart --------------------------------------------------------- */
.ctp-demand-chart-wrapper {
    padding: 4px 12px 8px;
    min-height: 180px;
}

/* -- Audit Entries -------------------------------------------------------- */
.ctp-audit-entry {
    padding: 2px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    line-height: 1.4;
}
.ctp-audit-entry .badge-sm {
    font-size: 0.65rem;
    padding: 1px 4px;
}

/* -- Compliance Badge ----------------------------------------------------- */
#ctp_compliance_badge {
    font-size: 0.75rem;
    vertical-align: middle;
}

/* -- Utility -------------------------------------------------------------- */
.gap-2 { gap: 8px; }

/* -- Responsive ----------------------------------------------------------- */
@media (max-width: 768px) {
    .ctp-container {
        height: auto;
        min-height: 100vh;
    }

    .ctp-map-section {
        flex: 0 0 250px;
    }

    .ctp-table-section {
        min-height: 400px;
    }

    .ctp-stats-bar {
        flex-wrap: wrap;
        gap: 8px;
    }

    .ctp-expand-content {
        grid-template-columns: 1fr;
    }

    .ctp-sidebar {
        width: 100%;
    }
}
