/*
 * SysUBS - Sistema de Vigilância de Unidades Básicas de Saúde
 * Modern Application Styles
 */

/* ===== CSS Variables - Modern Color Palette ===== */
:root {
  /* Primary Colors - Deep Blue/Slate */
  --primary-50: #f8fafc;
  --primary-100: #f1f5f9;
  --primary-200: #e2e8f0;
  --primary-300: #cbd5e1;
  --primary-400: #94a3b8;
  --primary-500: #64748b;
  --primary-600: #475569;
  --primary-700: #334155;
  --primary-800: #1e293b;
  --primary-900: #0f172a;
  
  /* Accent Colors - Modern Blue */
  --accent-50: #eff6ff;
  --accent-100: #dbeafe;
  --accent-200: #bfdbfe;
  --accent-300: #93c5fd;
  --accent-400: #60a5fa;
  --accent-500: #3b82f6;
  --accent-600: #2563eb;
  --accent-700: #1d4ed8;
  --accent-800: #1e40af;
  --accent-900: #1e3a8a;
  
  /* Success Green */
  --success-500: #22c55e;
  --success-600: #16a34a;
  
  /* Warning Orange */
  --warning-500: #f59e0b;
  --warning-600: #d97706;
  
  /* Danger Red */
  --danger-500: #ef4444;
  --danger-600: #dc2626;
  
  /* Sidebar */
  --sidebar-bg: linear-gradient(180deg, var(--primary-900) 0%, var(--primary-800) 100%);
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 0px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;
  
  /* Legacy Support */
  --colorbasic: var(--primary-800);
  --colorbasic2: var(--accent-600);
  --colortext: #ffffff;
  --colortext-menu: #ffffff;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--primary-100);
  color: var(--primary-800);
  line-height: 1.6;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  color: var(--primary-900);
  margin-bottom: 0.5rem;
}

p {
  color: var(--primary-600);
  margin-bottom: 1rem;
}

/* ===== Links ===== */
a {
  color: var(--accent-600);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-700);
}

/* ===== App Layout ===== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  color: white;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform var(--transition-normal);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar.collapsed {
  transform: translateX(-100%);
}

/* Sidebar Header */
.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: white;
  text-decoration: none;
}

.sidebar-brand:hover {
  color: white;
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--accent-500), var(--accent-600));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: var(--shadow-md);
}

.brand-text {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary-400);
  padding: 1.25rem 1.5rem 0.5rem;
  margin-top: 0.5rem;
}

.nav-item {
  margin: 0.125rem 0.75rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--primary-300);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  font-size: 0.9rem;
  font-weight: 500;
}

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

.nav-link.active {
  background: linear-gradient(135deg, var(--accent-600), var(--accent-700));
  color: white;
  box-shadow: var(--shadow-md);
}

.nav-icon {
  width: 20px;
  text-align: center;
  font-size: 1rem;
  opacity: 0.9;
}

/* Submenu */
.has-submenu .nav-link {
  justify-content: flex-start;
}

.submenu-arrow {
  margin-left: auto;
  font-size: 0.65rem;
  transition: transform var(--transition-fast);
}

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

.submenu {
  list-style: none;
  padding: 0.25rem 0 0.25rem 1rem;
  margin: 0;
}

.submenu .nav-link {
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  color: var(--primary-400);
}

.submenu .nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.submenu .nav-icon {
  font-size: 0.8rem;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: auto;
}

.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem;
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

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

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition-normal);
}

.sidebar.collapsed + .main-content {
  margin-left: 0;
}

/* Top Navbar */
.top-navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: white;
  border-bottom: 1px solid var(--primary-200);
  box-shadow: var(--shadow-sm);
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--primary-100);
  border: none;
  border-radius: var(--radius-md);
  color: var(--primary-600);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
  background: var(--accent-100);
  color: var(--accent-600);
}

.breadcrumb {
  font-size: 0.875rem;
  background: none;
  padding: 0;
}

.breadcrumb-item a {
  color: var(--primary-500);
}

.breadcrumb-item.active {
  color: var(--primary-700);
}

/* User Dropdown */
.user-dropdown {
  position: relative;
}

.user-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--primary-50);
  border: 1px solid var(--primary-200);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.user-btn:hover {
  background: var(--primary-100);
  border-color: var(--primary-300);
}

.user-btn::after {
  display: none;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent-500), var(--accent-600));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.875rem;
}

.user-name {
  font-weight: 500;
  color: var(--primary-700);
  font-size: 0.875rem;
}

/* Page Content */
.page-content {
  flex: 1;
  padding: 1.5rem;
}

/* Main Footer */
.main-footer {
  padding: 1rem 1.5rem;
  background: white;
  border-top: 1px solid var(--primary-200);
  font-size: 0.8rem;
}

/* ===== Sidebar Overlay (Mobile) ===== */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ===== Buttons ===== */
.btn {
  font-weight: 500;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.colorprimarybtn,
.btn-primary {
  background: linear-gradient(135deg, var(--accent-500), var(--accent-600));
  border: none;
  color: white;
  box-shadow: var(--shadow-sm);
}

.colorprimarybtn:hover,
.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-600), var(--accent-700));
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  color: white;
}

a.colorprimarybtn:link,
a.colorprimarybtn:visited {
  text-decoration: none;
  color: white;
}

.btn-success {
  background: linear-gradient(135deg, var(--success-500), var(--success-600));
  border: none;
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger-500), var(--danger-600));
  border: none;
}

.btn-outline-primary {
  border: 2px solid var(--accent-500);
  color: var(--accent-600);
  background: transparent;
}

.btn-outline-primary:hover {
  background: var(--accent-500);
  color: white;
}

/* ===== Cards ===== */
.card {
  background: white;
  border: 1px solid var(--primary-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  background: var(--primary-50);
  border-bottom: 1px solid var(--primary-200);
  padding: 1rem 1.25rem;
  font-weight: 600;
}

.card-body {
  padding: 1.25rem;
}

.card-menu {
  background: linear-gradient(135deg, var(--accent-500), var(--accent-600));
  color: white;
}

/* ===== Forms ===== */
.form-control,
.form-select {
  border: 1px solid var(--primary-300);
  border-radius: var(--radius-md);
  padding: 0.625rem 0.875rem;
  transition: all var(--transition-fast);
  font-size: 0.9rem;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--accent-400);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  outline: none;
}

.form-label {
  font-weight: 500;
  color: var(--primary-700);
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
}

.required:after {
  content: " *";
  color: var(--danger-500);
  font-weight: 600;
}

/* ===== Tables ===== */
.table {
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 0;
}

.table thead th {
  background: var(--primary-50);
  border-bottom: 2px solid var(--primary-200);
  color: var(--primary-700);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  padding: 0.875rem 1rem;
  white-space: nowrap;
}

.table tbody td {
  padding: 0.875rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--primary-100);
}

.table tbody tr:hover {
  background: var(--primary-50);
}

.table-responsive {
  border-radius: var(--radius-lg);
  border: 1px solid var(--primary-200);
  background: white;
}

/* Table Actions */
table.table td a.view {
  color: var(--accent-500);
}

table.table td a.edit {
  color: var(--warning-500);
}

table.table td a.delete {
  color: var(--danger-500);
}

table.table td a.student {
  color: var(--success-500);
}

/* ===== Pagination ===== */
.pagination {
  margin-top: 1.5rem;
  gap: 0.25rem;
}

.page-link {
  border: 1px solid var(--primary-200);
  color: var(--primary-600);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.875rem;
  font-weight: 500;
  margin: 0 0.125rem;
}

.page-link:hover {
  background: var(--primary-100);
  border-color: var(--primary-300);
  color: var(--primary-700);
}

.page-item.active .page-link {
  background: linear-gradient(135deg, var(--accent-500), var(--accent-600));
  border-color: transparent;
  color: white;
}

/* ===== Page Header ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--primary-200);
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-900);
  margin: 0;
}

/* ===== Alerts ===== */
.alert {
  border-radius: var(--radius-md);
  border: none;
  padding: 1rem 1.25rem;
}

.alert-success {
  background: #dcfce7;
  color: #166534;
}

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

.alert-warning {
  background: #fef3c7;
  color: #92400e;
}

.alert-info {
  background: var(--accent-100);
  color: var(--accent-800);
}

/* ===== Login Page ===== */
.login-container {
  max-width: 420px;
  margin: 60px auto;
  padding: 2.5rem;
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
}

.login-container h2 {
  text-align: center;
  margin-bottom: 2rem;
  color: var(--primary-900);
  font-weight: 700;
}

/* ===== Nested Fields (Cocoon) ===== */
.nested-fields {
  padding: 1.25rem;
  margin-bottom: 1rem;
  border: 1px solid var(--primary-200);
  border-radius: var(--radius-lg);
  background: var(--primary-50);
}

/* ===== Maps ===== */
#mapa {
  height: 400px;
  width: 400px;
  border-radius: var(--radius-lg);
}

#mapa-menu {
  height: 93%;
  width: 100%;
  min-height: 200px;
  border-radius: var(--radius-lg);
}

/* ===== Table Widths ===== */
.min-width-table {
  min-width: 600px;
}

.min-width-td {
  min-width: 80px;
}

.min-width-td-2 {
  min-width: 85px;
}

.min-width-td-lg {
  min-width: 300px;
}

.min-width-td-md {
  min-width: 200px;
}

/* ===== Sticky Columns ===== */
.sticky-col {
  position: -webkit-sticky;
  position: sticky;
  background-color: white;
}

.first-col {
  width: 150px;
  min-width: 150px;
  max-width: 150px;
  left: 0px;
}

.second-col {
  width: 250px;
  min-width: 250px;
  max-width: 250px;
  left: 150px;
}

/* ===== Number Input ===== */
input[type=number] {
  -moz-appearance: textfield;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ===== Password Field ===== */
.field-icon {
  float: right;
  margin-right: 8px;
  margin-top: -32px;
  position: relative;
  z-index: 2;
  cursor: pointer;
  color: var(--primary-400);
}

/* ===== Error Messages ===== */
.mensagem-erro-cabecalho {
  color: var(--danger-500);
  font-weight: 500;
}

/* ===== Select2 Customization ===== */
.select2-container--bootstrap-5 .select2-selection {
  border-radius: var(--radius-md);
  border-color: var(--primary-300);
}

.select2-container--bootstrap-5 .select2-selection:focus {
  border-color: var(--accent-400);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ===== Toastr Customization ===== */
.toast-success {
  background-color: var(--success-500) !important;
}

.toast-error {
  background-color: var(--danger-500) !important;
}

.toast-warning {
  background-color: var(--warning-500) !important;
}

.toast-info {
  background-color: var(--accent-500) !important;
}

/* ===== Simple Calendar ===== */
.simple-calendar .prev-month,
.simple-calendar .next-month,
.simple-calendar .day {
  background-color: white;
  border-radius: var(--radius-sm);
}

/* ===== Menu Icons ===== */
.menuicone {
  margin-top: 25px;
  text-align: center;
}

.menuprincipal {
  background: linear-gradient(135deg, var(--accent-500), var(--accent-600)) !important;
  margin-bottom: 25px;
  border-radius: var(--radius-lg);
}

.menucard a:hover {
  color: white;
}

.menucard {
  text-align: center;
}

/* ===== Responsive ===== */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.active {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .top-navbar {
    padding: 0.75rem 1rem;
  }
  
  .page-content {
    padding: 1rem;
  }
}

@media (max-width: 576px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .page-header h2 {
    font-size: 1.25rem;
  }
  
  .btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
}

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

.page-content > .container-fluid {
  animation: fadeIn 0.3s ease-out;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--primary-100);
}

::-webkit-scrollbar-thumb {
  background: var(--primary-300);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-400);
}

/* Sidebar scrollbar */
.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

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


