/* ============================================================
   SINAGEM — Sistema Nacional de Gestão de Mercados
   app.css v6.0 — Refactored: Bootstrap 5 + DataTables
   ============================================================ */

/* ============================================================
   VARIABLES
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,300;14..32,400;14..32,500;14..32,600;14..32,700;14..32,800&display=swap');

:root {
  /* Brand Colors */
  --sin-red:          #e03030;
  --sin-red-dark:     #c02020;
  --sin-red-light:    #f05050;
  --sin-red-subtle:   rgba(224, 48, 48, 0.08);

  --sin-green:        #27ae60;
  --sin-green-dark:   #1e8449;

  --sin-orange:       #e67e22;
  --sin-yellow:       #f1c40f;
  --sin-dark:         #1a1a2e;

  /* Surface */
  --sin-bg:           #f0f2f5;
  --sin-card:         #ffffff;
  --sin-table-alt:    #f9fafb;
  --sin-hover:        rgba(224, 48, 48, 0.04);

  /* Text */
  --sin-text:         #1a1a2e;
  --sin-text-sub:     #6b7280;
  --sin-text-muted:   #9ca3af;

  /* Border */
  --sin-border:       #e5e7eb;
  --sin-border-light: #f1f5f9;

  /* Shadows */
  --sin-shadow-sm:    0 1px 2px rgba(0,0,0,.05);
  --sin-shadow-md:    0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
  --sin-shadow-lg:    0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
  --sin-shadow-xl:    0 20px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.1);
  --sin-shadow-card:  0 2px 8px rgba(0,0,0,.06);

  /* Layout */
  --sin-sidebar-w:    280px;
  --sin-sidebar-col:  70px;
  --sin-topbar-h:     64px;

  /* Radius */
  --sin-radius-sm:    6px;
  --sin-radius-md:    10px;
  --sin-radius-lg:    14px;
  --sin-radius-xl:    18px;

  /* Transitions */
  --sin-t-fast:       150ms ease;
  --sin-t-base:       250ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Typography */
  --sin-font:         'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* Bootstrap overrides (align with brand) */
  --bs-primary:       var(--sin-red);
  --bs-primary-rgb:   224, 48, 48;
  --bs-success-rgb:   39, 174, 96;
  --bs-border-color:  var(--sin-border);
  --bs-border-radius: var(--sin-radius-md);
  --bs-font-sans-serif: var(--sin-font);
  --bs-body-font-family: var(--sin-font);
  --bs-body-color:    var(--sin-text);
  --bs-body-bg:       var(--sin-bg);
  --bs-link-color:    var(--sin-red);
  --bs-link-hover-color: var(--sin-red-dark);

  /* Z-Index */
  --sin-z-sidebar:    1040;
  --sin-z-header:     1030;
  --sin-z-overlay:    1039;
}

:root {
  --sin-z-sidebar:  1040; /* manter */
  --sin-z-header:   1030; /* manter */
  --sin-z-overlay:  1039; /* manter */
}

/* ============================================================
   BASE
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--sin-font);
  font-size: 0.9375rem;
  color: var(--sin-text);
  background-color: var(--sin-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--sin-t-fast);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

ul, ol {
  list-style: none;
  margin: 0;
  padding: 0;
}


/* ============================================================
   TYPOGRAPHY
   ============================================================ */
.sin-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--sin-text);
}

.sin-subtitle {
  font-size: 0.75rem;
  color: var(--sin-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sin-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--sin-text-muted);
}


/* ============================================================
   LAYOUT
   ============================================================ */
#wrapper {
  display: flex;
  min-height: 100vh;
}

#page-content-wrapper {
  flex: 1;
  margin-left: var(--sin-sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--sin-t-base);
}

.sinagem-main {
  flex: 1;
  padding: 10px;
  animation: sin-fadeup 0.35s ease both;
}

@keyframes sin-fadeup {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes sin-slidedown {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ============================================================
   SIDEBAR
   ============================================================ */
#sidebar-wrapper {
  position: fixed;
  inset-block: 0;
  left: 0;
  width: var(--sin-sidebar-w);
  background: var(--sin-card);
  color: var(--sin-text);
  z-index: var(--sin-z-sidebar);
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: var(--sin-shadow-xl);
  transition: transform var(--sin-t-base), width var(--sin-t-base);
  scrollbar-width: thin;
  scrollbar-color: var(--sin-red-light) var(--sin-border-light);
}

/* Logo */
.sb-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem;
  border-bottom: 1px solid var(--sin-border);
  margin-bottom: 1rem;
  text-decoration: none;
  transition: background var(--sin-t-fast);
}

.sb-logo:hover {
  background: var(--sin-bg);
}

.sb-logo-badge {
  width: 44px;
  height: 44px;
  background: var(--sin-red);
  border-radius: var(--sin-radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(224, 48, 48, 0.3);
}

.sb-logo-badge i {
  font-size: 1.375rem;
  color: #fff;
}

.sb-logo-text {
  flex: 1;
  min-width: 0;
}

.sb-brand {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--sin-text);
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.sb-tagline {
  font-size: 0.6rem;
  color: var(--sin-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* Mobile close */
.sidebar-close-mobile {
  display: none;
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  border-radius: var(--sin-radius-sm);
  background: var(--sin-bg);
  border: 1px solid var(--sin-border);
  color: var(--sin-text-sub);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: var(--sin-t-fast);
}

.sidebar-close-mobile:hover {
  background: var(--sin-red-subtle);
  color: var(--sin-red);
  border-color: var(--sin-red);
}

/* Nav */
.sb-nav {
  padding: 0.5rem 0;
}

.sb-section {
  padding: 0.75rem 1.25rem 0.375rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--sin-text-muted);
}

.sb-item {
  margin: 2px 0.75rem;
}

.sb-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--sin-radius-md);
  color: var(--sin-text-sub);
  font-size: 0.85rem;
  font-weight: 500;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--sin-t-fast), color var(--sin-t-fast);
}

.sb-link i {
  width: 20px;
  font-size: 1rem;
  text-align: center;
  flex-shrink: 0;
}

.sb-link:hover {
  background: var(--sin-bg);
  color: var(--sin-red);
}

.sb-link.active {
  background: var(--sin-red);
  color: #fff;
  box-shadow: 0 2px 8px rgba(224, 48, 48, 0.3);
}

.sb-link[aria-expanded="true"] {
  background: var(--sin-red-subtle);
  color: var(--sin-red);
}

.sb-label {
  flex: 1;
}

.sb-arrow {
  font-size: 0.7rem;
  margin-left: auto;
  transition: transform var(--sin-t-fast);
}

.sb-link[aria-expanded="true"] .sb-arrow {
  transform: rotate(180deg);
}

/* Submenu */
.sb-submenu.collapse:not(.show) { display: none; }
.sb-submenu.show { display: block; }

.sb-sub {
  margin-left: 2.5rem;
  padding: 0.25rem 0;
  border-left: 1px solid var(--sin-border);
}

.sb-sub-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.875rem;
  border-radius: var(--sin-radius-sm);
  color: var(--sin-text-sub);
  font-size: 0.8rem;
  text-decoration: none;
  transition: background var(--sin-t-fast), color var(--sin-t-fast);
}

.sb-sub-link i {
  width: 18px;
  font-size: 0.8rem;
  text-align: center;
}

.sb-sub-link:hover {
  background: var(--sin-bg);
  color: var(--sin-red);
}

.sb-sub-link.active {
  background: var(--sin-red-subtle);
  color: var(--sin-red);
  font-weight: 500;
}

/* Footer */
.sb-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--sin-border);
  margin-top: auto;
}

/* Overlay */
.sb-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: var(--sin-z-overlay);
  /* Remova esta linha: */
  /* backdrop-filter: blur(4px); */
}

.sb-overlay.show {
  display: block;
}

/* Collapsed (desktop) */
#sidebar-wrapper.collapsed {
  width: var(--sin-sidebar-col);
}

#sidebar-wrapper.collapsed .sb-logo-text,
#sidebar-wrapper.collapsed .sb-label,
#sidebar-wrapper.collapsed .sb-arrow,
#sidebar-wrapper.collapsed .sb-section {
  display: none;
}

#sidebar-wrapper.collapsed .sb-link {
  justify-content: center;
  padding: 0.75rem 0.5rem;
}

#sidebar-wrapper.collapsed .sb-submenu {
  display: none;
}

/* Mobile */
@media (max-width: 992px) {
  #sidebar-wrapper {
    transform: translateX(-100%);
    width: var(--sin-sidebar-w) !important;
  }

  #sidebar-wrapper.sb-open {
    transform: translateX(0);
  }

  .sidebar-close-mobile {
    display: flex;
  }

  #page-content-wrapper {
    margin-left: 0 !important;
  }
}


/* ============================================================
   HEADER
   ============================================================ */
#sinagem-header {
  background: var(--sin-card);
  border-bottom: 1px solid var(--sin-border);
  padding: 0 1.5rem;
  height: var(--sin-topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: var(--sin-z-header);
  box-shadow: var(--sin-shadow-sm);
}

#sidebarToggle {
  background: transparent;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: var(--sin-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--sin-text-sub);
  font-size: 1.2rem;
  transition: background var(--sin-t-fast), color var(--sin-t-fast);
}

#sidebarToggle:hover {
  background: var(--sin-bg);
  color: var(--sin-red);
}

.hdr-page-area {
  flex: 1;
  margin-left: 1rem;
}

.hdr-page-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--sin-text);
  margin-bottom: 2px;
}

.hdr-breadcrumb {
  font-size: 0.75rem;
  color: var(--sin-text-muted);
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
}

.hdr-breadcrumb .bc-item {
  color: var(--sin-text-sub);
}

.hdr-breadcrumb .bc-current {
  color: var(--sin-red);
  font-weight: 600;
}

.hdr-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.hdr-icon-btn {
  position: relative;
  background: transparent;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: var(--sin-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--sin-text-sub);
  font-size: 1.1rem;
  transition: background var(--sin-t-fast), color var(--sin-t-fast);
}

.hdr-icon-btn:hover {
  background: var(--sin-bg);
  color: var(--sin-red);
}

.hdr-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--sin-red);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 9999px;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--sin-card);
}

.hdr-user {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.375rem 0.75rem 0.375rem 0.5rem;
  border-radius: 9999px;
  background: var(--sin-bg);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--sin-t-fast), border-color var(--sin-t-fast), box-shadow var(--sin-t-fast);
}

.hdr-user:hover {
  background: var(--sin-card);
  border-color: var(--sin-border);
  box-shadow: var(--sin-shadow-sm);
}

.hdr-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
}

.hdr-avatar-text {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--sin-red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.hdr-username {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--sin-text);
}

@media (max-width: 992px) {
  .hdr-username { display: none; }
  #sinagem-header { padding: 0 1rem; }
}


/* ============================================================
   COMPONENTS — KPI CARDS
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.kpi-card {
  background: var(--sin-card);
  border-radius: var(--sin-radius-lg);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--sin-shadow-card);
  border: 1px solid var(--sin-border);
  position: relative;
  overflow: hidden;
  transition: transform var(--sin-t-fast), box-shadow var(--sin-t-fast);
}

.kpi-card::after {
  content: '';
  position: absolute;
  bottom: -20px;
  right: -20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(0,0,0,.03);
  pointer-events: none;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--sin-shadow-md);
}

.kpi-card .kpi-info h3 {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--sin-text-muted);
  margin-bottom: 0.5rem;
}

.kpi-card .kpi-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--sin-text);
  line-height: 1;
}

.kpi-card .kpi-icon {
  width: 48px;
  height: 48px;
  background: var(--sin-red-subtle);
  border-radius: var(--sin-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sin-red);
  font-size: 1.4rem;
  flex-shrink: 0;
}

.kpi-card.green .kpi-icon  { background: rgba(39,174,96,.1);   color: var(--sin-green); }
.kpi-card.dark .kpi-icon   { background: rgba(26,26,46,.1);    color: var(--sin-dark); }
.kpi-card.orange .kpi-icon { background: rgba(230,126,34,.1);  color: var(--sin-orange); }
.kpi-card.yellow .kpi-icon { background: rgba(241,196,15,.1);  color: var(--sin-yellow); }

@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
}

@media (max-width: 576px) {
  .kpi-grid { grid-template-columns: 1fr; gap: 0.75rem; }
}


/* ============================================================
   COMPONENTS — CARDS
   ============================================================ */
.s-card {
  border-radius: var(--sin-radius-lg);
  border: 1px solid var(--sin-border);
  box-shadow: var(--sin-shadow-sm);
  margin-bottom: 1.5rem;
  transition: box-shadow var(--sin-t-fast);
}

.s-card:hover {
  box-shadow: var(--sin-shadow-md);
}

.s-card-header {
  background: var(--sin-card);
  padding: 1.125rem 1.375rem;
  border-bottom: 1px solid var(--sin-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--sin-radius-lg) var(--sin-radius-lg) 0 0;
}

.s-card-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--sin-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.s-card-title i {
  color: var(--sin-red);
  font-size: 1.1rem;
}

.s-card-body {
  padding: 0.625rem;
  background: var(--sin-card);
  border-radius: 0 0 var(--sin-radius-lg) var(--sin-radius-lg);
}

@media (max-width: 768px) {
  .s-card-header,
  .s-card-body { padding: 1rem; }
}


/* ============================================================
   COMPONENTS — TABLES
   Complements Bootstrap table + DataTables styles
   ============================================================ */
.s-table-wrapper {
  overflow-x: auto;
  border-radius: var(--sin-radius-lg);
}

.s-table {
  width: 100%;
  border-collapse: collapse;
}

.s-table thead th {
  background: var(--sin-table-alt);
  padding: 0.875rem 1rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--sin-text-muted);
  border-bottom: 1px solid var(--sin-border);
  text-align: left;
  white-space: nowrap;
}

.s-table tbody tr {
  border-bottom: 1px solid var(--sin-border-light);
  transition: background var(--sin-t-fast);
}

.s-table tbody tr:hover {
  background: var(--sin-hover);
}

.s-table tbody td {
  padding: 0.75rem 1rem;
  color: var(--sin-text-sub);
  vertical-align: middle;
  font-size: 0.8125rem;
}

.s-table tbody tr td:first-child {
  font-weight: 500;
  color: var(--sin-text);
}


/* ============================================================
   DATATABLES — Bootstrap 5 integration
   ============================================================ */
.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
  font-size: 0.8125rem;
  color: var(--sin-text-sub);
  font-weight: 500;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  border: 1px solid var(--sin-border);
  border-radius: var(--sin-radius-md);
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--sin-text);
  background: var(--sin-card);
  transition: border-color var(--sin-t-fast), box-shadow var(--sin-t-fast);
}

.dataTables_wrapper .dataTables_filter input:focus {
  border-color: var(--sin-red);
  box-shadow: 0 0 0 3px var(--sin-red-subtle);
  outline: none;
}

.dataTables_wrapper .dataTables_info {
  font-size: 0.8rem;
  color: var(--sin-text-muted);
  padding-top: 0.75rem;
}

.dataTables_wrapper .dataTables_paginate {
  padding-top: 0.75rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--sin-border);
  border-radius: var(--sin-radius-sm);
  font-size: 0.8125rem;
  color: var(--sin-text-sub) !important;
  background: var(--sin-card);
  cursor: pointer;
  transition: all var(--sin-t-fast);
  margin: 0 2px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.disabled) {
  border-color: var(--sin-red);
  color: var(--sin-red) !important;
  background: var(--sin-red-subtle);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--sin-red) !important;
  border-color: var(--sin-red) !important;
  color: #fff !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

table.dataTable thead > tr > th.sorting,
table.dataTable thead > tr > th.sorting_asc,
table.dataTable thead > tr > th.sorting_desc {
  background: var(--sin-table-alt);
  color: var(--sin-text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

table.dataTable > tbody > tr:hover > * {
  background: var(--sin-hover);
}


/* ============================================================
   COMPONENTS — BADGES
   Extends Bootstrap badges
   ============================================================ */
.badge-pago {
  background: var(--sin-green);
  color: #fff;
}

.badge-pendente {
  background: var(--sin-orange);
  color: #fff;
}

.badge-atrasado {
  background: var(--sin-red);
  color: #fff;
}

/* Legacy support — kept minimal, prefer Bootstrap .badge classes */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge i {
  font-size: 0.65rem;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fed7aa; color: #92400e; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-neutral { background: var(--sin-table-alt); color: var(--sin-text-sub); }


/* ============================================================
   COMPONENTS — BUTTONS
   Extends Bootstrap .btn — do not recreate base styles
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  border-radius: var(--sin-radius-md);
  transition: all var(--sin-t-fast);
  white-space: nowrap;
}

.btn i {
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--sin-red);
  border-color: var(--sin-red);
  color: #fff;
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--sin-red-dark);
  border-color: var(--sin-red-dark);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--sin-shadow-md);
}

.btn-outline-primary {
  border-color: var(--sin-red);
  color: var(--sin-red);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
  background: var(--sin-red);
  border-color: var(--sin-red);
  color: #fff;
}

.btn-success {
  background: var(--sin-green);
  border-color: var(--sin-green);
  color: #fff;
}

.btn-success:hover,
.btn-success:focus {
  background: var(--sin-green-dark);
  border-color: var(--sin-green-dark);
  color: #fff;
}

.btn-outline-success {
  border-color: var(--sin-green);
  color: var(--sin-green);
}

.btn-outline-success:hover,
.btn-outline-success:focus {
  background: var(--sin-green);
  border-color: var(--sin-green);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border-color: var(--sin-border);
  color: var(--sin-text-sub);
}

.btn-ghost:hover {
  background: var(--sin-bg);
  color: var(--sin-text);
}

.btn-icon {
  padding: 0.5rem;
  border-radius: var(--sin-radius-md);
}


/* ============================================================
   COMPONENTS — FORMS
   Extends Bootstrap form controls
   ============================================================ */
.form-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--sin-text);
  margin-bottom: 0.375rem;
}

.form-label .required {
  color: var(--sin-red);
  margin-left: 0.1875rem;
}

.form-control,
.form-select {
  font-size: 0.8125rem;
  color: var(--sin-text);
  border-color: var(--sin-border);
  border-radius: var(--sin-radius-md);
  transition: border-color var(--sin-t-fast), box-shadow var(--sin-t-fast);
}

.form-control:hover,
.form-select:hover {
  border-color: var(--sin-red-light);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--sin-red);
  box-shadow: 0 0 0 3px var(--sin-red-subtle);
}

.form-control.is-invalid { border-color: var(--sin-red); background-color: #fef2f2; }
.form-control.is-valid   { border-color: var(--sin-green); background-color: #f0fdf4; }

.form-error {
  font-size: 0.75rem;
  color: var(--sin-red);
  margin-top: 0.25rem;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--sin-text-muted);
  margin-top: 0.25rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.25rem;
}

@media (max-width: 768px) {
  .form-row { grid-template-columns: 1fr; gap: 1rem; }
}


/* ============================================================
   COMPONENTS — ALERTS
   Complements Bootstrap alerts
   ============================================================ */
.sinagem-flash-alert {
  animation: sin-slidedown 0.3s ease;
}

.sinagem-alert {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.125rem;
  border-radius: var(--sin-radius-md);
  font-size: 0.8125rem;
  font-weight: 500;
  border-left: 4px solid;
  background: #fff;
  box-shadow: var(--sin-shadow-sm);
  margin-bottom: 1rem;
}

.sinagem-alert i { font-size: 1rem; }

.sinagem-alert-success { border-left-color: var(--sin-green);  background: #f0fdf4; color: #166534; }
.sinagem-alert-danger  { border-left-color: var(--sin-red);    background: #fef2f2; color: #991b1b; }
.sinagem-alert-warning { border-left-color: var(--sin-orange); background: #fffbeb; color: #92400e; }
.sinagem-alert-info    { border-left-color: #3b82f6;           background: #eff6ff; color: #1e40af; }

.flash-close {
  margin-left: auto;
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.flash-close:hover { opacity: 1; }


/* ============================================================
   COMPONENTS — PAGINATION
   Use Bootstrap .pagination where possible;
   these classes are for custom pagination UI
   ============================================================ */
.sin-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 0;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.sin-pagination-info {
  font-size: 0.8125rem;
  color: var(--sin-text-muted);
}

.sin-pagination-buttons {
  display: flex;
  gap: 0.3125rem;
}

.sin-pagination-btn {
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--sin-border);
  background: #fff;
  border-radius: var(--sin-radius-sm);
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--sin-text-sub);
  transition: all var(--sin-t-fast);
}

.sin-pagination-btn:hover {
  border-color: var(--sin-red);
  color: var(--sin-red);
}

.sin-pagination-btn.active {
  background: var(--sin-red);
  color: #fff;
  border-color: var(--sin-red);
}

.sin-pagination-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Legacy — kept for backward compat */
.pagination-info     { font-size: 0.8125rem; color: var(--sin-text-muted); }
.pagination-buttons  { display: flex; gap: 0.3125rem; }
.pagination-btn      { padding: 0.375rem 0.75rem; border: 1px solid var(--sin-border); background: #fff; border-radius: var(--sin-radius-sm); cursor: pointer; font-size: 0.8125rem; color: var(--sin-text-sub); transition: all var(--sin-t-fast); }
.pagination-btn:hover { border-color: var(--sin-red); color: var(--sin-red); }
.pagination-btn.active { background: var(--sin-red); color: #fff; border-color: var(--sin-red); }
.pagination-btn:disabled { opacity: 0.45; cursor: not-allowed; }

@media (max-width: 576px) {
  .sin-pagination { flex-direction: column; align-items: flex-start; }
}


/* ============================================================
   COMPONENTS — INFO SECTIONS (detail views)
   ============================================================ */
.info-section {
  background: var(--sin-card);
  border-radius: var(--sin-radius-md);
  padding: 1rem 0;
}

.info-section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--sin-text);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--sin-red);
  display: inline-block;
}

.info-section-title i {
  color: var(--sin-red);
  margin-right: 0.5rem;
}

.info-table {
  width: 100%;
  border-collapse: collapse;
}

.info-table tr {
  border-bottom: 1px solid var(--sin-border-light);
}

.info-table tr:last-child {
  border-bottom: none;
}

.info-table th {
  width: 35%;
  padding: 0.75rem 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--sin-text-sub);
  text-align: left;
}

.info-table td {
  width: 65%;
  padding: 0.75rem 0;
  font-size: 0.85rem;
  color: var(--sin-text);
}

.merchant-photo {
  width: 100%;
  max-width: 300px;
  border-radius: var(--sin-radius-md);
  box-shadow: var(--sin-shadow-sm);
}

.empty-photo {
  text-align: center;
  padding: 2rem;
  background: var(--sin-bg);
  border-radius: var(--sin-radius-md);
  color: var(--sin-text-muted);
}

.empty-photo i {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  opacity: 0.5;
  display: block;
}

.empty-photo p {
  font-size: 0.8rem;
  margin: 0;
}

.metadata-pre {
  background: var(--sin-bg);
  padding: 1rem;
  border-radius: var(--sin-radius-sm);
  font-size: 0.7rem;
  overflow-x: auto;
  color: var(--sin-text-sub);
}

@media (max-width: 768px) {
  .info-table th,
  .info-table td { padding: 0.5rem 0; font-size: 0.75rem; }
  .info-section-title { font-size: 0.85rem; }
  .merchant-photo { max-width: 100%; }
}


/* ============================================================
   FOOTER
   ============================================================ */
.sinagem-footer {
  background: var(--sin-card);
  border-top: 1px solid var(--sin-border);
  padding: 1rem 1.5rem;
  margin-top: auto;
  text-align: center;
  font-size: 0.75rem;
  color: var(--sin-text-muted);
}


/* ============================================================
   UTILITIES
   Prefer Bootstrap utilities; these are sinagem-specific only
   ============================================================ */
.text-sin-red     { color: var(--sin-red) !important; }
.text-sin-green   { color: var(--sin-green) !important; }
.text-sin-orange  { color: var(--sin-orange) !important; }
.bg-sin-red       { background: var(--sin-red) !important; }
.bg-sin-red-muted { background: var(--sin-red-subtle) !important; }
.bg-sin-green     { background: var(--sin-green) !important; }

.cursor-pointer { cursor: pointer; }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--sin-border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb { background: var(--sin-red-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--sin-red); }


/* ============================================================
   PRINT
   ============================================================ */
@media print {
  #sidebar-wrapper,
  #sinagem-header,
  .sinagem-footer,
  .btn { display: none !important; }

  #page-content-wrapper {
    margin-left: 0 !important;
    padding: 0 !important;
  }

  .sinagem-main { padding: 0 !important; }

  .s-card {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* ============================================================
   MODAL FIX — Bootstrap 5 z-index alignment
   ============================================================ */

/* Garante que o backdrop fica acima de tudo do layout */
.modal-backdrop {
  z-index: 1045 !important;
}

.modal {
  z-index: 1050 !important;
}

/* O header sticky não pode criar stacking context acima do modal */
#sinagem-header {
  z-index: 1020 !important; /* abaixo do backdrop (1045) */
}

/* O sidebar também deve ficar abaixo do backdrop quando modal está aberto */
body.modal-open #sidebar-wrapper {
  z-index: 1020 !important;
}
