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

:root {
  --primary: #ff0000;
  --primary-dark: #b30000;
  --secondary: #64748b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
}

/* Login Page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #ec6868 0%, #c90000 100%);
  padding: 20px;
}

.login-container {
  width: 100%;
  max-width: 450px;
  padding: 20px;
}

.login-box {
  background: white;
  border-radius: 12px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
  .login-box {
    padding: 30px 20px;
  }
  
  .login-header h1 {
    font-size: 24px;
  }
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.login-header h1 {
  font-size: 28px;
  color: var(--primary);
  margin-bottom: 8px;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 14px;
}

.login-form .form-group {
  margin-bottom: 20px;
}

.login-form label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-primary);
}

.login-form input {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.3s;
}

.login-form input:focus {
  outline: none;
  border-color: var(--primary);
}

.login-footer {
  text-align: center;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
}

/* Dashboard Layout */
.dashboard-container {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: 300px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  overflow: hidden;
  transition: width 0.3s ease, transform 0.3s ease;
  z-index: 9999;
}

.sidebar.collapsed {
  width: 70px;
}

.sidebar.collapsed .sidebar-header h2 span,
.sidebar.collapsed .nav-item span:not(.icon),
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .user-details,
.sidebar.collapsed .btn-logout {
  display: none;
}

.sidebar.collapsed .sidebar-header h2,
.sidebar.collapsed .nav-item {
  justify-content: center;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.sidebar-header h2 {
  color: white;
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-toggle-btn {
  position: fixed;
  left: 285px;
  top: 28px;
  width: 30px;
  height: 30px;
  background: var(--sidebar-bg);
  border: 3px solid white;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  
  align-items: center;
  justify-content: center;
  font-size: 20px;
  
  transition: all 0.3s;
  z-index: 10000;
}

.sidebar-toggle-btn:hover {
  background: var(--secondary);
  transform: scale(1.1);
}

body.sidebar-collapsed .sidebar-toggle-btn {
  left: 55px;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

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

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

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

.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: all 0.2s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.nav-item.active {
  background: rgba(79, 70, 229, 0.2);
  color: white;
  border-left: 3px solid var(--primary);
}

.nav-item .icon {
  margin-right: 12px;
  font-size: 18px;
}

.nav-section {
  margin-top: 20px;
}

.nav-section-title {
  padding: 8px 20px;
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.5px;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  gap: 12px;
}

.sidebar.collapsed .user-info {
  justify-content: center;
}

.sidebar.collapsed .user-avatar {
  margin-right: 0;
}

.user-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  font-size: 20px;
}

.user-details {
  flex: 1;
}

.user-name {
  color: white;
  font-weight: 500;
  font-size: 14px;
}

.user-role {
  color: var(--sidebar-text);
  font-size: 12px;
}

.btn-logout {
  display: block;
  width: 100%;
  padding: 8px;
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  text-align: center;
  border-radius: 6px;
  text-decoration: none;
  font-size: 14px;
  transition: background 0.2s;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.3);
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 300px;
  padding: 40px;
  width: calc(100% - 300px);
  max-width: 100%;
  transition: margin-left 0.3s ease, width 0.3s ease;
}

.sidebar.collapsed ~ .main-content,
body.sidebar-collapsed .main-content {
  margin-left: 70px;
  width: calc(100% - 70px);
}

.content-header h1 {
  font-size: 32px;
  margin-bottom: 8px;
}

.content-header p {
  color: var(--text-secondary);
  font-size: 16px;
}

.content-body {
  margin-top: 40px;
}

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

@media (max-width: 1400px) {
  .cards-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1024px) {
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border: 1px solid var(--border);
}

.card:hover {
  transform: translateY(-8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  border-color: var(--primary);
}

.card-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #ec6868 0%, #c90000 100%);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(255, 0, 0, 0.2);
}

.card-icon svg {
  width: 48px;
  height: 48px;
  color: white;
}

.card-content {
  width: 100%;
}

.card-content h3 {
  font-size: 22px;
  margin-bottom: 12px;
  color: var(--text-primary);
  font-weight: 600;
}

.card-content p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
  line-height: 1.5;
}

.card-link {
  display: inline-block;
  background: var(--primary);
  color: white;
  padding: 12px 32px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: all 0.2s;
}

.card-link:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
}

.card-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 24px;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

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

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

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

.btn-secondary:hover {
  background: #475569;
}

.btn-block {
  width: 100%;
  text-align: center;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  transition: transform 0.2s;
  vertical-align: middle;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  transform: scale(1.2);
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 14px;
}

.alert-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* Admin Content */
.admin-content {
  width: 100%;
  max-width: 100%;
}

.content-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.content-header-bar h1 {
  font-size: 28px;
}

/* Tables */
.table-container {
  background: var(--bg-card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

.data-table thead {
  background: var(--bg-main);
}

.data-table th {
  padding: 16px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.data-table td {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.data-table tbody tr:hover {
  background: var(--bg-main);
}

.data-table .actions {
  display: flex;
  gap: 8px;
}

/* Forms */
.form-container {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  max-width: 600px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.3s;
}

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

.form-group small {
  display: block;
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 12px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.checkbox-label input {
  width: auto;
  margin-right: 8px;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-admin {
  background: #dbeafe;
  color: #1e40af;
}

.badge-user {
  background: #e0e7ff;
  color: #4338ca;
}

.badge-success {
  background: #d1fae5;
  color: #065f46;
}

.badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

/* Admin Dashboard */
.admin-dashboard {
  max-width: 100%;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin: 30px 0;
}

.stat-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stat-icon {
  font-size: 48px;
  margin-right: 20px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  color: var(--text-secondary);
  font-size: 14px;
}

.quick-actions {
  margin-top: 40px;
}

.quick-actions h2 {
  margin-bottom: 20px;
}

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

.action-btn {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  text-decoration: none;
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all 0.2s;
}

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

.action-btn .icon {
  font-size: 32px;
  display: block;
  margin-bottom: 8px;
}

/* Permissions Matrix */
.permissions-info {
  background: #dbeafe;
  border: 1px solid #93c5fd;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
  color: #1e40af;
}

.permissions-matrix {
  background: var(--bg-card);
  border-radius: 12px;
  overflow-x: auto;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

.matrix-table thead {
  background: var(--bg-main);
}

.matrix-table th {
  padding: 16px;
  text-align: center;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
}

.matrix-table th:first-child {
  text-align: left;
}

.module-header {
  min-width: 120px;
}

.module-icon {
  font-size: 24px;
  margin-bottom: 4px;
}

.module-name {
  font-size: 12px;
  color: var(--text-secondary);
}

.matrix-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.dept-name {
  font-weight: 500;
}

.checkbox-cell {
  text-align: center;
}

.checkbox-container {
  display: inline-block;
  position: relative;
  cursor: pointer;
}

.checkbox-container input {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

/* Error Pages */
.error-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-main);
}

.error-content {
  text-align: center;
  max-width: 600px;
  padding: 40px;
}

.error-content h1 {
  font-size: 120px;
  color: var(--primary);
  margin-bottom: 20px;
}

.error-content h2 {
  font-size: 32px;
  margin-bottom: 16px;
}

.error-content p {
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.error-details {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  padding: 16px;
  text-align: left;
  font-size: 12px;
  color: #991b1b;
  margin: 20px 0;
  overflow-x: auto;
}

/* Ícones SVG */
.icon-svg {
  width: 20px;
  height: 20px;
  display: inline-block;
  vertical-align: middle;
}

.logo-icon {
  width: 28px;
  height: 28px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}

.card-icon .icon-svg {
  width: 48px;
  height: 48px;
}

.card-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.card-icon svg {
  width: 48px;
  height: 48px;
}

/* Responsive */
@media (max-width: 1024px) {
  .cards-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 280px;
    transform: translateX(-100%);
    z-index: 1001;
  }
  
  .sidebar.active {
    transform: translateX(0);
  }
  
  .sidebar.collapsed {
    width: 280px;
  }
  
  .sidebar-toggle-btn {
    display: none !important;
  }
  
  .main-content,
  .sidebar.collapsed ~ .main-content,
  body.sidebar-collapsed .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    padding: 70px 20px 20px 20px;
  }
  
  .cards-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }
  
  .card {
    padding: 24px;
  }
  
  .card-icon {
    width: 60px;
    height: 60px;
  }
  
  .card-icon svg {
    width: 36px;
    height: 36px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .content-header-bar {
    flex-direction: column;
    gap: 15px;
    align-items: flex-start !important;
  }
  
  .content-header h1 {
    font-size: 24px;
  }
  
  .data-table {
    font-size: 11px;
  }
  
  .data-table th,
  .data-table td {
    padding: 8px 6px;
  }
  
  .form-container {
    padding: 20px;
  }
  
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .matrix-table {
    font-size: 11px;
  }
  
  .matrix-table th,
  .matrix-table td {
    padding: 8px;
  }
  
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1002;
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 22px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    width: 48px;
    height: 48px;
  }
  
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
  }
  
  .sidebar-overlay.active {
    display: block;
  }
  
  .btn {
    width: 100%;
    text-align: center;
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  .form-actions .btn {
    width: 100%;
  }
  
  .badge {
    font-size: 10px;
    padding: 3px 8px;
  }
  
  .actions-grid {
    grid-template-columns: 1fr;
  }
  
  .action-btn {
    padding: 16px;
  }
  
  .stat-card {
    flex-direction: column;
    text-align: center;
  }
  
  .stat-icon {
    margin-right: 0;
    margin-bottom: 10px;
  }
  
  .permissions-matrix {
    font-size: 11px;
  }
  
  .module-header {
    min-width: 80px;
  }
  
  .module-icon {
    font-size: 18px;
  }
  
  .checkbox-container input {
    width: 16px;
    height: 16px;
  }
}

@media (min-width: 769px) {
  .mobile-menu-btn {
    display: none !important;
  }
  
  .sidebar-overlay {
    display: none !important;
  }
}

/* Admin Header com Settings Icon */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.admin-header h1 {
  font-size: 32px;
  margin: 0;
}

.settings-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border-radius: 50%;
  transition: all 0.3s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.settings-icon:hover {
  background: var(--primary);
  transform: rotate(90deg) scale(1.1);
  box-shadow: 0 4px 12px rgba(255, 0, 0, 0.3);
}

.settings-icon .icon-svg {
  width: 24px;
  height: 24px;
  color: var(--text-primary);
}

.settings-icon:hover .icon-svg {
  color: white;
}

/* Stat Cards Clicáveis */
.stat-card.clickable {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: all 0.3s;
  border: 1px solid var(--border);
}

.stat-card.clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-color: var(--primary);
}

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

.stat-card .stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 20px;
}

.stat-card .stat-icon .icon-svg {
  width: 48px;
  height: 48px;
  color: var(--primary);
}

/* Action Buttons com SVG Icons */
.action-btn .icon .icon-svg {
  width: 32px;
  height: 32px;
  color: var(--primary);
}

/* Ícones SVG pequenos para ações */
.icon-svg-small {
  width: 18px;
  height: 18px;
  display: inline-block;
  vertical-align: middle;
}

.btn-icon .icon-svg-small {
  color: var(--text-secondary);
  transition: color 0.2s;
}

.btn-icon:hover .icon-svg-small {
  color: var(--primary);
}

/* Permissions List */
.permissions-list {
  background: var(--bg-card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.permissions-list .data-table tbody tr:hover {
  background: var(--bg-main);
}

/* Checkbox desabilitado */
.checkbox-container input:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.checkbox-container input:disabled ~ .checkmark {
  background-color: #e2e8f0;
  cursor: not-allowed;
}

/* Responsive para Admin Header */
@media (max-width: 768px) {
  .admin-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
  
  .admin-header h1 {
    font-size: 24px;
  }
  
  .settings-icon {
    width: 36px;
    height: 36px;
  }
  
  .settings-icon .icon-svg {
    width: 20px;
    height: 20px;
  }
}
