/**
 * Global Form Styling - Matrix Theme
 * Universal form styling that applies to ALL templates across the application
 * Ensures consistent Matrix theme styling for forms, inputs, and checkboxes
 */

/* === UNIVERSAL FORM FIELD STYLING === */

/* Text inputs, selects, and textareas - Global */
input[type="text"],
input[type="email"],
input[type="password"], 
input[type="date"],
input[type="time"],
input[type="url"],
input[type="tel"],
input[type="number"],
select,
textarea {
    background: rgba(0, 0, 0, 0.9) !important;
    border: 1px solid rgba(0, 255, 65, 0.3) !important;
    color: var(--matrix-green) !important;
    padding: 0.75rem !important;
    border-radius: 4px !important;
    font-family: 'Courier New', monospace !important;
    width: 100% !important;
    transition: border-color 0.3s ease !important;
    font-size: 0.9375rem !important;
    box-sizing: border-box !important;
}

/* Textarea specific styling */
textarea {
    min-height: 120px !important;
    resize: vertical !important;
    vertical-align: top !important;
    white-space: pre-wrap !important;
}

/* Focus states for all form fields */
input:focus,
select:focus,
textarea:focus {
    outline: none !important;
    border-color: var(--matrix-green) !important;
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.3) !important;
}

/* Placeholder styling */
input::placeholder,
textarea::placeholder {
    color: rgba(0, 255, 65, 0.5) !important;
    font-family: 'Courier New', monospace !important;
    font-style: italic !important;
}

/* === UNIVERSAL CHECKBOX STYLING === */

input[type="checkbox"] {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    margin-right: 0.75rem !important;
    border: 2px solid rgba(0, 255, 65, 0.4) !important;
    border-radius: 4px !important;
    background: rgba(0, 0, 0, 0.9) !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    position: relative !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    transition: all 0.2s ease !important;
}

input[type="checkbox"]:checked {
    background: rgba(0, 255, 65, 0.2) !important;
    border-color: var(--matrix-green) !important;
    box-shadow: 0 0 8px rgba(0, 255, 65, 0.3) !important;
}

input[type="checkbox"]:checked::after {
    content: '✓' !important;
    color: var(--matrix-green) !important;
    font-size: 14px !important;
    font-weight: bold !important;
    line-height: 1 !important;
}

input[type="checkbox"]:focus {
    outline: 2px solid rgba(0, 255, 65, 0.5) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 8px rgba(0, 255, 65, 0.3) !important;
}

input[type="checkbox"]:hover {
    border-color: rgba(0, 255, 65, 0.6) !important;
}

/* === UNIVERSAL LABEL STYLING === */

/* Global form label styling */
label {
    color: rgba(0, 255, 65, 0.9) !important;
    font-family: 'Courier New', monospace !important;
    font-size: 0.9375rem !important;
    font-weight: 600 !important;
    margin-bottom: 0.5rem !important;
    display: block !important;
    transition: color 0.2s ease !important;
}

label:hover {
    color: var(--matrix-green) !important;
}

/* Labels next to checkboxes should be inline */
input[type="checkbox"] + label,
label:has(+ input[type="checkbox"]),
label:has(input[type="checkbox"]) {
    display: flex !important;
    align-items: center !important;
    cursor: pointer !important;
    user-select: none !important;
}

/* === FORM BUTTONS === */

button[type="submit"],
input[type="submit"],
.btn {
    font-family: 'Courier New', monospace !important;
    text-transform: uppercase !important;
    letter-spacing: 0.025em !important;
    transition: all 0.2s ease !important;
}

/* === MOBILE RESPONSIVE FORM STYLING === */

@media (max-width: 768px) {
    /* Mobile form fields */
    input[type="text"],
    input[type="email"],
    input[type="password"], 
    input[type="date"],
    input[type="time"],
    input[type="url"],
    input[type="tel"],
    input[type="number"],
    select,
    textarea {
        padding: 0.625rem !important;
        font-size: 16px !important; /* Prevent zoom on iOS */
    }
    
    /* Mobile textarea */
    textarea {
        min-height: 100px !important;
    }
    
    /* Mobile checkboxes */
    input[type="checkbox"] {
        width: 18px !important;
        height: 18px !important;
        min-width: 18px !important;
        min-height: 18px !important;
        margin-right: 0.5rem !important;
        border-radius: 3px !important;
    }
    
    input[type="checkbox"]:checked::after {
        font-size: 12px !important;
    }
    
    /* Mobile labels */
    label {
        font-size: 0.875rem !important;
    }
    
    /* Ensure touch targets are large enough on mobile */
    input,
    select,
    textarea,
    button {
        min-height: 44px !important;
        touch-action: manipulation !important;
    }
}

/* === FOOTER POSITIONING FIX - ALL DEVICES === */

/* Base footer positioning for all screen sizes */
html, body {
    height: 100% !important;
    overflow-x: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}

body {
    display: flex !important;
    flex-direction: column !important;
    min-height: 100vh !important;
}

main {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
}

footer {
    flex-shrink: 0 !important;
    margin-top: auto !important;
    position: relative !important;
    z-index: 100 !important;
    background: rgba(0, 0, 0, 0.95) !important;
    width: 100% !important;
}

/* Mobile-specific footer fixes */
@media (max-width: 768px) {
    body {
        max-height: 100vh !important;
        position: relative !important;
    }
    
    main {
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }
    
    footer {
        position: sticky !important;
        bottom: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Ensure footer container touches the bottom */
    footer .container-matrix {
        margin: 0 !important;
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
    
    /* Prevent any content from extending beyond viewport */
    .min-h-screen {
        min-height: auto !important;
        max-height: none !important;
    }
    
    /* Ensure Matrix canvas doesn't cause scroll */
    #matrix-canvas,
    canvas[id*="matrix"] {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        z-index: -1 !important;
        pointer-events: none !important;
        opacity: 0.7 !important;
    }
}

/* === ADMIN FORMS === */

/* Django admin forms */
.django-admin input,
.django-admin select,
.django-admin textarea,
.admin input,
.admin select,
.admin textarea {
    background: rgba(0, 0, 0, 0.9) !important;
    border: 1px solid rgba(0, 255, 65, 0.3) !important;
    color: var(--matrix-green) !important;
}

/* === ACCESSIBILITY === */

/* High contrast mode support */
@media (prefers-contrast: high) {
    input,
    select,
    textarea {
        border-width: 2px !important;
    }
    
    input[type="checkbox"] {
        border-width: 3px !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    input,
    select,
    textarea,
    input[type="checkbox"] {
        transition: none !important;
    }
}