/* Custom styles for Arcade Inventory UI */
body {
    background-color: #f8f9fa;
}

/* Utility: prevent letter-stacking for selected columns */
.tabulator .tabulator-row .tabulator-cell.nowrap {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* User profile dropdown styles */
.dropdown-menu {
    min-width: 250px;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    border: none;
    padding: 0.5rem 0;
}

.dropdown .avatar-wrapper {
    display: flex;
    align-items: center;
}

.dropdown-item:active, .dropdown-item:focus {
    background-color: #f8f9fa;
    color: #212529;
}

.dropdown-item:hover {
    background-color: #e9ecef;
}

/* Ensure navbar dropdown renders above cards/content */
.navbar .dropdown-menu {
  z-index: 2000;
}
/* Ensure right-aligned navbar dropdowns are actually right-aligned with Popper */
.navbar .dropdown-menu.dropdown-menu-end[data-bs-popper] {
  left: auto;
  right: 0;
}

.page {
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.navbar-brand {
    font-weight: bold;
}

.card {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    border: none;
    border-radius: 6px;
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
    padding: 0.75rem 1.25rem;
}

.card-header h4 {
    margin-bottom: 0;
}

#dashboard-summary .card {
    transition: transform 0.2s;
}

#dashboard-summary .card:hover {
    transform: translateY(-5px);
}

table.dataTable {
    width: 100% !important;
}

.dataTables_wrapper .dataTables_filter {
    margin-bottom: 1rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: #0d6efd;
    color: white !important;
    border-color: #0d6efd;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #0b5ed7;
    color: white !important;
    border-color: #0b5ed7;
}

/* ------------------ Tabulator Mobile Readability ------------------ */
/* Allow wrapping in Tabulator cells only on small screens,
   so collapsed "card" view shows readable multi-line values. */
@media (max-width: 576px) {
  /* Standard cells */
  .tabulator .tabulator-row .tabulator-cell {
    white-space: normal !important;
    text-overflow: initial !important;
    overflow: visible !important;
    word-break: break-word;
    line-height: 1.2rem;
  }

  /* Collapsed details container */
  .tabulator .tabulator-responsive-collapse {
    white-space: normal;
  }

  /* Labels in responsive collapse appear bold; ensure spacing */
  .tabulator .tabulator-responsive-collapse > div {
    padding: 0.25rem 0;
    border-bottom: 1px solid #f1f3f5;
  }

  .tabulator .tabulator-responsive-collapse > div:last-child {
    border-bottom: none;
  }
}

/* -------------- Tabulator Control Column Buttons -------------- */
/* Allow wrapping and proper layout so control buttons never get cut off */
.tabulator .tabulator-cell.control-cell {
  white-space: normal !important; /* override Tabulator's nowrap */
}
.tabulator .tabulator-cell.control-cell .control-btns {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem; /* consistent spacing between buttons when wrapped */
}
.tabulator .tabulator-cell.control-cell .control-btns .btn {
  margin: 0 0.25rem 0.25rem 0; /* small margins aid wrapping aesthetics */
}

/* Compact button style for dense control areas (mobile only) */
@media (max-width: 576px) {
  .btn-compact {
    padding: 0.125rem 0.35rem;
    line-height: 1.1;
    font-size: 0.75rem;
  }
  .btn-compact i {
    font-size: 0.9em;
  }
}

/* Slightly taller rows to accommodate two-line controls without overlap */
.tabulator .tabulator-row {
  min-height: 42px; /* default is ~33px; this gives a little extra breathing room */
}

/* (status pills removed; using Bootstrap badges in JS formatter) */

/* ------------------ Navbar user menu mobile tweaks ------------------ */
@media (max-width: 576px) {
  /* Hide long user name to avoid pushing layout; keep avatar icon */
  .navbar .navbar-text { display: none !important; }
  .navbar .fa-caret-down { display: none !important; }
  /* Constrain dropdown width to viewport; let Bootstrap/Popper position it */
  .navbar .dropdown-menu { max-width: calc(100vw - 1rem); }
  /* Move user avatar to the right side inside collapsed navbar */
  .navbar .ms-auto.d-flex.align-items-center { width: 100%; justify-content: flex-end; }
}

/* ------------------ GenericTable header mobile layout ------------------ */
/* Make header controls wrap and become icon-only on small screens */
@media (max-width: 576px) {
  .generic-table .table-header { flex-wrap: wrap; gap: 0.25rem; }
  .generic-table .table-header h4 { font-size: 1rem; margin-bottom: 0.25rem !important; }
  .generic-table .table-header .badge { display: none; }
  .generic-table .table-header .d-flex.align-items-center { flex-wrap: wrap; gap: 0.25rem; }
  /* Hide text labels inside buttons but keep icon and numeric badges */
  .generic-table .table-header .btn > span:not(.badge) { display: none; }
  .generic-table .table-header .btn { padding: 0.25rem 0.4rem; font-size: 0.85rem; }
  /* Hide action button labels inside table rows on phones; keep icons */
  .tabulator .table-actions .label { display: none; }
}

/* ------------------ PromQL Editor (CodeMirror) ------------------ */
.promql-editor-wrap {
  width: 100%;
}
.promql-editor {
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  overflow: hidden;
}
/* Match textarea height roughly; allow internal scrolling. */
.promql-editor .cm-editor {
  min-height: 140px;
}
.promql-editor .cm-scroller {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
.promql-fallback {
  margin-top: 0.5rem;
}

.promql-editor .cm-content .tok-keyword { color: #708 !important; }
.promql-editor .cm-content .tok-operatorKeyword { color: #c586c0 !important; }
.promql-editor .cm-content .tok-string { color: #a11 !important; }
.promql-editor .cm-content .tok-number { color: #164 !important; }
.promql-editor .cm-content .tok-operator { color: #333 !important; }
.promql-editor .cm-content .tok-comment { color: #940 !important; }
.promql-editor .cm-content .tok-variableName { color: #0b5ed7 !important; }
.promql-editor .cm-content .tok-function { color: #6610f2 !important; }
.promql-editor .cm-content .tok-functionName { color: #6610f2 !important; }
.promql-editor .cm-content .tok-propertyName { color: #9cdcfe !important; }
.promql-editor .cm-content .tok-typeName { color: #4ec9b0 !important; }
.promql-editor .cm-content .tok-punctuation { color: #d4d4d4 !important; }

.script-editor-wrap {
  width: 100%;
  min-height: 220px;
  height: 260px;
  resize: vertical;
  overflow: auto;
}
.script-editor {
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  overflow: hidden;
  height: 100%;
}
.script-editor .cm-editor {
  min-height: 220px;
  height: 100%;
}
.script-editor .cm-scroller {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  height: 100%;
}
.script-fallback {
  margin-top: 0.5rem;
  min-height: 220px;
  height: 100%;
  resize: vertical;
}

.script-editor .cm-content .tok-keyword { color: #708 !important; }
.script-editor .cm-content .tok-operatorKeyword { color: #c586c0 !important; }
.script-editor .cm-content .tok-string { color: #a11 !important; }
.script-editor .cm-content .tok-number { color: #164 !important; }
.script-editor .cm-content .tok-operator { color: #333 !important; }
.script-editor .cm-content .tok-comment { color: #940 !important; }
.script-editor .cm-content .tok-variableName { color: #0b5ed7 !important; }
.script-editor .cm-content .tok-function { color: #6610f2 !important; }
.script-editor .cm-content .tok-functionName { color: #6610f2 !important; }
.script-editor .cm-content .tok-propertyName { color: #9cdcfe !important; }
.script-editor .cm-content .tok-typeName { color: #4ec9b0 !important; }
.script-editor .cm-content .tok-punctuation { color: #d4d4d4 !important; }

.script-editor .cm-content .cm-shell-command {
  color: #0d6efd;
  font-weight: 600;
}
