/* Tourism Housing Assistance & Recovery Programme - Public Form Styles */

/* Variables */
:root {
    --primary-dark: #111827;
    --primary-blue: #4C96BD;
    --primary-blue-light: #A1D1E4;
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --red-500: #ef4444;
    --red-50: #fef2f2;
    --green-500: #22c55e;
    --green-50: #f0fdf4;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--gray-800);
    background: linear-gradient(135deg, var(--primary-blue-light) 0%, var(--primary-blue) 100%);
    min-height: 100vh;
}

/* Container */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.main-header {
    background-color: var(--primary-dark);
    color: var(--white);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--white);
    object-fit: contain;
    padding: 0px;
}

.header-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.header-text p {
    font-size: 0.875rem;
    opacity: 0.8;
}

@media (min-width: 640px) {
    .header-text h1 {
        font-size: 1.5rem;
    }
}

/* Main Content */
.main-content {
    padding: 2rem 0;
}

/* Cards */
.intro-card,
.form-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
}

.intro-card h2 {
    color: var(--primary-dark);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.intro-card p {
    margin-bottom: 1rem;
    color: var(--gray-600);
}

.privacy-notice {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1rem;
    margin: 1.5rem 0;
}

.privacy-notice h3 {
    font-size: 1rem;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

.privacy-notice p {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.required-note {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.required {
    color: var(--red-500);
}

.form-card h3 {
    color: var(--primary-dark);
    font-size: 1.25rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-blue-light);
}

.section-note {
    font-size: 0.875rem;
    color: var(--gray-600);
    background: var(--gray-50);
    padding: 0.75rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

/* Form Elements */
.form-group {
    margin-bottom: 1.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .form-row {
        grid-template-columns: 1fr 1fr;
    }
}

label {
    display: block;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
    font-size: 0.9375rem;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(76, 150, 189, 0.2);
}

input:invalid:not(:placeholder-shown),
select:invalid:not(:placeholder-shown) {
    border-color: var(--red-500);
}

input[type="file"] {
    padding: 0.5rem;
    cursor: pointer;
}

input[type="file"]::file-selector-button {
    padding: 0.5rem 1rem;
    margin-right: 1rem;
    border: none;
    border-radius: var(--radius);
    background: var(--primary-blue);
    color: var(--white);
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

input[type="file"]::file-selector-button:hover {
    background: var(--primary-dark);
}

small {
    display: block;
    font-size: 0.8125rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

/* Radio & Checkbox Groups */
.radio-group,
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.radio-group.vertical,
.checkbox-group.vertical {
    flex-direction: column;
    gap: 0.75rem;
}

.radio-label,
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: normal;
    margin-bottom: 0;
}

.radio-label input,
.checkbox-label input {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--primary-blue);
    cursor: pointer;
}

.checkbox-label.agreement {
    align-items: flex-start;
    background: var(--gray-50);
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}

.checkbox-label.agreement input {
    margin-top: 0.125rem;
    flex-shrink: 0;
}

.checkbox-label.agreement span {
    line-height: 1.5;
}

/* Terms Content */
.terms-content {
    background: var(--gray-50);
    padding: 1.25rem;
    border-radius: var(--radius);
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1.5rem;
    border: 1px solid var(--gray-200);
}

.terms-content p {
    margin-bottom: 1rem;
    font-size: 0.9375rem;
}

.terms-content ol {
    padding-left: 1.5rem;
}

.terms-content li {
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: var(--gray-600);
}

.terms-content li strong {
    color: var(--gray-800);
}

/* Signature Pad */
.signature-container {
    background: var(--gray-50);
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

#signaturePad {
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    cursor: crosshair;
    touch-action: none;
    width: 100%;
    max-width: 100%;
}

#clearSignature {
    margin-top: 0.75rem;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-dark) 100%);
    color: var(--white);
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-submit {
    margin-top: 1rem;
}

/* Turnstile */
.cf-turnstile {
    display: flex;
    justify-content: center;
    margin: 1rem 0;
}

/* Footer */
.main-footer {
    background-color: var(--primary-dark);
    color: var(--white);
    padding: 2.5rem 0 1.5rem;
    margin-top: 2rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 640px) {
    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.footer-section h4 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.footer-section p {
    font-size: 0.875rem;
    opacity: 0.8;
    margin-bottom: 0.5rem;
}

.footer-section a {
    color: var(--primary-blue-light);
    text-decoration: none;
}

.footer-section a:hover {
    color: var(--white);
}

.footer-logo {
    width: 70px;
    height: 70px;
    margin-bottom: 1rem;
}

.social-links {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.social-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transition: background-color 0.2s;
}

.social-links a:hover {
    background: rgba(255, 255, 255, 0.2);
}

.social-links svg {
    width: 20px;
    height: 20px;
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    margin-top: 2rem;
    padding-top: 1.5rem;
    text-align: center;
}

.footer-bottom p {
    font-size: 0.875rem;
    opacity: 0.6;
}

/* Error & Success States */
.error-message {
    background: var(--red-50);
    border: 1px solid var(--red-500);
    color: var(--red-500);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.success-message {
    background: var(--green-50);
    border: 1px solid var(--green-500);
    color: var(--green-500);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

/* Field Error */
.field-error {
    border-color: var(--red-500) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
}

.error-text {
    color: var(--red-500);
    font-size: 0.8125rem;
    margin-top: 0.25rem;
}

/* Inline Error Alert (for declaration section) */
.inline-error-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: var(--red-50);
    border: 1px solid var(--red-500);
    border-left: 4px solid var(--red-500);
    color: var(--red-700, #b91c1c);
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    margin: 1rem 0;
    font-size: 0.9375rem;
    line-height: 1.5;
}

.inline-error-alert svg {
    flex-shrink: 0;
    color: var(--red-500);
    margin-top: 0.125rem;
}

.inline-error-alert span {
    flex: 1;
}

/* CAPTCHA Error Alert with Retry Button */
.captcha-error-alert {
    background: var(--red-50);
    border: 1px solid var(--red-500);
    border-left: 4px solid var(--red-500);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.captcha-error-content {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.captcha-error-content svg {
    flex-shrink: 0;
    color: var(--red-500);
    margin-top: 0.125rem;
}

.captcha-error-text {
    flex: 1;
}

.captcha-error-text strong {
    display: block;
    color: #b91c1c;
    font-size: 0.9375rem;
    margin-bottom: 0.25rem;
}

.captcha-error-text p {
    color: #7f1d1d;
    font-size: 0.875rem;
    margin: 0;
}

.btn-retry-captcha {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary-blue);
    color: var(--white);
    border: none;
    padding: 0.625rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-retry-captcha:hover {
    background: #3a7a9c;
}

.btn-retry-captcha svg {
    flex-shrink: 0;
}

/* Loading State */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .header-text h1 {
        font-size: 0.9375rem;
        margin-bottom: 0.125rem;
    }

    .header-text p {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 0.75rem;
    }

    .intro-card,
    .form-card {
        padding: 1rem;
    }

    #signaturePad {
        width: 100%;
        height: 150px;
    }
}

/* Print styles */
@media print {
    .main-header,
    .main-footer,
    .btn-primary,
    .btn-secondary,
    .cf-turnstile {
        display: none !important;
    }

    body {
        background: white;
    }

    .form-card {
        box-shadow: none;
        border: 1px solid var(--gray-300);
    }
}

/* File Preview */
.file-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.file-preview-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 80px;
    padding: 0.5rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

.file-preview-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    background: var(--white);
}

.file-preview-pdf {
    width: 60px;
    height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--white);
    border-radius: 4px;
    color: var(--red-500);
}

.file-preview-pdf svg {
    width: 32px;
    height: 32px;
}

.file-preview-pdf span {
    font-size: 0.625rem;
    font-weight: 600;
    margin-top: 2px;
}

.file-preview-name {
    font-size: 0.6875rem;
    color: var(--gray-600);
    text-align: center;
    margin-top: 0.25rem;
    word-break: break-all;
    line-height: 1.2;
}

/* Privacy Notice Images */
.privacy-images {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.privacy-image {
    width: 100%;
    max-width: 100%;
    height: auto;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

/* Multiple File Upload */
#damagePhotosContainer {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.file-input-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-input-row input[type="file"] {
    flex: 1;
}

.btn-remove-file {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: var(--radius);
    background: var(--red-50);
    color: var(--red-500);
    font-size: 1.25rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-remove-file:hover {
    background: var(--red-500);
    color: white;
}

.btn-add-more {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.btn-add-more svg {
    flex-shrink: 0;
}

.btn-add-more:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Dev Fill Button */
.btn-dev-fill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 2px dashed #f59e0b;
    border-radius: var(--radius);
    background: #fef3c7;
    color: #92400e;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 1rem;
}

.btn-dev-fill:hover {
    background: #fde68a;
    border-color: #d97706;
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    /* Hide non-essential elements */
    header,
    .main-header,
    .intro-card,
    .confirmation-actions,
    .pdf-save-tip,
    .btn-dev-fill {
        display: none !important;
    }

    /* Reset page styles */
    body {
        background: white !important;
        margin: 0;
        padding: 20px;
    }

    .main-content {
        padding: 0 !important;
    }

    .container {
        max-width: 100% !important;
        padding: 0 !important;
    }

    /* Style the confirmation card for print */
    .form-card {
        box-shadow: none !important;
        border: 1px solid #e5e7eb !important;
        page-break-inside: avoid;
    }

    #confirmationCard {
        max-width: 600px;
        margin: 0 auto;
    }

    .confirmation-content {
        padding: 1.5rem !important;
    }

    .confirmation-details {
        background: #f9fafb !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Add header for print */
    #confirmationCard::before {
        content: "Tourism Housing Assistance & Recovery Programme";
        display: block;
        text-align: center;
        font-size: 1.25rem;
        font-weight: 600;
        color: #111827;
        padding-bottom: 1rem;
        margin-bottom: 1rem;
        border-bottom: 2px solid #4C96BD;
    }

    /* Add footer for print */
    #confirmationCard::after {
        content: "Tourism Enhancement Fund - Ministry of Tourism Jamaica";
        display: block;
        text-align: center;
        font-size: 0.75rem;
        color: #6b7280;
        padding-top: 1rem;
        margin-top: 1rem;
        border-top: 1px solid #e5e7eb;
    }
}

/* ============================================
   Submission Progress Indicator
   ============================================ */
.submission-progress {
    margin-top: 1.25rem;
    padding: 1rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.progress-step {
    font-weight: 600;
    color: var(--primary-dark);
    font-size: 0.9375rem;
}

.progress-time {
    font-size: 0.8125rem;
    color: var(--gray-500);
    font-variant-numeric: tabular-nums;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-blue) 0%, var(--green-500) 100%);
    border-radius: 4px;
    transition: width 0.3s ease-out;
}

.progress-detail {
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    color: var(--gray-500);
    min-height: 1.25rem;
}

/* Button loading spinner */
.btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.btn-loading-text {
    font-size: 0.9375rem;
}

/* ============================================
   GPS Map Styles
   ============================================ */
.field-help-text {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.inline-pin-icon {
    display: inline-block;
    vertical-align: middle;
    margin: 0 2px;
}

.btn-get-location {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px dashed var(--primary-blue);
    border-radius: var(--radius);
    background: var(--primary-blue-light);
    color: var(--primary-dark);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 0.75rem;
}

.btn-get-location:hover {
    background: var(--primary-blue);
    color: var(--white);
    border-style: solid;
}

.btn-get-location:hover svg {
    stroke: var(--white);
}

.btn-get-location svg {
    flex-shrink: 0;
    stroke: var(--primary-blue);
    transition: stroke 0.2s;
}

.btn-get-location small {
    font-size: 0.8125rem;
    font-weight: 400;
    opacity: 0.8;
}

.btn-get-location.loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn-get-location.loading svg {
    animation: spin 1s linear infinite;
}

.location-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
    color: var(--gray-500);
    font-size: 0.875rem;
}

.location-divider::before,
.location-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gray-300);
}

.map-search-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.map-search-input {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
}

.map-search-input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(76, 150, 189, 0.2);
}

.btn-map-search {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--radius);
    background: var(--primary-blue);
    color: var(--white);
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-map-search:hover {
    background: var(--primary-dark);
}

.gps-map-container {
    width: 100%;
    height: 350px;
    border-radius: var(--radius);
    border: 2px solid var(--gray-300);
    background: var(--gray-100);
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.gps-map-container.field-error {
    border-color: var(--red-500);
}

@media (max-width: 640px) {
    .gps-map-container {
        height: 300px;
    }
}

.gps-coordinates {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    background: var(--green-50);
    border: 1px solid var(--green-500);
    border-radius: var(--radius);
    color: var(--green-500);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.gps-coordinates svg {
    flex-shrink: 0;
}

/* Google Places Autocomplete dropdown styling */
.pac-container {
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
    font-family: inherit;
    z-index: 10000;
}

.pac-item {
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    cursor: pointer;
}

.pac-item:hover {
    background: var(--gray-50);
}

.pac-item-selected {
    background: var(--primary-blue-light);
}

.pac-icon {
    margin-right: 0.5rem;
}

.pac-matched {
    font-weight: 600;
}
