/**
 * I-9 PDF Overlay Form Styles
 * Matches the dark Bootstrap theme from black-theme.css
 *
 * PDF Page Size: 612px x 792px (US Letter in points)
 */

/* ===================================
   NAVIGATION BAR
   =================================== */

.i9-nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
    padding: 20px;
    background: linear-gradient(135deg, #252525 0%, #1a1a1a 100%);
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.i9-nav-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #f5f5f5;
    display: flex;
    align-items: center;
    gap: 10px;
}

.i9-icon {
    font-size: 1.5rem;
}

.i9-page-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.i9-page-tab {
    background: linear-gradient(135deg, #3a3a3a 0%, #2a2a2a 100%);
    border: 2px solid #505050;
    color: #d4d4d4;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.i9-page-tab:hover {
    background: linear-gradient(135deg, #4a4a4a 0%, #3a3a3a 100%);
    border-color: #606060;
    color: #ffffff;
}

.i9-page-tab.active {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border-color: #28a745;
    color: #ffffff;
}

.i9-page-tab small {
    display: block;
    font-size: 0.75rem;
    opacity: 0.8;
    margin-top: 2px;
}

.i9-zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 12px;
    border-radius: 6px;
}

.i9-zoom-btn {
    background: #3a3a3a;
    border: 1px solid #505050;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
}

.i9-zoom-btn:hover {
    background: #4a4a4a;
}

.i9-zoom-level {
    color: #d4d4d4;
    font-size: 0.9rem;
    min-width: 50px;
    text-align: center;
}

/* ===================================
   PDF PAGES CONTAINER
   =================================== */

.i9-pages-wrapper {
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
    padding: 30px;
    border-radius: 10px;
    overflow-x: auto;
    margin-bottom: 20px;
}

.i9-page-container {
    display: flex;
    justify-content: center;
}

.i9-page-scaler {
    transform-origin: top center;
    transition: transform 0.3s ease;
}

.i9-page {
    position: relative;
    /* Base size matches PDF dimensions in points */
    width: 612px;
    height: 792px;
    background: #ffffff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
    margin: 0 auto;
}

.i9-pdf-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

/* ===================================
   FORM FIELDS OVERLAY
   =================================== */

.i9-fields-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.i9-field {
    position: absolute;
    pointer-events: auto;
    box-sizing: border-box;
}

/* Text Input Fields */
.i9-field-text,
.i9-field-date {
    background: rgba(255, 255, 200, 0.15);
    border: 1px solid rgba(0, 100, 200, 0.3);
    padding: 1px 3px;
    font-size: 9px;
    font-family: Arial, Helvetica, sans-serif;
    color: #000000;
    outline: none;
    transition: all 0.2s ease;
    line-height: 1;
}

.i9-field-text:focus,
.i9-field-date:focus {
    background: rgba(255, 255, 150, 0.5);
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
    z-index: 10;
}

.i9-field-text:hover,
.i9-field-date:hover {
    background: rgba(255, 255, 180, 0.3);
}

.i9-field-text.is-invalid,
.i9-field-date.is-invalid {
    border-color: #dc3545;
    background: rgba(255, 200, 200, 0.4);
}

.i9-field-text.filled,
.i9-field-date.filled {
    background: rgba(200, 255, 200, 0.2);
}

/* Textarea Fields */
.i9-field-textarea {
    background: rgba(255, 255, 200, 0.15);
    border: 1px solid rgba(0, 100, 200, 0.3);
    padding: 2px 3px;
    font-size: 8px;
    font-family: Arial, Helvetica, sans-serif;
    color: #000000;
    outline: none;
    resize: none;
    overflow: auto;
    line-height: 1.2;
}

.i9-field-textarea:focus {
    background: rgba(255, 255, 150, 0.5);
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
    z-index: 10;
}

/* Checkbox Fields */
.i9-field-checkbox {
    appearance: none;
    -webkit-appearance: none;
    background: rgba(255, 255, 200, 0.2);
    border: 1px solid rgba(0, 100, 200, 0.4);
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0;
    padding: 0;
}

.i9-field-checkbox:checked {
    background: #28a745;
    border-color: #28a745;
}

.i9-field-checkbox:checked::after {
    content: '\2713';
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 8px;
    font-weight: bold;
    width: 100%;
    height: 100%;
    line-height: 1;
}

.i9-field-checkbox:hover {
    background: rgba(255, 255, 180, 0.4);
}

.i9-field-checkbox:focus {
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Select Fields */
.i9-field-select {
    background: rgba(255, 255, 200, 0.25);
    border: 1px solid rgba(0, 100, 200, 0.3);
    padding: 0 2px;
    font-size: 8px;
    font-family: Arial, Helvetica, sans-serif;
    color: #000000;
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.i9-field-select:focus {
    background: rgba(255, 255, 150, 0.5);
    border-color: #007bff;
}

/* Signature Fields */
.i9-field-signature {
    background: rgba(255, 255, 200, 0.1);
    border: 1px dashed rgba(0, 100, 200, 0.4);
    cursor: crosshair;
    position: relative;
}

.i9-signature-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.i9-sig-clear {
    position: absolute;
    bottom: 1px;
    right: 1px;
    padding: 1px 4px;
    font-size: 7px;
    background: rgba(220, 53, 69, 0.8);
    color: white;
    border: none;
    border-radius: 2px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.i9-field-signature:hover .i9-sig-clear {
    opacity: 1;
}

.i9-sig-clear:hover {
    background: #dc3545;
}

/* Conditional Fields (hidden by default) */
.i9-field[data-conditional] {
    opacity: 0.3;
    pointer-events: none;
}

.i9-field[data-conditional].enabled {
    opacity: 1;
    pointer-events: auto;
}

/* ===================================
   REFERENCE PAGE (Page 2)
   =================================== */

.i9-reference-page {
    position: relative;
}

.i9-reference-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.02);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 20px;
}

.i9-reference-badge {
    background: rgba(23, 162, 184, 0.9);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ===================================
   FORM ACTIONS
   =================================== */

.i9-form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #252525 0%, #1a1a1a 100%);
    border-radius: 10px;
    margin-bottom: 20px;
}

/* ===================================
   VALIDATION SUMMARY
   =================================== */

.i9-validation-summary {
    margin-top: 20px;
}

.i9-validation-summary ul {
    margin-bottom: 0;
    padding-left: 20px;
}

.i9-validation-summary li {
    cursor: pointer;
    color: #007bff;
}

.i9-validation-summary li:hover {
    text-decoration: underline;
}

/* ===================================
   HELP TEXT
   =================================== */

.i9-help-text {
    background: linear-gradient(135deg, #1a3a4a 0%, #0d2535 100%);
    border: 1px solid #17a2b8;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 20px;
    color: #d4edff;
}

.i9-help-text h5 {
    color: #5bc0de;
    margin-bottom: 10px;
}

.i9-help-text ul {
    margin-bottom: 0;
    padding-left: 20px;
}

/* ===================================
   RESPONSIVE SCALING
   =================================== */

@media (max-width: 768px) {
    .i9-nav-bar {
        flex-direction: column;
        text-align: center;
    }

    .i9-page-tabs {
        justify-content: center;
    }

    .i9-form-actions {
        flex-direction: column;
        gap: 15px;
    }

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

    .i9-pages-wrapper {
        padding: 15px;
    }
}

/* ===================================
   PRINT-ONLY ELEMENTS (hidden on screen)
   =================================== */

.i9-signature-print-img,
.i9-check-print {
    display: none;
}

/* ===================================
   SPANISH TOOLTIPS
   =================================== */

.i9-tooltip {
    position: absolute;
    background: linear-gradient(135deg, #1a3a4a 0%, #0d2535 100%);
    border: 1px solid #17a2b8;
    border-radius: 8px;
    padding: 10px 14px;
    color: #fff;
    font-size: 12px;
    max-width: 280px;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(5px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.i9-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.i9-tooltip::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 20px;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #17a2b8;
}

.i9-tooltip-label {
    font-weight: 600;
    color: #5bc0de;
    margin-bottom: 4px;
    display: block;
}

.i9-tooltip-help {
    color: #d4edff;
    line-height: 1.4;
}

.i9-tooltip-flag {
    font-size: 14px;
    margin-right: 6px;
}

/* Tooltip indicator on fields with Spanish help */
.i9-field[data-tooltip-es]::after {
    content: '🇪🇸';
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 10px;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.i9-field[data-tooltip-es]:hover::after,
.i9-field[data-tooltip-es]:focus::after {
    opacity: 1;
}

/* ===================================
   LOCKED (EMPLOYER-ONLY) FIELDS
   =================================== */

.i9-field-locked {
    background: rgba(100, 100, 100, 0.3) !important;
    border: 1px dashed #666 !important;
    color: #888 !important;
    cursor: not-allowed !important;
    pointer-events: none;
}

.i9-field-locked::placeholder {
    color: transparent;
}

.i9-field-signature.i9-field-locked {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(80, 80, 80, 0.4) !important;
}

.i9-locked-label {
    font-size: 7px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===================================
   PRINT STYLES
   Prints the form exactly like official PDF
   =================================== */
@media print {
    /* Hide all UI elements */
    .i9-nav-bar,
    .i9-zoom-controls,
    .i9-form-actions,
    .i9-validation-summary,
    .i9-help-text,
    .i9-page-tabs,
    .i9-sig-clear,
    .i9-reference-overlay,
    .i9-reference-badge,
    .i9-locked-label,
    .nav-tabs,
    .progress-bar,
    .btn,
    header,
    footer,
    .sidebar {
        display: none !important;
    }

    /* Reset page */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    html, body {
        width: 100%;
        height: 100%;
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
    }

    /* Page container */
    .i9-pages-wrapper {
        background: white !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }

    .i9-page-container {
        display: block !important;
        page-break-after: always;
        page-break-inside: avoid;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .i9-page-scaler {
        transform: none !important;
        width: 100% !important;
    }

    /* PDF page - exact letter size */
    .i9-page {
        width: 8.5in !important;
        height: 11in !important;
        margin: 0 auto !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        position: relative !important;
        background: white !important;
        overflow: hidden !important;
    }

    /* PDF background image */
    .i9-pdf-bg {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        object-fit: contain !important;
    }

    /* Fields layer */
    .i9-fields-layer {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 612px !important;
        height: 792px !important;
        transform: scale(calc(8.5 / 8.5)) !important;
        transform-origin: top left !important;
    }

    /* All form fields - invisible borders, show text */
    .i9-field {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        color: black !important;
        font-family: Arial, Helvetica, sans-serif !important;
        font-size: 9px !important;
        line-height: 1.2 !important;
        padding: 1px 2px !important;
        overflow: visible !important;
    }

    .i9-field-text,
    .i9-field-date,
    .i9-field-select {
        -webkit-appearance: none !important;
        appearance: none !important;
    }

    /* Checkboxes - show checkmark */
    .i9-field-checkbox {
        -webkit-appearance: none !important;
        appearance: none !important;
        background: transparent !important;
        border: none !important;
    }

    .i9-field-checkbox:checked::after {
        content: "✓" !important;
        font-size: 12px !important;
        font-weight: bold !important;
        color: black !important;
        position: absolute !important;
        top: -2px !important;
        left: 0 !important;
    }

    /* Signatures - hide canvas, show rendered image */
    .i9-field-signature {
        background: transparent !important;
        border: none !important;
    }

    .i9-signature-canvas {
        display: none !important;
    }

    .i9-signature-print-img {
        display: block !important;
    }

    /* Checkmark spans for checkboxes */
    .i9-check-print {
        display: block !important;
    }

    /* Locked fields - still print values if any */
    .i9-field-locked {
        background: transparent !important;
        border: none !important;
        color: black !important;
    }

    /* Textarea */
    .i9-field-textarea {
        resize: none !important;
        overflow: hidden !important;
    }

    /* Hide empty pages */
    .i9-page-container[style*="display: none"] {
        display: none !important;
    }

    /* Page size settings */
    @page {
        size: letter portrait;
        margin: 0;
    }
}
