/* Typography */
body {
  font-family: var(--font-family-base);
  background-color: var(--color-surface-muted);
  color: var(--color-text);
}

/* Focus */
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
.nav-link:focus-visible,
.sortable-header:focus-visible {
  box-shadow: var(--focus-ring);
  outline: 0;
}

/* Navbar */
.navbar-brand {
  font-weight: 600;
}

.nav-user-name {
  max-width: 180px;
}

.navbar-nav .nav-link.active {
  font-weight: 600;
  background-color: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
}

/* Notifications */
.notification-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: var(--z-notification);
  max-width: 400px;
}

.notification {
  margin-bottom: 10px;
  padding: 15px 20px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease-out;
  position: relative;
}

.notification-success {
  background: #d4edda;
  border: 1px solid #c3e6cb;
  color: #155724;
}

.notification-error {
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  color: #721c24;
}

.notification-warning {
  background: #fff3cd;
  border: 1px solid #ffeaa7;
  color: #856404;
}

.notification-close {
  position: absolute;
  top: 5px;
  right: 10px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.6;
}

.notification-close:hover {
  opacity: 1;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Page header */
.page-header {
  margin-bottom: var(--space-4);
}

.page-header__title {
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}

.page-header__meta {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.action-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

/* Filter bar */
.filter-bar .card-body {
  padding: var(--space-3) var(--space-4);
}

.filter-bar__presets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.25rem 0.6rem;
  font-size: 0.8125rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 2rem;
  color: var(--color-text);
  text-decoration: none;
}

.filter-chip:hover {
  background: var(--color-surface-muted);
  color: var(--color-text);
}

.filter-chip__remove {
  opacity: 0.6;
  line-height: 1;
}

.filter-chip__remove:hover {
  opacity: 1;
}

#filtro-busca-romaneio:focus,
.filter-bar input[name="busca"]:focus {
  border-color: var(--color-primary);
  box-shadow: var(--focus-ring);
}

/* Data table */
.data-table-section .table-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.table-container-fixed {
  max-height: min(60vh, 600px);
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background-color: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.table-container-fixed .table {
  margin-bottom: 0;
  border: none;
  font-size: var(--font-size-table-min);
}

.table-container-fixed .table thead th {
  position: sticky;
  top: 0;
  z-index: var(--z-table-header);
  background-color: var(--color-table-header) !important;
  border-bottom: 2px solid var(--color-border);
  vertical-align: middle;
  white-space: nowrap;
}

#tabela-romaneios tbody tr {
  transition: background-color 0.15s ease, opacity 0.2s ease;
}

#tabela-romaneios tbody tr:hover {
  background-color: var(--table-row-hover) !important;
}

#tabela-romaneios tbody tr.row-selected {
  background-color: var(--table-row-selected) !important;
}

#tabela-romaneios.table-density-compact td,
#tabela-romaneios.table-density-compact th {
  padding: 0.35rem 0.5rem;
}

.col-align-center { text-align: center !important; }
.col-align-start { text-align: left !important; }
.col-align-end { text-align: right !important; font-variant-numeric: tabular-nums; }

.cell-truncate {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-truncate-wide {
  max-width: 200px;
}

.col-sticky-check,
.col-sticky-check-header {
  position: sticky;
  left: 0;
  z-index: var(--z-sticky-col);
  background-color: inherit;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.06);
}

.col-sticky-actions,
.col-sticky-actions-header {
  position: sticky;
  right: 0;
  z-index: var(--z-sticky-col);
  background-color: inherit;
  box-shadow: -2px 0 4px rgba(0, 0, 0, 0.06);
}

.table-container-fixed thead .col-sticky-check-header,
.table-container-fixed thead .col-sticky-actions-header {
  background-color: var(--color-table-header) !important;
}

.table-container-fixed tbody .col-sticky-check,
.table-container-fixed tbody .col-sticky-actions {
  background-color: var(--color-surface);
}

.table-striped > tbody > tr:nth-of-type(odd) > .col-sticky-check,
.table-striped > tbody > tr:nth-of-type(odd) > .col-sticky-actions {
  background-color: #f8f9fa;
}

.table-striped > tbody > tr.row-selected > .col-sticky-check,
.table-striped > tbody > tr.row-selected > .col-sticky-actions {
  background-color: var(--table-row-selected);
}

/* Sortable headers */
.sortable-header {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  color: #fff !important;
  text-decoration: none !important;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: background-color 0.2s ease;
  white-space: nowrap;
}

.sortable-header:hover {
  background-color: rgba(255, 255, 255, 0.12);
  color: #fff !important;
}

.sortable-header .bi-arrow-down-up {
  opacity: 0.5;
  font-size: 0.75em;
}

/* Status & email */
.status-badge {
  display: inline-block;
  padding: 0.2em 0.55em;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 2rem;
  white-space: nowrap;
}

.status-badge--pending {
  background: var(--status-pending-bg);
  color: var(--status-pending-text);
}

.status-badge--sent {
  background: var(--status-sent-bg);
  color: var(--status-sent-text);
}

.status-badge--other {
  background: var(--color-border-subtle);
  color: var(--color-text-muted);
}

.email-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  font-size: 0.9rem;
}

.email-status--sent {
  background: var(--status-sent-bg);
  color: var(--status-sent-text);
}

.email-status--pending {
  background: var(--color-border-subtle);
  color: var(--color-text-muted);
}

.vinculo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Selection bar */
.selection-bar {
  display: none;
  position: sticky;
  bottom: 0;
  z-index: var(--z-selection-bar);
  margin-top: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.selection-bar.is-visible {
  display: flex;
}

.selection-bar__stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: 0.875rem;
}

.selection-bar__stat strong {
  font-variant-numeric: tabular-nums;
}

/* Mobile cards */
.romaneio-mobile-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.romaneio-mobile-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  box-shadow: var(--shadow-sm);
}

.romaneio-mobile-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.romaneio-mobile-card__title {
  font-weight: 600;
  font-size: 0.9375rem;
  margin: 0;
}

.romaneio-mobile-card__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  font-size: var(--font-size-table-min);
}

.romaneio-mobile-card__label {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  display: block;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
}

.empty-state__icon {
  font-size: 3rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

#sem-resultados-romaneio {
  animation: fadeIn 0.3s ease;
}

/* Modal sections */
.modal-section-card .card-header {
  background: var(--color-surface-muted) !important;
  color: var(--color-text) !important;
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
}

.modal-section-card .card-header i {
  color: var(--color-primary);
}

.modal-tab-progress {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.modal-tab-progress .step.is-active {
  color: var(--color-primary);
  font-weight: 600;
}

/* Dismissible alerts */
.alert-dismissible-persistent[data-alert-key] {
  margin-bottom: var(--space-3);
}

/* Pagination */
.pagination-area {
  background-color: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.filtro-highlight {
  background-color: rgba(255, 193, 7, 0.1) !important;
}

#loading-icon-romaneio i {
  animation: spin 1s linear infinite;
}

/* Column hide */
[data-col-hidden="true"] {
  display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
  .notification-container {
    max-width: 90%;
    right: 5%;
    top: 10px;
  }

  .notification {
    padding: 10px 15px;
    font-size: 0.9rem;
  }

  .page-header__title {
    font-size: 1.5rem;
  }

  .table,
  .romaneio-mobile-card__grid {
    font-size: var(--font-size-table-min);
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .table-container-fixed {
    max-height: min(55vh, 500px);
  }
}

@media (max-width: 576px) {
  .page-header__title {
    font-size: 1.25rem;
  }
}
