/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Global Styles */
* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #1f2937;
  line-height: 1.6;
  min-height: 100vh;
  margin: 0;
  padding-top: 60px; /* Space for fixed navbar */
  overflow-x: hidden;
  max-width: 100vw;
}

/* Navigation Bar */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 1000;
}

.navbar-container {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
}

.navbar-brand {
  flex-shrink: 0;
}

.navbar-logo {
  text-decoration: none;
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  transition: all 0.2s ease;
}

.navbar-logo:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.navbar-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.navbar-toggle-icon {
  width: 24px;
  height: 3px;
  background: #374151;
  border-radius: 2px;
  transition: all 0.2s ease;
}

.navbar-menu {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex: 1;
  justify-content: space-between;
  margin-left: 3rem;
}

.navbar-links {
  display: flex;
  gap: 0.5rem;
}

.navbar-link {
  padding: 0.5rem 1rem;
  text-decoration: none;
  color: #4b5563;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.navbar-link:hover {
  background: #f3f4f6;
  color: #1f2937;
}

.navbar-link.active {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.navbar-username {
  color: #374151;
  font-weight: 500;
  font-size: 0.95rem;
}

.navbar-signout {
  color: #dc2626;
}

.navbar-signout:hover {
  background: #fef2f2;
  color: #b91c1c;
}

h1, h2, h3, h4 {
  color: #111827;
  font-weight: 700;
}

/* Accordion styles */
.accordion-section {
  margin-bottom: 1.5rem;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  background: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.accordion-header {
  padding: 1.25rem 1.5rem;
  background: #f9fafb;
  cursor: pointer;
  user-select: none;
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: #374151;
  transition: all 0.2s ease;
}

.accordion-header:hover {
  background: #f3f4f6;
}

.accordion-content {
  padding: 0 1rem;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.accordion-section.open .accordion-content {
  padding: 1rem;
}

/* Autocomplete styles */
.autocomplete-results {
  position: relative;
  background: white;
  border: 2px solid #e5e7eb;
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 300px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.autocomplete-results:not(:empty) {
  display: block;
}

.autocomplete-item {
  padding: 0.875rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  transition: all 0.15s ease;
}

.autocomplete-item:hover {
  background: #f9fafb;
}

.client-address-display {
  margin-top: 0.75rem;
  padding: 0.875rem 1rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.9rem;
}

.client-address-display:empty {
  display: none;
}

/* Form styles */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #374151;
  font-size: 0.95rem;
}

/* Checkbox-specific styling */
.form-group input[type="checkbox"] {
  margin-right: 0.5rem;
  width: auto;
  display: inline-block;
  cursor: pointer;
}

.form-group input[type="checkbox"] + label {
  display: inline;
  font-weight: 400;
  margin-bottom: 0;
  cursor: pointer;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.2s ease;
  background: white;
}

.form-control:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-control:hover {
  border-color: #d1d5db;
}

.form-actions {
  margin-top: 2rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Button Base Styles */
.btn {
  padding: 0.75rem 1.5rem;
  border: 2px solid transparent;
  border-radius: 8px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: white;
  font-weight: 500;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border-color: #2563eb;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
  color: white;
  border-color: #4b5563;
}

.btn-secondary:hover {
  background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
}

.info-box {
  padding: 1.25rem;
  background: #eff6ff;
  border: 2px solid #bfdbfe;
  border-radius: 12px;
  margin-top: 1rem;
}

.errors {
  background: #fef2f2;
  border: 2px solid #fecaca;
  color: #991b1b;
  padding: 1.25rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 4px rgba(220, 38, 38, 0.1);
}

/* Flash messages */
.flash {
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 2rem;
  border-radius: 12px;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.flash.notice {
  background: #f0fdf4;
  border: 2px solid #bbf7d0;
  color: #166534;
}

.flash.alert {
  background: #fef2f2;
  border: 2px solid #fecaca;
  color: #991b1b;
}

/* Field-level errors */
.field-error {
  border-color: #dc3545 !important;
  background-color: #fff5f5;
}

.field-error-message {
  display: block;
  color: #dc3545;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.errors ul {
  margin: 0.5rem 0 0 0;
  padding-left: 1.5rem;
}

.errors li {
  margin: 0.25rem 0;
}

/* Test Results styles */
.transcript-section {
  background: #f9fafb;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.transcript-section label {
  font-size: 1rem;
}

.test-results-header {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.test-result-card {
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  gap: 1.5rem;
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

.test-result-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-color: #d1d5db;
}

.test-result-photo {
  flex-shrink: 0;
  width: 200px;
}

.test-result-photo img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.test-result-details {
  flex-grow: 1;
}

.test-readings {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1rem;
  margin: 1rem 0;
}

.test-readings dt {
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-left: 0.5rem;
  font-weight: 500;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.photo-preview-container {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}

.photo-preview {
  width: 100%;
  height: 150px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.manual-test-form {
  border: 2px solid #e5e7eb;
  padding: 1.5rem;
  border-radius: 12px;
  margin: 1.5rem 0;
  background: #fafafa;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  border-color: #dc2626;
}

.btn-danger:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 1.5rem;
  border-bottom: 3px solid #e5e7eb;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.table thead {
  background: #f8f9fa;
}

.table th,
.table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid #ddd;
}

.test-result-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

section {
  margin-bottom: 3rem;
  padding: 1.5rem;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

section h2 {
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 3px solid #3b82f6;
  color: #1f2937;
  font-size: 1.5rem;
}

dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1rem;
}

dl dt {
  font-weight: 600;
}

dl dd {
  margin: 0;
}

.test-results-list {
  margin-top: 1rem;
}

/* Attachments Styles */
.attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.attachment-card {
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 1rem;
  background: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.attachment-preview {
  width: 100%;
  height: 150px;
  object-fit: cover;
  border-radius: 8px;
}

.pdf-icon {
  width: 100%;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
  border-radius: 8px;
  font-size: 3rem;
}

.attachment-info {
  flex-grow: 1;
}

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

/* Mobile responsiveness */
@media (max-width: 768px) {
  body {
    padding-top: 60px;
  }

  .container {
    padding: 1rem;
    max-width: 100%;
  }

  .flash {
    margin: 1rem;
  }

  section {
    padding: 1rem;
    margin-bottom: 1.5rem;
  }

  .transcript-section {
    padding: 1rem;
  }

  .accordion-content {
    padding: 0 0.5rem;
  }

  .accordion-section.open .accordion-content {
    padding: 0.75rem;
  }

  .header {
    flex-direction: column;
    align-items: stretch;
  }

  .header .btn {
    width: 100%;
    text-align: center;
  }

  /* Mobile Navigation */
  .navbar-toggle {
    display: flex;
  }

  .navbar-menu {
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: white;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin-left: 0;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }

  .navbar-menu.active {
    max-height: 400px;
    border-top: 1px solid #e5e7eb;
  }

  .navbar-links {
    flex-direction: column;
    gap: 0;
    width: 100%;
  }

  .navbar-link {
    padding: 1rem 1.5rem;
    border-radius: 0;
    border-bottom: 1px solid #f3f4f6;
  }

  .navbar-user {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.5rem 0;
    border-top: 2px solid #e5e7eb;
  }

  .navbar-username {
    padding: 0.75rem 1.5rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
  }

  .navbar-signout {
    padding: 1rem 1.5rem;
  }

  .test-result-card {
    flex-direction: column;
    padding: 1rem;
    margin-left: 0;
    margin-right: 0;
  }

  .test-result-photo {
    width: 100%;
  }

  .manual-test-form {
    padding: 1rem;
    margin-left: 0;
    margin-right: 0;
  }

  .test-readings {
    grid-template-columns: 1fr;
  }

  .test-readings dt {
    margin-top: 0.5rem;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  .accordion-header {
    font-size: 1rem;
    padding: 0.75rem;
  }

  .table {
    font-size: 0.875rem;
  }

  .table th,
  .table td {
    padding: 0.5rem;
  }

  dl {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  dl dt {
    margin-top: 0.75rem;
  }

  .test-results-header {
    flex-direction: column;
  }

  .test-results-header .btn {
    width: 100%;
  }

  .test-result-actions {
    flex-direction: column;
  }

  .test-result-actions .btn {
    width: 100%;
  }

  .attachments-grid {
    grid-template-columns: 1fr;
  }
}

/* Touch-friendly buttons for mobile */
.btn {
  min-height: 44px;
  min-width: 44px;
}

/* File input styling */
input[type="file"].hidden-file-input {
  display: none;
}

input[type="file"]:not(.hidden-file-input) {
  padding: 0.5rem;
  border: 2px dashed #3b82f6;
  border-radius: 8px;
  background: #eff6ff;
  cursor: pointer;
  width: 100%;
}

input[type="file"]:not(.hidden-file-input):hover {
  border-color: #2563eb;
  background: #dbeafe;
}

/* Image Modal */
.image-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.image-modal.active {
  display: flex;
}

.image-modal-content {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-modal-image {
  max-width: 100%;
  max-height: 95vh;
  height: auto;
  width: auto;
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.image-modal-close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.95);
  color: #1f2937;
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
  z-index: 10000;
}

.image-modal-close:hover {
  background: white;
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.test-result-photo img {
  cursor: pointer;
  transition: all 0.2s ease;
}

.test-result-photo img:hover {
  opacity: 0.9;
  transform: scale(1.02);
}

/* Utility Classes - Tailwind-inspired */
.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.space-y-6 > * + * { margin-top: 1.5rem; }

.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }

.rounded { border-radius: 4px; }
.rounded-lg { border-radius: 8px; }
.rounded-xl { border-radius: 12px; }

.shadow-sm { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
.shadow { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); }
.shadow-lg { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15); }

.bg-white { background: white; }
.bg-gray-50 { background: #f9fafb; }
.bg-gray-100 { background: #f3f4f6; }

.border { border: 1px solid #e5e7eb; }
.border-2 { border: 2px solid #e5e7eb; }

.text-gray-600 { color: #4b5563; }
.text-gray-700 { color: #374151; }
.text-gray-900 { color: #111827; }
