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

/* Root Variables */
:root {
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-success: #059669;
  --color-error: #dc2626;
  --color-warning: #d97706;
  --color-text: #1f2937;
  --color-text-light: #6b7280;
  --color-border: #e5e7eb;
  --color-background: #ffffff;
  --color-surface: #f9fafb;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --transition: all 0.2s ease-in-out;
}

/* Base Styles */
html {
  font-size: 16px;
  line-height: 1.5;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell',
    sans-serif;
  color: var(--color-text);
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* App Layout */
.app {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 2rem;
}

.title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.5rem;
  letter-spacing: -0.025em;
}

.subtitle {
  font-size: 1rem;
  color: var(--color-text-light);
  font-weight: 400;
}

/* Main Content */
.main {
  margin-bottom: 2rem;
}

.search-card {
  background: var(--color-background);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  border: 1px solid var(--color-border);
}

/* Input Group */
.input-group {
  margin-bottom: 1.5rem;
}

.postcode-input {
  width: 100%;
  padding: 1rem 1.25rem;
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--color-text);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  transition: var(--transition);
  text-align: center;
  letter-spacing: 0.05em;
  outline: none;
}

.postcode-input::placeholder {
  color: var(--color-text-light);
  font-weight: 400;
}

.postcode-input:focus {
  border-color: var(--color-primary);
  background: var(--color-background);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

.postcode-input:focus::placeholder {
  color: transparent;
}

/* Result Card */
.result-card {
  min-height: 4rem;
}

.result {
  width: 100%;
  min-height: 4rem;
  padding: 1rem 1.25rem;
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
  border-radius: var(--radius);
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  word-break: keep-all;
}

/* Result States */
.result:not(:empty) {
  background: var(--color-background);
  color: var(--color-text);
}

.result.success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: var(--color-success);
  cursor: pointer;
  transition: var(--transition);
}

.result.success:hover {
  background: #dcfce7;
  border-color: #86efac;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.15);
}

.result.error {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--color-error);
}

.result.loading {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: var(--color-primary);
  position: relative;
}

.result.loading::after {
  content: '';
  position: absolute;
  right: 1rem;
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--color-primary);
  border-top: 2px solid transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Footer */
.footer {
  text-align: center;
}

.footer p {
  font-size: 0.875rem;
  color: var(--color-text-light);
}

.footer a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
}

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

/* Responsive Design */
@media (max-width: 640px) {
  .app {
    padding: 0.5rem;
  }

  .title {
    font-size: 1.75rem;
  }

  .subtitle {
    font-size: 0.875rem;
  }

  .search-card {
    padding: 1.5rem;
  }

  .postcode-input {
    font-size: 1rem;
    padding: 0.875rem 1rem;
  }

  .result {
    font-size: 0.875rem;
    padding: 0.875rem 1rem;
  }
}

@media (max-width: 480px) {
  .title {
    font-size: 1.5rem;
  }

  .search-card {
    padding: 1.25rem;
  }

  .postcode-input {
    font-size: 0.875rem;
    padding: 0.75rem 0.875rem;
  }
}

/* Focus Management */
.postcode-input:focus {
  transform: translateY(-1px);
}

/* Smooth Animations */
.search-card {
  animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(1rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  :root {
    --color-border: #000000;
    --shadow: 0 0 0 1px #000000;
    --shadow-lg: 0 0 0 2px #000000;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .result.loading::after {
    animation: none;
  }
}
