/* ============================================
   CRITICAL FIX: Form Input Visibility
   ============================================
   Purpose: Ensure checkboxes and radio buttons are always visible
   Issue: Tailwind CDN doesn't include form plugin by default
   Solution: Explicit CSS styling for form inputs
   ============================================ */

/* Base styling for all checkboxes and radio buttons */
input[type="checkbox"],
input[type="radio"] {
    /* Force visible size */
    width: 1.25rem !important;
    height: 1.25rem !important;
    min-width: 1.25rem !important;
    min-height: 1.25rem !important;
    
    /* Prevent shrinking */
    flex-shrink: 0;
    
    /* Display properties */
    display: inline-block !important;
    vertical-align: middle;
    
    /* Restore native appearance */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    
    /* Interaction */
    cursor: pointer;
    
    /* Spacing */
    margin: 0;
    
    /* Visibility */
    opacity: 1 !important;
    visibility: visible !important;
    
    /* Smooth transitions */
    transition: all 0.15s ease-in-out;
}

/* Checkbox-specific styling */
input[type="checkbox"] {
    border-radius: 0.25rem;
}

/* Radio button-specific styling */
input[type="radio"] {
    border-radius: 50%;
}

/* Visible border for better visibility */
input[type="checkbox"],
input[type="radio"] {
    border: 2px solid #d1d5db !important;
    background-color: white !important;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* Hover state */
input[type="checkbox"]:hover:not(:disabled),
input[type="radio"]:hover:not(:disabled) {
    border-color: #9ca3af !important;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

/* Checked state styling */
input[type="checkbox"]:checked {
    background-color: currentColor !important;
    border-color: currentColor !important;
    background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e") !important;
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
}

input[type="radio"]:checked {
    background-color: currentColor !important;
    border-color: currentColor !important;
    background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='8' cy='8' r='3'/%3e%3c/svg%3e") !important;
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
}

/* Focus state for accessibility */
input[type="checkbox"]:focus,
input[type="radio"]:focus {
    outline: none !important;
    border-color: currentColor !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
}

/* Disabled state */
input[type="checkbox"]:disabled,
input[type="radio"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #f3f4f6 !important;
}

/* Color variants for different contexts */
/* Green theme (for tips) */
input[type="checkbox"].text-green-600:checked,
input[type="radio"].text-green-600:checked {
    background-color: #16a34a !important;
    border-color: #16a34a !important;
}

input[type="checkbox"].text-green-600:focus,
input[type="radio"].text-green-600:focus {
    border-color: #16a34a !important;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1) !important;
}

/* Purple theme (for reports) */
input[type="checkbox"].text-purple-600:checked,
input[type="radio"].text-purple-600:checked {
    background-color: #9333ea !important;
    border-color: #9333ea !important;
}

input[type="checkbox"].text-purple-600:focus,
input[type="radio"].text-purple-600:focus {
    border-color: #9333ea !important;
    box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.1) !important;
}

/* Indigo theme (for volunteers) */
input[type="checkbox"].text-indigo-600:checked,
input[type="radio"].text-indigo-600:checked {
    background-color: #4f46e5 !important;
    border-color: #4f46e5 !important;
}

input[type="checkbox"].text-indigo-600:focus,
input[type="radio"].text-indigo-600:focus {
    border-color: #4f46e5 !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1) !important;
}

/* Blue theme (default) */
input[type="checkbox"]:checked:not(.text-green-600):not(.text-purple-600):not(.text-indigo-600),
input[type="radio"]:checked:not(.text-green-600):not(.text-purple-600):not(.text-indigo-600) {
    background-color: #3b82f6 !important;
    border-color: #3b82f6 !important;
}

/* Ensure labels are clickable */
label:has(input[type="checkbox"]),
label:has(input[type="radio"]) {
    cursor: pointer;
    user-select: none;
}

/* Fix for any parent containers that might hide inputs */
label input[type="checkbox"],
label input[type="radio"],
.flex input[type="checkbox"],
.flex input[type="radio"] {
    position: relative !important;
    clip: auto !important;
    width: 1.25rem !important;
    height: 1.25rem !important;
    margin-right: 0.75rem !important; /* Ensure spacing */
}

/* Additional safety: prevent any hiding */
input[type="checkbox"][hidden],
input[type="radio"][hidden] {
    display: inline-block !important;
    visibility: visible !important;
}

/* Better alignment in flex containers */
.flex.items-center input[type="checkbox"],
.flex.items-center input[type="radio"],
.flex.items-start input[type="checkbox"],
.flex.items-start input[type="radio"] {
    align-self: flex-start;
    margin-top: 0.125rem;
}

/* Ensure proper spacing between radio/checkbox and adjacent content */
/* Only apply if no margin is already set */
label input[type="checkbox"]:not([class*="mr-"]) + div,
label input[type="radio"]:not([class*="mr-"]) + div,
label input[type="checkbox"]:not([class*="mr-"]) + *,
label input[type="radio"]:not([class*="mr-"]) + * {
    margin-left: 0.75rem;
}
