/* Global Variables & Reset */
:root {
  --correios-blue: #00467f;
  --correios-blue-dark: #00335b;
  --correios-blue-button: #005696;
  --correios-yellow: #ffcc00;
  --correios-yellow-dark: #e6b800;
  --correios-card-bg: #eaeff4;
  --correios-text: #222222;
  --correios-text-muted: #555555;
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: #ffffff;
  color: var(--correios-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top Utility Bar */
.top-nav-bar {
  background-color: var(--correios-blue);
  color: #ffffff;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 6px 20px;
  letter-spacing: 0.5px;
}

.top-nav-inner {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.portal-tag {
  opacity: 0.95;
}

.top-nav-links {
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0.85;
}

.nav-sep {
  opacity: 0.5;
}

/* Minimalist Header with Yellow Line */
.header-minimal {
  background-color: #ffffff;
  border-bottom: 4px solid var(--correios-yellow);
  padding: 14px 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.header-container {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-badge {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--correios-blue);
  background-color: #eaf1f8;
  padding: 5px 14px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}

.correios-logo-svg {
  height: 32px;
  width: auto;
}

/* Main Container */
.main-content {
  flex: 1;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 28px 16px 44px 16px;
}

/* Search Card Component */
.search-card {
  background-color: var(--correios-card-bg);
  border: 1px solid #dce4ec;
  border-radius: 12px;
  padding: 26px 22px;
  margin-bottom: 24px;
  box-shadow: 0 4px 16px rgba(0, 70, 127, 0.05);
}

.search-prompt-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--correios-blue-button);
  margin-bottom: 18px;
}

/* Flex Row for Box Icon & Input */
.search-box-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.box-search-icon-left {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.box-search-icon-left svg {
  width: 100%;
  height: 100%;
}

.input-wrapper-rel {
  position: relative;
  flex: 1;
}

.input-wrapper-rel input {
  width: 100%;
  height: 48px;
  padding: 10px 40px 10px 14px;
  font-size: 0.95rem;
  font-weight: 500;
  border: 1px solid #767676;
  border-radius: 6px;
  background-color: #ffffff;
  font-family: inherit;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: #222;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper-rel input::placeholder {
  color: #888888;
  font-weight: 400;
  font-size: 0.88rem;
  text-transform: none;
}

.input-wrapper-rel input:focus {
  outline: none;
  border-color: var(--correios-blue-button);
  box-shadow: 0 0 0 3px rgba(0, 86, 150, 0.18);
}

.input-search-icon-right {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.input-search-icon-right svg {
  width: 100%;
  height: 100%;
}

.limit-hint {
  font-size: 0.8rem;
  color: var(--correios-text-muted);
  margin-top: 6px;
  margin-bottom: 18px;
}

.btn-consultar {
  width: 100%;
  height: 46px;
  background-color: var(--correios-blue-button);
  color: #ffffff;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}

.btn-consultar:hover {
  background-color: var(--correios-blue-dark);
}

.btn-consultar:active {
  transform: scale(0.99);
}

/* Loading Spinner Container */
.loading-container {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  margin-bottom: 24px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #cbd5e1;
  border-top-color: var(--correios-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

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

.loading-text {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--correios-blue);
}

/* Result Section Container */
.result-section {
  display: none;
  margin-bottom: 24px;
  animation: slideUpFade 0.4s ease-out;
}

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

.tracking-result-card {
  background-color: var(--correios-card-bg);
  border: 1px solid #dce4ec;
  border-radius: 12px;
  padding: 26px 22px;
  box-shadow: 0 4px 16px rgba(0, 70, 127, 0.05);
}

.result-header {
  text-align: center;
  margin-bottom: 24px;
}

.service-name {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--correios-blue);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.service-arrow {
  color: var(--correios-yellow-dark);
  font-weight: 900;
}

.estimate-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--correios-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.estimate-value {
  font-size: 1.05rem;
  font-weight: 800;
  font-style: italic;
  color: #222222;
  margin-top: 2px;
}

/* Timeline Components */
.timeline {
  position: relative;
  margin: 0 0 24px 8px;
  padding-left: 10px;
}

.timeline-item {
  position: relative;
  padding-left: 44px;
  padding-bottom: 28px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

/* Yellow Line Connector */
.timeline-item::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 32px;
  bottom: -4px;
  width: 3px;
  background-color: var(--correios-yellow);
}

.timeline-item:last-child::before {
  display: none;
}

.timeline-icon {
  position: absolute;
  left: 0;
  top: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: #ffffff;
  border: 1px solid #d0d7de;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--correios-blue);
  z-index: 2;
}

.timeline-icon svg {
  width: 18px;
  height: 18px;
}

.timeline-details {
  padding-top: 2px;
}

.timeline-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 4px;
  line-height: 1.35;
}

.timeline-date {
  font-size: 0.82rem;
  color: #666666;
  font-weight: 500;
}

/* Action Button Inside Result Card */
.result-action-box {
  margin-top: 16px;
}

.btn-intermediacao {
  background-color: var(--correios-blue-button);
  color: #ffffff;
  border: none;
  padding: 12px 22px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 2px 6px rgba(0, 86, 150, 0.25);
}

.btn-intermediacao:hover {
  background-color: var(--correios-blue-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 86, 150, 0.35);
}

.btn-intermediacao:active {
  transform: translateY(0);
}

/* Promo Banner Image */
.promo-banner {
  border-radius: 12px;
  overflow: hidden;
  margin-top: 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  border: 1px solid #e1e7ec;
}

.banner-img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

/* Yellow Institutional Footer */
.footer-yellow {
  background-color: var(--correios-yellow);
  color: #000000;
  padding: 40px 24px 28px 24px;
  margin-top: auto;
}

.footer-inner {
  max-width: 1040px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
}

@media (min-width: 768px) {
  .footer-inner {
    grid-template-columns: 1.2fr 1fr 1fr;
    gap: 40px;
  }
}

.footer-section h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: #000000;
  margin-bottom: 16px;
  letter-spacing: -0.2px;
}

.footer-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.footer-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  font-weight: 500;
  color: #1a1a1a;
  cursor: default;
}

.footer-item-label {
  color: #1a1a1a;
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.35;
  cursor: default;
}

/* Black Icons Styling */
.icon-black {
  width: 18px;
  height: 18px;
  stroke: #000000;
  fill: none;
  flex-shrink: 0;
}

.copyright-bar {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid rgba(0, 0, 0, 0.12);
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: #333333;
  grid-column: 1 / -1;
}

/* Modal Popup Window */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  padding: 20px;
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.modal-window {
  background-color: #ffffff;
  border-radius: 8px;
  width: 100%;
  max-width: 440px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  transform: translateY(12px);
  transition: transform 0.25s ease;
}

.modal-backdrop.active .modal-window {
  transform: translateY(0);
}

.modal-header {
  padding: 16px 20px 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.modal-title-text {
  font-size: 1.25rem;
  font-weight: 800;
  color: #222222;
  width: 100%;
  text-align: center;
}

.modal-close-icon {
  position: absolute;
  right: 16px;
  top: 14px;
  background: none;
  border: none;
  font-size: 1.6rem;
  color: #666666;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.modal-close-icon:hover {
  color: #000000;
}

.modal-body-content {
  padding: 10px 24px 24px 24px;
  font-size: 0.88rem;
  color: #333333;
  line-height: 1.55;
  overflow-y: auto;
  text-align: left;
}

.modal-body-content p {
  margin-bottom: 12px;
}

.modal-body-content strong {
  font-weight: 700;
  color: #111111;
}

/* Mobile Optimization (iPhone, Android, Tablets) */
@media (max-width: 600px) {
  /* Prevent iOS Safari auto-zoom on input focus */
  .input-wrapper-rel input {
    font-size: 16px !important;
    height: 48px;
  }

  .main-content {
    padding: 16px 12px 32px 12px;
  }

  .search-card {
    padding: 20px 16px;
    border-radius: 10px;
    margin-bottom: 18px;
  }

  .search-prompt-title {
    font-size: 1.2rem;
    margin-bottom: 14px;
  }

  .box-search-icon-left {
    width: 38px;
    height: 38px;
  }

  .btn-consultar {
    height: 48px;
    font-size: 1rem;
    font-weight: 700;
  }

  .tracking-result-card {
    padding: 20px 16px;
    border-radius: 10px;
    margin-bottom: 18px;
  }

  .service-name {
    font-size: 1.15rem;
  }

  .timeline {
    margin-left: 0;
    padding-left: 2px;
  }

  .timeline-item {
    padding-left: 40px;
    padding-bottom: 22px;
  }

  .timeline-icon {
    width: 30px;
    height: 30px;
  }

  .timeline-icon svg {
    width: 16px;
    height: 16px;
  }

  .timeline-item::before {
    left: 14px;
    top: 30px;
  }

  .timeline-title {
    font-size: 0.88rem;
  }

  .timeline-date {
    font-size: 0.78rem;
  }

  .btn-intermediacao {
    width: 100%;
    padding: 13px 18px;
    font-size: 0.95rem;
  }

  .promo-banner {
    border-radius: 10px;
    margin-top: 18px;
  }

  /* Footer on Mobile with Safe Area for iPhone */
  .footer-yellow {
    padding: 28px 18px max(28px, env(safe-area-inset-bottom)) 18px;
  }

  .footer-inner {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .footer-section h3 {
    font-size: 1.1rem;
    margin-bottom: 12px;
  }

  .footer-list {
    gap: 10px;
  }

  .footer-list li {
    font-size: 0.88rem;
  }

  /* Modal on Mobile */
  .modal-window {
    width: calc(100vw - 24px);
    max-height: 85vh;
    border-radius: 12px;
  }

  .modal-header {
    padding: 14px 16px;
  }

  .modal-title-text {
    font-size: 1.15rem;
  }

  .modal-body-content {
    padding: 10px 18px 22px 18px;
    font-size: 0.86rem;
  }
}

/* Extra small devices (iPhone SE, 320-375px) */
@media (max-width: 380px) {
  .search-box-row {
    gap: 8px;
  }
  
  .box-search-icon-left {
    width: 32px;
    height: 32px;
  }
  
  .input-wrapper-rel input {
    padding: 10px 36px 10px 10px;
  }
}
