/* ==========================================================================
   Consulta de Boletos — Ergontech Soluções
   Cores alinhadas a ergontech.com.br (#42c1c7 / #2a4d5e)
   ========================================================================== */

:root {
  --color-bg: #f3fafb;
  --color-bg-pattern: #e8f4f5;
  --color-surface: #ffffff;
  --color-border: #cfe6e8;
  --color-border-soft: #eef6f7;
  --color-text: #162f3b;
  --color-text-muted: #385767;
  --color-text-soft: #7a8f98;
  --color-primary: #42c1c7;
  --color-primary-hover: #2fa8ae;
  --color-primary-dark: #2a4d5e;
  --color-primary-soft: #e6f7f8;
  --color-accent: #64d9df;
  --color-warning: #f5a623;
  --color-warning-bg: #fff8e6;
  --color-warning-border: #f0d78c;
  --color-warning-text: #8a6d1b;
  --color-danger: #c0392b;
  --color-danger-bg: #fdf0ee;
  --color-danger-border: #f0c4be;
  --color-success: #7baf42;
  --color-success-bg: #f3f9eb;
  --color-info: #2a4d5e;
  --color-info-bg: #eef4f6;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(22, 47, 59, 0.06);
  --shadow-md: 0 4px 16px rgba(22, 47, 59, 0.08);
  --font-sans: "DM Sans", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --space: 1rem;
  --max-width: 780px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--color-text);
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(66, 193, 199, 0.28) 0%, transparent 55%),
    linear-gradient(180deg, var(--color-bg) 0%, var(--color-bg-pattern) 100%);
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  margin-bottom: 1.75rem;
  padding: 1.15rem 1.25rem;
  background: linear-gradient(135deg, #2a4d5e 0%, #162f3b 100%);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(22, 47, 59, 0.22);
  color: #fff;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 0.95rem;
}

.header__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--color-accent) 0%, var(--color-primary) 55%, #2fa8ae 100%);
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(66, 193, 199, 0.45);
}

.header__copy {
  min-width: 0;
}

.header__brand-name {
  margin: 0 0 0.15rem;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-primary);
  line-height: 1.2;
}

.header__title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: #ffffff;
}

.header__tagline {
  margin: 0;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.4;
  flex: 1;
}

.header__bottom {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(66, 193, 199, 0.28);
}

.btn--install-header {
  height: 34px;
  padding: 0 0.75rem;
  background: rgba(66, 193, 199, 0.18);
  color: var(--color-primary);
  border: 1px solid rgba(66, 193, 199, 0.45);
  font-size: 0.8125rem;
  flex-shrink: 0;
}

.btn--install-header:hover:not(:disabled) {
  background: rgba(66, 193, 199, 0.3);
}

/* --------------------------------------------------------------------------
   PWA install banner
   -------------------------------------------------------------------------- */

.install-banner {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  background: #ffffff;
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
}

.install-banner__content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.install-banner__icon img {
  display: block;
  border-radius: 10px;
}

.install-banner__text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.install-banner__text strong {
  font-size: 0.9rem;
  color: var(--color-text);
}

.install-banner__text span {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.install-banner__actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn--install {
  height: 36px;
  min-width: auto;
  padding: 0 1rem;
  font-size: 0.875rem;
}

.btn--install-dismiss {
  height: 36px;
  background: transparent;
  color: var(--color-text-muted);
}

.btn--install-dismiss:hover:not(:disabled) {
  background: var(--color-border-soft);
  color: var(--color-text);
}

.main {
  flex: 1;
}

.footer {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
  text-align: center;
}

.footer p {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--color-text-soft);
}

/* --------------------------------------------------------------------------
   Search panel
   -------------------------------------------------------------------------- */

.search-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}

.search-panel__title {
  margin: 0 0 0.25rem;
  font-size: 1.0625rem;
  font-weight: 650;
}

.search-panel__hint {
  margin: 0 0 1.25rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.field__label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 0.4rem;
}

.field__control {
  display: flex;
  gap: 0.625rem;
  flex-wrap: wrap;
}

.field__input {
  flex: 1;
  min-width: 200px;
  height: 46px;
  padding: 0 0.875rem;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--color-text);
  background: #fafbfc;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.field__input:hover {
  border-color: #9ecfd3;
}

.field__input:focus {
  border-color: var(--color-primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(66, 193, 199, 0.22);
}

.field__input.is-invalid {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.12);
}

.field__error {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  color: var(--color-danger);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 46px;
  padding: 0 1.25rem;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--color-primary);
  color: #fff;
  min-width: 130px;
  box-shadow: 0 2px 8px rgba(66, 193, 199, 0.35);
}

.btn--primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.btn--ghost {
  height: 34px;
  padding: 0 0.75rem;
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
  font-size: 0.8125rem;
}

.btn--ghost:hover:not(:disabled) {
  background: #d4f1f3;
}

.btn--copy.is-copied {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.btn__spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --------------------------------------------------------------------------
   Alerts
   -------------------------------------------------------------------------- */

.alert {
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
  border: 1px solid transparent;
}

.alert--error {
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
  color: var(--color-danger);
}

.alert--info {
  background: var(--color-info-bg);
  border-color: #c5dde0;
  color: var(--color-info);
}

.alert--success {
  background: var(--color-success-bg);
  border-color: #b8dfc8;
  color: var(--color-success);
}

/* --------------------------------------------------------------------------
   Results toolbar & filters
   -------------------------------------------------------------------------- */

.results__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.results__count {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  background: var(--color-surface);
  padding: 0.3rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.filter-btn {
  height: 32px;
  padding: 0 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.filter-btn:hover {
  color: var(--color-text);
  background: var(--color-border-soft);
}

.filter-btn.is-active {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(66, 193, 199, 0.35);
}

/* --------------------------------------------------------------------------
   Boletos vencidos (alerta vermelho) — aparece primeiro
   -------------------------------------------------------------------------- */

.vencidos {
  margin-bottom: 1.5rem;
}

.vencidos__banner {
  display: flex;
  gap: 0.875rem;
  align-items: flex-start;
  padding: 1rem 1.125rem;
  background: var(--color-danger-bg);
  border: 1.5px solid var(--color-danger-border);
  border-radius: var(--radius-md);
  margin-bottom: 0.875rem;
}

.vencidos__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #f8d4cf;
  color: var(--color-danger);
}

.vencidos__title {
  margin: 0 0 0.2rem;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--color-danger);
}

.vencidos__text {
  margin: 0;
  font-size: 0.8125rem;
  color: #8f3a32;
  line-height: 1.45;
}

.vencidos .boleto-card {
  border-color: var(--color-danger-border);
  background: linear-gradient(180deg, #fff8f7 0%, #fff 60%);
}

.vencidos .boleto-card + .boleto-card {
  margin-top: 0.75rem;
}

/* --------------------------------------------------------------------------
   Próximos vencimentos (alerta amarelo)
   -------------------------------------------------------------------------- */

.proximos {
  margin-bottom: 1.5rem;
}

.proximos__banner {
  display: flex;
  gap: 0.875rem;
  align-items: flex-start;
  padding: 1rem 1.125rem;
  background: var(--color-warning-bg);
  border: 1.5px solid var(--color-warning-border);
  border-radius: var(--radius-md);
  margin-bottom: 0.875rem;
}

.proximos__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #ffe9a8;
  color: var(--color-warning-text);
}

.proximos__title {
  margin: 0 0 0.2rem;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--color-warning-text);
}

.proximos__text {
  margin: 0;
  font-size: 0.8125rem;
  color: #7a6420;
  line-height: 1.45;
}

.proximos .boleto-card {
  border-color: var(--color-warning-border);
  background: linear-gradient(180deg, #fffdf7 0%, #fff 60%);
}

.proximos .boleto-card + .boleto-card {
  margin-top: 0.75rem;
}

/* --------------------------------------------------------------------------
   Boleto cards
   -------------------------------------------------------------------------- */

.boleto-list {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.boleto-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.125rem 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, border-color 0.15s;
}

.boleto-card:hover {
  box-shadow: var(--shadow-md);
}

.boleto-card[data-status="vencido"] {
  border-left: 3px solid var(--color-danger);
}

.boleto-card[data-status="proximo"] {
  border-left: 3px solid var(--color-warning);
}

.boleto-card[data-status="a_vencer"] {
  border-left: 3px solid var(--color-info);
}

.boleto-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.boleto-card__label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-soft);
  margin-bottom: 0.15rem;
}

.boleto-card__data {
  font-size: 1rem;
  font-weight: 650;
}

.boleto-card__badge {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 0.65rem;
  font-size: 0.75rem;
  font-weight: 650;
  border-radius: 999px;
  white-space: nowrap;
}

.boleto-card__badge--proximo {
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
  border: 1px solid var(--color-warning-border);
}

.boleto-card__badge--vencido {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid var(--color-danger-border);
}

.boleto-card__badge--a_vencer {
  background: var(--color-info-bg);
  color: var(--color-info);
  border: 1px solid #c5dde0;
}

.boleto-card__badge--indefinido {
  background: var(--color-border-soft);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.boleto-card__valor {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
  margin-bottom: 0.875rem;
}

.boleto-card__meta {
  margin-bottom: 0.875rem;
  padding-bottom: 0.875rem;
  border-bottom: 1px solid var(--color-border-soft);
}

.boleto-card__nosso {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 500;
}

.boleto-card__linha-row {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  flex-wrap: wrap;
}

.boleto-card__codigo {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.55;
  color: var(--color-text);
  background: #f3fafb;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem;
  word-break: break-all;
}

/* --------------------------------------------------------------------------
   Empty states
   -------------------------------------------------------------------------- */

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--color-text-muted);
  font-size: 0.9375rem;
}

.empty-state--initial {
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 3rem 1.5rem;
}

.empty-state__icon {
  color: var(--color-text-soft);
  margin-bottom: 0.75rem;
}

.empty-state p {
  margin: 0;
  max-width: 320px;
  margin-inline: auto;
}

.empty-state .btn {
  margin-top: 0.875rem;
}

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */

[hidden] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 560px) {
  .page {
    padding: 1.1rem 0.875rem 2rem;
  }

  .header {
    padding: 1rem 1.05rem;
  }

  .header__title {
    font-size: 1.25rem;
  }

  .header__brand-name {
    font-size: 0.75rem;
  }

  .header__bottom {
    flex-direction: column;
    align-items: stretch;
  }

  .btn--install-header {
    width: 100%;
  }

  .install-banner {
    flex-direction: column;
    align-items: stretch;
  }

  .install-banner__actions {
    width: 100%;
  }

  .install-banner__actions .btn {
    flex: 1;
  }

  .search-panel {
    padding: 1.15rem;
  }

  .field__control {
    flex-direction: column;
  }

  .field__input,
  .btn--primary {
    width: 100%;
  }

  .boleto-card__valor {
    font-size: 1.3rem;
  }

  .filter-group {
    width: 100%;
  }

  .filter-btn {
    flex: 1;
    text-align: center;
    justify-content: center;
  }

  .proximos__banner,
  .vencidos__banner {
    flex-direction: column;
    gap: 0.65rem;
  }
}
