/**
 * Pague Azul Cliente - CSS Principal
 * Arquivo unico consolidado para simplificar
 */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--background);
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--primary);
  text-decoration: none;
}

img, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

ul, ol {
  list-style: none;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

/* ==================== VARIABLES ==================== */
:root {
  /* Branding por cidade (theming) - default = tema atual.
     Branding.aplicar() (core/branding.js) sobrescreve estas 2 vars via JS
     quando a cidade tem cores configuradas. */
  --pa-cor-primaria: #4a4a4a;
  --pa-cor-secundaria: #57A773;

  /* Cores principais - Tema Cinza Chumbo (derivam do branding da cidade) */
  --primary: var(--pa-cor-primaria);
  --primary-dark: #333333;
  --primary-light: #666666;

  /* Secundárias */
  --secondary: var(--pa-cor-secundaria);
  --accent: #EE6C4D;

  /* Neutros */
  --background: #F8F9FA;
  --surface: #FFFFFF;
  --text-primary: #293241;
  --text-secondary: #6C757D;
  --border: #DEE2E6;

  /* Status */
  --success: #57A773;
  --error: #DC3545;
  --warning: #F4A261;
  --info: #4A6FA5;

  /* Sombras */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.16);

  /* Espaçamentos */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* Compatibilidade com código existente */
  --color-primary: var(--primary);
  --color-primary-dark: var(--primary-dark);
  --color-success: var(--success);
  --color-danger: var(--error);
  --color-warning: var(--warning);
  --color-info: var(--info);
  --color-white: var(--surface);
  --color-gray-50: #f9fafb;
  --color-gray-100: #f3f4f6;
  --color-gray-200: var(--border);
  --color-gray-300: #d1d5db;
  --color-gray-500: var(--text-secondary);
  --color-gray-600: #4b5563;
  --color-gray-700: #374151;
  --color-gray-900: var(--text-primary);
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --border-radius: var(--radius-sm);
  --border-radius-lg: var(--radius-md);
  --border-radius-full: 9999px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ==================== LAYOUT ==================== */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

.page-content {
  padding: var(--spacing-md);
  padding-bottom: calc(100px + var(--spacing-md));
}

/* Garantir padding-bottom em todas as páginas com footer-nav */
main[class$="-content"] {
  padding-bottom: calc(100px + var(--spacing-md, 16px));
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
  border-radius: var(--border-radius);
  transition: all 150ms ease;
  cursor: pointer;
  border: none;
  text-align: center;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background-color: var(--color-primary);
  color: var(--color-white);
}
.btn-primary:hover:not(:disabled) {
  background-color: var(--color-primary-dark);
}

.btn-secondary {
  background-color: var(--color-gray-200);
  color: var(--color-gray-900);
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--color-primary);
  color: var(--color-primary);
}

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

.btn-link {
  background: none;
  color: var(--color-primary);
  padding: 4px;
  font-size: 14px;
}

.btn.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn.loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* ==================== FORMS ==================== */
.form-group {
  margin-bottom: var(--spacing-md);
}

.form-label {
  display: block;
  margin-bottom: var(--spacing-xs);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-gray-700);
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  border: 1px solid var(--color-gray-300);
  border-radius: var(--border-radius);
  background-color: var(--color-white);
  transition: border-color 150ms ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
}

.form-control.error {
  border-color: var(--color-danger);
}

.form-text {
  display: block;
  margin-top: var(--spacing-xs);
  font-size: 14px;
  color: var(--color-gray-500);
}

.form-error {
  display: block;
  margin-top: var(--spacing-xs);
  font-size: 14px;
  color: var(--color-danger);
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group .form-control {
  padding-right: 48px;
}

.input-group .input-icon {
  position: absolute;
  right: 12px;
  color: var(--color-gray-500);
  cursor: pointer;
  padding: 8px;
}

/* ==================== CARDS ==================== */
.card {
  background-color: var(--color-white);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: var(--spacing-md);
}

.card-header {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--color-gray-200);
}

.card-body {
  padding: var(--spacing-md);
}

.card-footer {
  padding: var(--spacing-md);
  border-top: 1px solid var(--color-gray-200);
  background-color: var(--color-gray-50);
}

/* ==================== AUTH PAGES ==================== */
.auth-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--spacing-lg);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.auth-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--spacing-lg);
  background: rgba(255,255,255,0.2);
  border-radius: var(--border-radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: var(--color-white);
  font-weight: 700;
}

.auth-card {
  background: var(--color-white);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-lg);
}

.auth-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-gray-900);
  margin-bottom: var(--spacing-xs);
  text-align: center;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--color-gray-500);
  margin-bottom: var(--spacing-lg);
  text-align: center;
}

.auth-footer {
  margin-top: var(--spacing-lg);
  text-align: center;
  font-size: 14px;
  color: var(--color-gray-600);
}

.auth-footer a {
  color: var(--color-primary);
  font-weight: 500;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin: var(--spacing-lg) 0;
  color: var(--color-gray-500);
  font-size: 14px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background-color: var(--color-gray-200);
}

/* ==================== LOADING ==================== */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-gray-200);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

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

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* ==================== TOAST NOTIFICATIONS ==================== */
#toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10100; /* Maior que modal (10001) para aparecer na frente */
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 90%;
  width: 380px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(-20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  border-left: 4px solid var(--info);
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

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

.toast-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.toast-success .toast-icon { background: var(--success); }
.toast-error .toast-icon { background: var(--error); }
.toast-warning .toast-icon { background: var(--warning); }
.toast-info .toast-icon { background: var(--info); }

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-message {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.4;
  word-wrap: break-word;
}

.toast-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.toast-close:hover {
  opacity: 1;
}

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

/* ==================== MODAL ==================== */
#modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  /* altura = area visivel (dvh acompanha barra do navegador/teclado) */
  height: 100vh;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  padding-top: calc(20px + env(safe-area-inset-top, 0px));
  opacity: 0;
  transition: opacity 0.3s ease;
}

#modal-overlay.show {
  opacity: 1;
}

/* Qualquer janela dentro do overlay nunca passa da area visivel */
#modal-overlay > * {
  max-height: 100%;
}

/* Cabecalho e rodape fixos; so o corpo rola (telas pequenas, ex. 360x640) */
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 400px;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto; /* janelas sem .modal-body rolam inteiras */
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-lg);
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#modal-overlay.show .modal-box {
  transform: scale(1) translateY(0);
}

.modal-box > * {
  flex-shrink: 0;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-box > .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-body {
  padding: 24px;
}

.modal-body p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.6;
  font-size: 15px;
}

.modal-footer {
  padding: 16px 24px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap; /* botoes de texto longo descem de linha em vez de serem cortados (360px) */
  gap: 12px;
  justify-content: flex-end;
}

/* Compatibilidade */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal {
  background-color: var(--color-white);
  border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes slideDown { from { transform: translateY(0); } to { transform: translateY(100%); } }

/* ==================== UTILITIES ==================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: var(--spacing-xs); }
.mt-2 { margin-top: var(--spacing-sm); }
.mt-3 { margin-top: var(--spacing-md); }
.mt-4 { margin-top: var(--spacing-lg); }
.mb-1 { margin-bottom: var(--spacing-xs); }
.mb-2 { margin-bottom: var(--spacing-sm); }
.mb-3 { margin-bottom: var(--spacing-md); }
.mb-4 { margin-bottom: var(--spacing-lg); }
.text-muted { color: var(--color-gray-500); }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }

/* ==================== BOTÕES SOCIAIS ==================== */
.social-login {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.btn-social {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-social:hover:not(:disabled) {
  background: var(--background);
  border-color: var(--text-secondary);
}

.btn-social:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-social svg {
  width: 20px;
  height: 20px;
}

/* ==================== AUTH DIVIDER (atualizado) ==================== */
.auth-divider {
  display: flex;
  align-items: center;
  margin: 24px 0;
  gap: 16px;
}

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

.auth-divider span {
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
}

/* ==================== FIELD ERROR ==================== */
.field-error {
  display: block;
  font-size: 12px;
  color: var(--error);
  margin-top: 6px;
  min-height: 18px;
}

.form-group input.error,
.form-group input:invalid:not(:placeholder-shown) {
  border-color: var(--error);
}

/* ==================== FOOTER NAVIGATION ==================== */
.footer-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 20px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-around;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 12px;
  transition: all 0.2s;
  min-width: 56px;
}

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

.nav-item:hover {
  background: var(--background);
}

.nav-item i {
  font-size: 20px;
}

.nav-item span {
  font-size: 11px;
  font-weight: 500;
}

/* Spacer para conteudo nao ficar atras do footer */
.footer-spacer {
  height: 80px;
}
