/* ============================================
   C.Hill HVAC - Progressive Web App Styles
   ============================================ */

:root {
  --red: #E53935;
  --red-dark: #C62828;
  --blue: #1A237E;
  --blue-light: #283593;
  --white: #FFFFFF;
  --gray-50: #FAFAFA;
  --gray-100: #F5F5F5;
  --gray-200: #EEEEEE;
  --gray-300: #E0E0E0;
  --gray-400: #BDBDBD;
  --gray-500: #9E9E9E;
  --gray-600: #757575;
  --gray-700: #616161;
  --gray-800: #424242;
  --gray-900: #212121;
  --gradient: linear-gradient(135deg, var(--red) 0%, var(--blue) 100%);
  --gradient-vertical: linear-gradient(180deg, var(--red) 0%, var(--blue) 100%);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.15), 0 5px 10px rgba(0,0,0,0.08);
  --shadow-xl: 0 20px 40px rgba(0,0,0,0.2);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --nav-height: 64px;
  --header-height: 60px;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: calc(var(--nav-height) + 16px);
  -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
  background: var(--gradient);
  color: var(--white);
  padding: 12px 16px;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--white);
}

.header-logo { width: 36px; height: 36px; border-radius: 8px; }

.header-text h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.5px; line-height: 1.2; }
.header-text .tagline { font-size: 0.7rem; opacity: 0.85; letter-spacing: 1.5px; text-transform: uppercase; }

.header-phone {
  display: flex; align-items: center; gap: 6px;
  color: var(--white); text-decoration: none;
  font-size: 0.85rem; font-weight: 600;
  background: rgba(255,255,255,0.15);
  padding: 6px 12px; border-radius: 20px;
  transition: var(--transition);
}
.header-phone:hover { background: rgba(255,255,255,0.25); }

/* Main Content */
.app-content {
  margin-top: var(--header-height);
  padding: 16px;
  max-width: 800px;
  margin-left: auto; margin-right: auto;
}

.page-section { display: none; animation: fadeIn 0.3s ease; }
.page-section.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* Install Banner */
.install-banner {
  background: var(--gradient);
  color: var(--white);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-md);
}
.install-banner.show { display: flex; }
.install-banner-text { font-size: 0.9rem; font-weight: 500; }
.install-banner-text strong { display: block; font-size: 1rem; }

.install-btn {
  background: var(--white); color: var(--blue);
  border: none; padding: 8px 20px; border-radius: 20px;
  font-weight: 700; font-size: 0.85rem; cursor: pointer;
  white-space: nowrap; transition: var(--transition);
}
.install-btn:hover { transform: scale(1.05); }

.install-dismiss {
  background: none; border: none; color: var(--white);
  font-size: 1.2rem; cursor: pointer; padding: 4px; opacity: 0.7;
}
.install-dismiss:hover { opacity: 1; }

/* Hero Search */
.hero-search {
  background: var(--gradient);
  border-radius: var(--radius-lg);
  padding: 32px 20px 28px;
  text-align: center;
  margin-bottom: 20px;
  box-shadow: var(--shadow-lg);
  position: relative; overflow: hidden;
}
.hero-search::before {
  content: '';
  position: absolute; top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.08), transparent 60%);
  pointer-events: none;
}
.hero-search h2 { color: var(--white); font-size: 1.3rem; margin-bottom: 4px; font-weight: 700; position: relative; }
.hero-search p { color: rgba(255,255,255,0.85); font-size: 0.9rem; margin-bottom: 20px; position: relative; }

.search-box { position: relative; max-width: 500px; margin: 0 auto; }
.search-box input {
  width: 100%; padding: 14px 50px 14px 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 28px; font-size: 1.05rem;
  background: #FFFFFF; color: #212121;
  outline: none; transition: var(--transition);
  -webkit-text-fill-color: #212121;
  opacity: 1;
}
.search-box input::placeholder { color: #9E9E9E; -webkit-text-fill-color: #9E9E9E; }
.search-box input:focus {
  border-color: var(--white); background: #FFFFFF;
  box-shadow: 0 0 0 4px rgba(255,255,255,0.3);
  color: #212121; -webkit-text-fill-color: #212121;
}
.search-box button {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: var(--gradient); color: var(--white); border: none;
  width: 40px; height: 40px; border-radius: 50%;
  font-size: 1.1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.search-box button:hover { transform: translateY(-50%) scale(1.1); }

/* Quick Actions Grid */
.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
.quick-action {
  background: var(--white); border: none; border-radius: var(--radius-md);
  padding: 20px 16px; text-align: center; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: var(--transition);
  text-decoration: none; color: var(--gray-900);
}
.quick-action:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.quick-action .icon { font-size: 2rem; display: block; margin-bottom: 8px; }
.quick-action .label { font-size: 0.85rem; font-weight: 600; color: var(--gray-700); }

/* Recent Searches */
.recent-searches { margin-bottom: 20px; }
.recent-searches h3 { font-size: 0.9rem; color: var(--gray-600); margin-bottom: 8px; padding-left: 4px; }
.recent-list { display: flex; flex-wrap: wrap; gap: 8px; }
.recent-chip {
  background: var(--white); border: 1px solid var(--gray-300);
  border-radius: 20px; padding: 6px 14px; font-size: 0.85rem;
  color: var(--gray-700); cursor: pointer; transition: var(--transition);
  display: flex; align-items: center; gap: 6px;
}
.recent-chip:hover { background: var(--gray-200); }
.recent-chip .remove { font-size: 0.7rem; opacity: 0.5; cursor: pointer; }
.recent-chip .remove:hover { opacity: 1; color: var(--red); }

/* Search Results */
.search-results { display: none; }
.search-results.active { display: block; animation: slideUp 0.3s ease; }
.results-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.results-header h3 { font-size: 1rem; color: var(--gray-800); }
.results-back {
  background: none; border: 1px solid var(--gray-300);
  color: var(--gray-600); padding: 6px 14px; border-radius: 20px;
  font-size: 0.8rem; cursor: pointer; transition: var(--transition);
}
.results-back:hover { background: var(--gray-200); }

.results-tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  background: var(--gray-200); border-radius: var(--radius-sm); padding: 4px;
}
.results-tab {
  flex: 1; background: none; border: none;
  padding: 10px 12px; font-size: 0.85rem; font-weight: 600;
  color: var(--gray-600); border-radius: 6px;
  cursor: pointer; transition: var(--transition);
}
.results-tab.active { background: var(--white); color: var(--blue); box-shadow: var(--shadow-sm); }
.results-tab:hover:not(.active) { color: var(--gray-800); }
.results-content { display: none; }
.results-content.active { display: block; }

/* Error Code Cards */
.error-card {
  background: var(--white); border-radius: var(--radius-md);
  padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--red); transition: var(--transition);
}
.error-card:hover { box-shadow: var(--shadow-md); }
.error-card.expanded { border-left-color: var(--blue); }

.error-code-header { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.error-code-label { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.error-code {
  background: var(--gradient); color: var(--white);
  font-weight: 700; font-size: 0.85rem; padding: 4px 10px;
  border-radius: 6px; font-family: 'SF Mono', 'Fira Code', monospace;
  white-space: nowrap; flex-shrink: 0;
}
.error-description { font-size: 0.9rem; font-weight: 600; color: var(--gray-800); overflow: hidden; text-overflow: ellipsis; }
.error-expand-icon { font-size: 0.8rem; color: var(--gray-400); transition: transform 0.2s ease; flex-shrink: 0; margin-left: 8px; }
.error-card.expanded .error-expand-icon { transform: rotate(180deg); }

.error-details {
  display: none; margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--gray-200);
}
.error-card.expanded .error-details { display: block; animation: fadeIn 0.2s ease; }

.error-detail-row { display: flex; gap: 8px; margin-bottom: 8px; font-size: 0.9rem; }
.error-detail-row .label { font-weight: 600; color: var(--gray-600); min-width: 100px; flex-shrink: 0; }
.error-detail-row .value { color: var(--gray-800); }

.error-brand-tag {
  display: inline-block; font-size: 0.7rem; font-weight: 700;
  padding: 2px 6px; border-radius: 4px; color: var(--white);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.error-brand-tag.mitsubishi { background: #E4002B; }
.error-brand-tag.daikin { background: #00A0E4; }
.error-brand-tag.fujitsu { background: #E60012; }
.error-brand-tag.american-standard { background: #003DA5; }

/* Error Codes Page */
.error-search-box { position: relative; margin-bottom: 16px; }
.error-search-box input {
  width: 100%; padding: 12px 16px 12px 42px;
  border: 2px solid var(--gray-300); border-radius: var(--radius-sm);
  font-size: 1rem; background: #FFFFFF; color: #212121;
  outline: none; transition: var(--transition);
  -webkit-text-fill-color: #212121;
}
.error-search-box input::placeholder { color: #9E9E9E; -webkit-text-fill-color: #9E9E9E; }
.error-search-box input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26, 35, 126, 0.1); }
.error-search-box .search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 1rem; color: var(--gray-400); }

.brand-filter {
  display: flex; gap: 8px; margin-bottom: 16px;
  overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch;
}
.brand-filter-btn {
  background: var(--white); border: 2px solid var(--gray-300);
  border-radius: 20px; padding: 8px 16px; font-size: 0.85rem;
  font-weight: 600; color: var(--gray-600); cursor: pointer;
  white-space: nowrap; transition: var(--transition);
}
.brand-filter-btn.active { background: var(--gradient); color: var(--white); border-color: transparent; }
.brand-filter-btn:hover:not(.active) { border-color: var(--blue); color: var(--blue); }

.error-count { font-size: 0.85rem; color: var(--gray-500); margin-bottom: 12px; }

/* Brands Page */
.brand-card {
  background: var(--white); border-radius: var(--radius-md);
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.brand-card:hover { box-shadow: var(--shadow-md); }
.brand-card-header { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.brand-icon {
  width: 48px; height: 48px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 700; color: var(--white); flex-shrink: 0;
}
.brand-icon.mitsubishi { background: #E4002B; }
.brand-icon.american-standard { background: #003DA5; }
.brand-icon.daikin { background: #00A0E4; }
.brand-icon.fujitsu { background: #E60012; }

.brand-card-header h3 { font-size: 1.1rem; font-weight: 700; }
.brand-card-header .brand-type { font-size: 0.8rem; color: var(--gray-500); }
.brand-models { margin-bottom: 12px; }
.brand-models h4 { font-size: 0.85rem; color: var(--gray-600); margin-bottom: 8px; }
.model-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.model-tag {
  background: var(--gray-100); color: var(--gray-700);
  font-size: 0.8rem; padding: 4px 10px; border-radius: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  cursor: pointer; transition: var(--transition);
}
.model-tag:hover { background: var(--gray-200); color: var(--gray-900); }
.brand-links { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 12px; border-top: 1px solid var(--gray-200); }
.brand-link {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--blue); text-decoration: none; font-size: 0.85rem;
  font-weight: 600; padding: 4px 8px; border-radius: 6px; transition: var(--transition);
}
.brand-link:hover { background: rgba(26, 35, 126, 0.08); }

/* Contact Page */
.contact-hero {
  background: var(--gradient); border-radius: var(--radius-lg);
  padding: 28px 20px; text-align: center; margin-bottom: 20px;
  color: var(--white); box-shadow: var(--shadow-lg);
}
.contact-hero h2 { font-size: 1.4rem; margin-bottom: 4px; }
.contact-hero p { opacity: 0.85; font-size: 0.95rem; margin-bottom: 20px; }
.contact-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.contact-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px; border-radius: 28px; font-size: 1rem;
  font-weight: 700; text-decoration: none; transition: var(--transition);
  border: none; cursor: pointer;
}
.contact-btn.primary { background: var(--white); color: var(--blue); }
.contact-btn.secondary { background: rgba(255,255,255,0.2); color: var(--white); border: 2px solid rgba(255,255,255,0.5); }
.contact-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* Contact Form */
.contact-form-card { background: var(--white); border-radius: var(--radius-md); padding: 24px 20px; box-shadow: var(--shadow-sm); }
.contact-form-card h3 { font-size: 1.1rem; margin-bottom: 4px; }
.contact-form-card > p { color: var(--gray-500); font-size: 0.9rem; margin-bottom: 20px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.form-group label .required { color: var(--red); }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 12px 14px; border: 2px solid var(--gray-300);
  border-radius: var(--radius-sm); font-size: 1rem; font-family: inherit;
  color: var(--gray-900); background: var(--white); outline: none; transition: var(--transition);
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26, 35, 126, 0.1);
}
.form-group textarea { min-height: 100px; resize: vertical; }
.form-submit {
  width: 100%; padding: 14px; background: var(--gradient);
  color: var(--white); border: none; border-radius: var(--radius-sm);
  font-size: 1.05rem; font-weight: 700; cursor: pointer; transition: var(--transition);
}
.form-submit:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

/* Bottom Navigation */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-height); background: var(--white);
  border-top: 1px solid var(--gray-200);
  display: flex; justify-content: space-around; align-items: center;
  z-index: 1000; box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 16px; background: none; border: none;
  color: var(--gray-500); font-size: 0.7rem; font-weight: 600;
  cursor: pointer; transition: var(--transition); position: relative;
  text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.nav-item .icon { font-size: 1.3rem; transition: var(--transition); }
.nav-item.active { color: var(--blue); }
.nav-item.active .icon { transform: scale(1.1); }
.nav-item.active::after {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 24px; height: 3px; background: var(--gradient); border-radius: 0 0 3px 3px;
}
.nav-item:hover { color: var(--blue); }

/* FAB */
.fab-help {
  position: fixed; bottom: calc(var(--nav-height) + 16px); right: 16px;
  width: 56px; height: 56px; background: var(--gradient);
  color: var(--white); border: none; border-radius: 50%;
  font-size: 1.5rem; cursor: pointer; box-shadow: var(--shadow-lg);
  z-index: 999; display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.fab-help:hover { transform: scale(1.1); box-shadow: var(--shadow-xl); }

/* Toast */
.toast {
  position: fixed; bottom: calc(var(--nav-height) + 80px);
  left: 50%; transform: translateX(-50%) translateY(100px);
  background: var(--gray-900); color: var(--white);
  padding: 12px 24px; border-radius: 28px; font-size: 0.9rem;
  font-weight: 500; box-shadow: var(--shadow-lg); z-index: 2000;
  opacity: 0; transition: all 0.3s ease; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Favorites */
.favorite-btn {
  background: none; border: none; font-size: 1.2rem;
  cursor: pointer; padding: 4px; transition: var(--transition);
}
.favorite-btn:hover { transform: scale(1.2); }
.favorite-btn.active { color: #FFD700; }

/* Utility */
.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;
}

.section-title {
  font-size: 1.15rem; font-weight: 700; color: var(--gray-900);
  margin-bottom: 16px; padding-left: 4px;
}

.divider { height: 1px; background: var(--gray-200); margin: 16px 0; }

/* Manual/Spec links */
.resource-link {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: var(--white); border-radius: var(--radius-sm);
  margin-bottom: 8px; box-shadow: var(--shadow-sm);
  text-decoration: none; color: var(--gray-800); transition: var(--transition);
}
.resource-link:hover { box-shadow: var(--shadow-md); transform: translateX(4px); }
.resource-link .icon { font-size: 1.3rem; flex-shrink: 0; }
.resource-link .info { flex: 1; }
.resource-link .title { font-weight: 600; font-size: 0.95rem; }
.resource-link .subtitle { font-size: 0.8rem; color: var(--gray-500); }
.resource-link .arrow { color: var(--gray-400); font-size: 0.9rem; }

/* Model info header */
.model-info-header {
  background: var(--white); border-radius: var(--radius-md);
  padding: 16px 20px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: space-between;
}
.model-info-header .model-name { font-size: 1.1rem; font-weight: 700; font-family: 'SF Mono', 'Fira Code', monospace; }
.model-info-header .model-brand { font-size: 0.85rem; color: var(--gray-500); }

/* Responsive */
@media (min-width: 600px) {
  .quick-actions { grid-template-columns: repeat(4, 1fr); }
  .contact-buttons { gap: 16px; }
  .hero-search { padding: 40px 32px 36px; }
  .hero-search h2 { font-size: 1.6rem; }
}

@media (min-width: 800px) {
  .app-content { padding: 24px; }
  .error-card { padding: 20px; }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --gray-50: #1a1a1a; --gray-100: #212121; --gray-200: #303030;
    --gray-300: #424242; --gray-400: #616161; --gray-500: #9E9E9E;
    --gray-600: #BDBDBD; --gray-700: #E0E0E0; --gray-800: #EEEEEE;
    --gray-900: #FAFAFA;
  }
  body { background: #121212; color: #FAFAFA; }
  .app-header { background: linear-gradient(135deg, #b71c1c 0%, #0d1642 100%); }
  .bottom-nav { background: #1a1a1a; border-top-color: #303030; }
  .search-box input { background: #FFFFFF; color: #212121; -webkit-text-fill-color: #212121; }
  .search-box input::placeholder { color: #9E9E9E; -webkit-text-fill-color: #9E9E9E; }
  .error-search-box input { background: #1a1a1a; color: #FAFAFA; -webkit-text-fill-color: #FAFAFA; }
  .error-search-box input::placeholder { color: #757575; -webkit-text-fill-color: #757575; }
}
