/* FieldForms Lite - Print Styles */

@media print {
    /* Reset and Page Setup */
    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    @page {
        size: A4;
        margin: 1.5cm;
    }

    body {
        background: white !important;
        color: black !important;
        font-size: 12pt;
        line-height: 1.5;
    }

    /* Hide UI Elements */
    nav,
    aside,
    .print\\:hidden,
    button:not(.keep-on-print),
    .nav-btn,
    #installBtn,
    .fixed.inset-0.bg-black,
    [class*="bg-black"],
    [class*="bg-opacity"] {
        display: none !important;
    }

    /* Hide modal background overlays */
    .fixed.inset-0 {
        background: transparent !important;
    }

    /* Main Content */
    main {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .view-content {
        display: block !important;
    }

    /* Submission Modal Content */
    #submissionModal {
        position: static !important;
        background: white !important;
        box-shadow: none !important;
        max-width: 100% !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Hide modal overlay background */
    #submissionModal::before,
    #submissionModal::after {
        display: none !important;
    }

    /* Modal inner content */
    #submissionModal > div {
        box-shadow: none !important;
        border: none !important;
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        max-height: none !important;
        overflow: visible !important;
    }

    #submissionContent {
        padding: 0 !important;
        max-width: 100% !important;
    }

    /* Print Header */
    .print-header {
        border-bottom: 2px solid #333;
        padding-bottom: 1rem;
        margin-bottom: 1.5rem;
    }

    .print-header h1 {
        font-size: 24pt;
        margin: 0;
        color: #333;
    }

    .print-header .metadata {
        font-size: 10pt;
        color: #666;
        margin-top: 0.5rem;
    }

    /* Form Fields in Print */
    .form-field {
        margin-bottom: 1.5rem;
        page-break-inside: avoid;
    }

    .form-field label {
        font-weight: bold;
        display: block;
        margin-bottom: 0.25rem;
        font-size: 11pt;
    }

    .form-field .field-value {
        padding: 0.5rem;
        border: 1px solid #ddd;
        border-radius: 4px;
        min-height: 2rem;
        background: #f9f9f9;
    }

    /* Images and Signatures */
    .image-preview,
    .signature-canvas,
    img {
        max-width: 100% !important;
        width: auto !important;
        height: auto !important;
        page-break-inside: avoid;
        border: 1px solid #ddd;
        padding: 0.5rem;
        background: white;
        display: block;
        margin: 0.5rem 0;
    }

    .signature-canvas {
        max-height: 150px !important;
        max-width: 400px !important;
    }

    /* Field values with images */
    .field-value img {
        max-width: 500px !important;
        max-height: 400px !important;
        object-fit: contain;
    }

    /* Tables */
    table {
        width: 100%;
        border-collapse: collapse;
        page-break-inside: auto;
        margin: 1rem 0;
    }

    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    th, td {
        border: 1px solid #ddd;
        padding: 0.5rem;
        text-align: left;
        font-size: 10pt;
    }

    th {
        background: #f0f0f0;
        font-weight: bold;
    }

    /* Section Headers */
    h2, h3, h4 {
        page-break-after: avoid;
        color: #333;
        margin-top: 1.5rem;
        margin-bottom: 0.75rem;
    }

    h2 {
        font-size: 18pt;
        border-bottom: 1px solid #ddd;
        padding-bottom: 0.5rem;
    }

    h3 {
        font-size: 14pt;
    }

    h4 {
        font-size: 12pt;
    }

    /* Lists */
    ul, ol {
        margin: 0.5rem 0;
        padding-left: 1.5rem;
    }

    li {
        margin-bottom: 0.25rem;
    }

    /* Cards and Containers */
    .form-card,
    .submission-card,
    .field-card {
        border: 1px solid #ddd;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: none !important;
        page-break-inside: avoid;
    }

    /* Remove shadows and hover effects */
    * {
        box-shadow: none !important;
        transition: none !important;
    }

    /* Reset positioning for print */
    .fixed,
    .absolute,
    .sticky {
        position: static !important;
    }

    /* Reset z-index */
    * {
        z-index: auto !important;
    }

    /* Ensure submission modal displays when printing */
    #submissionModal:not(.print\\:hidden) {
        display: block !important;
    }

    /* Links */
    a {
        color: black;
        text-decoration: underline;
    }

    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 9pt;
        color: #666;
    }

    /* Page Numbers and Footer */
    .print-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        text-align: center;
        font-size: 9pt;
        color: #666;
        padding: 0.5rem;
        border-top: 1px solid #ddd;
    }

    .print-footer:after {
        counter-increment: page;
        content: "Page " counter(page);
    }

    /* Badges */
    .badge {
        border: 1px solid #333;
        padding: 0.25rem 0.5rem;
        background: white !important;
        color: black !important;
    }

    /* Grid Layouts */
    .grid {
        display: block !important;
    }

    .grid > * {
        width: 100% !important;
        margin-bottom: 1rem;
    }

    /* Flex Layouts */
    .flex {
        display: block !important;
    }

    .flex.justify-between {
        display: flex !important;
    }

    .flex.space-x-2,
    .flex.space-x-4 {
        gap: 0 !important;
    }

    .flex > * {
        margin: 0 !important;
    }

    /* Form Preview Area */
    #formPreview {
        border: 1px solid #ddd !important;
        padding: 1rem !important;
        background: white !important;
    }

    /* Required Indicator */
    .required::after {
        content: '*';
        color: black;
    }

    /* Checkbox and Radio Button Styling */
    input[type="checkbox"],
    input[type="radio"] {
        -webkit-appearance: none;
        appearance: none;
        width: 14px;
        height: 14px;
        border: 1px solid #333;
        margin-right: 0.5rem;
        vertical-align: middle;
    }

    input[type="checkbox"]:checked::before {
        content: '✓';
        display: block;
        text-align: center;
        line-height: 14px;
        font-size: 12px;
    }

    input[type="radio"] {
        border-radius: 50%;
    }

    input[type="radio"]:checked::before {
        content: '●';
        display: block;
        text-align: center;
        line-height: 14px;
        font-size: 10px;
    }

    /* Metadata Info */
    .metadata {
        background: #f9f9f9;
        padding: 1rem;
        border-radius: 4px;
        margin-top: 0.5rem;
    }

    .metadata > div {
        padding: 0.25rem 0;
    }

    .metadata-row {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border-bottom: 1px solid #eee;
    }

    .metadata-row:last-child {
        border-bottom: none;
    }

    .metadata-label {
        font-weight: bold;
        min-width: 150px;
    }

    /* Spacing utilities */
    .space-y-6 > * + *,
    .space-y-4 > * + *,
    .space-y-3 > * + *,
    .space-y-2 > * + * {
        margin-top: 1.5rem !important;
    }

    .mb-6 {
        margin-bottom: 1.5rem !important;
    }

    .mb-4 {
        margin-bottom: 1rem !important;
    }

    .mb-2 {
        margin-bottom: 0.5rem !important;
    }

    .mt-6 {
        margin-top: 1.5rem !important;
    }

    .pt-4 {
        padding-top: 1rem !important;
    }

    /* Avoid breaking these elements */
    .no-break {
        page-break-inside: avoid;
    }

    /* QR Code or Barcodes if added later */
    .qr-code,
    .barcode {
        page-break-inside: avoid;
        max-width: 200px;
        margin: 1rem 0;
    }

    /* Empty values */
    .empty-value {
        color: #999;
        font-style: italic;
    }

    /* Signature Area */
    .signature-area {
        margin-top: 2rem;
        page-break-inside: avoid;
    }

    .signature-line {
        border-top: 1px solid #333;
        width: 250px;
        margin-top: 3rem;
        padding-top: 0.5rem;
        text-align: center;
        font-size: 10pt;
    }

    /* Repeatable Groups */
    .repeatable-group {
        border: 1px solid #ddd;
        padding: 1rem;
        margin-bottom: 1rem;
        background: #fafafa;
        page-break-inside: avoid;
    }

    .repeatable-group-header {
        font-weight: bold;
        margin-bottom: 0.5rem;
        padding-bottom: 0.5rem;
        border-bottom: 1px solid #ddd;
    }
}
