/* Sidebar layout styles */
html, body { height: 100%; }
body { min-height: 100vh; background-color: #f4f6f9; }
#app { min-height: 100vh; display: flex; }
.sidebar {
  width: 220px;
  min-width: 220px;
  height: 100vh;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #071226 0%, #08182a 100%);
}
.sidebar .nav-link { color: rgba(255,255,255,0.9); }
.sidebar .nav-link:hover { background: rgba(255,255,255,0.03); color: #fff; }
.sidebar .nav { flex: 1; background-color: #212529; }
.sidebar .nav-header { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

@media (max-width: 768px) {
  .sidebar { position: absolute; z-index: 1030; transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
}

/* Desktop: keep sidebar fixed/sticky and spanning full viewport height */
@media (min-width: 769px) {
  /* Keep the sidebar fixed to the left side of the viewport */
  .sidebar { position: fixed; height: 100vh; left: 0; top: 0; z-index: 1000; width: 220px; min-width: 220px; }
  /* Allow the main app element to grow with content */
  #app { height: auto; }
  /* Main content has margin to account for fixed sidebar */
  #app > .flex-grow-1 { margin-left: 220px; flex: 1; }
}

/* Small helpers */

/* small metadata font for dashboard stats */
.meta-size {
  font-size: 0.875rem; /* slightly smaller than .small */
  color: #8998a5;
  font-weight: 600;
}
.theme-terminal-dark .meta-size { color: rgba(180,255,180,0.6) !important; }

/* Compose table */
#compose-table { background-color: #f4f6f9; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 6px rgba(0,0,0,0.06); }
#compose-table thead th { background-color: #f8f9fa !important; color: #343a40 !important; border: none; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

/* Larger service badges in Compose Projects table */
#compose-table td .badge {
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
}
#compose-table td .badge.bg-light { background-color: #ffffff; }

#compose-table .btn { font-size: 0.875rem; font-weight: 500; padding: 0.375rem 0.75rem; }

/* Log / Inspect styles */
/* Allow these containers to expand naturally so the page's main scroll (base layout) controls scrolling
   instead of inner fixed-height panes. */
.log-container, .terminal-container, .stats-container, .inspect-container { background-color: #1e1e1e; border-radius: 8px; overflow: visible; }
.log-header, .terminal-header, .stats-header, .inspect-header { background-color: #2d2d2d; padding: 0.75rem 1rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #3d3d3d; }
.log-content, .terminal-body, .stats-content, .inspect-content { padding: 0.5rem; max-height: 70vh; overflow-y: auto; overflow-x: auto; color: #c7f9c7; font-family: 'Fira Mono', 'Consolas', 'Monaco', 'Courier New', monospace; font-size: 0.95rem; line-height: 1.4; background: #0f1720; }
.log-line, .stats-line { padding: 0.25rem 0.5rem; margin-bottom: 0.25rem; border-radius: 4px; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; display: flex; gap: 0.75rem; align-items: flex-start; }
.log-line:nth-child(even), .stats-line:nth-child(even) { background-color: rgba(255,255,255,0.02); }
.log-line:nth-child(odd), .stats-line:nth-child(odd) { background-color: rgba(255,255,255,0.01); }
.lnum { color: #6c757d; min-width: 3ch; text-align: right; }
.btn-log-control, .btn-stats-control { padding: 0.25rem 0.75rem; font-size: 0.875rem; }

/* JSON viewer */
.json-item { padding-left: 1rem; color: #c7f9c7; font-family: 'Fira Mono', monospace; font-size: 0.9rem; line-height: 1.4; }
.json-toggle { cursor: pointer; color: #c7f9c7; font-weight: bold; margin-right: 0.5rem; }
.json-children { margin-left: 1rem; }
.json-key { color: #74c0fc; }
.json-string { color: #c7f9c7; }
.json-number { color: #ffd166; }
.json-boolean { color: #ff6b6b; }
.json-null { color: #adb5bd; }
.json-string-truncated { cursor: pointer; text-decoration: underline; color: #74c0fc; }
.json-string-full { display: none; }

/* Search highlight for inspect JSON viewer (no layout shift) */
.json-match { background: rgba(255,209,102,0.06); box-shadow: inset 3px 0 0 0 #ffd166; padding-left: 0.5rem; border-radius: 4px; box-sizing: border-box; }
.json-match-active { background: rgba(255,209,102,0.14); box-shadow: inset 5px 0 0 0 #ff9f1c; padding-left: 0.5rem; border-radius: 4px; }

/* Stable search count badge — fixed width so the search bar doesn't shift */
#inspectSearchCount { min-width: 64px; display: inline-block; text-align: center; transition: opacity 0.12s ease; font-variant-numeric: tabular-nums; }
#inspectSearchCount.inspect-count-empty { opacity: 0.45; color: #495057; background-color: rgba(255,255,255,0.03); }

.inspect-nav-btn { padding: 0.22rem 0.45rem; min-width: 36px; display: inline-flex; align-items: center; justify-content: center; }
.inspect-nav-btn:disabled { opacity: 0.5; }

/* Prevent layout shift: wrap long JSON strings and constrain widths inside the viewer */
.inspect-content, .json-item, .json-children { max-width: 100%; box-sizing: border-box; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.json-string-full { display: none; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; max-width: 100%; }

#inspectSearchInput { min-width: 160px; }

/* Terminal specific */
.terminal-container .terminal-header { padding: 0.5rem 1rem; }
.terminal-body { padding: 1rem; max-height: 70vh; min-height: 400px; overflow-y: auto; overflow-x: auto; font-family: 'Consolas', 'Monaco', 'Courier New', monospace; font-size: 0.875rem; line-height: 1.6; }
.terminal-prompt { color: #00ff00; margin-right: 0.5rem; white-space: nowrap; }
.terminal-input { flex: 1; background: transparent; border: none; outline: none; color: #00ff00; font-family: inherit; font-size: inherit; caret-color: #00ff00; }
.terminal-hint { color: #666; font-size: 0.75rem; margin-top: 0.5rem; }

/* Card variants */
.card-header.bg-primary { background-color: #0d6efd !important; }
.card-header.bg-success { background-color: #198754 !important; }

/* Containers list styles */
.wrap-cell { padding-right: 0.5rem; vertical-align: middle; }
.wrap-cell .ellipsis { display: inline-block; max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.btn-cell { text-align: center; white-space: nowrap; }
.status-running { color: #198754; font-weight: 500; }
.status-exited { color: #dc3545; }
.status-paused { color: #ffc107; }
.action-buttons { display: flex; justify-content: flex-start; margin-top: 0; padding: 0.5rem 1rem; border-top: 1px solid rgba(0,0,0,0.04); background: transparent; }
.btn-group-custom { display: flex; gap: 0.25rem; flex-wrap: wrap; }

/* Page header */
.page-header { padding: 0.5rem 0; }
.page-header h3 { font-size: 1.25rem; margin: 0; font-weight: 700; }

/* Header controls: align icons, dropdown and search */
.page-header .input-group { display: flex; align-items: center; gap: 0.5rem; }
.page-header .input-group .input-group-text,
.page-header .input-group .form-control {
  height: 38px;
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
}
.page-header .input-group .form-select {
  /* Don't treat native select as a flex container; keep it native to preserve caret alignment */
  height: 38px;
  padding: 0 0.75rem;
  line-height: 1.2;
  vertical-align: middle;
  align-self: center;
  min-height: 38px;
  box-sizing: border-box;
}
.page-header .input-group .input-group-text { width: 50px; justify-content: center; }
.page-header .input-group .form-control { padding-left: .5rem; }

/* Ensure any unexpected control (buttons, selects, small icons) within the header aligns and matches height */
.page-header > .d-flex.align-items-center > * {
  display: flex;
  align-items: center;
  height: 38px;
}
.page-header > .d-flex.align-items-center > *:not(.input-group) {
  margin-right: 0.5rem;
}
.page-header .btn, .page-header .btn-outline-secondary, .page-header .btn-outline-light {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.5rem;
}
.page-header .input-group-text i, .page-header .btn i { line-height: 1; }


@media (max-width: 992px) { .wrap-cell .ellipsis { max-width: 200px; } }
@media (max-width: 576px) { .wrap-cell .ellipsis { max-width: 120px; } }
.dt-search-wrapper { border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.08); display:flex; align-items:center; gap:0.5rem; }
.dt-search-wrapper .input-group-text { background: #f4f6f9; border-right: 1px solid rgba(0,0,0,0.06); }
#tableSearch { background: #ffffff; border: none; }
#tableSearch::placeholder { color: #8fa6c1; opacity: 1; }
#tableSearch::placeholder { color: #8fa6c1; opacity: 1; }
.dataTables_length { margin-left: 8px; }

/* DataTables length control: normalize select appearance and alignment */
.dataTables_length label { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; }
.dataTables_length select {
  min-width: 72px;
  height: 38px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.08);
  background: #f4f6f9;
  font: inherit;
  -webkit-appearance: menulist-button;
  appearance: menulist-button;
}

/* Inline placement when moved next to search */
.dt-length-inline { display: inline-flex; align-items: center; gap: 6px; }
.dt-length-inline select { margin-right: 6px; }
.dataTables_length select { height: 32px; padding: 4px 8px; border-radius: 6px; border: 1px solid rgba(0,0,0,0.08); }
.dt-length-inline select { margin-right: 6px; }
@media (max-width: 576px) { .dt-search-wrapper { max-width: 180px !important; } .dataTables_length { display: none; } .card-header label { display: none; }
}
.card-header .form-select { min-width: 200px; max-width: 800px; box-sizing: border-box; padding-right: 40px; background-position: right 10px center; background-repeat: no-repeat; }
@media (max-width: 479px) { .card-header .form-select { width: 100%; padding-right: 36px; } }

/* Active link styling */
.sidebar .nav-link.active { background: rgba(255,255,255,0.06); font-weight: 600; }
.sidebar .nav-link.active i { color: #fff; }

/* Visual polish: darker sidebar, subtle card accents */
.nav-link { color: rgba(255,255,255,0.92); }
.navbar.bg-light { background: #f4f6f9 !important; border-bottom: 1px solid rgba(0,0,0,0.04); }

/* Theme-specific navbar overrides */
.theme-terminal-dark .navbar.bg-light { background: #020202 !important; border-bottom: 1px solid rgba(255,255,255,0.03) !important; color: #bfffbf !important; }
.theme-terminal-dark .navbar.bg-light .navbar-page-title, .theme-terminal-dark .navbar.bg-light .navbar-brand, .theme-terminal-dark .navbar.bg-light .nav-link, .theme-terminal-dark .navbar.bg-light .btn, .theme-terminal-dark .navbar.bg-light .input-group-text { color: #bfffbf !important; }
.theme-terminal-dark .navbar.bg-light .form-select, .theme-terminal-dark .navbar.bg-light .form-control { background:#040404 !important; color:#dfffd8 !important; border: 1px solid #333 !important; }
.theme-terminal-dark .navbar.bg-light .alert { background: transparent !important; border: 1px solid rgba(255,255,255,0.03) !important; color: #dfffd8 !important; }
.theme-terminal-dark .navbar.bg-light .btn-outline-secondary { color: #cfcfcf !important; border-color: rgba(255,255,255,0.03) !important; }
.theme-terminal-dark .btn-close { filter: invert(1) grayscale(1) contrast(2) !important; }
.theme-terminal-dark .toast, .theme-terminal-dark .alert { color: #dfffd8 !important; }

.card.shadow-sm { transition: transform 0.15s ease, box-shadow 0.15s ease; }
.card.shadow-sm:hover { box-shadow: 0 8px 20px rgba(2,6,23,0.08); }
.card-header { font-weight: 700; }

/* Small icon size adjustments */
.sidebar .nav-link i { width: 18px; text-align: center; color: #fff !important; }

/* Form validation helpers */
.is-invalid { border-color: #dc3545 !important; box-shadow: 0 0 0 0.075rem rgba(220,53,69,0.25); }
.invalid-feedback { display: block; }

/* Theme: terminal-dark overrides */
.theme-terminal-dark { background: #000 !important; color: #cfcfcf !important; }
.theme-terminal-dark body, .theme-terminal-dark html { background: #000 !important; color: #cfcfcf !important; }
.theme-terminal-dark .container-fluid, .theme-terminal-dark main { background: transparent !important; color: #cfcfcf !important; }

/* Cards */
.theme-terminal-dark .card, .theme-terminal-dark .card-body { background: #070707 !important; color: #dfffd8 !important; border-color: #111 !important; }
.theme-terminal-dark .card-header { background: transparent !important; color: #bfffbf !important; border-bottom: 1px solid #111 !important; }

/* Tables */
.theme-terminal-dark table, .theme-terminal-dark .table { background: transparent !important; color: #bfffbf !important; border-collapse: collapse; }
.theme-terminal-dark .table thead th, .theme-terminal-dark thead.table-light th { background: #020202 !important; color: #9efd9e !important; border-bottom: 1px solid #222 !important; }
.theme-terminal-dark .table thead.table-light { background: #020202 !important; }
.theme-terminal-dark .table tbody td { background: transparent !important; color: #dfffd8 !important; border-top: 1px solid rgba(255,255,255,0.02) !important; }
.theme-terminal-dark .table-striped tbody tr:nth-of-type(odd) { background: rgba(0,255,0,0.02) !important; }
.theme-terminal-dark .table-hover tbody tr:hover { background: rgba(0,255,0,0.04) !important; }

/* DataTables controls */
.theme-terminal-dark .dataTables_wrapper { color: #dfffd8 !important; }
.theme-terminal-dark .dataTables_wrapper .dataTables_filter, .theme-terminal-dark .dataTables_wrapper .dataTables_length { background: transparent !important; }
.theme-terminal-dark .dataTables_wrapper .dataTables_filter input, .theme-terminal-dark .dataTables_wrapper .dataTables_length select, .theme-terminal-dark #tableSearch { background:#020202; color:#bfffbf; border:1px solid #333; }
.theme-terminal-dark .dt-search-wrapper .input-group-text { background: transparent !important; color: #bfffbf !important; border: 1px solid #333 !important; }
.theme-terminal-dark .dt-length-inline .form-select { background:#020202; color:#bfffbf; border:1px solid #333; }
.theme-terminal-dark .dt-length-inline .small { color: rgba(180,255,180,0.75) !important; }
.theme-terminal-dark .dataTables_wrapper .dataTables_paginate .paginate_button { background: transparent; color: #bfffbf; border: 1px solid transparent; }
.theme-terminal-dark .dataTables_wrapper .dataTables_paginate .paginate_button.current { background:#033003; border-color:#066006; color:#001900; box-shadow:0 0 8px rgba(0,255,0,0.08); }

/* Bootstrap pagination (ensure page links are dark and match theme) */
.theme-terminal-dark .pagination .page-link { background: transparent !important; color: #bfffbf !important; border: 1px solid rgba(255,255,255,0.03) !important; }
.theme-terminal-dark .pagination .page-link:hover { background: rgba(0,255,0,0.02) !important; }
.theme-terminal-dark .pagination .page-item.active .page-link { background: #033003 !important; border-color:#066006 !important; color: #001900 !important; box-shadow:0 0 8px rgba(0,255,0,0.08) !important; }
/* DataTables uses both classes; cover both */
.theme-terminal-dark .dataTables_wrapper .paginate_button, .theme-terminal-dark .paginate_button { background: transparent !important; color: #bfffbf !important; border: 1px solid transparent !important; }
.theme-terminal-dark .dataTables_wrapper .paginate_button.current, .theme-terminal-dark .paginate_button.current { background:#033003 !important; border-color:#066006 !important; color:#001900 !important; box-shadow:0 0 8px rgba(0,255,0,0.08) !important; }
.theme-terminal-dark .dataTables_wrapper .dataTables_info { color: #bfffbf !important; }

/* Ensure dropdown label/container hidden original label matches theme */
.theme-terminal-dark .dataTables_length { color: #bfffbf !important; }

/* Buttons and controls */
.theme-terminal-dark .btn { border-color: #133; color: #bfffbf; }
.theme-terminal-dark .btn-primary { background: linear-gradient(180deg,#0a8f0a 0%, #067006 100%) !important; border-color:#066006 !important; color: #001900 !important; }
.theme-terminal-dark .btn-primary:hover { background: linear-gradient(180deg,#0c9f0c 0%, #078007 100%) !important; }
.theme-terminal-dark .btn-outline-secondary { color: #bfffbf !important; border-color: #333 !important; background: transparent !important; }

/* Checkbox accent color */
.theme-terminal-dark input[type="checkbox"] { accent-color: #00ff00 !important; }


/* Navigation */
.theme-terminal-dark .sidebar { background: linear-gradient(180deg, #02040a 0%, #031018 100%); }
.theme-terminal-dark .sidebar .nav-link { color: rgba(180,255,180,0.95) !important; }
.theme-terminal-dark .nav-header, .theme-terminal-dark .sidebar .nav-header { color: rgba(140,255,140,0.75) !important; }
.theme-terminal-dark .nav-link.active { background: rgba(0,255,0,0.06) !important; color: #fff !important; }

.theme-terminal-dark a { color: #9efd9e !important; }
.theme-terminal-dark .badge { background: rgba(0,255,0,0.08) !important; color: #bfffbf !important; }

/* Terminal/log area */
.theme-terminal-dark .terminal-body, .theme-terminal-dark .log-content, .theme-terminal-dark .json-item, .theme-terminal-dark .inspect-content {
  background: #000000 !important;
  color: #00ff00 !important;
}
.theme-terminal-dark .terminal-prompt { color: #00ff00 !important; font-weight: 700; }
.theme-terminal-dark .terminal-input { color: #00ff00 !important; caret-color: #00ff00 !important; }
.theme-terminal-dark .terminal-header, .theme-terminal-dark .log-header { background: #020202 !important; border-bottom: 1px solid #111 !important; }

/* Dashboard & Cards: ensure no white panels and readable text */
.theme-terminal-dark .card.shadow-sm, .theme-terminal-dark .card { background: #070707 !important; border: 1px solid #111 !important; color: #dfffd8 !important; }
.theme-terminal-dark .content-cards .card-body { padding: 1.25rem !important; }
.theme-terminal-dark .content-cards .h2 { color: #9efd9e !important; }
.theme-terminal-dark .text-muted { color: rgba(180,255,180,0.55) !important; }

/* Quick actions buttons */
.theme-terminal-dark .btn-outline-primary { color: #9efd9e !important; border-color: rgba(160,255,160,0.08) !important; background: rgba(0,0,0,0.0) !important; }
.theme-terminal-dark .btn-outline-secondary { color: #cfcfcf !important; border-color: rgba(255,255,255,0.03) !important; }

/* List groups */
.theme-terminal-dark .list-group { background: transparent !important; }
.theme-terminal-dark .list-group-item { background: transparent !important; color: #dfffd8 !important; border: 0; padding: 0.5rem 0; }
.theme-terminal-dark .list-group-item .small { color: rgba(160,255,160,0.6) !important; }

/* Make sure badges with light/yellow backgrounds also look good */
.theme-terminal-dark .badge.bg-warning { background-color: rgba(255,200,0,0.06) !important; color: #ffd56b !important; }
.theme-terminal-dark .badge.bg-light { background-color: rgba(255,255,255,0.02) !important; color: #cfcfcf !important; }

/* Improve table contrast */
.theme-terminal-dark .table { color: #dfffd8 !important; }
.theme-terminal-dark .table thead th { background: #020202 !important; color: #9efd9e !important; }
.theme-terminal-dark .table tbody td { background: transparent !important; color: #dfffd8 !important; }

/* xterm.js overrides for better contrast */
.theme-terminal-dark .xterm, .theme-terminal-dark .xterm-viewport { background: #000 !important; color: #00ff00 !important; }
.theme-terminal-dark .xterm .xterm-viewport { background: #000 !important; }

/* About page specific adjustments */
.theme-terminal-dark .p-3.bg-light { background: #0b0b0b !important; color: #dfffd8 !important; border: 1px solid #111 !important; }
.theme-terminal-dark .p-3.bg-light h6, .theme-terminal-dark .p-3.bg-light .fw-semibold { color: #bfffbf !important; }
.theme-terminal-dark .lead.text-muted { color: rgba(180,255,180,0.85) !important; }
.theme-terminal-dark .card-footer.bg-light { background: #020202 !important; border-top: 1px solid #111 !important; color: #dfffd8 !important; }
.theme-terminal-dark .btn-dark { background: linear-gradient(180deg,#0a8f0a 0%, #067006 100%) !important; color: #001900 !important; border-color:#066006 !important; }
.theme-terminal-dark .p-3.bg-light .fa-solid { color: #9efd9e !important; }

/* Generic override to ensure any .bg-light in theme becomes dark */
.theme-terminal-dark .bg-light { background: #020202 !important; color: #dfffd8 !important; border-color: #111 !important; }




