/*
  style.css

  Description:
    Primary application stylesheet for the Accident Report form UI.
    Provides base typography, layout container, form control styling, map and signature canvas sizing,
    responsive adjustments for mobile, and h-captcha related display fixes.

  Notes:
    - Only comments/documentation were updated for clarity.
    - No functional changes were made to the CSS rules.
    - Keep accessibility in mind when adjusting styles in future updates.

  Maintainer:
    Accident Report App team
*/

body { font-family: Arial, sans-serif; background-color: #f8f8f8; margin: 0; padding: 20px; }
.container { max-width: 1100px; margin: auto; background: #fff; padding: 30px; border-radius: 8px; box-shadow: 0 0 10px rgba(0,0,0,0.1); }
h2, h3 { text-align: center; color: #333; }
label { font-weight: bold; }
input[type="text"], input[type="date"], input[type="datetime-local"], input[type="tel"], input[type="file"], textarea, select {
    width: 100%; padding: 8px; margin: 6px 0 12px 0; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box;
}
table { width: 100%; border-collapse: collapse; margin-bottom: 25px; }
th, td { border: 1px solid #ccc; padding: 10px; text-align: left; }
th { background-color: #3498db; color: white; }
#map { height: 400px; margin-bottom: 20px; }
#signatureCanvas { touch-action: none; border: 1px solid #ccc; width: 100%; height: 150px; }
button { background-color: #3498db; color: white; padding: 12px 20px; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; }
button:hover { background-color: #2980b9; }
@media (max-width: 768px) { .container { padding: 15px; } }
.submit-captcha { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; margin-top:16px; width:100%; }
.captcha-wrapper { display:inline-block; }
.hidden { display: none !important; }
button[disabled] { opacity: 0.6; cursor: not-allowed; }
.flashes { list-style: none; padding: 0; margin: 0 0 16px 0; }
.flash { padding: 12px; border-radius: 6px; margin-bottom: 8px; border: 1px solid transparent; color: #333; }
.flash.success { background: #e6ffed; border-color: #57d36c; color: #155724; }
.flash.error   { background: #ffe6e6; border-color: #d9534f; color: #721c24; }
.flash.info    { background: #f0f0f0; border-color: #ccc; color: #333; }
#signatureLabel { display:inline-block; font-weight:700; font-size:1rem; line-height:1.2; margin-bottom:.5rem; color:inherit; }

/* Grid layout for vehicle info and repeatable rows */
.grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 20px; }
.grid.two-col { grid-template-columns: 1fr; }
.grid-row { display: flex; flex-direction: column; }
.grid-row label { margin-bottom: 6px; font-weight:700; }

.repeatable-list { display:flex; flex-direction:column; gap:8px; margin-bottom:12px; }
.repeat-row { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.repeat-row input, .repeat-row textarea { flex: 1 1 180px; min-width:120px; }
.repeat-row button { flex: 0 0 auto; padding:6px 10px; font-size:14px; }

/* Address row: default inline, stacked on small screens */
.address-row { display:flex; gap:8px; align-items:center; margin-bottom:10px; }
.address-row .address-input { flex:1 1 auto; }
.small-btn { padding:10px 12px; }

/* responsive adjustments */
@media (max-width: 700px) {
    #map { height: 300px; }

    /* stack address input above find button on narrow screens */
    .address-row { flex-direction: column; align-items: stretch; }
    .address-row .small-btn { width: 100%; }

    /* make buttons full width on phones */
    button { width: 100%; padding: 14px; font-size: 18px; }

    /* hide table headers if any remain (legacy tables) */
    th { display: none !important; }

    /* convert legacy table rows into stacked blocks if present */
    table { border: none; }
    thead { display: none; }
    tr { display: block; margin-bottom: 1rem; border-bottom: 1px solid rgba(0,0,0,0.06); padding-bottom: 8px; }
    td { display: block; padding: 0.25rem 0; border: none; }
    td:first-child { font-weight: 700; color: #333; margin-bottom: 6px; }
    td:nth-child(2) { margin-bottom: 6px; }

    /* Ensure two-col grids stack vertically on mobile to avoid cramped inputs */
    .grid.two-col { grid-template-columns: 1fr; }

    /* signature canvas */
    #signatureCanvas { width: 100%; height: 200px; }
}

/* very narrow device polish */
@media (max-width: 380px) {
    .container { padding: 12px; }
    input[type="text"], textarea, select { padding: 10px; font-size: 15px; }
}

/* ensure captcha is clickable and stays visually inside the form */
.submit-captcha, .captcha-wrapper, .h-captcha {
  pointer-events: auto !important;
  position: relative !important;
  z-index: 9999 !important;
  -webkit-transform: none !important;
  transform: none !important;
}

/* ensure captcha iframe is clickable and above other page elements */
.h-captcha, .h-captcha iframe {
  pointer-events: auto !important;
  position: relative !important;
  z-index: 99999 !important;
}

/* Prevent outer container clipping of positioned children (helps mobile iframes) */
.container {
  overflow: visible;
}

/* Styles for the captcha portal used on small portrait screens */
.hcaptcha-portal-fixed {
  border-radius: 8px;
  padding: 6px;
  background: #fff;
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
  -webkit-tap-highlight-color: transparent;
}

/* backdrop: visual only (do not block pointer events) so iframe remains clickable and background not frozen */
#hcaptcha-portal-backdrop {
  display: block;
  pointer-events: none; /* <--- allow touches to pass through to captcha overlay which sits above */
  background: rgba(0,0,0,0.25);
}
