@import url("https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700;800&display=swap");

:root {
  --header-start: #287b99;
  --header-end: #0066cc;
  --title-blue: #0077b3;
  --footer-blue: #287b99;
  --panel-bg: #f5f5f5;
  --result-bg: #f0f4f8;
  --page-bg: #ffffff;
  --text: #18181b;
  --muted: #5c5c5c;
  --value: #666671;
  --line: #d1d5db;
  --line-light: #dee2e6;
  --label-bg: #f9fafb;
  --primary: #0a58ca;
  --primary-hover: #0846a0;
  --danger: #dc3545;
  --danger-hover: #b02a37;
  --pay: #00897b;
  --pay-hover: #00796b;
  --warning: #8a5a00;
  --success: #187353;
  --back-pink: #f06292;
  --icon-blue: #1e88e5;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  width: 100%;
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--page-bg);
  color: var(--text);
  font-family: "Open Sans", Arial, Helvetica, sans-serif;
}

.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: 105px;
  padding: 0 32px;
  background: linear-gradient(90deg, var(--header-start), var(--header-end));
  color: #ffffff;
}

.header-logo-detran {
  display: block;
  width: auto;
  max-width: min(240px, 52vw);
  height: 100px;
  object-fit: contain;
}

.header-logo-gov {
  display: block;
  width: auto;
  max-width: min(190px, 36vw);
  height: 75px;
  object-fit: contain;
}

main {
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 187px);
  background: var(--page-bg);
}

.content-strip,
.result-strip {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.result-strip {
  padding: 24px 16px 40px;
  background: var(--result-bg);
}

.title-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #ecf0f5;
}

.title-strip h1 {
  max-width: 100%;
  margin: 0;
  color: var(--title-blue);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: break-word;
}

.search-container {
  width: 100%;
  padding: 20px;
  background: #ffffff;
}

.search-card {
  width: min(800px, 100%);
  margin: 0 auto;
  overflow: hidden;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.search-card-header {
  padding: 16px 20px;
  background: var(--panel-bg);
  color: var(--muted);
  font-size: 18px;
  font-weight: 700;
}

.search-card-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.search-card-body {
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
}

.search-card-body .fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 0 0 20px;
}

.search-card-body .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.search-card-body label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.search-card-body .required {
  color: #dc3545;
}

.search-card-body input {
  width: 100%;
  height: 46px;
  border: 1px solid #c1c1c1;
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
  color: #333333;
  font-size: 14px;
  font-weight: 500;
  outline: none;
  transition: border-color 0.2s;
}

.search-card-body input#plate {
  text-transform: uppercase;
}

.search-card-body input:focus {
  border-color: #3b82f6;
  box-shadow: none;
}

.search-card-body .actions {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  padding: 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  padding: 0 16px;
  gap: 6px;
}

.search-card-body .button {
  width: 85px;
  height: 35px;
  padding: 0;
}

.search-card-body .button--primary {
  background: #0a58ca;
}

.button--primary {
  background: var(--primary);
}

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

.search-card-body .button--primary:hover {
  opacity: 0.8;
}

.search-card-body .button--danger {
  background: #dc2626;
}

.search-card-body .button--danger:hover {
  opacity: 0.8;
}

.button--pay {
  width: 92px;
  height: 32px;
  border-color: var(--pay);
  border-radius: 4px;
  background: var(--pay);
  font-size: 13px;
  font-weight: 700;
}

.button--pay:hover {
  background: var(--pay-hover);
}

.button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.result {
  margin: 0 42px 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px 16px;
  background: #fafafa;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.result strong {
  display: block;
  margin-bottom: 4px;
  color: inherit;
}

.result--error {
  border-color: #f0aaa7;
  background: #fff7f7;
  color: #9b2723;
}

.result--warning {
  border-color: #efd48e;
  background: #fffaf0;
  color: var(--warning);
}

.result--success {
  border-color: #9bd2bd;
  background: #f2fbf7;
  color: var(--success);
}

.result a {
  color: inherit;
  font-weight: 800;
}

.result-main-title {
  width: 100%;
  max-width: 980px;
  margin: 0 auto 24px;
  color: var(--title-blue);
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.result-main-title span {
  display: inline;
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 980px;
  margin: 0 auto 20px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--title-blue);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}

.back-button svg {
  flex: none;
  width: 44px;
  height: 44px;
}

.back-button span {
  margin-top: 2px;
}

.info-panel,
.debts-panel {
  width: 100%;
  max-width: 980px;
  margin: 0 auto 20px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid #e0e0e0;
  background: #ffffff;
}

.debts-header {
  justify-content: space-between;
  background: var(--panel-bg);
}

.panel-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: var(--icon-blue);
}

.panel-icon svg {
  width: 14px;
  height: 14px;
}

.panel-header h2 {
  margin: 0;
  color: #222222;
  font-size: 15px;
  font-weight: 700;
}

.debts-header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.selected-total {
  margin: 0;
  color: #000000;
  font-size: 15px;
  font-weight: 700;
}

.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.info-table td {
  padding: 10px 16px;
  border-bottom: 1px solid #eeeeee;
}

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

.info-table td:nth-child(odd) {
  width: 15%;
  background: var(--label-bg);
  color: #333333;
  font-weight: 700;
}

.info-table td:nth-child(even) {
  width: 35%;
  background: #ffffff;
  color: #666666;
  font-weight: 400;
}

.debts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.debts-table th,
.debts-table td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid #eeeeee;
}

.debts-table th {
  color: #666666;
  font-weight: 700;
  background: #ffffff;
}

.debts-table td {
  color: #333333;
}

.debts-table td:nth-child(4),
.debts-table td:nth-child(5),
.debts-table th:nth-child(4),
.debts-table th:nth-child(5) {
  text-align: right;
}

.debts-table td:nth-child(5) {
  font-weight: 700;
}

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

.checkbox-cell {
  width: 48px;
  text-align: center;
}

.debts-table input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 1px solid #9ca3af;
  border-radius: 2px;
  background-color: #ffffff;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 12px 12px;
  cursor: pointer;
  accent-color: var(--icon-blue);
  vertical-align: middle;
  -webkit-tap-highlight-color: transparent;
}

.debts-table input[type="checkbox"]:checked {
  border-color: var(--icon-blue);
  background-color: var(--icon-blue);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M3.5 8.5 6.5 11.5 12.5 4.5'/%3E%3C/svg%3E");
}

.debts-table input[type="checkbox"]:focus {
  outline: none;
}

.debts-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid #e0e0e0;
  background: var(--panel-bg);
}

.portal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
  background: var(--footer-blue);
  color: #ffffff;
}

.footer-logo-gov {
  display: block;
  width: 240px;
  height: 95px;
}

.footer-logo-detran {
  display: block;
  width: 240px;
  height: 119px;
}

.footer-logo-prodest {
  display: block;
  width: 240px;
  height: 95px;
}

.footer-prodest {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.25;
}

.footer-prodest span {
  display: block;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.42);
  z-index: 10;
}

.loading-overlay[hidden] {
  display: none;
}

.loading-box {
  width: min(340px, 100%);
  border-radius: 6px;
  padding: 24px 22px;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.25);
  color: var(--text);
  text-align: center;
}

.loading-box strong {
  display: block;
  margin-top: 12px;
  color: #222222;
  font-size: 20px;
}

.loading-box p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.spinner {
  display: inline-block;
  width: 42px;
  height: 42px;
  border: 4px solid #d7ebf8;
  border-top-color: var(--title-blue);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.payment-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.6);
  z-index: 20;
}

.payment-modal[hidden] {
  display: none;
}

.payment-modal-content {
  position: relative;
  width: min(440px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  border-radius: 12px;
  padding: 28px 24px 30px;
  background: #ffffff;
  text-align: center;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.25);
}

.payment-modal-content h2 {
  margin: 0 40px 20px;
  color: var(--title-blue);
  font-size: 20px;
  line-height: 1.25;
}

.payment-modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.payment-modal-close:hover {
  background: #f3f4f6;
  color: var(--text);
}

#qr-code-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 0 0 16px;
}

#qr-code-container img,
#qr-code-container canvas {
  display: block;
  width: min(256px, 100%);
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

#payment-status,
#qr-code-container .result {
  width: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

#payment-status.result--success {
  color: var(--success);
  font-weight: 700;
}

.payment-success-animation {
  position: relative;
  width: 58px;
  height: 58px;
  margin: -2px 0 -4px;
}

.payment-success-animation::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(24, 115, 83, 0.18);
  transform: scale(0.7);
  opacity: 0;
}

.payment-success-animation svg {
  position: relative;
  z-index: 1;
  display: block;
  width: 58px;
  height: 58px;
}

.payment-success-circle {
  fill: var(--success);
  stroke: rgba(255, 255, 255, 0.65);
  stroke-width: 2;
  transform-origin: center;
}

.payment-success-check {
  fill: none;
  stroke: #ffffff;
  stroke-dasharray: 34;
  stroke-dashoffset: 34;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 6;
}

.payment-success-animation.is-animated {
  animation: paymentSuccessPop 460ms cubic-bezier(0.2, 0.9, 0.25, 1.25) both;
}

.payment-success-animation.is-animated::before {
  animation: paymentSuccessPulse 720ms ease-out both;
}

.payment-success-animation.is-animated .payment-success-check {
  animation: paymentSuccessDraw 520ms ease-out 180ms forwards;
}

.payment-approved #qr-code-container img,
.payment-approved #qr-code-container canvas {
  animation: paymentQrApproved 420ms ease-out both;
}

#pix-key-display {
  margin: 0 0 18px;
}

.pix-code-display {
  text-align: left;
}

.pix-code-label {
  display: block;
  margin-bottom: 6px;
  color: #374151;
  font-size: 13px;
  font-weight: 700;
}

.pix-code-value {
  display: block;
  width: 100%;
  min-height: 112px;
  max-height: 156px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f9fafb;
  color: #374151;
  font-family: "Open Sans", Arial, Helvetica, sans-serif;
  font-size: 12px;
  line-height: 1.45;
  cursor: text;
  overflow-wrap: anywhere;
  text-align: left;
  user-select: all;
  white-space: break-spaces;
  -webkit-user-select: all;
}

#copy-pix-button {
  width: min(260px, 100%);
  min-height: 44px;
  touch-action: manipulation;
  font-weight: 700;
}

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

@keyframes paymentSuccessPop {
  0% {
    opacity: 0;
    transform: scale(0.65);
  }
  70% {
    opacity: 1;
    transform: scale(1.08);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes paymentSuccessPulse {
  0% {
    opacity: 0.8;
    transform: scale(0.7);
  }
  100% {
    opacity: 0;
    transform: scale(1.8);
  }
}

@keyframes paymentSuccessDraw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes paymentQrApproved {
  0% {
    transform: scale(1);
  }
  55% {
    transform: scale(0.985);
  }
  100% {
    transform: scale(1);
  }
}

@media (max-width: 700px) {
  .portal-header {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
    gap: 14px;
    height: 103px;
    overflow: hidden;
    padding: 0 32px;
  }

  .header-logo-detran {
    width: min(220px, 43vw);
    height: auto;
    max-height: 88px;
  }

  .header-logo-gov {
    width: min(210px, 41vw);
    height: auto;
    max-height: 82px;
  }

  .identity--gov {
    justify-content: flex-start;
  }

  .local-chip {
    white-space: normal;
  }

  main {
    min-height: calc(100dvh - 186px);
    padding: 0 0 0;
  }

  .title-strip {
    min-height: 126px;
    padding: 28px 16px 30px;
  }

  .title-strip h1 {
    width: min(100%, 330px);
    font-size: clamp(25px, 7.1vw, 31px);
    line-height: 1.45;
    letter-spacing: 0;
  }

  .search-container {
    padding: 36px 34px 8px;
  }

  .search-card {
    width: 100%;
    border-radius: 6px;
  }

  .search-card-header {
    padding: 18px 28px;
  }

  .search-card-header h2 {
    font-size: 18px;
  }

  .search-card-body {
    padding: 18px 28px 28px;
  }

  .search-card-body .fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px;
    padding: 0 0 24px;
  }

  .search-card-body label {
    font-size: 14px;
  }

  .search-card-body input {
    height: 48px;
    font-size: 14px;
  }

  .search-card-body .actions {
    gap: 14px;
    padding: 0;
  }

  .search-card-body .button {
    width: 92px;
    height: 38px;
    font-size: 14px;
  }

  .result {
    margin-inline: 22px;
  }

  .payment-modal {
    align-items: center;
    padding: 12px;
  }

  .payment-modal-content {
    width: 100%;
    max-height: calc(100dvh - 24px);
    margin-top: 0;
    padding: 24px 14px 18px;
  }

  .payment-modal-content h2 {
    margin: 0 34px 16px;
    font-size: 19px;
  }

  #qr-code-container {
    gap: 10px;
    margin-bottom: 14px;
  }

  #qr-code-container img,
  #qr-code-container canvas {
    width: min(230px, 76vw);
  }

  #pix-key-display {
    margin-bottom: 14px;
  }

  .pix-code-value {
    min-height: 64px;
    max-height: 120px;
    padding: 10px;
    font-size: 11px;
  }

  #copy-pix-button {
    width: 100%;
  }

  .result-main-title {
    font-size: 18px;
  }

  .back-button {
    font-size: 18px;
  }

  .debts-header {
    align-items: center;
    gap: 10px;
  }

  .debts-header-actions {
    flex: 1;
    justify-content: space-between;
    gap: 10px;
  }

  .debts-header h2 {
    flex: 0 0 120px;
    font-size: 20px;
    font-weight: 400;
    line-height: 1.3;
  }

  .selected-total {
    max-width: 130px;
    font-size: 14px;
    line-height: 1.25;
  }

  .info-table tr {
    display: grid;
    grid-template-columns: minmax(130px, 46%) 1fr;
  }

  .info-table td {
    display: block;
    width: auto !important;
    min-height: 37px;
    padding: 9px 16px;
    border-bottom: 1px solid var(--line-light);
  }

  .info-table tr:last-child td {
    border-bottom: 1px solid var(--line-light);
  }

  .info-table tr:last-child td:nth-last-child(-n + 2) {
    border-bottom: none;
  }

  .debts-table,
  .debts-table thead,
  .debts-table tbody,
  .debts-table th,
  .debts-table td,
  .debts-table tr {
    display: block;
  }

  .debts-table thead {
    padding: 12px 16px;
    border-top: 1px solid var(--line-light);
    border-bottom: 1px solid var(--line-light);
  }

  .debts-table thead tr {
    display: flex;
  }

  .debts-table thead th {
    display: none;
  }

  .debts-table thead .checkbox-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    width: auto;
    padding: 0;
    border: none;
    color: var(--muted);
    font-weight: 400;
    text-align: left;
  }

  .debts-table thead .checkbox-cell::after {
    content: "Selecionar todos";
  }

  .debts-table tbody {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
  }

  .debts-table tbody tr {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    row-gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
  }

  .debts-table td {
    border: none;
    padding: 0;
    position: relative;
    text-align: left;
  }

  .debts-table tbody tr::after {
    content: attr(data-card-total);
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    color: #374151;
    font-weight: 700;
  }

  .debts-table tbody td:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
  }

  .debts-table tbody td:nth-child(2),
  .debts-table tbody td:nth-child(3) {
    grid-column: 1 / -1;
  }

  .debts-table tbody td:nth-child(4) {
    grid-column: 1;
  }

  .debts-table tbody td:nth-child(5) {
    grid-column: 2;
  }

  .debts-table td:nth-child(4),
  .debts-table td:nth-child(5) {
    text-align: right;
  }

  .debts-table tbody td:nth-child(4) {
    text-align: left;
  }

  .debts-table tbody td:nth-child(5)::before {
    text-align: right;
  }

  .debts-table td::before {
    content: attr(data-label);
    display: block;
    position: static;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
    text-align: left;
  }

  .debts-table .checkbox-cell::before {
    content: none;
  }

  .debts-footer {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .portal-footer {
    align-items: center;
    flex-direction: column;
    padding: 18px 20px;
  }

  .footer-logo,
  .footer-logo--gov {
    justify-content: center;
    min-width: 0;
  }
}

@media (max-width: 420px) {
  .portal-header {
    height: 103px;
    padding: 0 28px;
  }

  .header-logo-detran {
    width: min(210px, 43vw);
    max-height: 86px;
  }

  .header-logo-gov {
    width: min(200px, 41vw);
    max-height: 78px;
  }

  .title-strip h1 {
    width: min(100%, 320px);
    font-size: 28px;
  }

  .search-container {
    padding-inline: 28px;
  }

  .search-card-header {
    padding-inline: 24px;
  }

  .search-card-body {
    padding-inline: 24px;
  }

  .search-card-body .fields {
    gap: 20px;
  }
}
