/* ==========================================================================
   Design System Corporativo - Hospital Jaraguá
   Aplicação: Gestão de Usuários & Migração (usuario.hj.org.br)
   ========================================================================== */

:root {
  --primary: #00583C;
  --primary-dark: #00422c;
  --primary-light: #06724f;
  --accent: #059669;
  --accent-light: #10b981;
  
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-input: #ffffff;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-inverse: #ffffff;

  --border-color: #e2e8f0;
  --border-focus: #059669;

  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --success: #10b981;
  --success-bg: #f0fdf4;
  --info: #0284c7;
  --info-bg: #f0f9ff;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --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);

  --font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --header-height: 64px;
  --bottom-nav-height: 64px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Header / Topbar
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-height);
  background: var(--primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.header-logo {
  height: 38px;
  width: auto;
  border-radius: var(--radius-sm);
  background: white;
  padding: 2px 6px;
}

.header-title-wrap h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.header-title-wrap p {
  font-size: 0.72rem;
  opacity: 0.85;
}

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

.user-badge {
  background: rgba(255, 255, 255, 0.15);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-logout {
  background: rgba(239, 68, 68, 0.2);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

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

/* ==========================================================================
   Navegação por Abas (Desktop & Mobile)
   ========================================================================== */
.nav-tabs-desktop {
  display: flex;
  background: white;
  border-bottom: 1px solid var(--border-color);
  padding: 0 20px;
  gap: 8px;
  overflow-x: auto;
}

.nav-tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-tab-btn:hover {
  color: var(--primary);
  background: var(--bg-subtle);
}

.nav-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.nav-badge {
  background: var(--primary);
  color: white;
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-weight: 700;
}

.nav-badge.danger {
  background: var(--danger);
}

/* Bottom Nav (Mobile) */
.nav-tabs-mobile {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: white;
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
  z-index: 40;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-mobile-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  border: none;
  background: none;
  cursor: pointer;
  position: relative;
  padding: 6px 0;
  transition: color 0.15s;
}

.nav-mobile-btn.active {
  color: var(--primary);
}

.nav-mobile-btn .nav-icon {
  font-size: 1.25rem;
}

.nav-mobile-badge {
  position: absolute;
  top: 4px;
  right: 25%;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: var(--radius-full);
  font-weight: 700;
}

/* ==========================================================================
   Conteúdo Principal e Containers
   ========================================================================== */
.main-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 80px 20px;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.tab-pane.active {
  display: block;
}

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

/* ==========================================================================
   Cards e Seções
   ========================================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
}

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

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Stats Row */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-icon.danger { background: var(--danger-bg); color: var(--danger); }
.stat-icon.primary { background: var(--info-bg); color: var(--primary); }
.stat-icon.success { background: var(--success-bg); color: var(--success); }

.stat-val {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
}

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

/* ==========================================================================
   Formulários e Inputs
   ========================================================================== */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.input-control {
  width: 100%;
  padding: 12px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-main);
  transition: all 0.2s;
}

.input-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.search-bar-wrap {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.search-bar-wrap .input-control {
  flex: 1;
}

/* ==========================================================================
   Botões
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

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

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

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

.btn-success:hover {
  background: var(--primary-dark);
}

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

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   Tabelas & Listas de Usuários
   ========================================================================== */
.table-responsive {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.data-table th {
  background: var(--bg-subtle);
  padding: 12px 14px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-table td {
  padding: 14px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

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

.data-table tr:hover {
  background: rgba(0, 88, 60, 0.02);
}

/* Badges de Status */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
}

.status-pill.blocked {
  background: var(--danger-bg);
  color: var(--danger);
}

.status-pill.active {
  background: var(--success-bg);
  color: var(--accent);
}

.status-pill.badge-unit {
  background: var(--info-bg);
  color: var(--info);
}

/* ==========================================================================
   Cards de Usuários Bloqueados (Mobile Friendly)
   ========================================================================== */
.blocked-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.blocked-card {
  background: white;
  border: 1.5px solid #fecaca;
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.05);
}

.blocked-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.blocked-user-name {
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--text-main);
}

.blocked-user-login {
  font-family: monospace;
  font-size: 0.82rem;
  color: var(--primary);
  background: rgba(0,88,60,0.06);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  display: inline-block;
  margin-top: 2px;
}

.blocked-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ==========================================================================
   Tela de Login (Autenticação Tasy)
   ========================================================================== */
.login-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #00583C 0%, #002e1f 100%);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  width: 100%;
  max-width: 420px;
  padding: 32px 28px;
  text-align: center;
}

.login-logo {
  width: 90px;
  height: auto;
  margin: 0 auto 16px auto;
  display: block;
}

.login-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary-dark);
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* Toasts de Notificação */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: white;
  border-left: 4px solid var(--primary);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideIn 0.3s ease-out;
  max-width: 360px;
}

.toast.success { border-left-color: var(--success); }
.toast.danger { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

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

/* ==========================================================================
   Responsividade Mobile (< 768px)
   ========================================================================== */
@media (max-width: 768px) {
  .nav-tabs-desktop {
    display: none;
  }
  .nav-tabs-mobile {
    display: flex;
  }
  .main-content {
    padding-bottom: 84px;
  }
  .header-title-wrap h1 {
    font-size: 0.95rem;
  }
  .toast-container {
    left: 20px;
    right: 20px;
    top: 10px;
  }
}
