/* ============================================================
   HEMOCARE - Global Styles
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: var(--font-size-base); scroll-behavior: smooth; }

body {
  font-family: var(--font-family);
  background-color: var(--bg-body);
  color: var(--text-primary);
  line-height: var(--line-height-base);
  transition: background-color var(--transition-slow), color var(--transition-slow);
  min-height: 100vh;
  overflow-x: hidden;
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--gray-700); }

/* === LAYOUT WRAPPER === */
.app-wrapper { display: flex; min-height: 100vh; }

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-base);
}

.sidebar-collapsed .main-content { margin-left: var(--sidebar-collapsed); }

.page-content {
  flex: 1;
  padding: var(--content-padding);
  padding-top: calc(var(--topbar-height) + var(--content-padding));
}

/* === CARD === */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition-base), transform var(--transition-base);
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
  padding: 18px 20px 0;
  border-bottom: none;
  background: transparent;
}

.card-body { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border-color); background: transparent; }

/* Altura mínima do card-header para alinhar cards lado a lado na rolagem horizontal.
   62px = 18px topo + 28.5px (btn-sm) + 14px (pb-3) + 2px da borda do card.
   Cards sem botão à direita só têm a altura do h6 (~21px), então ficavam menores. */
.card-header-dash { min-height: 62px; }

/* === STAT CARDS === */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
  cursor: default;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-card .stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--border-radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}

.stat-card .stat-value {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  line-height: 1;
  margin: 8px 0 4px;
}

.stat-card .stat-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
}

.stat-card .stat-delta {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  padding: 2px 8px;
  border-radius: var(--border-radius-pill);
}

.stat-card::after {
  content: '';
  position: absolute;
  bottom: -20px; right: -20px;
  width: 80px; height: 80px;
  border-radius: 50%;
  opacity: 0.06;
}

/* === BADGES / STATUS === */
.badge-status {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border-radius: var(--border-radius-pill);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-status .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-funcionando { background: var(--success-light); color: var(--status-funcionando); border: 1px solid var(--success-border); }
.status-funcionando .dot { background: var(--status-funcionando); }

.status-preventiva { background: var(--warning-light); color: var(--status-preventiva); border: 1px solid var(--warning-border); }
.status-preventiva .dot { background: var(--status-preventiva); }

.status-corretiva, .status-parado { background: var(--danger-light); color: var(--status-corretiva); border: 1px solid var(--danger-border); }
.status-corretiva .dot, .status-parado .dot { background: var(--status-corretiva); }

.status-teste { background: var(--info-light); color: var(--status-teste); border: 1px solid var(--info-border); }
.status-teste .dot { background: var(--status-teste); }

.status-desativado { background: var(--gray-100); color: var(--gray-600); border: 1px solid var(--gray-300); }
.status-desativado .dot { background: var(--gray-500); }

.status-standby { background: #e8eaf6; color: #3949ab; border: 1px solid #9fa8da; }
.status-standby .dot { background: #3949ab; }

/* PRIORITY */
.priority-baixa   { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.priority-media   { background: #fff3e0; color: #e65100; border: 1px solid #ffcc80; }
.priority-alta    { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.priority-critica { background: var(--purple-light); color: var(--purple); border: 1px solid #ce93d8; }

/* === BUTTONS === */
.btn { border-radius: var(--border-radius-sm); font-weight: var(--font-weight-medium); font-size: var(--font-size-sm); transition: all var(--transition-base); display: inline-flex; align-items: center; gap: 6px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-icon { width: 36px; height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--border-radius-sm); }
.btn-icon-sm { width: 28px; height: 28px; font-size: 14px; }

/* === FORMS === */
.form-control, .form-select {
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  padding: 9px 13px;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,115,119,0.15);
  background: var(--bg-surface);
  color: var(--text-primary);
  outline: none;
}

.form-label { font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); color: var(--text-secondary); margin-bottom: 6px; }

/* === PAGE HEADER === */
.page-header { margin-bottom: 24px; }
.page-title { font-size: var(--font-size-2xl); font-weight: var(--font-weight-bold); color: var(--text-primary); margin: 0; }
.page-subtitle { font-size: var(--font-size-sm); color: var(--text-secondary); margin-top: 4px; }

/* === TABLE === */
.table { color: var(--text-primary); }
.table th { font-size: var(--font-size-xs); font-weight: var(--font-weight-semibold); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); border-bottom: 2px solid var(--border-color); padding: 10px 16px; background: var(--bg-surface-2); }
.table td { padding: 12px 16px; font-size: var(--font-size-sm); border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.table tbody tr:hover { background: var(--bg-surface-2); }
.table-responsive { border-radius: var(--border-radius); overflow: hidden; }

/* === AVATAR === */
.avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: var(--font-weight-bold); font-size: var(--font-size-sm); flex-shrink: 0; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 48px; height: 48px; font-size: var(--font-size-lg); }
.avatar-xl { width: 64px; height: 64px; font-size: var(--font-size-2xl); }

/* === DIVIDER === */
.divider { height: 1px; background: var(--border-color); margin: 16px 0; }

/* === EMPTY STATE === */
.empty-state { text-align: center; padding: 60px 24px; }
.empty-state i { font-size: 56px; color: var(--gray-300); margin-bottom: 16px; }
.empty-state h5 { color: var(--text-secondary); font-weight: var(--font-weight-semibold); }
.empty-state p { color: var(--text-muted); font-size: var(--font-size-sm); }

/* === ANIMATIONS === */
@keyframes fadeInUp { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeIn   { from { opacity:0; } to { opacity:1; } }
@keyframes pulse    { 0%,100% { transform:scale(1); } 50% { transform:scale(1.05); } }
@keyframes spin     { from { transform:rotate(0deg); } to { transform:rotate(360deg); } }
@keyframes slideInLeft { from { opacity:0; transform:translateX(-20px); } to { opacity:1; transform:translateX(0); } }
@keyframes countUp { from { opacity:0; transform:translateY(8px) scale(0.9); } to { opacity:1; transform:translateY(0) scale(1); } }

.animate-fade-up  { animation: fadeInUp 0.4s ease both; }
.animate-fade     { animation: fadeIn   0.3s ease both; }
.animate-slide    { animation: slideInLeft 0.35s ease both; }
.animate-count    { animation: countUp 0.5s var(--transition-bounce) both; }

.delay-1  { animation-delay: 0.05s; }
.delay-2  { animation-delay: 0.10s; }
.delay-3  { animation-delay: 0.15s; }
.delay-4  { animation-delay: 0.20s; }
.delay-5  { animation-delay: 0.25s; }
.delay-6  { animation-delay: 0.30s; }
.delay-7  { animation-delay: 0.35s; }
.delay-8  { animation-delay: 0.40s; }

/* === MISC === */
.text-primary-brand { color: var(--primary); }
.bg-primary-soft    { background: var(--primary-50); }
.cursor-pointer     { cursor: pointer; }
.rounded-xl         { border-radius: var(--border-radius-xl) !important; }
.fw-600             { font-weight: 600; }
.fw-700             { font-weight: 700; }
.fs-xs              { font-size: var(--font-size-xs); }
.fs-sm              { font-size: var(--font-size-sm); }
.gap-6              { gap: 6px; }
.gap-8              { gap: 8px; }
.gap-12             { gap: 12px; }

/* === RESPONSIVE === */
@media (max-width: 991.98px) {
  .main-content { margin-left: 0; }
  .page-content { padding: 16px; padding-top: calc(var(--topbar-height) + 16px); }
  .sidebar-collapsed .main-content { margin-left: 0; }
}
