/* Google Theme Variables */
:root {
  --bg-color: #ffffff;
  --text-color: #202124;
  --text-secondary: #70757a;
  --border-color: #dfe1e5;
  --btn-bg: #f8f9fa;
  --btn-border: #f8f9fa;
  --btn-text: #3c4043;
  --footer-bg: #f2f2f2;
  --footer-border: #dadce0;
  
  /* Google Logo Brand Colors */
  --g-blue: #4285F4;
  --g-red: #EA4335;
  --g-yellow: #FBBC05;
  --g-green: #34A853;
}

/* Global Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  position: fixed;
  width: 100%;
}

body {
  font-family: 'Inter', 'Sarabun', Arial, sans-serif;
  background-color: #ffffff;
  color: var(--text-color);
  display: flex;
  flex-direction: column;
}

/* Outer Layout Container */
.google-layout-container {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  min-height: 100dvh; /* Dynamic viewport height to prevent mobile browser height glitches */
  position: relative;
  width: 100%;
}

/* Top Header Navigation Row */
.top-nav {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 1rem 1.5rem;
  height: 60px;
}

.nav-pos-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  text-decoration: none;
  background: linear-gradient(135deg, #00c6ff 0%, #0072ff 60%, #1d4ed8 100%);
  color: #ffffff;
  border-radius: 6px;
  padding: 0.5rem 0.95rem;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: opacity 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 12px rgba(0, 114, 255, 0.2);
}

.nav-pos-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 114, 255, 0.3);
  color: #ffffff;
}

.nav-pos-btn:hover .arrow-icon {
  transform: translateX(2px);
}

.nav-pos-btn:active {
  transform: translateY(1px) scale(0.98);
}

.arrow-icon {
  transition: transform 0.15s ease;
}

/* Center Search Area (Flat Layout) */
.search-area {
  flex: 1 0 auto; /* Grow to fill remaining height, pushing footer to the bottom */
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 2.5rem 2.25rem;
  width: 100%;
  max-width: 480px;
  margin: 0 auto; /* Center horizontally only */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; /* Center search contents vertically */
  position: relative;
  z-index: 2;
}

/* Logo Styling */
.logo-wrapper {
  display: flex;
  align-items: baseline;
  font-family: 'Outfit', sans-serif;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 1.5rem;
  user-select: none;
  filter: drop-shadow(0 2px 6px rgba(0, 114, 255, 0.18));
}

.logo-main {
  background: linear-gradient(135deg, #00c6ff 0%, #0072ff 60%, #1d4ed8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-sub {
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: -0.5px;
  margin-left: 0.3rem;
}

/* Google Search Box Container */
.search-box-container {
  width: 100%;
  margin-bottom: 1rem;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 8px;
  height: 42px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.search-input-wrapper:hover {
  border-color: rgba(0, 114, 255, 0.35);
  box-shadow: 0 4px 12px rgba(0, 114, 255, 0.08);
}

.search-input-wrapper:focus-within {
  border-color: #0072ff;
  box-shadow: 0 4px 16px rgba(0, 114, 255, 0.15);
}

.search-icon {
  position: absolute;
  left: 12px;
  color: #9aa0a6;
  width: 16px;
  height: 16px;
}

#tracking-input {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-size: 0.88rem;
  color: var(--text-color);
  padding: 0 2.5rem;
  font-family: inherit;
}

.btn-clear {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  color: #70757a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
}

.btn-clear:hover {
  color: var(--text-color);
}

/* Detection Box */
.detection-box {
  width: 100%;
  background: rgba(15, 23, 42, 0.02);
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 8px;
  padding: 0.65rem 1rem;
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  animation: fadeIn 0.2s ease forwards;
}

.detect-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  letter-spacing: -0.01em;
}

.detect-badge.thpost {
  background-color: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.15);
}

.detect-badge.flash {
  background-color: rgba(245, 158, 11, 0.08);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.15);
}

.detect-badge.kerry {
  background-color: rgba(249, 115, 22, 0.08);
  color: #ea580c;
  border: 1px solid rgba(249, 115, 22, 0.15);
}

.detect-badge.jt {
  background-color: rgba(220, 38, 38, 0.08);
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, 0.15);
}

.detect-badge.shopee {
  background-color: rgba(249, 115, 22, 0.08);
  color: #ea580c;
  border: 1px solid rgba(249, 115, 22, 0.15);
}

.detect-badge.unknown {
  background-color: rgba(14, 74, 158, 0.06);
  color: #0e4a9e;
  border: 1px solid rgba(14, 74, 158, 0.15);
}

.detect-number {
  font-family: monospace;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-color);
}

/* Buttons Row */
.buttons-row {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.google-btn {
  background: linear-gradient(135deg, #00c6ff 0%, #0072ff 60%, #1d4ed8 100%);
  border: none;
  border-radius: 6px;
  color: #ffffff;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.55rem 1.25rem;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  min-width: 120px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 114, 255, 0.25);
}

.google-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 114, 255, 0.35);
  color: #ffffff;
}

.google-btn:active {
  transform: translateY(1px);
}

/* Supported Courier tags helper */
.carrier-tags-helper {
  font-size: 0.72rem;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  justify-content: center;
  line-height: 1.6;
}

.courier-tag {
  background: #f1f3f4;
  color: #3c4043;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-weight: 500;
}

/* Google-Style Footer */
.footer {
  background-color: var(--footer-bg);
  border-top: 1px solid var(--footer-border);
  width: 100%;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.footer-row {
  display: flex;
  padding: 0.75rem 1.5rem;
}

.footer-top {
  border-bottom: 1px solid var(--footer-border);
  font-weight: 500;
}

.footer-bottom {
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-links-left, .footer-links-right {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.footer-link {
  text-decoration: none;
  color: var(--text-secondary);
  transition: color 0.1s ease;
}

.footer-link:hover {
  color: var(--text-color);
  text-decoration: underline;
}

#footer-promo-link {
  font-weight: 700;
  color: var(--g-blue);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Toast Messages */
.toast-msg {
  position: fixed;
  bottom: 6rem;
  left: 50%;
  transform: translateX(-50%);
  background: #202124;
  color: white;
  font-size: 0.78rem;
  padding: 0.6rem 1.2rem;
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  animation: fadeIn 0.15s ease forwards;
}

/* Responsive Styles */
@media (max-width: 576px) {
  .top-nav {
    padding: 1.75rem 1.25rem 0.5rem !important; /* Added Safe Area notch spacing on mobile! */
  }
  .logo-wrapper {
    margin-bottom: 1.25rem !important;
  }
  .logo-wrapper img {
    width: 200px !important; /* Slightly smaller logo on small phone screen heights */
  }
  .footer-bottom {
    flex-direction: column !important;
    align-items: center !important;
    gap: 0.5rem !important;
    padding-bottom: 1.5rem !important;
  }
  .footer-links-left, .footer-links-right {
    justify-content: center !important;
    gap: 0.85rem !important;
    font-size: 0.72rem !important;
  }
}

/* Redirect Transition Overlay */
.redirect-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.2s ease forwards;
}

.redirect-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  padding: 1.75rem 1.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
}

/* Spinner Animation */
.spinner-ring {
  width: 32px;
  height: 32px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid var(--g-blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 0.25rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.redirect-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-color);
}

.carrier-target-box {
  background: #f8f9fa;
  border: 1px solid #dadce0;
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
}

.redirect-sub {
  font-size: 0.68rem;
  color: var(--text-secondary);
}

.redirect-promo-box {
  margin-top: 0.5rem;
  border-top: 1px dashed var(--border-color);
  padding-top: 0.8rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
}

.redirect-promo-box h4 {
  font-size: 0.75rem;
  font-weight: 700;
  color: #0F172A;
}

.redirect-promo-box p {
  font-size: 0.65rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.btn-promo-inline {
  text-decoration: none;
  background: var(--g-blue);
  color: white;
  font-weight: 700;
  font-size: 0.72rem;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  transition: background-color 0.15s ease;
  width: 100%;
  margin-top: 0.2rem;
}

.btn-promo-inline:hover {
  background-color: #357ae8;
}

/* PWA Install Banner Pop-up */
.pwa-install-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 480px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  padding: 1rem;
  z-index: 10000;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUp {
  0% { transform: translate(-50%, 100px); opacity: 0; }
  100% { transform: translate(-50%, 0); opacity: 1; }
}

.pwa-banner-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pwa-logo {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.pwa-text {
  flex: 1;
}

.pwa-text h4 {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-color);
  margin-bottom: 0.15rem;
}

.pwa-text p {
  font-size: 0.68rem;
  color: var(--text-secondary);
}

.pwa-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-pwa-sec {
  background: #f8f9fa;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-pwa-sec:hover {
  background: #e8eaed;
  color: var(--text-color);
}

.btn-pwa-pri {
  background: var(--g-blue);
  border: 1px solid var(--g-blue);
  border-radius: 6px;
  color: white;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-pwa-pri:hover {
  background: #357ae8;
  border-color: #357ae8;
}

/* For mobile devices, stack content vertically if needed, but flex row is clean */
@media (max-width: 480px) {
  .search-area {
    padding: 2.25rem 1.25rem 1.75rem;
    margin: 1.5rem auto;
    width: 94%;
  }
  .pwa-install-banner {
    width: 94%;
    bottom: 12px;
    padding: 0.8rem;
  }
  .pwa-logo {
    width: 36px;
    height: 36px;
  }
  .pwa-text h4 {
    font-size: 0.78rem;
  }
  .pwa-text p {
    font-size: 0.64rem;
  }
  .btn-pwa-pri, .btn-pwa-sec {
    padding: 0.35rem 0.65rem;
    font-size: 0.68rem;
  }
}

/* Search History Widget Styles */
.history-container {
  width: 100%;
  margin-top: 1.75rem;
  border-top: 1px solid rgba(226, 232, 240, 0.6);
  padding-top: 1.25rem;
  text-align: left;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.history-header span {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
}

.btn-clear-history {
  background: none;
  border: none;
  font-size: 0.68rem;
  font-weight: 600;
  color: #ef4444;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background-color 0.15s ease;
}

.btn-clear-history:hover {
  background-color: rgba(239, 68, 68, 0.08);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.history-item:hover {
  border-color: rgba(0, 114, 255, 0.2);
  box-shadow: 0 2px 8px rgba(0, 114, 255, 0.05);
  transform: translateY(-1px);
}

.history-item-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
}

.history-item-icon {
  color: var(--text-secondary);
  opacity: 0.5;
  display: flex;
  align-items: center;
}

.history-item-query {
  font-family: monospace;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-color);
}

.history-item-carrier {
  font-size: 0.62rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: -0.01em;
}

.history-item-delete {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.history-item-delete:hover {
  color: #ef4444;
  background-color: rgba(239, 68, 68, 0.08);
}

/* Hide footer and header when keyboard slides up on mobile (short screen height) */
@media (max-height: 520px) {
  .footer {
    display: none !important;
  }
  .top-nav {
    display: none !important;
  }
  .search-area {
    padding-top: 1rem !important;
    margin: 1rem auto !important;
  }
}

