/* VARIAVEIS E RESET */
:root {
  --primary-color: #4e73df;
  --primary-dark: #2e59d9;
  --secondary-color: #858796;
  --success-color: #1cc88a;
  --info-color: #36b9cc;
  --warning-color: #f6c23e;
  --danger-color: #e74a3b;
  --light-color: #f8f9fc;
  --dark-color: #5a5c69;
  --sidebar-width: 250px;
  --sidebar-collapsed-width: 80px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--light-color);
  color: #333;
  line-height: 1.6;
  max-width: 100%;
  overflow-x: hidden;
}

body.sidebar-open {
  overflow: hidden;
}

/*  LAYOUT PRINCIPAL */
.wrapper {
  display: flex;
  min-height: 100vh;
  max-width: 100%;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(
    180deg,
    var(--primary-color) 0%,
    var(--primary-dark) 100%
  );
  color: white;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  transition: all 0.3s;
  z-index: 1000;
}

.sidebar-overlay {
  display: none;
}

.sidebar-header {
  padding: 1.5rem;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h3 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.sidebar-header p {
  font-size: 0.85rem;
  opacity: 0.8;
}

.sidebar-menu {
  list-style: none;
  padding: 1rem 0;
}

.sidebar-menu li {
  margin-bottom: 0.5rem;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  transition: all 0.3s;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
}

.sidebar-menu i {
  font-size: 1.1rem;
  width: 25px;
  margin-right: 0.75rem;
}

/* CONTEUDO PRINCIPAL*/
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
  transition: all 0.3s;
}

/*  TOPBAR */

.topbar {
  background-color: white;
  padding: 1rem 2rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 999;
}

.topbar-left h4 {
  color: var(--dark-color);
  font-weight: 600;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.mobile-menu-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 4px;
  background-color: var(--primary-color);
  color: white;
  font-size: 1.1rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  transition: background-color 0.3s, box-shadow 0.3s;
}

.mobile-menu-toggle:hover,
.mobile-menu-toggle:focus {
  background-color: var(--primary-dark);
  outline: none;
  box-shadow: 0 0 0 3px rgba(78, 115, 223, 0.25);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
}

.user-details {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.user-role {
  font-size: 0.75rem;
  color: var(--secondary-color);
}

/*  CONTAINER DE CONTEUDO */
.content-container {
  padding: 2rem;
  max-width: 100%;
  min-width: 0;
}

.page-title {
  margin-bottom: 1.5rem;
}

.page-title h1 {
  font-size: 1.75rem;
  color: var(--dark-color);
  font-weight: 600;
}

/*   CARDS */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(400px, 100%), 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
  min-width: 0;
}

.dashboard-grid > * {
  min-width: 0;
}

.card {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s, box-shadow 0.3s;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.stat-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stat-info h3 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.stat-info p {
  color: var(--secondary-color);
  font-size: 0.9rem;
}

.stat-icon {
  font-size: 2.5rem;
  opacity: 0.3;
}

.card-primary {
  border-left: 4px solid var(--primary-color);
}
.card-success {
  border-left: 4px solid var(--success-color);
}
.card-info {
  border-left: 4px solid var(--info-color);
}
.card-warning {
  border-left: 4px solid var(--warning-color);
}
.card-danger {
  border-left: 4px solid var(--danger-color);
}

.icon-primary {
  color: var(--primary-color);
}
.icon-success {
  color: var(--success-color);
}
.icon-info {
  color: var(--info-color);
}
.icon-warning {
  color: var(--warning-color);
}
.icon-danger {
  color: var(--danger-color);
}

/* GRAFICOS */
.chart-card {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 2rem;
  min-width: 0;
}

.chart-card h2 {
  font-size: 1.25rem;
  color: var(--dark-color);
  margin-bottom: 1.5rem;
  font-weight: 600;
}

/* TABELAS*/
.table-card {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.table-card h2 {
  font-size: 1.25rem;
  color: var(--dark-color);
  margin-bottom: 1rem;
  font-weight: 600;
}

table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}

table thead {
  background-color: var(--light-color);
}

table th {
  padding: 0.75rem;
  text-align: left;
  font-weight: 600;
  color: var(--dark-color);
  border-bottom: 2px solid #dee2e6;
}

table td {
  padding: 0.75rem;
  border-bottom: 1px solid #dee2e6;
}

table tbody tr:hover {
  background-color: var(--light-color);
}

/*  FORMULARIOS */
.form-card {
  background: white;
  border-radius: 8px;
  padding: 2rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  max-width: 800px;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--dark-color);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #d1d3e2;
  border-radius: 4px;
  font-size: 0.95rem;
  transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

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

/*  BOTOES */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-dark);
}

.btn-success {
  background-color: var(--success-color);
  color: white;
}

.btn-danger {
  background-color: var(--danger-color);
  color: white;
}

.btn-warning {
  background-color: var(--warning-color);
  color: white;
}

.btn-info {
  background-color: var(--info-color);
  color: white;
}

.btn-secondary {
  background-color: var(--secondary-color);
  color: white;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.btn-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* BADGES */
.badge {
  display: inline-block;
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 12px;
  text-transform: uppercase;
}

.badge-success {
  background-color: var(--success-color);
  color: white;
}

.badge-warning {
  background-color: var(--warning-color);
  color: white;
}

.badge-danger {
  background-color: var(--danger-color);
  color: white;
}

.badge-primary {
  background-color: var(--primary-color);
  color: white;
}

.badge-secondary {
  background-color: var(--secondary-color);
  color: white;
}

/* ALERTS */
.alert {
  padding: 1rem 1.25rem;
  border-radius: 4px;
  margin-bottom: 1.5rem;
  border-left: 4px solid;
}

.alert-success {
  background-color: #d4edda;
  border-color: var(--success-color);
  color: #155724;
}

.alert-danger {
  background-color: #f8d7da;
  border-color: var(--danger-color);
  color: #721c24;
}

.alert-warning {
  background-color: #fff3cd;
  border-color: var(--warning-color);
  color: #856404;
}

.alert-info {
  background-color: #d1ecf1;
  border-color: var(--info-color);
  color: #0c5460;
}

/* SEARCH BAR */
.search-bar {
  margin-bottom: 1.5rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.search-bar form {
  min-width: 0;
}

.search-bar input,
.search-bar select {
  flex: 1;
  min-width: 250px;
  padding: 0.75rem;
  border: 1px solid #d1d3e2;
  border-radius: 4px;
}

/*  PAGINATION */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 2rem;
}

.pagination a,
.pagination span {
  padding: 0.5rem 1rem;
  border: 1px solid #d1d3e2;
  border-radius: 4px;
  text-decoration: none;
  color: var(--dark-color);
}

.pagination a:hover {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.pagination .active {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .wrapper {
    display: block;
  }

  .sidebar {
    width: min(82vw, var(--sidebar-width));
    transform: translateX(-100%);
    left: 0;
    top: 0;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.2);
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 999;
  }

  .sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  .main-content {
    margin-left: 0;
    width: 100%;
    min-width: 0;
  }

  .topbar {
    padding: 1rem;
    gap: 1rem;
    align-items: center;
  }

  .topbar-left h4 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-menu-toggle {
    display: inline-flex;
  }

  .content-container {
    padding: 1rem;
    max-width: 100%;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .card,
  .stat-card,
  .chart-card,
  .table-card,
  .form-card {
    width: 100%;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .chart-card {
    padding: 1rem;
  }

  .user-details {
    display: none;
  }

  .table-card {
    padding: 1rem;
    overflow-x: auto;
  }

  .d-flex.justify-between.align-center {
    flex-wrap: wrap;
    gap: 1rem;
  }

  .d-flex.justify-between.align-center .btn {
    width: 100%;
  }

  .search-bar form {
    width: 100%;
    flex-direction: column;
  }

  .search-bar input,
  .search-bar select,
  .search-bar .btn {
    width: 100%;
    min-width: 0;
  }

  .btn-group {
    flex-wrap: nowrap;
  }

  [id$="Modal"] > div {
    width: 100%;
    max-width: none !important;
    margin: 0 !important;
    padding: 1rem !important;
  }

  .form-card {
    max-width: none;
    padding: 1.25rem;
  }
}

@media (max-width: 480px) {
  .topbar-right {
    gap: 0.75rem;
  }

  .user-avatar {
    width: 36px;
    height: 36px;
  }

  .page-title h1,
  h1.page-title {
    font-size: 1.4rem;
  }

}

/*  LOGIN PAGE */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(
    135deg,
    var(--primary-color) 0%,
    var(--primary-dark) 100%
  );
}

.login-card {
  background: white;
  border-radius: 12px;
  padding: 3rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 400px;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header h1 {
  color: var(--dark-color);
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.login-header p {
  color: var(--secondary-color);
  font-size: 0.9rem;
}

.login-form .form-group {
  margin-bottom: 1.5rem;
}

.login-form button {
  width: 100%;
  padding: 0.875rem;
}

/* UTILITIES */
.text-center {
  text-align: center;
}
.text-right {
  text-align: right;
}
.mt-1 {
  margin-top: 0.5rem;
}
.mt-2 {
  margin-top: 1rem;
}
.mt-3 {
  margin-top: 1.5rem;
}
.mb-1 {
  margin-bottom: 0.5rem;
}
.mb-2 {
  margin-bottom: 1rem;
}
.mb-3 {
  margin-bottom: 1.5rem;
}
.d-flex {
  display: flex;
}
.justify-between {
  justify-content: space-between;
}
.align-center {
  align-items: center;
}
.gap-1 {
  gap: 0.5rem;
}
.gap-2 {
  gap: 1rem;
}

@media (max-width: 480px) {
  .login-container {
    padding: 1rem;
  }

  .login-card {
    padding: 2rem 1.25rem;
  }
}
