/* Estados do menu, tabelas adaptativas e telas estreitas. */

html[data-sidebar="collapsed"] {
  --layout-sidebar-width: 76px;
}

html[data-sidebar="hidden"] {
  --layout-sidebar-width: 0px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  transition: width 0.22s ease, min-width 0.22s ease, transform 0.28s ease;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.sidebar-nav ul {
  flex: 1 1 auto;
}

.sidebar-nav a {
  position: relative;
}

.sidebar-nav a.active {
  box-shadow: inset 3px 0 0 #fff;
  font-weight: 600;
}

.sidebar__controls {
  display: flex;
  gap: 0.35rem;
  justify-content: center;
  padding: 0.75rem;
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.sidebar__controls button {
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--sidebar-text);
  cursor: pointer;
}

.sidebar__controls button:hover,
.sidebar__controls button:focus-visible {
  background: rgba(255, 255, 255, 0.2);
  outline: none;
}

@media (min-width: 993px) {
  html[data-sidebar="collapsed"] .nav-label,
  html[data-sidebar="collapsed"] .sidebar__host,
  html[data-sidebar="collapsed"] .sidebar__brand h4 {
    display: none;
  }

  html[data-sidebar="collapsed"] .sidebar-nav a {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  html[data-sidebar="collapsed"] .sidebar-nav a:hover::after,
  html[data-sidebar="collapsed"] .sidebar-nav a:focus-visible::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: #263238;
    color: #fff;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    font-size: 0.78rem;
    white-space: nowrap;
    z-index: 1200;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  }

  html[data-sidebar="hidden"] .sidebar {
    transform: translateX(-100%);
    visibility: hidden;
  }

  html[data-sidebar="hidden"] .main-content {
    margin-left: 0;
    width: 100%;
  }
}

@media (max-width: 992px) {
  html[data-sidebar] .sidebar {
    width: min(300px, 88vw);
    min-width: 0;
    visibility: visible;
  }

  html[data-sidebar] .main-content {
    margin-left: 0;
    width: 100%;
  }

  .sidebar__controls {
    display: none;
  }

  .nav-label {
    display: inline;
  }
}

.app,
.main-content {
  max-width: 100%;
  overflow-x: hidden;
}

.page-content .row,
.page-content .card,
.page-content .card-content {
  max-width: 100%;
}

.extratos-toolbar,
.page-header,
.filters-panel .row {
  min-width: 0;
}

@media (max-width: 760px) {
  .top-bar-actions #user-name-display,
  .user-menu-caret {
    display: none;
  }

  #user-menu-btn {
    min-width: var(--touch-target-min);
    padding: 0 0.4rem;
  }

  .extratos-toolbar .btn-small,
  .page-content .btn,
  .page-content .btn-small {
    min-height: var(--touch-target-min);
  }

  .page-content .input-field,
  .filters-panel .input-field,
  .filters-panel .col {
    width: 100%;
  }

  .adaptive-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .adaptive-table,
  .adaptive-table tbody,
  .adaptive-table tr,
  .adaptive-table td {
    display: block;
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
  }

  table.adaptive-table {
    display: block;
  }

  .adaptive-table tr {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    margin: 0 0 12px;
    padding: 0.35rem 0.85rem 0.7rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  }

  .adaptive-table td {
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.4rem 0;
    text-align: right;
  }

  .adaptive-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #546e7a;
    text-align: left;
    flex: 0 0 42%;
  }

  .adaptive-table td[data-label=""]::before,
  .adaptive-table td:not([data-label])::before {
    content: none;
  }

  .adaptive-table td.col-secondary {
    display: none;
  }

  .adaptive-table tr.is-open td.col-secondary {
    display: flex;
  }

  .adaptive-table td[data-label="Valor"],
  .adaptive-table td[data-label="Data"] {
    font-size: 1.02rem;
    font-weight: 700;
  }

  .adaptive-table td.col-expand {
    display: block;
    text-align: left;
    padding-top: 0.35rem;
  }

  .adaptive-table td.col-expand::before {
    content: none;
  }
}

@media print {
  .adaptive-table,
  .adaptive-table tbody {
    display: table !important;
    width: 100% !important;
  }

  .adaptive-table thead {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    display: table-header-group !important;
  }

  .adaptive-table tr {
    display: table-row !important;
    box-shadow: none;
  }

  .adaptive-table td,
  .adaptive-table th {
    display: table-cell !important;
    text-align: left;
  }

  .adaptive-table td::before,
  .adaptive-table td.col-expand {
    display: none !important;
  }
}

.audit-shell,
.devices-shell {
  width: 100%;
  max-width: var(--layout-max-content);
  margin: 0 auto;
}

.audit-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.audit-filters label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: #546e7a;
}

.audit-filters input,
.audit-filters select {
  min-height: var(--touch-target-min);
  border: 1px solid #cfd8dc;
  border-radius: 8px;
  padding: 0 0.7rem;
  background: #fff;
}

.audit-card,
.device-card {
  background: #fff;
  border: 1px solid #eceff1;
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
}

.audit-card header,
.device-card header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.audit-meta {
  color: #607d8b;
  font-size: 0.82rem;
}

.badge-suspeito {
  background: #ffebee;
  color: #b71c1c;
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  font-size: 0.75rem;
}

.diff-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

@media (min-width: 800px) {
  .diff-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.diff-grid pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #f7faf9;
  border-radius: 8px;
  padding: 0.6rem;
  margin: 0.25rem 0 0;
  max-height: 180px;
  overflow: auto;
}
