/*----------------------------------------------
# Atelligo App-specific CSS
# Only things not covered by atelligo.css
----------------------------------------------*/

/* ===== Global: prevent horizontal page overflow ===== */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* ===== Always show hamburger on desktop too ===== */
.nav-toggle {
  display: flex !important;
}

/* ===== Topbar: fixed so overflow-x:hidden on body doesn't break sticky ===== */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 210;
}

/* ===== Desktop: make sidebar truly fixed (not just sticky) ===== */
/* sticky breaks when content causes overflow; fixed is reliable */
@media (min-width: 769px) {
  .sidebar {
    position: fixed;
    top: 48px;
    left: 0;
    height: calc(100vh - 48px);
    z-index: 90;
    transition: transform 0.22s ease;
  }
  .body-wrap {
    padding-top: 48px;    /* clear fixed topbar */
    padding-left: 240px;  /* match sidebar width */
    transition: padding-left 0.22s ease;
  }
  body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
  }
  body.sidebar-collapsed .body-wrap {
    padding-left: 0;
  }
}

@media (max-width: 768px) {
  .body-wrap {
    padding-top: 48px; /* clear fixed topbar on mobile too */
  }
}

/* ===== Theme button: centre the SVG icon ===== */
.theme-btn { display: inline-flex; align-items: center; justify-content: center; }

/* ===== Logo: a little taller, slightly less left gap ===== */
.topbar { padding-left: 12px; }
.topbar-logo img { height: 36px; }



/* ===== Tagify: match unfocused background to other form-controls ===== */
/* tagify.css (loaded before atelligo.css) provides structure; atelligo.css provides visuals */
.tagify { background: var(--color-bg-elevated) !important; align-items: center; min-height: 36px; padding: 0 6px; }
.tagify:focus-within { background: var(--color-bg-surface) !important; }
/* Keep internal input vertically centered; tagify.css default adds extra padding */
.tagify .tagify__input { margin: 0; padding: 0 4px; min-height: 0; line-height: 34px; }

/* Move background to the <tag> element so X and text share the same hover colour */
.tagify__tag { border-color: var(--color-border) !important; background: var(--tag-bg) !important; }
.tagify__tag > div { background: transparent !important; }
.tagify__tag:hover { background: var(--tag-hover) !important; }
.tagify__tag:hover > div { background: transparent !important; }
/* Restore normal right padding on text div; gap is controlled by the × button alone */
.tagify:not(.tagify--readonly) .tagify__tag > div { padding-right: 5px !important; }

/* Show remove (×) button — blends into the pill, no separate accent color */
.tagify__tag__removeBtn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: auto !important;
  height: auto !important;
  padding: 0 4px 0 0 !important;
  background: transparent !important;
  color: var(--color-text-muted) !important;
  opacity: 0.55;
  font-size: 11px;
  line-height: 1;
  margin-left: 0 !important;
  border-radius: 0;
  transition: opacity 0.15s;
  box-shadow: none !important;
}
/* Hover: only increase opacity — no hue change, no background tint */
.tagify__tag__removeBtn:hover,
.tagify__tag__removeBtn:focus {
  opacity: 1 !important;
  color: var(--color-text-muted) !important;
  background: transparent !important;
  box-shadow: none !important;
}
/* Prevent tagify.css fading the tag text when hovering × */
.tagify__tag__removeBtn:hover + div > .tagify__tag-text { opacity: 1 !important; }
.tagify--readonly .tagify__tag__removeBtn { display: none !important; }

/* ===== Content area: prevent horizontal overflow on desktop ===== */
.content { min-width: 0; overflow-x: hidden; }

/* ===== Mono cells: never wrap (table scrolls horizontally instead) ===== */
tbody td.mono { white-space: nowrap; }

/* ===== Table links: use text colour, not the global red link colour ===== */
tbody td a { color: inherit; }
tbody td a:hover { color: var(--color-text-primary); }

/* ===== User menu dropdown (not in atelligo.css) ===== */
.user-menu {
  position: relative;
}
.user-menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  overflow: hidden;
}
.user-menu-dropdown.open {
  display: block;
}
.user-menu-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.user-menu-header strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
}
.user-menu-header span {
  font-size: 11px;
  color: var(--color-text-subtle);
}
.user-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: background 0.12s;
}
.user-menu-item:hover {
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
}
.user-menu-divider {
  border-top: 1px solid var(--color-border);
  margin: 4px 0;
}

/* ===== App footer: centered, small, pinned to bottom ===== */
.app-footer {
  flex-shrink: 0;
  text-align: center;
  padding: 6px 16px;
  font-size: 11px;
  color: var(--color-text-subtle);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-surface);
}
.app-footer a {
  color: var(--color-text-subtle);
  text-decoration: none;
}
.app-footer a:hover {
  color: var(--color-text-primary);
}

/* ===== Breadcrumb: Bootstrap ol/li → atelligo style ===== */
/* Without Bootstrap loaded, <ol class="breadcrumb"> renders as a numbered list */
ol.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  list-style: none;
  margin: 0 0 12px 0;
  padding: 0;
  font-size: 12px;
  color: var(--color-text-subtle);
  gap: 2px;
}
ol.breadcrumb li.breadcrumb-item {
  display: flex;
  align-items: center;
  font-weight: 600;
}
ol.breadcrumb li.breadcrumb-item + li.breadcrumb-item::before {
  content: '/';
  color: var(--color-border);
  margin: 0 4px;
  font-weight: 600;
}
ol.breadcrumb li.breadcrumb-item a {
  color: var(--color-text-subtle);
  text-decoration: none;
  font-weight: 600;
}
ol.breadcrumb li.breadcrumb-item a:hover {
  color: var(--color-text-muted);
}
ol.breadcrumb li.breadcrumb-item.active {
  color: var(--color-text-subtle);
  font-weight: 600;
}

/*--------------------------------------------------------------
# DataTables 2.x — exact design-guide rules
# (pike-hub's atelligo.css predates DT 2.x support; these rules
#  are copied verbatim from atelligo-design/dist/atelligo.css)
--------------------------------------------------------------*/
.dt-container {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.dt-container .dt-layout-row { margin: 0; }

.dt-container > .dt-layout-row:first-child {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--color-border);
}
.dt-container > .dt-layout-row:first-child > .dt-layout-start {
  flex: 1; display: flex; align-items: center;
}
.dt-container > .dt-layout-row:first-child > .dt-layout-end {
  display: flex; align-items: center; gap: 8px;
}

.dt-container .dt-layout-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.dt-container .dt-layout-table table.dataTable { margin: 0 !important; width: 100% !important; }

.dt-container > .dt-layout-row:not(:first-child):not(.dt-layout-table) {
  display: flex; align-items: center;
  padding: 7px 14px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-base);
}
.dt-container > .dt-layout-row:not(:first-child):not(.dt-layout-table) > * {
  flex: 1; display: flex; align-items: center;
}

.dt2-title { font-size: 13px; font-weight: 600; color: var(--color-text-primary); flex: 1; }

.dt-container .dt-search label { font-size: 0; }
.dt-container .dt-search input {
  font-size: 12px; height: 30px; padding: 0 10px;
  font-family: var(--font-ui);
  background: var(--color-bg-elevated); color: var(--color-text-primary);
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  outline: none; width: 200px; box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.dt-container .dt-search input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-subtle);
  background-color: var(--color-bg-surface);
}
.dt-container .dt-search input::placeholder { color: var(--color-text-subtle); }

.dt-container > .dt-layout-row:first-child .dt-search {
  padding-left: 12px; border-left: 1px solid var(--color-border); margin-left: 4px;
}

/* Sort icons — style the injected <span class="dt-column-order"> directly */
.dt-column-order {
  display: inline-block; vertical-align: middle;
  position: relative; width: 18px; height: 14px; margin-left: 2px;
  flex-shrink: 0;
}
.dt-column-order::before {
  content: ''; position: absolute; left: 5px; top: 1px;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-bottom: 4px solid var(--color-text-muted); opacity: 0.3;
}
.dt-column-order::after {
  content: ''; position: absolute; left: 5px; top: 8px;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 4px solid var(--color-text-muted); opacity: 0.3;
}
th.dt-ordering-asc .dt-column-order::before  { opacity: 1; border-bottom-color: var(--color-primary); }
th.dt-ordering-asc .dt-column-order::after   { opacity: 0.15; }
th.dt-ordering-desc .dt-column-order::after  { opacity: 1; border-top-color: var(--color-primary); }
th.dt-ordering-desc .dt-column-order::before { opacity: 0.15; }
th.dt-orderable-none .dt-column-order { display: none; }

table.dataTable tbody tr.odd,
table.dataTable tbody tr.even { background: transparent; }
table.dataTable tbody td:first-child { padding: 0 4px 0 16px; }
table.dataTable tbody td.actions { text-align: right; padding-right: 12px; }
table.dataTable tbody tr.selected > td { background: var(--color-primary-subtle); }
table.dataTable input[type=checkbox] { accent-color: var(--color-primary); cursor: pointer; }

table.dataTable tbody td.dt-empty {
  text-align: center; color: var(--color-text-muted); font-size: 13px; padding: 32px 16px;
}

.dt-info { font-size: 12px; color: var(--color-text-muted); font-family: var(--font-ui); }

.dt-paging { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.dt-paging .dt-paging-button.previous,
.dt-paging .dt-paging-button.next {
  display: inline-flex; align-items: center; justify-content: center;
  height: 28px; padding: 0 10px;
  font-family: var(--font-ui); font-size: 12px; font-weight: 500;
  background: var(--color-bg-surface); color: var(--color-text-secondary);
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  cursor: pointer; box-shadow: var(--shadow-sm);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  user-select: none;
}
.dt-paging .dt-paging-button.previous:hover:not(.disabled),
.dt-paging .dt-paging-button.next:hover:not(.disabled) {
  background: var(--color-bg-elevated); border-color: #D1D5DB; color: var(--color-text-primary);
}
.dt-paging .dt-paging-button.previous.disabled,
.dt-paging .dt-paging-button.next.disabled { opacity: 0.4; cursor: not-allowed; }

.dt-paging .dt-paging-button:not(.previous):not(.next) {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 28px; padding: 0 5px;
  font-family: var(--font-ui); font-size: 12px; font-weight: 500;
  color: var(--color-text-muted);
  background: none; border: none; box-shadow: none;
  cursor: pointer; border-radius: var(--radius-sm);
  transition: color 0.12s, background 0.12s;
  user-select: none;
}
.dt-paging .dt-paging-button:not(.previous):not(.next):hover {
  color: var(--color-text-primary); background: var(--color-bg-elevated);
}
.dt-paging .dt-paging-button.current,
.dt-paging .dt-paging-button.current:hover {
  color: var(--color-primary); font-weight: 700; background: none;
}

/* ── DataTables Buttons: collection dropdown (ColVis, etc.) ── */
.dt-button-collection {
  position: absolute;
  z-index: 2001;
  display: flex !important;
  flex-direction: column;
  min-width: 160px;
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  gap: 1px;
}
.dt-button-collection .dt-button {
  display: flex !important;
  align-items: center;
  width: 100% !important;
  padding: 6px 12px !important;
  font-family: var(--font-ui) !important;
  font-size: 12px !important;
  font-weight: 400 !important;
  color: var(--color-text-secondary) !important;
  background: transparent !important;
  border: none !important;
  border-radius: var(--radius-sm) !important;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s;
  box-shadow: none !important;
  height: auto !important;
}
.dt-button-collection .dt-button:hover {
  background: var(--color-bg-elevated) !important;
  color: var(--color-text-primary) !important;
}
.dt-button-collection .dt-button.dt-button-active,
.dt-button-collection .dt-button.active {
  color: var(--color-primary) !important;
  font-weight: 500 !important;
}
.dt-button-collection .dt-button.dt-button-active::before,
.dt-button-collection .dt-button.active::before {
  content: '✓';
  margin-right: 6px;
  font-size: 10px;
}
.dt-button-background {
  position: fixed; inset: 0; z-index: 2000; background: transparent;
}

/*----------------------------------------------
# DataTable row highlight colors
----------------------------------------------*/
.verified {
  background-color: #a4ffa477 !important;
}

.takedown_attention {
  background-color: #e0937f77 !important;
}

.externalbrand {
  background-color: #99aaee44 !important;
}

.atelligo_inactive {
  background-color: #fa8072cc !important;
}

/*----------------------------------------------
# Vis.js timeline color overrides
----------------------------------------------*/
.vis-item.vis-background.safebrowse_blocked  { background-color: #fa8072cc; }
.vis-item.vis-background.safebrowse_notblocked { background-color: #b0e2ffcc; }
.vis-item.safebrowse_blocked  { background-color: #fa8072cc; }
.vis-item.safebrowse_notblocked { background-color: #b0e2ffcc; }
.vis-item.uptime_up      { background-color: #e42d0ccc; }
.vis-item.uptime_down    { background-color: #37d004cc; }
.vis-item.uptime_pending { background-color: #f8cb00cc; }

/*--------------------------------------------------------------
# HTMX swap animation
--------------------------------------------------------------*/
tr.htmx-swapping td {
  opacity: 0;
  transition: opacity 1s ease-out;
}

/*--------------------------------------------------------------
# Copyable text + clipboard feedback tooltip
--------------------------------------------------------------*/
.copyable-text {
  cursor: pointer;
  position: relative;
  padding: 2px 4px;
  border-radius: 3px;
  transition: background-color 0.2s ease;
}

.copyable-text:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.copy-feedback {
  position: absolute;
  background-color: #333;
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
  top: -25px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  z-index: 1000;
}

/*--------------------------------------------------------------
# Activity calendar (home dashboard)
--------------------------------------------------------------*/
.activity-calendar {
  padding: 10px;
  overflow-x: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  min-width: 300px;
}

.calendar-graph {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.calendar-months {
  display: flex;
  margin-left: 30px;
  font-size: 12px;
  color: var(--color-text-subtle);
  height: 20px;
  align-items: center;
}

.calendar-month {
  text-align: center;
  padding: 0 2px;
  border-right: 1px solid var(--color-border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.calendar-month:last-child { border-right: none; }

.calendar-content {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 5px;
  width: 100%;
}

.calendar-days {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  gap: 3px;
  height: 100%;
}

.calendar-day {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 12px;
  color: var(--color-text-subtle);
  height: 100%;
  line-height: 1;
  white-space: nowrap;
  padding-right: 5px;
}

.calendar-grid-container {
  overflow-x: auto;
  width: 100%;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(53, 1fr);
  gap: 3px;
  width: 100%;
  height: 100%;
}

.calendar-week {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  gap: 3px;
  height: 100%;
}

.calendar-cell {
  aspect-ratio: 1;
  min-width: 8px;
  min-height: 8px;
  max-width: 21px;
  max-height: 21px;
  width: 100%;
  height: 100%;
  border-radius: 2px;
  cursor: pointer;
  transition: transform 0.2s;
}

.calendar-cell:empty        { background-color: transparent; }
.calendar-cell[data-count="0"] { background-color: var(--color-bg-muted) !important; }
.calendar-cell:hover        { transform: scale(1.2); z-index: 1; }

@media (min-width: 1600px) { .calendar-cell { max-width: 25px; max-height: 25px; } }
@media (min-width: 1920px) { .calendar-cell { max-width: 30px; max-height: 30px; } }
@media (min-width: 2560px) { .calendar-cell { max-width: 35px; max-height: 35px; } }

@media (max-width: 768px) {
  .calendar-months,
  .calendar-days { font-size: 10px; }
  .calendar-days  { width: 20px; }
  .calendar-month { padding: 0 1px; }
}

/* ===== Native <dialog> modal (atelligo style) ===== */
.atl-dialog {
  /* Center in viewport regardless of scroll position */
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;

  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-surface);
  box-shadow: var(--shadow-xl);
  padding: 0;
  max-width: 480px;
  width: 90%;
  color: var(--color-text-primary);
}
.atl-dialog::backdrop {
  background: rgba(17,24,39,0.45);
  backdrop-filter: blur(2px);
}
.atl-dialog-header {
  padding: 13px 18px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.atl-dialog-title { font-size: 13px; font-weight: 600; }
.atl-dialog-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  flex-shrink: 0;
}
.atl-dialog-close:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}
.atl-dialog-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.atl-dialog-footer {
  padding: 11px 18px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--color-bg-base);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* File input styled to match form-control */
.form-control[type="file"] {
  height: auto;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  color: var(--color-text-secondary);
}
.form-control[type="file"]::file-selector-button {
  height: 24px;
  padding: 0 10px;
  margin-right: 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-ui);
  color: var(--color-text-secondary);
  background: var(--color-bg-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.form-control[type="file"]::file-selector-button:hover {
  background: var(--color-bg-elevated);
  border-color: var(--color-border-strong, var(--color-border));
}

/* ===== Textarea: reset the fixed 36px height set by .form-control ===== */
textarea.form-control {
  height: auto;
  padding: 8px 12px;
  resize: vertical;
}

/* ===== Dirty-field indicator (brand detail form) ===== */
input.is-dirty, textarea.is-dirty {
  border-color: var(--color-warning-border) !important;
  background: var(--color-warning-bg) !important;
}

/* ===== Detail info rows (read-only field display) ===== */
.detail-label {
  font-size: 12px; font-weight: 600; color: var(--color-text-muted);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px;
}
.detail-value {
  font-size: 13px; color: var(--color-text-secondary);
}
