/* ==========================================================================
   Error Codes - App-like No-Scroll Design
   ========================================================================== */

/* ==========================================================================
   App Container - Full Viewport
   ========================================================================== */

/* App-specific body styles */
/* Override default body styles only when this CSS is loaded */
body {
  margin: 0;
  padding: 0;
  height: 100vh; /* Fallback for older browsers */
  height: 100dvh; /* Modern dynamic viewport height */
  /* Additional fallback for browsers that don't support dvh */
  height: calc(var(--vh, 1vh) * 100);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Header styles preserved for PWA compatibility */
.header {
  /* Let styles.css handle the header styling */
  /* PWA-specific overrides will be handled by the main styles */
}

.main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: clamp(0.125rem, 0.5vw, 0.5rem);
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
  gap: clamp(0.125rem, 0.5vh, 0.25rem);
}

.footer {
  flex-shrink: 0;
  padding: var(--space-xs);
  padding-bottom: calc(var(--space-xs) + env(safe-area-inset-bottom));
  font-size: var(--font-size-xs);
}

/* ==========================================================================
   Warning Notice (Database Information)
   ========================================================================== */

.warning-notice {
  flex: 0 0 auto;
  padding: clamp(0.125rem, 0.5vh, 0.25rem);
}

.warning-card {
  padding: clamp(0.25rem, 0.75vh, 0.5rem);
}

/* ==========================================================================
   Search Form
   ========================================================================== */

.search-section {
  flex: 0 0 auto;
  padding: 0;
}

.search-container {
  background: var(--color-bg-secondary);
  border-radius: var(--radius-lg);
  padding: clamp(0.25rem, 0.75vh, 0.5rem);
  box-shadow: var(--shadow-sm);
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: clamp(0.25rem, 0.5vh, 0.375rem);
}

.search-inputs {
  display: flex;
  gap: clamp(0.25rem, 0.5vw, 0.375rem);
  flex-wrap: wrap;
}

.input-group {
  flex: 1;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  gap: clamp(0.0625rem, 0.25vh, 0.125rem);
}

.input-label {
  font-size: clamp(0.75rem, 2vw, 0.875rem);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
}

.search-select,
.search-input {
  padding: clamp(0.375rem, 1.5vh, 0.5rem);
  font-size: clamp(0.75rem, 2.5vw, 0.875rem);
  min-height: 36px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
}

.search-actions {
  display: flex;
  justify-content: center;
}

.search-btn {
  padding: clamp(0.5rem, 2vh, 0.75rem) clamp(1rem, 3vw, 1.5rem);
  font-size: clamp(0.875rem, 2.5vw, 1rem);
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.btn-icon {
  font-size: 1.2em;
}

/* Results stats */
.results-stats {
  flex: 0 0 auto;
  padding: clamp(0.125rem, 0.25vh, 0.25rem);
  font-size: clamp(0.75rem, 2vw, 0.875rem);
  color: var(--color-text-secondary);
  text-align: center;
}

/* ==========================================================================
   Results Section
   ========================================================================== */

.results-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.results-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: clamp(0.5rem, 1vh, 1rem);
}

.results-header {
  flex: 0 0 auto;
  padding-bottom: clamp(0.25rem, 0.5vh, 0.5rem);
}

.results-header h3 {
  font-size: clamp(0.875rem, 2.5vw, 1rem);
}

/* Table Container */
.table-container {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.table-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Responsive Table Styles */
.error-table {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(0.75rem, 2vw, 1rem); /* Scales from 12px to 16px max */
  background: var(--color-bg);
}

.error-table th {
  padding: clamp(0.5rem, 1.5vh, 0.875rem);
  font-size: clamp(0.75rem, 1.8vw, 0.9rem); /* Slightly larger headers */
  position: sticky;
  top: 0;
  background-color: var(--color-bg-secondary);
  border-bottom: 2px solid var(--color-border);
  text-align: left;
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  z-index: 10;
}

.error-table td {
  padding: clamp(0.5rem, 1.5vh, 0.875rem);
  font-size: clamp(0.75rem, 1.8vw, 1rem); /* Better scaling */
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: top;
}

.error-table tbody tr:hover {
  background-color: var(--color-bg-secondary);
}

/* Code column styling - center both ways */
.error-table td:nth-child(2) {
  text-align: center;
  vertical-align: middle;
  font-family: var(--font-family-mono);
  font-weight: var(--font-weight-bold);
  font-size: clamp(0.875rem, 2vw, 1.125rem); /* Slightly larger for codes */
  background-color: var(--color-bg-tertiary);
  border-radius: var(--radius-sm);
  width: 80px;
  min-width: 60px;
  max-width: 100px;
}

/* Model column */
.error-table td:first-child {
  font-weight: var(--font-weight-medium);
  color: var(--color-primary);
  min-width: 100px;
}

/* Description column */
.error-table td:last-child {
  line-height: 1.4;
}

/* Mobile Cards (Alternative Display) */
.mobile-results {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: clamp(0.25rem, 0.5vh, 0.5rem);
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.result-card {
  padding: clamp(0.5rem, 1vh, 0.75rem);
  margin-bottom: clamp(0.25rem, 0.5vh, 0.5rem);
  font-size: clamp(0.75rem, 2vw, 0.875rem);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.result-card .code {
  font-size: clamp(0.875rem, 2.5vw, 1rem);
  font-weight: var(--font-weight-semibold);
  color: var(--color-primary);
  margin-bottom: var(--space-xs);
}

.result-card .model {
  font-size: clamp(0.75rem, 2vw, 0.875rem);
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-medium);
}

.result-card .description {
  font-size: clamp(0.75rem, 2vw, 0.875rem);
  color: var(--color-text);
  margin-top: var(--space-xs);
}

/* ==========================================================================
   Loading & Empty States
   ========================================================================== */

.loading-state,
.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: var(--space-md);
  text-align: center;
}

.loading-spinner {
  width: clamp(2rem, 8vw, 3rem);
  height: clamp(2rem, 8vw, 3rem);
}

.empty-icon {
  font-size: clamp(2rem, 8vw, 3rem);
  margin-bottom: clamp(0.5rem, 1vh, 1rem);
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

/* iPhone SE and similar small screens */
@media (max-width: 400px) {
  .container {
    padding: 0.25rem;
    gap: 0.25rem;
  }

  .search-container {
    padding: 0.25rem;
    flex-shrink: 0;
  }

  .search-form {
    gap: 0.25rem;
  }

  .search-inputs {
    flex-direction: column;
    gap: 0.25rem;
  }

  .input-group {
    width: 100%;
    min-width: unset;
  }

  .input-label {
    font-size: 0.75rem;
    margin-bottom: 0.125rem;
  }

  .search-select,
  .search-input {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0.375rem 0.5rem;
    min-height: 32px;
  }

  .search-actions {
    margin-top: 0.25rem;
  }

  .search-btn {
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
    min-height: 32px;
    border-radius: 0.5rem;
    /* Override any inflated button styles */
    transform: none !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
  }

  .search-btn:hover,
  .search-btn:focus {
    transform: none !important;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2) !important;
  }

  .results-section {
    padding: 0.125rem;
  }

  .results-stats {
    padding: 0.125rem 0;
    font-size: 0.7rem;
    margin: 0;
    background: var(--color-bg);
    position: sticky;
    top: 0;
    z-index: 5;
  }

  /* Table view optimized for mobile */
  .table-container {
    margin: 0.25rem 0;
    border-radius: 0.5rem;
  }
  
  .table-scroll {
    max-height: calc(100vh - 300px);
    max-height: calc(100dvh - 300px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  
  /* Mobile table optimization */
  .error-table {
    font-size: 0.75rem;
  }
  
  .error-table th,
  .error-table td {
    padding: 0.375rem 0.25rem;
    font-size: 0.75rem;
  }
  
  .error-table th {
    font-size: 0.7rem;
    font-weight: 600;
  }
  
  /* Adjust code column for mobile */
  .error-table td:nth-child(2) {
    font-size: 0.875rem !important;
    width: 60px;
    min-width: 50px;
    padding: 0.25rem;
  }
  
  /* Compress model column on mobile */
  .error-table td:first-child {
    font-size: 0.7rem !important;
    min-width: 80px;
  }

  .warning-notice {
    flex-shrink: 0;
    padding: 0.25rem;
  }

  .warning-card {
    padding: 0.375rem;
    font-size: 0.75rem;
  }


  /* Ensure the warning notice is more compact */
  .warning-notice {
    padding: 0.125rem;
  }

  .warning-card {
    padding: 0.25rem;
    font-size: 0.7rem;
  }

  .warning-description {
    margin: 0;
    line-height: 1.2;
  }

}



/* Extra small height devices */
@media (max-height: 500px) {
  .container {
    gap: 2px;
    padding: 4px;
  }
  
  .warning-notice {
    display: none; /* Hide on very small screens */
  }
  
  .search-container {
    padding: 4px;
  }
  
  .search-inputs {
    gap: 4px;
  }
  
  .search-select,
  .search-input {
    padding: 4px 8px;
    font-size: 0.75rem;
    min-height: 28px;
  }
  
  .search-btn {
    padding: 6px 12px;
    font-size: 0.75rem;
    min-height: 32px;
  }
  
  .error-table th,
  .error-table td {
    padding: 2px 4px;
    font-size: 0.625rem;
  }
  
  .footer {
    display: none; /* Hide footer on tiny screens */
  }
}

/* Extremely small height devices - ultra compact */
@media (max-height: 400px) {
  .container {
    gap: 1px;
    padding: 2px;
  }
  
  .warning-notice {
    display: none;
  }
  
  .search-container {
    padding: 2px;
  }
  
  .search-form {
    gap: 2px;
  }
  
  .search-inputs {
    gap: 2px;
    flex-direction: column; /* Stack inputs vertically on tiny screens */
  }
  
  .input-group {
    gap: 1px;
  }
  
  .input-label {
    font-size: 0.625rem;
  }
  
  .search-select,
  .search-input {
    padding: 2px 4px;
    font-size: 0.625rem;
    min-height: 24px;
  }
  
  .search-btn {
    padding: 4px 8px;
    font-size: 0.625rem;
    min-height: 28px;
  }
  
  .btn-icon {
    font-size: 1em;
  }
  
  .results-stats {
    padding: 1px;
    font-size: 0.5rem;
  }
  
  .error-table th,
  .error-table td {
    padding: 1px 2px;
    font-size: 0.5rem;
  }
  
  .error-table th {
    border-bottom: 1px solid var(--color-border);
  }
  
  .result-card {
    padding: 2px 4px;
    margin-bottom: 1px;
    font-size: 0.625rem;
  }
  
  .result-card .code {
    font-size: 0.75rem;
    margin-bottom: 1px;
  }
  
  .result-card .model,
  .result-card .description {
    font-size: 0.5rem;
  }
  
  .loading-state,
  .empty-state {
    padding: 8px;
  }
  
  .loading-spinner {
    width: 1.5rem;
    height: 1.5rem;
  }
  
  .empty-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
  }
  
  .loading-text {
    font-size: 0.625rem;
  }
  
  .footer {
    display: none;
  }
}

/* Small height devices */
@media (min-height: 501px) and (max-height: 700px) {
  .warning-notice {
    padding: 4px;
  }
  
  .warning-card {
    padding: 6px 12px;
    font-size: 0.75rem;
  }
  
  .warning-icon {
    font-size: 1rem;
  }
}

/* Landscape small screens */
@media (orientation: landscape) and (max-height: 500px) {
  .container {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .warning-notice {
    display: none;
  }
  
  .search-section {
    flex: 0 0 300px;
    max-width: 300px;
  }
  
  .results-section {
    flex: 1;
    min-width: 0;
  }
}

/* Always show table view - much cleaner */
.mobile-results {
  display: none !important;
}

.table-container {
  display: block !important;
}

.table-scroll {
  display: block !important;
}

/* Medium screens - balanced sizing */
@media (min-width: 641px) and (max-width: 1024px) {
  .error-table {
    font-size: 0.875rem;
  }
  
  .error-table th,
  .error-table td {
    padding: 0.625rem 0.5rem;
    font-size: 0.875rem;
  }
  
  .error-table td:nth-child(2) {
    font-size: 1rem !important;
    width: 80px;
  }
}

/* Large screens - optimal readability with cap */
@media (min-width: 1025px) {
  .error-table {
    font-size: 1rem;
    max-width: 1200px;
    margin: 0 auto;
  }
  
  .error-table th,
  .error-table td {
    padding: 0.75rem 1rem;
    font-size: 1rem;
  }
  
  .error-table td:nth-child(2) {
    font-size: 1.125rem !important;
    width: 100px;
  }
  
  .table-container {
    max-width: 1200px;
    margin: 0 auto;
  }
}

/* Ensure touch targets are adequate on mobile */
@media (max-width: 640px) {
  .nav-link,
  .btn,
  .theme-toggle,
  .header-theme-toggle,
  .nav-toggle {
    min-height: 44px;
    min-width: 44px;
  }
}

/* ==========================================================================
   Dark Mode Adjustments
   ========================================================================== */

[data-theme="dark"] .results-table th {
  background-color: var(--color-bg-secondary);
  border-bottom-color: var(--color-border);
}

[data-theme="dark"] .table-container {
  background-color: var(--color-bg-elevated);
  border-color: var(--color-border);
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

/* Hide scrollbars but keep functionality */
.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

/* Ensure touch scrolling works smoothly */
.touch-scroll {
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
}