/**
 * portal_theme.css - Design System Tokens e Shell Mobile-First PWA
 * Conformidade com WCAG 2.1 AA (Toque >= 48px, Contraste >= 4.5:1)
 */

:root {
  --color-primary: #0d9488;
  --color-secondary: #1e293b;
  --color-accent: #0ea5e9;
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-hover: #f1f5f9;
  --color-border: #e2e8f0;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;

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

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);

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

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

body {
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  letter-spacing: -0.01em;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: stretch;
}

@media (min-width: 860px) {
  body {
    background: #f1f5f9;
  }
}

/* Container Responsivo Shell (Mobile: até 480px, Desktop: até 1140px) */
.pwa-app-shell {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  background-color: #ffffff;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  margin: 0 auto;
}

@media (min-width: 860px) {
  .pwa-app-shell {
    max-width: 1140px;
    min-height: 100vh;
    max-height: none;
    border-radius: 0;
    border: none;
    border-left: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    box-shadow: 0 0 35px rgba(15, 23, 42, 0.04);
    overflow-y: visible;
  }
}

/* Header Fixo Superior com Efeito Glassmorphism */
.pwa-header {
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  transition: all 0.2s ease;
}

.pwa-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--color-text);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.brand-monogram {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(13, 148, 136, 0.25);
}

.brand-title {
  color: var(--color-secondary);
  font-weight: 800;
  font-size: 16px;
}

.pwa-brand-logo {
  height: 34px;
  max-width: 140px;
  object-fit: contain;
}

/* Avatar do Usuário no Header */
.pwa-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  border: 1.5px solid #cbd5e1;
  color: var(--color-secondary);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.pwa-header-avatar:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border-color: var(--color-primary);
}

/* Alerta de Conexão Offline Flutuante */
.pwa-offline-alert {
  background-color: #fee2e2;
  color: #991b1b;
  border-bottom: 1px solid #fca5a5;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: sticky;
  top: var(--header-height);
  z-index: 45;
  animation: fadeIn 0.2s ease;
}

/* Área Principal de Conteúdo */
.pwa-main-content {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(var(--bottom-nav-height) + 24px);
  overflow-y: auto;
}

/* Barra de Navegação Inferior (Bottom Navigation) com Glassmorphism */
.pwa-bottom-nav {
  position: fixed;
  bottom: 0;
  width: 100%;
  max-width: 440px;
  height: var(--bottom-nav-height);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(226, 232, 240, 0.85);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.04);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  min-width: 64px;
  min-height: 48px;
  gap: 4px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.nav-item svg {
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), stroke 0.2s;
  stroke: #64748b;
}

.nav-item.active {
  color: var(--color-primary);
  font-weight: 700;
}

.nav-item.active svg {
  stroke: var(--color-primary);
  transform: translateY(-2px);
}

.nav-item:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
  border-radius: var(--radius-xs);
}

/* Componentes de UI: Cards, Botões e Inputs */
.card, .pwa-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.04);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

/* Formulários & Campos de Entrada */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-secondary);
  margin-bottom: 6px;
}

.form-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.form-input, .form-control {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  font-size: 15px;
  font-family: inherit;
  border: 1.5px solid var(--color-border);
  border-radius: 12px;
  background-color: #ffffff;
  color: var(--color-text);
  transition: all 0.2s ease;
  outline: none;
  box-sizing: border-box;
}

.form-input:focus, .form-control:focus {
  border-color: var(--color-primary);
  background-color: #ffffff;
  box-shadow: 0 0 0 3.5px rgba(13, 148, 136, 0.14);
}

.form-input::placeholder, .form-control::placeholder {
  color: #94a3b8;
  font-size: 14px;
}

/* Input Groups com Ícones */
.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-icon-prefix {
  position: absolute;
  left: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  pointer-events: none;
  transition: color 0.2s ease;
  z-index: 2;
}

.input-with-icon:focus-within .input-icon-prefix {
  color: var(--color-primary);
}

.form-input.has-prefix, .form-control.has-prefix {
  padding-left: 42px;
}

.form-input.has-suffix, .form-control.has-suffix {
  padding-right: 44px;
}

.toggle-password-btn {
  position: absolute;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
  z-index: 2;
  padding: 0;
}

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

/* Botões do Design System */
.btn, .pwa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 48px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  padding: 0 20px;
  gap: 8px;
  box-sizing: border-box;
  user-select: none;
}

.btn-primary, .pwa-btn-primary {
  background: linear-gradient(135deg, var(--color-primary), #0f766e);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.28);
}

.btn-primary:hover, .pwa-btn-primary:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(13, 148, 136, 0.35);
}

.btn-primary:active, .pwa-btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled, .pwa-btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.btn-secondary, .pwa-btn-secondary {
  background-color: #ffffff;
  border: 1.5px solid var(--color-border);
  color: var(--color-secondary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.btn-secondary:hover, .pwa-btn-secondary:hover {
  background-color: #f8fafc;
  border-color: #cbd5e1;
  color: var(--color-text);
  transform: translateY(-1px);
}

.btn-secondary:active, .pwa-btn-secondary:active {
  transform: scale(0.98);
}

.btn:focus-visible, .pwa-btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* Componentes Especializados de Autenticação */
.auth-page-container {
  max-width: 440px;
  margin: 20px auto;
  padding: 0 16px;
}

.auth-card {
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 20px;
  padding: 28px 24px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.auth-brand-badge {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.12), rgba(14, 165, 233, 0.15));
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.1);
}

.auth-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--color-secondary);
  margin-bottom: 6px;
  letter-spacing: -0.02em;
  text-align: center;
}

.auth-subtitle {
  font-size: 13.5px;
  color: var(--color-text-muted);
  line-height: 1.45;
  text-align: center;
  margin-bottom: 22px;
}

.auth-divider {
  display: flex;
  align-items: center;
  margin: 20px 0 14px;
}

.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--color-border);
}

.auth-divider span {
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.auth-link-forgot {
  font-size: 12px;
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.15s;
}

.auth-link-forgot:hover {
  text-decoration: underline;
  opacity: 0.85;
}

.auth-footer-prompt {
  text-align: center;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
  font-size: 13px;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.auth-highlight-action {
  color: var(--color-primary);
  font-weight: 700;
  text-decoration: none;
}

.auth-highlight-action:hover {
  text-decoration: underline;
}

.auth-trust-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 20px;
  font-size: 11.5px;
  color: #94a3b8;
  font-weight: 500;
}

.auth-trust-badge svg {
  color: var(--color-primary);
}

/* Banner de Notificação / Instalação PWA */
.pwa-install-banner {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: #ffffff;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
  animation: slideDown 0.3s ease-out;
}

.pwa-install-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.pwa-install-banner-icon {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pwa-install-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.install-btn {
  background-color: #ffffff;
  color: var(--color-secondary);
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  min-height: 36px;
  transition: transform 0.15s, background-color 0.15s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.install-btn:hover {
  transform: translateY(-1px);
  background-color: #f8fafc;
}

.install-dismiss-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 20px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 4px;
}

.install-dismiss-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
}

/* Botão de Instalação na Barra de Navegação Desktop */
.desktop-install-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  color: #334155;
  border: 1px solid #e2e8f0;
  padding: 6px 14px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.desktop-install-btn .install-btn-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(13, 148, 136, 0.10);
  color: var(--color-primary, #0d9488);
  transition: all 0.2s ease;
}

.desktop-install-btn:hover {
  background: #ffffff;
  border-color: var(--color-primary, #0d9488);
  color: var(--color-primary, #0d9488);
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.15);
  transform: translateY(-1px);
}

.desktop-install-btn:hover .install-btn-icon-wrapper {
  background: var(--color-primary, #0d9488);
  color: #ffffff;
}

.desktop-install-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(13, 148, 136, 0.1);
}

/* Modal Explicativo de Instalação PWA */
.pwa-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.pwa-modal-card {
  background: #ffffff;
  border-radius: 16px;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  padding: 24px;
  animation: modalPop 0.25s ease-out;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.pwa-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.pwa-modal-close-btn {
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}

.pwa-modal-close-btn:hover {
  background: #f1f5f9;
  color: #334155;
}

.pwa-guide-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 16px;
}

.pwa-guide-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #1e293b;
  margin-bottom: 8px;
}

.pwa-guide-title svg {
  color: var(--color-primary);
}

.pwa-guide-steps {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  color: #475569;
  line-height: 1.6;
}

.pwa-reinstall-tip {
  margin-top: 10px;
  padding: 10px 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  font-size: 12px;
  color: #1e40af;
  line-height: 1.5;
}

.pwa-modal-footer {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}

.pwa-modal-btn-primary {
  background: var(--color-primary);
  color: #ffffff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.pwa-modal-btn-primary:hover {
  opacity: 0.9;
}
