/* ========================================
   RESET E VARIÁVEIS GLOBAIS
   ======================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #6366f1; /* Indigo from the image vibe */
  --primary-dark: #4f46e5;
  --bg-sidebar: #ffffff;
  --bg-body: #f3f4f6;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --accent-purple: #8b5cf6;
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-orange: #f59e0b;
  --border-color: #e5e7eb;
  --card-shadow:
    0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --sidebar-width: 260px;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden; /* Prevent body scroll if we want internal scrolling */
}

a {
  text-decoration: none;
  color: inherit;
}

ul {
  list-style: none;
}

/* ========================================
   LAYOUT GRID
   ======================================== */
.dashboard-container {
  display: flex;
  height: 100vh;
}

/* ========================================
   SIDEBAR
   ======================================== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  flex-shrink: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 2rem;
  padding: 0 0.5rem;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 20px;
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.menu-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  padding-left: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
}

.nav-item:hover {
  background-color: #f3f4f6;
  color: var(--primary);
}

.nav-item.active {
  background-color: var(--primary);
  color: white;
  box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.4);
}

.nav-icon {
  margin-right: 12px;
  width: 20px;
  text-align: center;
  font-size: 1.1rem;
}

.spacer {
  flex-grow: 1;
}

.logout-btn {
  margin-top: auto;
  color: var(--accent-red);
}
.logout-btn:hover {
  background-color: #fef2f2;
  color: var(--accent-red);
}

/* ========================================
   MAIN CONTENT
   ======================================== */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info {
  text-align: right;
}

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

.user-role {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.avatar {
  width: 40px;
  height: 40px;
  background-color: #e5e7eb;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
}

/* ========================================
   WELCOME BANNER
   ======================================== */
.welcome-banner {
  background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
  border-radius: 16px;
  padding: 2rem;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3);
  position: relative;
  overflow: hidden;
}

.banner-content {
  z-index: 10;
  max-width: 70%;
}

.banner-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.banner-subtitle {
  opacity: 0.9;
  font-size: 1rem;
}

.banner-icon {
  background: rgba(255, 255, 255, 0.2);
  width: 60px;
  height: 60px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  backdrop-filter: blur(5px);
}

/* ========================================
   STATS GRID & CARDS
   ======================================== */
.stats-grid {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.stat-card {
  flex: 1;
  min-width: 200px;
  background: white;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s;
  border: 1px solid white;
  position: relative; /* Needed for split card desktop styling */
}

/* SPLIT CARD STYLES (For Patients/Procedures) */
.stat-content-text {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.stat-content-icon {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
}

/* Shared Stat Styles */
.stat-card:hover {
  transform: translateY(-2px);
  border-color: #e5e7eb;
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 1rem;
}

.stat-title {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-right: 0.5rem; /* space from icon */
}

.stat-icon-bg {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background-color: #f5f3ff; /* Light purple background */
  color: var(--primary); /* Primary purple color for icon */
  transition: all 0.2s ease;
}

.stat-icon-bg:hover {
  background-color: var(--primary);
  color: white;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.stat-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ========================================
   BOTTOM SECTIONS
   ======================================== */
.bottom-section {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
}

.card-panel {
  background: white;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.panel-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Custom list styling for tasks */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.task-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  border-radius: 8px;
  background-color: #f9fafb;
  border-left: 4px solid var(--border-color);
}

.task-item.priority-high {
  border-left-color: var(--accent-red);
}
.task-item.priority-medium {
  border-left-color: var(--accent-orange);
}
.task-item.priority-normal {
  border-left-color: var(--accent-green);
}

.task-content {
  flex: 1;
}

.task-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
}
.task-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.status-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-blue {
  background: #eff6ff;
  color: var(--accent-blue);
}
.badge-green {
  background: #ecfdf5;
  color: var(--accent-green);
}

/* Birthday bubbles */
.birthday-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.birthday-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bday-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fbc2eb 0%, #a6c1ee 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: white;
  font-weight: bold;
}

/* Mobile Menu Button - Hidden on desktop */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-main);
  margin-right: 1rem;
  padding: 0.5rem;
  line-height: 1;
}

/* Overlay for sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
  display: block;
  opacity: 1;
}

body.no-scroll {
  overflow: hidden;
}

/* ========================================
   RESPONSIVO
   ======================================== */
@media (max-width: 1024px) {
  .stats-grid {
    gap: 1rem;
  }
}

@media (max-width: 768px) {
  /* Allow scrolling on mobile body */
  body {
    height: auto;
    overflow-y: auto;
  }

  /* Show Mobile Menu Button */
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Sidebar - Off-canvas functionality */
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px; /* Hide sidebar */
    width: 280px;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    padding: 1.5rem 1rem;
    border-right: none;
    border-bottom: none;
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
  }

  .sidebar.open {
    left: 0; /* Show sidebar */
  }

  /* Restore Sidebar Elements */
  .sidebar-header,
  .menu-label,
  .spacer,
  .logout-btn {
    display: flex !important;
  }
  .sidebar-header {
    margin-bottom: 2rem;
  }

  /* Reset Nav Menu */
  .nav-menu {
    flex-direction: column;
    overflow-x: visible;
    padding-bottom: 0;
    gap: 0.5rem;
  }

  .nav-item {
    flex-direction: row;
    padding: 0.75rem 1rem;
    font-size: inherit;
    text-align: left;
    white-space: normal;
    justify-content: flex-start;
    flex: none;
  }

  .nav-icon {
    margin-right: 12px;
    margin-bottom: 0;
    font-size: 1.1rem;
  }

  /* Top Bar - Mobile Layout */
  .top-bar {
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .page-title {
    display: block;
    width: 100%;
    order: 3;
    margin-top: 0.5rem;
    font-size: 1.25rem;
  }

  /* Main Content */
  .main-content {
    padding: 1rem;
    width: 100%;
  }

  .top-bar {
    position: sticky;
    top: 0;
    background: var(--bg-body); /* Ensure background is solid */
    z-index: 10;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05); /* Subtle separator */
  }

  .bottom-section {
    grid-template-columns: 1fr;
  }

  /* Responsive Tables (Card View) */
  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
  }

  thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  tr {
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
  }

  td {
    border: none;
    border-bottom: 1px solid #eee;
    position: relative;
    padding-left: 40%;
    display: flex;
    align-items: center;
    min-height: 40px;
    text-align: right;
    justify-content: flex-end; /* Content to right */
  }

  td:before {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 1rem;
    width: 35%;
    padding-right: 10px;
    white-space: nowrap;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    content: attr(data-label);
    text-align: left;
  }

  td:last-child {
    border-bottom: none;
    padding-left: 1rem; /* Actions usually don't need label */
    justify-content: flex-end;
  }

  /* Hide label for actions row usually if it is named 'Ações' or similar */
  td[data-label="Ações"]:before,
  td[data-label="Actions"]:before {
    display: none;
  }

  /* Adjust Search Bar */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .search-container {
    margin-right: 0 !important;
    max-width: 100%;
  }

  .search-box {
    max-width: 100% !important;
  }

  .btn {
    width: 100%;
  }

  /* Charts */
  .charts-container {
    grid-template-columns: 1fr !important;
  }
}

/* ========================================
   TABLES & LISTS
   ======================================== */
table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  margin-bottom: 2rem;
}

th,
td {
  padding: 1rem 1.5rem;
  text-align: left;
}

th {
  background-color: #f9fafb;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
}

td {
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.95rem;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background-color: #f9fafb;
}

/* ========================================
   FORMS & INPUTS
   ======================================== */
.form-group {
  margin-bottom: 1.5rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-main);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.95rem;
  transition: all 0.2s;
  font-family: inherit;
  background-color: white;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Remove Autofill Blue Background */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus, 
input:-webkit-autofill:active{
    -webkit-box-shadow: 0 0 0 30px white inset !important;
    -webkit-text-fill-color: var(--text-main) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  font-size: 0.9rem;
  text-decoration: none;
  gap: 0.5rem;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
  box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
  background-color: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: white;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: #f9fafb;
  border-color: #d1d5db;
}

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

.btn-danger:hover {
  background-color: #dc2626;
}

/* ========================================
   UTILITIES & CONTAINERS
   ======================================== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.search-container {
  margin-bottom: 1.5rem;
}

.container-card {
  background: white;
  padding: 2rem;
  border-radius: 16px;
  box-shadow: var(--card-shadow);
}

/* Action Buttons (Standardized Grey) */
.action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #6b7280; /* Standardized grey color */
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.action-btn:hover {
  color: #4f46e5; /* Primary color on hover */
  background-color: #f3f4f6;
}

.action-link-grey {
  color: #6b7280;
  text-decoration: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 6px;
  transition: all 0.2s;
}
.action-link-grey:hover {
  color: #4f46e5;
  background-color: #f3f4f6;
}

/* Circular Action Buttons Pattern */
.action-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #d1d5db;
  background-color: white;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.action-icon-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.action-icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
}

/* Variants */
.action-icon-btn.complete {
  color: #10b981;
  border-color: #10b981;
}
.action-icon-btn.complete:hover {
  background-color: #ecfdf5;
  color: #059669;
}

.action-icon-btn.edit {
  color: #3b82f6;
  border-color: #3b82f6;
}
.action-icon-btn.edit:hover {
  background-color: #eff6ff;
  color: #2563eb;
}

.action-icon-btn.delete {
  color: #ef4444;
  border-color: #ef4444;
}
.action-icon-btn.delete:hover {
  background-color: #fef2f2;
  color: #dc2626;
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
  .sidebar, .mobile-menu-btn, .user-profile, .btn, .no-print {
    display: none !important;
  }
  .dashboard-container {
    display: block;
    height: auto;
  }
  .main-content {
    margin: 0;
    padding: 0;
    width: 100%;
    overflow: visible;
  }
  body {
    background: white;
    height: auto;
    overflow: visible;
  }
  .report-card, .chart-container {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #eee;
  }
}
