/* =============================================================================
   FireBreak Landing Page - Design System Foundation
   ============================================================================= */

/* Import additional stylesheets - must be at top */
@import url('./screens.css');
@import url('./transitions.css');

/* =============================================================================
   CSS Reset
   ============================================================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
}

/* =============================================================================
   CSS Custom Properties
   ============================================================================= */

:root {
    /* Brand Colors */
    --navy-blue: #1a2b66;
    --papyrus-gold: #f5e6d3;
    --papyrus-light: #faf3e8;
    --papyrus-medium: #f0ddc0;
    --green-grade: #71B956;
    --orange-grade: #E67234;
    --red-grade: #D63B3B;

    /* Spacing tokens */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    --font-size-sm: 12px;
    --font-size-base: 14px;
    --font-size-md: 16px;
    --font-size-lg: 20px;
    --font-size-xl: 24px;
    --font-weight-normal: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    /* Layout */
    --header-height: 60px;
    --max-content-width: 1200px;
    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;

    /* Safe Area Insets */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
}

/* =============================================================================
   Base Styles
   ============================================================================= */

html {
    font-size: 100%;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-normal);
    line-height: 1.5;
    color: white;
    background-color: var(--navy-blue);
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

/* Typography - Headings */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-weight-bold);
    line-height: 1.2;
    color: white;
}

h1 {
    font-size: 2.5rem;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.5rem;
}

h4 {
    font-size: 1.25rem;
}

h5 {
    font-size: 1rem;
}

h6 {
    font-size: 0.875rem;
}

/* Links */
a {
    color: var(--navy-blue);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--orange-grade);
}

a:focus {
    outline: 2px solid var(--navy-blue);
    outline-offset: 2px;
}

/* Paragraphs */
p {
    margin-bottom: var(--space-md);
}

p:last-child {
    margin-bottom: 0;
}

/* Lists */
ul, ol {
    padding-left: var(--space-lg);
}

/* Images */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Button Reset */
button {
    font-family: inherit;
    font-size: inherit;
    font-weight: var(--font-weight-semibold);
    line-height: 1;
    color: inherit;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

button:focus {
    outline: 2px solid var(--navy-blue);
    outline-offset: 2px;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* Form Elements Reset */
input,
textarea,
select {
    font-family: inherit;
    font-size: inherit;
}

/* =============================================================================
   Utility Classes
   ============================================================================= */

/* Container */
.container {
    width: 100%;
    max-width: var(--max-content-width);
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--space-md);
    padding-right: var(--space-md);
}

/* Visually Hidden (Accessibility) */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Spacing Utilities - Margin */
.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

.mb-xs { margin-bottom: var(--space-xs); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.ml-xs { margin-left: var(--space-xs); }
.ml-sm { margin-left: var(--space-sm); }
.ml-md { margin-left: var(--space-md); }
.ml-lg { margin-left: var(--space-lg); }
.ml-xl { margin-left: var(--space-xl); }

.mr-xs { margin-right: var(--space-xs); }
.mr-sm { margin-right: var(--space-sm); }
.mr-md { margin-right: var(--space-md); }
.mr-lg { margin-right: var(--space-lg); }
.mr-xl { margin-right: var(--space-xl); }

.mx-auto { margin-left: auto; margin-right: auto; }
.my-xs { margin-top: var(--space-xs); margin-bottom: var(--space-xs); }
.my-sm { margin-top: var(--space-sm); margin-bottom: var(--space-sm); }
.my-md { margin-top: var(--space-md); margin-bottom: var(--space-md); }
.my-lg { margin-top: var(--space-lg); margin-bottom: var(--space-lg); }
.my-xl { margin-top: var(--space-xl); margin-bottom: var(--space-xl); }

/* Spacing Utilities - Padding */
.pt-xs { padding-top: var(--space-xs); }
.pt-sm { padding-top: var(--space-sm); }
.pt-md { padding-top: var(--space-md); }
.pt-lg { padding-top: var(--space-lg); }
.pt-xl { padding-top: var(--space-xl); }

.pb-xs { padding-bottom: var(--space-xs); }
.pb-sm { padding-bottom: var(--space-sm); }
.pb-md { padding-bottom: var(--space-md); }
.pb-lg { padding-bottom: var(--space-lg); }
.pb-xl { padding-bottom: var(--space-xl); }

.pl-xs { padding-left: var(--space-xs); }
.pl-sm { padding-left: var(--space-sm); }
.pl-md { padding-left: var(--space-md); }
.pl-lg { padding-left: var(--space-lg); }
.pl-xl { padding-left: var(--space-xl); }

.pr-xs { padding-right: var(--space-xs); }
.pr-sm { padding-right: var(--space-sm); }
.pr-md { padding-right: var(--space-md); }
.pr-lg { padding-right: var(--space-lg); }
.pr-xl { padding-right: var(--space-xl); }

.p-xs { padding: var(--space-xs); }
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.p-xl { padding: var(--space-xl); }

/* Text Alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Display Utilities */
.hidden { display: none !important; }
.block { display: block; }
.inline { display: inline; }
.inline-block { display: inline-block; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }

/* Flexbox Utilities */
.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

/* Width Utilities */
.w-full { width: 100%; }
.w-auto { width: auto; }

/* =============================================================================
   Safe Area Support (Notched Devices)
   ============================================================================= */

/* Ensure content respects safe areas on iOS devices */
@supports (padding: env(safe-area-inset-top)) {
    .safe-area-top {
        padding-top: var(--safe-area-top);
    }

    .safe-area-bottom {
        padding-bottom: var(--safe-area-bottom);
    }

    .safe-area-left {
        padding-left: var(--safe-area-left);
    }

    .safe-area-right {
        padding-right: var(--safe-area-right);
    }

    .safe-area-inset {
        padding-top: var(--safe-area-top);
        padding-right: var(--safe-area-right);
        padding-bottom: var(--safe-area-bottom);
        padding-left: var(--safe-area-left);
    }
}

/* Full viewport height accounting for safe areas */
.min-h-screen-safe {
    min-height: calc(100vh - var(--safe-area-top) - var(--safe-area-bottom));
}

/* Fixed elements that need safe area consideration */
.fixed-top-safe {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding-top: var(--safe-area-top);
}

.fixed-bottom-safe {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding-bottom: var(--safe-area-bottom);
}

/* ========================================
   LAYOUT & WHITESPACE
   ======================================== */

.main-content {
  padding-top: var(--header-height);
  min-height: 100vh;
  background: var(--navy-blue);
  /* Account for safe area on notched devices */
  padding-top: calc(var(--header-height) + env(safe-area-inset-top));
  overflow-x: hidden;
  width: 100%;
}

.section {
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

@media (min-width: 768px) {
  .section {
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
  }
}

.card {
  background: white;
  border-radius: var(--border-radius-md);
  padding: var(--space-md);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

@media (min-width: 768px) {
  .card {
    padding: var(--space-lg);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  }
}

.touch-target {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Grid system */
.grid {
  display: grid;
  gap: var(--space-md);
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 767px) {
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* Prevent horizontal scroll */
html, body {
  overflow-x: hidden;
}

/* ========================================
   HEADER COMPONENT
   ======================================== */

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--navy-blue);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 var(--space-md);
  z-index: 1000;
  /* Safe area for notched devices */
  padding-top: env(safe-area-inset-top);
}

.header-logo {
  display: flex;
  align-items: center;
  padding: var(--space-sm);
  cursor: pointer;
  text-decoration: none;
}

.logo-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

@media (min-width: 768px) {
  .logo-icon {
    width: 32px;
    height: 32px;
  }
}

.header-title {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  color: var(--papyrus-gold);
  margin: 0;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .header-title {
    font-size: var(--font-size-lg);
  }
}

.header-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* ========================================
   LOGO VARIANTS
   ======================================== */

/* Favicon/icon logo for header - styles already in header section */
.header-logo:hover {
  opacity: 0.9;
}

.header-logo:focus {
  outline: 2px solid var(--papyrus-gold);
  outline-offset: 2px;
}

/* Full wordmark logo for hero/splash */
.wordmark-logo {
  max-width: 180px;
  height: auto;
  margin-bottom: var(--space-lg);
}

@media (min-width: 768px) {
  .wordmark-logo {
    max-width: 220px;
  }
}

/* Ensure logos don't overflow */
.wordmark-logo,
.logo-icon {
  display: block;
  max-width: 100%;
}

/* ========================================
   STATUS INDICATOR
   ======================================== */

.status-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: var(--border-radius-sm);
  transition: background-color 0.2s ease;
}

.status-indicator:hover,
.status-indicator:focus {
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: background-color 0.3s ease;
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--green-grade);
  box-shadow: 0 0 4px var(--green-grade);
}

.status-dot.offline {
  background: var(--red-grade);
  box-shadow: 0 0 4px var(--red-grade);
}

.status-text {
  font-size: var(--font-size-sm);
  color: var(--papyrus-gold);
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: max-width 0.3s ease;
}

.status-indicator:hover .status-text,
.status-indicator:focus .status-text,
.status-indicator.expanded .status-text {
  max-width: 60px;
}

/* ========================================
   END SESSION LINK
   ======================================== */

.end-session-link {
  display: none;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm);
  color: #888;
  text-decoration: none;
  font-size: var(--font-size-sm);
  border-radius: var(--border-radius-sm);
  transition: color 0.2s ease, background-color 0.2s ease;
}

/* Show end session link when in inspection mode */
body.inspection-active .end-session-link {
  display: flex;
}

.end-session-link:hover,
.end-session-link:focus {
  color: var(--papyrus-gold);
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

.end-session-link .link-text {
  display: inline;
}

/* Confirmation state */
.end-session-link.confirm {
  color: var(--orange-grade);
}

.end-session-link.confirm .link-icon::before {
  content: "\f00c"; /* fa-check */
}

/* ========================================
   HERO SECTION
   ======================================== */

.hero-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: calc(100vh - var(--header-height) - env(safe-area-inset-top));
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}

.hero-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: white;
  margin-bottom: var(--space-sm);
  line-height: 1.3;
}

@media (min-width: 768px) {
  .hero-title {
    font-size: var(--font-size-xl);
  }
}

.hero-subtitle {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: white;
  margin-bottom: var(--space-xl);
  max-width: 320px;
  line-height: 1.3;
  padding: 0;
}

@media (min-width: 768px) {
  .hero-subtitle {
    max-width: 480px;
    font-size: 28px;
  }
}

.address-input-container {
  width: calc(100% - var(--space-xl) * 2);
  max-width: 340px;
  margin-top: var(--space-md);
  margin-bottom: var(--space-lg);
  position: relative;
  transition: all 0.3s ease;
}

@media (min-width: 768px) {
  .address-input-container {
    max-width: 500px;
  }
}

/* Focused state - autocomplete dropdown positioning */
.address-input-container.focused .autocomplete-dropdown {
  /* Dropdown inherits container width */
}

.address-input {
  width: 100%;
  padding: var(--space-lg) var(--space-xl);
  border: none;
  border-radius: var(--border-radius-lg);
  /* 18px for prominence while preventing iOS zoom */
  font-size: 18px;
  font-weight: var(--font-weight-medium);
  font-family: var(--font-family);
  background: white;
  transition: box-shadow 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.address-input:focus {
  outline: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.address-input:disabled {
  background: rgba(255, 255, 255, 0.9);
  color: #666;
}

.address-input::placeholder {
  color: #999;
}

.cta-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  max-width: 320px;
  padding: var(--space-md) var(--space-lg);
  background: var(--papyrus-gold);
  color: var(--navy-blue);
  border: none;
  border-radius: var(--border-radius-md);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-family);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cta-button:hover,
.cta-button:focus {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(26, 43, 102, 0.3);
  outline: none;
}

.cta-button:active {
  transform: translateY(0);
}

.learn-more-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-xl);
  color: rgba(255, 255, 255, 0.6);
  font-size: var(--font-size-sm);
  text-decoration: none;
  padding: var(--space-sm) var(--space-md);
  transition: color 0.2s ease;
}

.learn-more-link:hover,
.learn-more-link:focus {
  color: var(--papyrus-gold);
}

.learn-more-link:hover {
  text-decoration: underline;
}

.learn-more-link i {
  font-size: 10px;
  transition: transform 0.2s ease;
}

.learn-more-link:hover i {
  transform: translateY(2px);
}

/* =============================================================================
   Autocomplete Dropdown - iOS Glass UI Style
   ============================================================================= */

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: transparent;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.2s ease;
  z-index: 100;
  margin-top: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: 0;
}

.autocomplete-dropdown.active {
  max-height: 400px;
  opacity: 1;
  overflow-y: auto;
  padding: var(--space-xs);
}

.autocomplete-item {
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  color: white;
  font-size: var(--font-size-base);
  transition: all 0.2s ease;
  /* Glass morphism effect */
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--border-radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.4);
  transform: scale(1.02);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.autocomplete-item-name {
  font-weight: var(--font-weight-semibold);
  color: white;
}

.autocomplete-item-address {
  font-size: var(--font-size-sm);
  color: rgba(255, 255, 255, 0.7);
  margin-top: 4px;
}

.autocomplete-no-results,
.autocomplete-loading,
.autocomplete-error {
  padding: var(--space-md) var(--space-lg);
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
  font-style: italic;
  /* Glass pill style */
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--border-radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.autocomplete-error {
  color: var(--red-grade);
  background: rgba(214, 59, 59, 0.15);
  border-color: rgba(214, 59, 59, 0.3);
}

/* =============================================================================
   Map Component
   ============================================================================= */

#map-container {
  width: 100%;
  padding: var(--space-md);
  /* Ensure map starts below header with more space */
  padding-top: calc(var(--space-xl) + var(--space-lg));
}

#leaflet-map {
  border-radius: var(--border-radius-lg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Address confirmation card - unified design */
.address-confirm-card {
  margin-top: var(--space-lg);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.confirmed-address {
  font-size: var(--font-size-md);
  color: white;
  margin: 0;
  padding: var(--space-lg);
  background: rgba(255, 255, 255, 0.1);
  text-align: center;
  line-height: 1.4;
}

.confirm-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-lg);
  border: none;
  border-radius: 0;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--green-grade);
  color: white;
}

.confirm-btn:hover {
  background: #5fa348;
}

.confirm-btn:active {
  transform: scale(0.98);
}

.change-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-md);
  margin-top: var(--space-md);
  border: none;
  border-radius: var(--border-radius-md);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all 0.2s ease;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
}

.change-btn:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.map-placeholder,
.map-loading,
.map-error {
  text-align: center;
  padding: var(--space-xl);
  color: rgba(255, 255, 255, 0.7);
}

.map-error {
  color: var(--red-grade);
}
