@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  /* =========================================
     1. TOKENS: COLORS
     ========================================= */
  /* Primary: Blue (Moraes) */
  --c-primary: #005CA9;
  --c-primary-hover: #004b8a;
  --c-primary-light: rgba(0, 92, 169, 0.1);
  --c-primary-border: rgba(0, 92, 169, 0.3);

  /* Secondary: Orange (Moraes) */
  --c-secondary: #F79E00;
  --c-secondary-hover: #d98a00;
  --c-secondary-light: rgba(247, 158, 0, 0.1);

  /* Surfaces & Backgrounds */
  --c-bg: #F4F6F8;             /* Light gray background for app */
  --c-surface: #FFFFFF;        /* White cards */
  --c-surface-secondary: #F8FAFC; /* Slightly off-white for headers/footers of cards */
  --c-surface-hover: #F1F5F9;

  /* Borders */
  --c-border: #E2E8F0;
  --c-border-hover: #CBD5E1;

  /* Typography */
  --c-text-primary: #0F172A;   /* Headings, main text */
  --c-text-secondary: #475569; /* Subtitles, labels */
  --c-text-muted: #64748B;     /* Helper text, icons */
  --c-text-faint: #94A3B8;     /* Placeholders */
  --c-text-inverse: #FFFFFF;   /* Text on primary buttons */

  /* Semantic / Feedback */
  --c-success: #10B981;
  --c-success-light: #D1FAE5;
  --c-warning: #F59E0B;
  --c-warning-light: #FEF3C7;
  --c-danger: #EF4444;
  --c-danger-light: #FEE2E2;
  --c-info: #3B82F6;
  --c-info-light: #DBEAFE;

  /* =========================================
     2. TOKENS: SPACING (Base 4px/8px)
     ========================================= */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* =========================================
     3. TOKENS: BORDER RADIUS
     ========================================= */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-full: 9999px;

  /* =========================================
     4. TOKENS: SHADOWS (Subtle SaaS Shadows)
     ========================================= */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
  --shadow-float: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
}

/* =========================================
   BASE RESET & TYPOGRAPHY
   ========================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', sans-serif;
  background-color: var(--c-bg);
  color: var(--c-text-primary);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbar for a cleaner SaaS look */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--c-border-hover);
  border-radius: var(--r-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--c-text-muted);
}

/* Text Utilities */
h1, h2, h3, h4, h5, h6 { color: var(--c-text-primary); font-weight: 700; letter-spacing: -0.01em; }
.text-display { font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; }
.text-h1 { font-size: 1.5rem; font-weight: 800; }
.text-h2 { font-size: 1.25rem; font-weight: 700; }
.text-h3 { font-size: 1.125rem; font-weight: 600; }
.text-body { font-size: 0.875rem; }
.text-body-small { font-size: 0.8125rem; }
.text-caption { font-size: 0.75rem; }
.text-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }

.font-semi { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extra { font-weight: 800; }

.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }

.text-muted { color: var(--c-text-muted); }
.text-secondary { color: var(--c-text-secondary); }
.text-faint { color: var(--c-text-faint); }
.text-primary { color: var(--c-primary); }
.text-success { color: var(--c-success); }
.text-danger { color: var(--c-danger); }
.text-warning { color: var(--c-warning); }
.text-center { text-align: center; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* =========================================
   LAYOUT UTILITIES
   ========================================= */
.flex { display: flex; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-5 { gap: var(--sp-5); }
.gap-6 { gap: var(--sp-6); }
.gap-8 { gap: var(--sp-8); }

.ml-auto { margin-left: auto; }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mb-1 { margin-bottom: var(--sp-1); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mb-8 { margin-bottom: var(--sp-8); }
.w-full { width: 100%; }
.h-full { height: 100%; }

/* Grid */
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1024px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* Dashboard Layout Specific */
.dashboard-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 1024px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }
}

/* =========================================
   COMPONENTS: CARDS
   ========================================= */
.card {
  background: var(--c-surface);
  border-radius: var(--r-xl);
  border: 1px solid var(--c-border);
  box-shadow: none; /* Removed shadow for cleaner look */
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  max-width: 100%;
  min-width: 0; /* allows shrinking in grid */
}
.card-header {
  padding-bottom: var(--sp-4);
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-title { font-size: 1rem; font-weight: 700; color: var(--c-text-primary); }

/* KPI Cards */
.kpi-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  transition: transform 0.2s, box-shadow 0.2s;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.kpi-label { font-size: 0.8125rem; font-weight: 600; color: var(--c-text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-value { font-size: 1.5rem; font-weight: 800; color: var(--c-text-primary); }
.kpi-trend { font-size: 0.75rem; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.kpi-trend.positive { color: var(--c-success); }
.kpi-trend.negative { color: var(--c-danger); }
.kpi-trend.neutral { color: var(--c-text-muted); }
.kpi-trend .material-icons-round { font-size: 14px; }

/* =========================================
   COMPONENTS: FORMS & INPUTS
   ========================================= */
.form-group { margin-bottom: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-1); }
.form-label { font-size: 0.8125rem; font-weight: 600; color: var(--c-text-secondary); }
.form-hint { font-size: 0.75rem; color: var(--c-text-muted); margin-top: 2px; }

.form-control {
  width: 100%;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  color: var(--c-text-primary);
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 0.875rem;
  transition: all 0.2s;
}
.form-control:hover { border-color: var(--c-border-hover); }
.form-control:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-light);
}
.form-control:disabled { background: var(--c-surface-secondary); color: var(--c-text-muted); cursor: not-allowed; }
.form-control::placeholder { color: var(--c-text-faint); }
.form-control.has-error { border-color: var(--c-danger); }
.form-control.has-error:focus { box-shadow: 0 0 0 3px var(--c-danger-light); }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}

.input-icon-wrap { position: relative; display: flex; align-items: center; }
.input-icon-wrap .material-icons-round { position: absolute; left: 12px; color: var(--c-text-muted); font-size: 18px; pointer-events: none; }
.input-icon-wrap .form-control { padding-left: 38px; }

/* =========================================
   COMPONENTS: BUTTONS
   ========================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 8px 16px; border-radius: var(--r-md);
  font-size: 0.875rem; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all 0.2s; border: 1px solid transparent; outline: none;
  text-decoration: none;
}
.btn:focus-visible { box-shadow: 0 0 0 3px var(--c-primary-light); }
.btn:disabled, .btn.loading { opacity: 0.6; cursor: not-allowed; pointer-events: none; }
.btn .material-icons-round { font-size: 18px; }

/* Primary Button */
.btn-primary { background: var(--c-primary); color: var(--c-text-inverse); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--c-primary-hover); box-shadow: var(--shadow-md); }

/* Secondary Button (Outline) */
.btn-secondary { background: var(--c-surface); color: var(--c-text-primary); border-color: var(--c-border); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--c-surface-hover); border-color: var(--c-border-hover); }

/* Ghost / Text Button */
.btn-ghost { background: transparent; color: var(--c-text-secondary); }
.btn-ghost:hover { background: var(--c-surface-hover); color: var(--c-text-primary); }

/* Danger Button */
.btn-danger { background: var(--c-danger); color: white; }
.btn-danger:hover { background: #DC2626; }
.btn-danger-ghost { color: var(--c-danger); background: transparent; }
.btn-danger-ghost:hover { background: var(--c-danger-light); }

/* Sizes */
.btn-sm { padding: 6px 12px; font-size: 0.8125rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; border-radius: var(--r-lg); }
.btn-icon { padding: 8px; border-radius: var(--r-md); aspect-ratio: 1; }
.btn-icon.btn-sm { padding: 6px; }

/* =========================================
   COMPONENTS: BADGES
   ========================================= */
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--r-full);
  font-size: 0.75rem; font-weight: 600; white-space: nowrap; gap: 4px;
}
.badge-primary { background: var(--c-primary-light); color: var(--c-primary); }
.badge-secondary { background: var(--c-secondary-light); color: var(--c-secondary); }
.badge-success { background: var(--c-success-light); color: var(--c-success); }
.badge-warning { background: var(--c-warning-light); color: var(--c-warning); }
.badge-danger { background: var(--c-danger-light); color: var(--c-danger); }
.badge-muted { background: var(--c-surface-secondary); color: var(--c-text-secondary); border: 1px solid var(--c-border); }

/* =========================================
   COMPONENTS: SAAS TABLE
   ========================================= */
.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-radius: var(--r-lg);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  -webkit-overflow-scrolling: touch;
}
.table-saas {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
}
.table-saas th {
  padding: 12px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--c-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--c-surface-secondary);
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
.table-saas td {
  padding: 14px 16px;
  font-size: 0.875rem;
  color: var(--c-text-primary);
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}
.table-saas tr:last-child td { border-bottom: none; }
.table-saas tbody tr { transition: background 0.15s; cursor: pointer; }
.table-saas tbody tr:hover { background: var(--c-surface-hover); }

@media (max-width: 768px) {
  .table-saas, .table-saas tbody, .table-saas tr, .table-saas td {
    display: block;
    width: 100%;
  }
  .table-saas thead { display: none; }
  .table-saas tr {
    margin-bottom: 16px;
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    padding: 4px 12px;
    background: #fff;
  }
  .table-saas td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--c-surface-secondary);
    text-align: right !important;
  }
  .table-saas td:last-child { border-bottom: none; }
  .table-saas td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--c-text-secondary);
    text-transform: uppercase;
    font-size: 0.70rem;
    text-align: left;
    margin-right: 16px;
  }
  .table-saas td .flex.items-center { flex-direction: row-reverse; justify-content: flex-start; gap: 8px; }
  .table-saas td .badge { margin-left: auto; }
}

/* =========================================
   COMPONENTS: MODAL & DRAWER
   ========================================= */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.2s;
  padding: var(--sp-4);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--c-surface); width: 100%; max-width: 500px;
  border-radius: var(--r-xl); box-shadow: var(--shadow-float);
  transform: translateY(20px) scale(0.98); transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex; flex-direction: column; max-height: 90vh;
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--c-border); display: flex; justify-content: space-between; align-items: center; }
.modal-title { font-size: 1.125rem; font-weight: 700; color: var(--c-text-primary); }
.modal-body { padding: 24px; overflow-y: auto; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--c-border); display: flex; justify-content: flex-end; gap: var(--sp-3); background: var(--c-surface-secondary); border-bottom-left-radius: var(--r-xl); border-bottom-right-radius: var(--r-xl); }

/* =========================================
   COMPONENTS: TOASTS
   ========================================= */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 12px; pointer-events: none; }
.toast {
  background: var(--c-surface); color: var(--c-text-primary); padding: 12px 16px;
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--c-border);
  display: flex; align-items: flex-start; gap: 12px; font-weight: 500; font-size: 0.875rem;
  pointer-events: auto; max-width: 350px;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast-icon { flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.toast-content { flex: 1; }
.toast-title { font-weight: 600; margin-bottom: 2px; }
.toast-msg { color: var(--c-text-secondary); font-size: 0.8125rem; font-weight: 400; line-height: 1.4; }

.toast.success .toast-icon { color: var(--c-success); }
.toast.error .toast-icon { color: var(--c-danger); }
.toast.info .toast-icon { color: var(--c-info); }
.toast.warning .toast-icon { color: var(--c-warning); }
.toast.removing { animation: slideOut 0.2s forwards; }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { to { transform: translateX(100%); opacity: 0; } }

/* =========================================
   COMPONENTS: EMPTY STATES & SKELETON
   ========================================= */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 24px; text-align: center; color: var(--c-text-muted);
}
.empty-state .material-icons-round { font-size: 48px; color: var(--c-border-hover); margin-bottom: 16px; }
.empty-state-title { font-size: 1rem; font-weight: 600; color: var(--c-text-primary); margin-bottom: 8px; }
.empty-state-desc { font-size: 0.875rem; color: var(--c-text-secondary); max-width: 320px; margin: 0 auto 24px auto; }

.skeleton {
  background: linear-gradient(90deg, var(--c-surface-secondary) 25%, var(--c-border) 50%, var(--c-surface-secondary) 75%);
  background-size: 200% 100%; animation: skeletonLoading 1.5s infinite;
  border-radius: var(--r-md);
}
.skeleton-text { height: 16px; width: 100%; margin-bottom: 8px; }
.skeleton-text.short { width: 60%; }
.skeleton-circle { border-radius: 50%; }
.skeleton-rect { height: 64px; width: 100%; }
@keyframes skeletonLoading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* =========================================
   LAYOUT: SIDEBAR + HEADER (MedCaixa App Layout)
   ========================================= */
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
  background: var(--c-bg);
  position: relative;
}

/* Sidebar Styling */
.sidebar {
  width: 250px;
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  height: 68px;
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--c-text-primary);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  color: var(--c-text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.sidebar-link .material-icons-round {
  font-size: 20px;
  color: var(--c-text-muted);
  transition: color 0.15s ease;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.sidebar-link:hover {
  background: var(--c-surface-hover);
  color: var(--c-text-primary);
}

.sidebar-link:hover .material-icons-round {
  color: var(--c-primary);
}

.sidebar-link.active {
  background: var(--c-primary-light);
  color: var(--c-primary);
  font-weight: 600;
}

.sidebar-link.active .material-icons-round {
  color: var(--c-primary);
}

.sidebar-bottom {
  padding: 16px 12px;
  border-top: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: auto;
  flex-shrink: 0;
}

/* Collapsed Sidebar (Desktop) */
.sidebar.collapsed {
  width: 72px;
}

.sidebar.collapsed .sidebar-logo {
  padding: 0;
  justify-content: center;
}

.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .sidebar-link span:not(.material-icons-round) {
  display: none;
}

.sidebar.collapsed .sidebar-link {
  justify-content: center;
  padding: 12px 10px;
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  background: var(--c-bg);
}

/* Topbar Header */
.topbar {
  height: 68px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 6px;
  border-radius: var(--r-full);
  background: var(--c-surface-secondary);
  border: 1px solid var(--c-border);
  transition: all 0.2s ease;
  cursor: pointer;
}

.topbar-user:hover {
  background: var(--c-surface-hover);
  border-color: var(--c-border-hover);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--c-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}

/* Page Content Container */
.page-content {
  flex: 1;
  padding: 28px 32px;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

.page-header {
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--c-text-primary);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--c-text-secondary);
  margin-top: 4px;
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 1500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

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

/* Responsive Logic (Mobile & Tablet) */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    width: 260px;
    box-shadow: var(--shadow-lg);
    z-index: 1600;
  }

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

  .topbar {
    padding: 0 16px;
  }

  .page-content {
    padding: 20px 16px;
  }

  .hidden-desktop {
    display: inline-block;
  }
}

@media (min-width: 1025px) {
  .hidden-desktop {
    display: none !important;
  }
}

/* =========================================
   MOBILE APP BOTTOM NAVIGATION & SCROLLBAR
   ========================================= */
.mobile-bottom-nav {
  display: none;
}
@media (max-width: 1024px) {
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 64px;
    background: var(--c-surface);
    border-top: 1px solid var(--c-border);
    z-index: 900;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  }
  .bottom-nav-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: var(--c-text-muted); text-decoration: none; flex: 1; height: 100%;
    transition: color 0.2s;
  }
  .bottom-nav-item.active { color: var(--c-primary); }
  .bottom-nav-item .material-icons-round { font-size: 24px; margin-bottom: 2px; }
  .bottom-nav-item .nav-label { font-size: 0.65rem; font-weight: 600; }
  
  .bottom-nav-item.fab { position: relative; flex: 0 0 60px; }
  .fab-inner {
    width: 52px; height: 52px; background: var(--c-secondary); color: white;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    position: absolute; top: -20px; left: 50%; transform: translateX(-50%);
    box-shadow: 0 6px 12px rgba(126,58,242,0.4);
    transition: transform 0.2s, box-shadow 0.2s;
  }
  .fab-inner:active { transform: translateX(-50%) scale(0.95); box-shadow: 0 4px 8px rgba(126,58,242,0.3); }
  .fab-inner .material-icons-round { font-size: 28px; margin: 0; }
  
  /* Make room for bottom nav so content isn't hidden */
  .main-content { padding-bottom: 90px !important; }
  
  /* HIDE SCROLLBAR GLOBALLY ON MOBILE TO FEEL LIKE NATIVE APP */
  ::-webkit-scrollbar {
    display: none;
  }
  * {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
}

/* =========================================
   AUTH LAYOUT (Split Screen Style - MedCaixa)
   ========================================= */
.auth-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  background: var(--c-surface);
}

.auth-left-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 50%;
  padding: 40px;
  position: relative;
}

.auth-logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--c-text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-form-wrapper {
  margin: auto;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
}

.auth-header-text {
  margin-bottom: 32px;
  text-align: center;
}

.auth-header-text h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--c-text-primary);
  margin-bottom: 8px;
}

.auth-header-text p {
  color: var(--c-text-secondary);
  font-size: 0.875rem;
}

/* Custom Auth Forms */
.auth-form .form-group {
  margin-bottom: 20px;
}
.auth-form .form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--c-text-primary);
  margin-bottom: 6px;
}
.auth-form .form-control {
  height: 44px;
  border-radius: var(--r-sm);
  padding: 0 14px;
  font-size: 0.875rem;
}
.auth-form .input-icon-wrap .form-control {
  padding-right: 40px;
  padding-left: 14px;
}
.auth-form .input-icon-wrap .material-icons-round {
  right: 12px;
  left: auto;
  pointer-events: auto;
  cursor: pointer;
  color: var(--c-text-muted);
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 24px 0;
  color: var(--c-text-faint);
  font-size: 0.75rem;
  font-weight: 600;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--c-border);
}
.divider::before { margin-right: 16px; }
.divider::after { margin-left: 16px; }

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: white;
  border: 1px solid var(--c-border);
  color: var(--c-text-primary);
  height: 44px;
  border-radius: var(--r-sm);
  font-weight: 600;
  width: 100%;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-google:hover {
  background: var(--c-surface-hover);
  border-color: var(--c-border-hover);
}
.btn-google img {
  width: 18px;
  height: 18px;
}

.auth-footer-text {
  font-size: 0.7rem;
  color: var(--c-text-muted);
  text-align: center;
  margin-top: auto;
  padding-top: 40px;
}
.auth-footer-text a {
  color: var(--c-text-secondary);
  text-decoration: underline;
}

/* Right Column */
.auth-right-col {
  flex: 1;
  background-color: var(--c-primary);
  background-image: url('../img/doctor.jpg'); /* Doctor background image */
  background-size: cover;
  background-position: center;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 40px;
}

.auth-right-col::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 92, 169, 0.75); /* Moraes Blue overlay */
  z-index: 0;
}

.auth-right-logo, .auth-toast {
  position: relative;
  z-index: 1;
}

.auth-right-logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  margin-top: auto; /* Push to bottom */
}

.auth-toast {
  background: white;
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  margin-left: auto;
  margin-top: 16px;
}
.auth-toast-icon {
  color: var(--c-primary);
  display: flex;
}
.auth-toast-text {
  flex: 1;
  font-size: 0.8125rem;
  color: var(--c-text-primary);
  font-weight: 500;
  line-height: 1.4;
}
.auth-toast-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 900px) {
  .auth-left-col { max-width: 100%; padding: 24px; }
  .auth-right-col { display: none; }
  .auth-form-wrapper { max-width: 100%; }
}

/* Utilities */
.hidden { display: none !important; }
.rotate-anim { animation: rotate 1s linear infinite; }
@keyframes rotate { 100% { transform: rotate(360deg); } }
.fade-in { animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

