:root {
  --eco-primary: #28a745;
  --eco-secondary: #20c997;
  --eco-dark: #155724;
  --sidebar-width: 280px;
}

body {
  background-color: #f8f9fa;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: -280px;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(135deg, var(--eco-primary), var(--eco-secondary));
  color: white;
  transition: left 0.3s ease;
  z-index: 1050;
  overflow-y: auto;
}

.sidebar.active {
  left: 0;
}

.sidebar .nav-link {
  color: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  margin: 4px 0;
  padding: 12px 20px;
  transition: all 0.3s ease;
}

.sidebar .nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
  transform: translateX(5px);
}

.sidebar .nav-link.active {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
}

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1040;
  display: none;
}

.sidebar-overlay.active {
  display: block;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: 0;
  padding: 20px;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

.main-content.shifted {
  margin-left: var(--sidebar-width);
}

/* ===== NAVBAR ===== */
.navbar {
  background: white !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ===== CARDS ===== */
.card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

.stat-card {
  background: linear-gradient(135deg, var(--eco-primary), var(--eco-secondary));
  color: white;
}

.stat-card .card-body {
  position: relative;
  overflow: hidden;
}

.stat-card .card-body::before {
  content: "";
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  transform: scale(0);
  transition: transform 0.6s ease;
}

.stat-card:hover .card-body::before {
  transform: scale(2);
}

/* ===== BUTTONS ===== */
.btn-eco {
  background: linear-gradient(135deg, var(--eco-primary), var(--eco-secondary));
  border: none;
  color: white;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.btn-eco:hover {
  background: linear-gradient(135deg, var(--eco-secondary), var(--eco-primary));
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

/* ===== MELHORIAS PARA TABELAS RESPONSIVAS ===== */

/* Container responsivo melhorado */
.table-responsive {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
  position: relative;
  overflow-x: auto;
}

/* Indicador de scroll horizontal */
.table-responsive::after {
  content: "← Deslize para ver mais →";
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(40, 167, 69, 0.9);
  color: white;
  padding: 4px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  z-index: 10;
  display: none;
  animation: pulse 2s infinite;
  pointer-events: none;
}

@media (max-width: 768px) {
  .table-responsive::after {
    display: block;
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.7;
  }
  50% {
    opacity: 1;
  }
}

/* Scroll horizontal mais visível */
.table-responsive {
  scrollbar-width: thin;
  scrollbar-color: #28a745 #f8f9fa;
}

.table-responsive::-webkit-scrollbar {
  height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
  background: #f8f9fa;
  border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: #28a745;
  border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
  background: #1e7e34;
}

/* ===== TABLES ===== */
.table thead th {
  background-color: var(--eco-primary);
  color: white;
  border: none;
  font-weight: 600;
  padding: 15px;
  position: sticky;
  top: 0;
  z-index: 2;
}

.table tbody tr {
  transition: background-color 0.2s ease;
}

.table tbody tr:hover {
  background-color: rgba(40, 167, 69, 0.05);
}

/* ===== MELHORIAS ESPECÍFICAS PARA MOBILE ===== */

@media (max-width: 768px) {
  /* Reduzir padding das células */
  .table td,
  .table th {
    padding: 8px 6px !important;
    font-size: 0.85rem;
    vertical-align: middle;
  }

  /* Largura mínima das colunas */
  .table td,
  .table th {
    min-width: 80px;
    white-space: nowrap;
  }

  /* Primeira coluna (ID) fixa durante scroll horizontal */
  .table td:first-child,
  .table th:first-child {
    min-width: 50px;
    position: sticky;
    left: 0;
    background: white;
    z-index: 3;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
  }

  .table th:first-child {
    background: #28a745 !important;
    color: white;
    z-index: 4;
  }

  /* Classes específicas para colunas */
  .table .col-name {
    min-width: 120px;
    max-width: 150px;
    white-space: normal;
    word-wrap: break-word;
  }

  .table .col-phone {
    min-width: 110px;
    font-size: 0.8rem;
  }

  .table .col-address {
    min-width: 120px;
    max-width: 140px;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .table .col-actions {
    min-width: 100px;
    position: sticky;
    right: 0;
    background: white;
    z-index: 3;
    box-shadow: -2px 0 4px rgba(0, 0, 0, 0.1);
  }

  .table .col-actions .btn {
    padding: 4px 6px;
    margin: 1px;
    font-size: 0.75rem;
  }

  /* Esconder colunas menos importantes em telas muito pequenas */
  @media (max-width: 576px) {
    .table .hide-xs {
      display: none;
    }
  }

  /* Badges menores */
  .badge {
    font-size: 0.7rem;
    padding: 3px 6px;
  }

  /* Melhor contraste para texto pequeno */
  .table {
    color: #212529;
    font-weight: 500;
  }
}

/* ===== LAYOUT ALTERNATIVO EM CARDS PARA MOBILE ===== */

@media (max-width: 576px) {
  .mobile-card-view {
    display: none;
  }

  .mobile-card-view.active {
    display: block;
  }

  .mobile-card-view .card {
    margin-bottom: 1rem;
    border-left: 4px solid #28a745;
  }

  .mobile-card-view .card-body {
    padding: 0.75rem;
  }

  .mobile-card-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
  }

  .mobile-card-item strong {
    color: #28a745;
    margin-right: 0.5rem;
    min-width: 80px;
  }

  /* Toggle para alternar views */
  .view-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }
}

/* ===== MELHORIAS GERAIS DE UX ===== */

/* Highlight na linha ao tocar (mobile) */
@media (hover: none) {
  .table tbody tr:active {
    background-color: rgba(40, 167, 69, 0.1) !important;
  }
}

/* Loading skeleton para tabelas */
.table-skeleton {
  animation: skeleton-loading 1s infinite alternate;
}

@keyframes skeleton-loading {
  0% {
    opacity: 0.6;
  }
  100% {
    opacity: 1;
  }
}

/* ===== MODALS ===== */
.modal-header {
  background: linear-gradient(135deg, var(--eco-primary), var(--eco-secondary));
  color: white;
  border-radius: 12px 12px 0 0;
}

/* ===== FORMS ===== */
.form-control,
.form-select {
  border-radius: 8px;
  border: 2px solid #e9ecef;
  transition: border-color 0.3s ease;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--eco-primary);
  box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

/* ===== LOGIN ===== */
.login-container {
  height: 100vh;
  background: linear-gradient(135deg, var(--eco-primary), var(--eco-secondary));
}

.login-card {
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

/* ===== SECTIONS ===== */
.section {
  display: none;
}

.section.active {
  display: block;
}

/* ===== UTILITIES ===== */
.counting-mode-badge {
  position: absolute;
  top: 15px;
  right: 15px;
  font-size: 0.75rem;
}

.spinner-border-sm {
  width: 1rem;
  height: 1rem;
}

.alert-dismissible .btn-close {
  padding: 0.75rem 1rem;
}

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1060;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .main-content {
    padding: 10px;
  }

  .main-content.shifted {
    margin-left: 0;
  }

  .sidebar {
    width: 100vw;
    left: -100vw;
  }

  .sidebar.active {
    left: 0;
  }

  /* Navbar mais compacta no mobile */
  .navbar {
    padding: 0.5rem 1rem;
  }

  .navbar h4 {
    font-size: 1.1rem;
  }

  /* Cards de estatísticas em coluna única */
  .stat-card .card-body {
    padding: 1rem;
    text-align: center;
  }

  .stat-card h3 {
    font-size: 1.5rem;
  }
}

@media (max-width: 576px) {
  .main-content {
    padding: 5px;
  }

  /* Botões menores */
  .btn {
    font-size: 0.8rem;
    padding: 0.375rem 0.75rem;
  }

  /* Modais ocupam toda a tela */
  .modal-dialog {
    margin: 0;
    max-width: 100%;
    height: 100vh;
  }

  .modal-content {
    height: 100vh;
    border-radius: 0;
  }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section.active {
  animation: fadeIn 0.3s ease-in-out;
}

/* ===== SCROLLBAR ===== */
.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}
