/* =====================================================
   CONSOLE RADLAUDO — BASE CSS
   Sidebar, Topbar, Componentes comuns
   
   🔤 Para trocar a fonte do sistema, altere apenas esta linha:
   --font: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
===================================================== */

:root {
  /* Fonte — altere apenas aqui para trocar em todo o sistema */
  --font: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;

  /* Brand */
  --brand:        #4A90E2;
  --brand-dark:   #3a78c7;
  --brand-deep:   #1d4ed8;
  --brand-soft:   rgba(74, 144, 226, 0.08);
  --brand-border: rgba(74, 144, 226, 0.18);

  /* Layout */
  --sidebar-w:    260px;
  --sidebar-c:    72px;
  --topbar-h:     64px;

  /* Superfícies */
  --surface:      #ffffff;
  --bg:           #f0f4f8;
  --bg-subtle:    #f8fafc;
  --bg-muted:     #f1f5f9;

  /* Texto */
  --text:         #0f172a;
  --text-muted:   #64748b;
  --text-faint:   #94a3b8;

  /* Bordas */
  --border:       #e2e8f0;
  --border-hover: #cbd5e1;

  /* Feedback */
  --success:      #10b981;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --info:         #3b82f6;
}

/* ── Reset ──────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* =====================================================
   LAYOUT PRINCIPAL
===================================================== */

.console-layout {
  display: flex;
  min-height: 100vh;
}

/* =====================================================
   SIDEBAR
===================================================== */

.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  z-index: 100;
}

.sidebar.collapsed {
  width: var(--sidebar-c);
}

/* Header — altura idêntica ao topbar via variável compartilhada */
.sidebar-header {
  height: var(--topbar-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* border-bottom: 1px solid var(--border); */
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  overflow: hidden;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* background: var(--brand-soft); */
}

.brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-text {
  overflow: hidden;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  letter-spacing: -0.2px;
}

.brand-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar.collapsed .brand-text { display: none; }

/* Toggle */
.toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 6px;
  transition: all 0.2s;
  flex-shrink: 0;
  font-size: 13px;
}

.toggle-btn:hover {
  background: #f1f5f9;
  color: var(--text);
}

/* Botão some quando collapsed — logo assume a função de expandir */
.sidebar.collapsed .toggle-btn {
  display: none;
}

/* Logo vira cursor pointer quando collapsed (indica que é clicável para expandir) */
.sidebar.collapsed .brand {
  cursor: pointer;
  justify-content: center;
}

.sidebar.collapsed .toggle-btn i {
  transform: rotate(180deg);
}

/* Body */
.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  scrollbar-width: none;
}

.sidebar-body::-webkit-scrollbar { display: none; }

/* Seção */
.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
  padding: 12px 8px 4px;
  white-space: nowrap;
}

.sidebar.collapsed .sidebar-section-label { display: none; }

/* Item */
.menu-item {
  margin-bottom: 1px;
}

.menu-item a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
  overflow: hidden;
}

.menu-item a:hover {
  background: #f1f5f9;
  color: var(--text);
}

.menu-item.active a {
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-weight: 600;
}

/* Ícone */
.menu-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  background: #f1f5f9;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all 0.15s;
}

.menu-item.active .menu-icon {
  background: var(--brand);
  color: #fff;
}

.menu-item a:hover .menu-icon {
  background: #e2e8f0;
  color: var(--text);
}

.sidebar.collapsed .menu-item a {
  justify-content: center;
  padding: 8px;
}

/* Labels e badges somem no collapse */
.sidebar.collapsed .menu-label,
.sidebar.collapsed .menu-badge,
.sidebar.collapsed .soon-badge { display: none; }

/* Badge de alerta */
.menu-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  flex-shrink: 0;
}

/* Badge "em breve" */
.soon-badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-faint);
  background: #f1f5f9;
  padding: 2px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

/* Footer */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 10px 8px;
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  cursor: default;
  margin-bottom: 2px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-footer-info {
  overflow: hidden;
}

.user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 10.5px;
  color: var(--brand);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar.collapsed .sidebar-footer-info { display: none; }
.sidebar.collapsed .sidebar-user { justify-content: center; padding: 8px; }

.btn-logout {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  font-family: var(--font);
}

.btn-logout:hover {
  background: #fef2f2;
  color: var(--danger);
}

.sidebar.collapsed .btn-logout {
  justify-content: center;
  padding: 8px;
}

.sidebar.collapsed .btn-logout span { display: none; }

/* =====================================================
   MAIN
===================================================== */

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.main.collapsed {
  margin-left: var(--sidebar-c);
}

/* =====================================================
   TOPBAR
===================================================== */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}

.topbar-left h1 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

.topbar-left p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

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

.topbar-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-deep);
}

.topbar-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* Usuário na topbar */
.topbar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 10px 5px 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-subtle);
  cursor: default;
}

.topbar-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.topbar-user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.topbar-user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-user-role {
  font-size: 10px;
  font-weight: 700;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* =====================================================
   CONTEÚDO
===================================================== */

.content {
  padding: 24px 28px;
  flex: 1;
}

/* =====================================================
   CARD BASE
===================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.card-header p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-action {
  font-size: 12px;
  color: var(--brand);
  font-weight: 600;
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 7px;
  transition: background 0.15s;
  white-space: nowrap;
}

.card-action:hover { background: var(--brand-soft); }

/* =====================================================
   STATUS DOTS E BADGES
===================================================== */

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
}

.status-dot::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.online  { color: var(--success); }
.status-dot.online::before  { background: var(--success); }
.status-dot.offline { color: var(--danger); }
.status-dot.offline::before { background: var(--danger); }
.status-dot.pending { color: var(--warning); }
.status-dot.pending::before { background: var(--warning); }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
}

.badge.hospital { background: rgba(74,144,226,0.1);  color: var(--brand-deep); }
.badge.clinica  { background: rgba(16,185,129,0.1);  color: #059669; }
.badge.medico   { background: rgba(139,92,246,0.1);  color: #7c3aed; }
.badge.success  { background: rgba(16,185,129,0.1);  color: #059669; }
.badge.warning  { background: rgba(245,158,11,0.1);  color: #d97706; }
.badge.danger   { background: rgba(239,68,68,0.1);   color: #dc2626; }

/* =====================================================
   BOTÕES
===================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(74,144,226,0.3);
}

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

.btn-secondary:hover {
  background: #f1f5f9;
  border-color: var(--border-hover);
}

.btn-danger {
  background: rgba(239,68,68,0.1);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.15);
}

.btn-danger:hover {
  background: rgba(239,68,68,0.15);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}

.btn.loading .btn-spinner { display: block; }

@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================
   TOAST
===================================================== */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  animation: toastIn 0.3s ease;
}

.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.info    { background: var(--brand); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =====================================================
   SKELETON LOADER
===================================================== */

.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e8edf2 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* =====================================================
   UTILITÁRIOS
===================================================== */

.text-muted   { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-brand   { color: var(--brand); }

.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-faint);
  font-size: 13.5px;
}

.empty-state i {
  font-size: 32px;
  margin-bottom: 12px;
  display: block;
  opacity: 0.4;
}

/* =====================================================
   RESPONSIVO
===================================================== */

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main { margin-left: 0 !important; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
}
