/**
 * W-4 PDF Overlay Form Styles
 * Matches the dark theme from black-theme.css
 */

/* ===================================
   NAVIGATION BAR
   =================================== */
.w4-nav-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 15px 20px;
    background: linear-gradient(135deg, #252525 0%, #1a1a1a 100%);
    border: 1px solid #444;
    border-radius: 8px;
    margin-bottom: 20px;
}

.w4-nav-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.w4-icon {
    font-size: 1.3rem;
}

.w4-page-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.w4-page-tab {
    padding: 8px 16px;
    background: #333;
    border: 1px solid #555;
    border-radius: 6px;
    color: #ccc;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.w4-page-tab small {
    font-size: 0.7rem;
    color: #888;
    margin-top: 2px;
}

.w4-page-tab:hover {
    background: #444;
    border-color: #666;
    color: #fff;
}

.w4-page-tab.active {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    border-color: #007bff;
    color: #fff;
}

.w4-page-tab.active small {
    color: rgba(255, 255, 255, 0.8);
}

.w4-zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.w4-zoom-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #555;
    background: #333;
    color: #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.w4-zoom-btn:hover {
    background: #444;
    color: #fff;
}

.w4-zoom-level {
    color: #aaa;
    font-size: 0.85rem;
    min-width: 45px;
    text-align: center;
}

/* ===================================
   PAGE CONTAINER
   =================================== */
.w4-pages-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #1a1a1a;
    padding: 30px;
    border-radius: 8px;
    border: 1px solid #333;
    min-height: 500px;
    overflow-x: auto;
}

.w4-page-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.w4-page-scaler {
    transform-origin: top center;
    transition: transform 0.2s ease;
}

.w4-page {
    position: relative;
    width: 612px;
    height: 792px;
    background: #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
    border-radius: 2px;
}

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

/* ===================================
   FORM FIELDS
   =================================== */
.w4-fields-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.w4-field {
    position: absolute;
    box-sizing: border-box;
    padding: 2px 4px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    line-height: 1.2;
    border: 1px solid transparent;
    background: transparent;
    transition: all 0.15s ease;
}

.w4-field:hover {
    background: rgba(255, 255, 200, 0.3);
    border-color: rgba(0, 100, 200, 0.4);
}

.w4-field:focus {
    outline: none;
    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;
}

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

.w4-field.is-invalid {
    border-color: #dc3545 !important;
    background: rgba(220, 53, 69, 0.1) !important;
}

/* Text fields */
.w4-field-text,
.w4-field-date {
    color: #000;
    resize: none;
    overflow: hidden;
}

.w4-field-date::placeholder {
    color: #999;
    font-size: 8px;
}

/* Checkboxes */
.w4-field-checkbox {
    width: 12px !important;
    height: 12px !important;
    padding: 0;
    margin: 0;
    cursor: pointer;
    accent-color: #007bff;
}

/* Signature */
.w4-field-signature {
    background: rgba(255, 255, 220, 0.3);
    border: 1px dashed #999;
    cursor: crosshair;
    padding: 0;
}

.w4-signature-canvas {
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.w4-sig-clear {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    padding: 0;
    border: none;
    background: rgba(220, 53, 69, 0.8);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

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

/* ===================================
   REFERENCE PAGE
   =================================== */
.w4-reference-page .w4-fields-layer {
    display: none;
}

.w4-reference-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
}

.w4-reference-badge {
    background: rgba(23, 162, 184, 0.9);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* ===================================
   VALIDATION
   =================================== */
.w4-validation-summary {
    margin-top: 20px;
}

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

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

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

/* ===================================
   HELP TEXT
   =================================== */
.w4-help-text {
    background: linear-gradient(135deg, #1a3a4a 0%, #0d2535 100%);
    border: 1px solid #17a2b8;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 20px;
}

.w4-help-text h5 {
    color: #17a2b8;
    margin-bottom: 10px;
    font-size: 1rem;
}

.w4-help-text ul {
    margin: 0;
    padding-left: 20px;
    color: #ccc;
    font-size: 0.9rem;
}

.w4-help-text li {
    margin-bottom: 5px;
}

/* ===================================
   FORM ACTIONS
   =================================== */
.w4-form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 25px;
    padding: 20px;
    background: linear-gradient(135deg, #252525 0%, #1a1a1a 100%);
    border: 1px solid #444;
    border-radius: 8px;
}

/* ===================================
   RESPONSIVE
   =================================== */
@media (max-width: 768px) {
    .w4-nav-bar {
        flex-direction: column;
        align-items: stretch;
    }

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

    .w4-zoom-controls {
        justify-content: center;
    }

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

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

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

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

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

.w4-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;
}

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

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

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

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

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

/* Tooltip indicator on fields with Spanish help */
.w4-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;
}

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

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

.w4-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;
}

/* ===================================
   PRINT STYLES
   Prints the form exactly like official PDF
   =================================== */
@media print {
    /* Hide all UI elements */
    .w4-nav-bar,
    .w4-zoom-controls,
    .w4-form-actions,
    .w4-validation-summary,
    .w4-help-text,
    .w4-page-tabs,
    .w4-sig-clear,
    .w4-reference-overlay,
    .w4-reference-badge,
    .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 */
    .w4-pages-wrapper {
        background: white !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }

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

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

    /* PDF page - exact letter size */
    .w4-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 */
    .w4-pdf-bg {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        object-fit: contain !important;
    }

    /* Fields layer */
    .w4-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 */
    .w4-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;
    }

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

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

    .w4-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 */
    .w4-field-signature {
        background: transparent !important;
        border: none !important;
    }

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

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

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

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

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

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