/* Enhanced styles.css - Mobile and Desktop Optimized - FIXED VERSION */
:root {
    --primary-color: #4a90e2;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --border-radius: 8px;
    --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    --ferikind-blue: #0066cc;
    --mankind-orange: #ff6600;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 800px;
    margin: 20px auto;
    padding: 20px;
}

/* Logo Section - Enhanced for Mobile */
.logos-section {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
}

.logo {
    max-height: 80px;
    max-width: 200px;
    height: auto;
    width: auto;
    object-fit: contain;
}

/* Header Improvements - FIXED */
header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    color: var(--ferikind-blue);
    margin-bottom: 8px;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 700;
    line-height: 1.2;
    /* Fallback color in case CSS variables fail */
    color: #0066cc;
    /* Re-apply CSS variable */
    color: var(--ferikind-blue);
    /* Ensure visibility */
    display: block;
    visibility: visible;
}

.subtitle {
    color: var(--secondary-color);
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
    margin-bottom: 25px;
    font-style: italic;
    /* Fallback color */
    color: #6c757d;
    /* Re-apply CSS variable */
    color: var(--secondary-color);
}

/* Welcome Message - Mobile Optimized */
.welcome-message {
    background-color: white;
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 30px;
    border-left: 4px solid var(--ferikind-blue);
}

.welcome-message p:first-child {
    font-weight: bold;
    color: var(--ferikind-blue);
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
    background-color: #f0f8ff;
    padding: 15px;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--ferikind-blue);
    margin-bottom: 0;
    text-align: center;
    line-height: 1.5;
    /* Fallback color */
    color: #0066cc;
    /* Re-apply CSS variable */
    color: var(--ferikind-blue);
}

/* Form Container - Enhanced */
.form-container {
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 25px;
    margin-bottom: 20px;
}

/* Management and Healthcare Info Boxes */
.management-info-box, .healthcare-info-box {
    background-color: white;
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 25px;
    transition: var(--transition);
}

.management-info-box:hover, .healthcare-info-box:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.management-info-box {
    border-left: 4px solid var(--ferikind-blue);
}

.healthcare-info-box {
    border-left: 4px solid #28a745;
}

.info-box-title {
    color: var(--ferikind-blue);
    font-size: 1.3em;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
    font-weight: 600;
}

.healthcare-info-box .info-box-title {
    color: #28a745;
}

/* Form Groups - Mobile Enhanced */
.form-group {
    margin-bottom: 25px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 16px;
    color: var(--dark-color);
}

.required {
    color: var(--danger-color);
    font-weight: bold;
}

/* Input Fields - Mobile Optimized */
input[type="text"],
input[type="email"],
input[type="tel"],
select {
    width: 100%;
    padding: 16px;
    border: 2px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 16px; /* Prevents zoom on iOS */
    transition: var(--transition);
    background-color: white;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Focus States */
input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
select:focus {
    border-color: var(--ferikind-blue);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
    transform: translateY(-1px);
}

/* File Input - Enhanced */
input[type="file"] {
    width: 100%;
    padding: 12px;
    border: 2px dashed #ddd;
    border-radius: var(--border-radius);
    background-color: #fafafa;
    cursor: pointer;
    transition: var(--transition);
    font-size: 16px;
}

input[type="file"]:hover {
    border-color: var(--ferikind-blue);
    background-color: #f0f8ff;
}

input[type="file"]:focus {
    border-color: var(--ferikind-blue);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

/* Field Validation Styling */
input.valid, select.valid {
    border: 2px solid #28a745;
    background-color: #f8fff8;
}

input.error, select.error {
    border: 2px solid var(--danger-color);
    background-color: #fff8f8;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Field Info Text */
.field-info {
    font-size: 14px;
    color: var(--secondary-color);
    margin-top: 5px;
    font-style: italic;
}

.file-info {
    font-size: 14px;
    color: var(--secondary-color);
    margin-top: 8px;
    line-height: 1.5;
}

/* File List - Enhanced */
.file-list {
    margin-top: 15px;
}

.file-item {
    background-color: #f0f8ff;
    padding: 12px;
    border-radius: var(--border-radius);
    margin-bottom: 8px;
    border-left: 3px solid var(--ferikind-blue);
    transition: var(--transition);
}

.file-item:hover {
    background-color: #e6f3ff;
    transform: translateY(-1px);
}

.file-info-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.file-icon {
    font-size: 20px;
    color: var(--danger-color);
}

.file-name {
    flex: 1;
    font-weight: 500;
    word-break: break-word;
    min-width: 200px;
}

.file-size {
    color: var(--secondary-color);
    font-size: 12px;
    background-color: rgba(0, 0, 0, 0.05);
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
}

/* Employee ID and Contact Number Special Styling */
#mrEmployeeId, #amEmployeeId, #contactNo {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    letter-spacing: 1px;
    font-weight: 500;
}

/* Select Dropdown Enhancement */
select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 45px;
    cursor: pointer;
}

select:focus {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230066cc' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
}

/* Submit Button - Enhanced */
button[type="submit"] {
    background: linear-gradient(135deg, var(--ferikind-blue), #004499);
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    transition: var(--transition);
    width: 100%;
    position: relative;
    overflow: hidden;
}

button[type="submit"]:hover:not(:disabled) {
    background: linear-gradient(135deg, #004499, #003366);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 102, 204, 0.3);
}

button[type="submit"]:active {
    transform: translateY(0);
}

button[type="submit"]:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.submit-group {
    text-align: center;
    margin-top: 40px;
}

/* Modal Styles - Enhanced for Mobile */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 30px;
    width: 90%;
    max-width: 600px;
    border-radius: var(--border-radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(50px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: var(--secondary-color);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.close:hover {
    color: var(--danger-color);
    background-color: rgba(220, 53, 69, 0.1);
}

#errorMessage {
    color: var(--danger-color);
    margin-top: 15px;
    font-size: 16px;
    line-height: 1.5;
}

#errorModal h2 {
    color: var(--danger-color);
    margin-bottom: 15px;
}

#successModal h2 {
    color: var(--success-color);
    text-align: center;
    margin-bottom: 20px;
}

/* Success Modal Content */
.success-content {
    text-align: center;
}

.success-content p {
    margin-bottom: 15px;
    line-height: 1.6;
    font-size: 16px;
}

.reference-section {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: var(--border-radius);
    margin: 25px 0;
    border-left: 4px solid var(--ferikind-blue);
}

.reference-section p {
    margin: 0;
    font-size: 18px;
}

#referenceNumber {
    color: var(--ferikind-blue);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-weight: bold;
    letter-spacing: 1px;
    font-size: 20px;
}

.thank-you-signature {
    margin: 25px 0;
    padding-top: 20px;
    border-top: 2px solid #eee;
}

.thank-you-signature p {
    margin: 0;
    color: var(--dark-color);
}

/* Thank You Page Logos */
.thank-you-logos {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 25px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #eee;
    flex-wrap: wrap;
}

.thank-you-logo {
    max-height: 60px;
    max-width: 150px;
    height: auto;
    width: auto;
    opacity: 0.8;
    transition: var(--transition);
}

.thank-you-logo:hover {
    opacity: 1;
    transform: scale(1.05);
}

/* Responsive Design - Mobile First */
@media (max-width: 768px) {
    .container {
        padding: 15px;
        margin: 10px auto;
    }
    
    .form-container, .management-info-box, .healthcare-info-box {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    /* Logo adjustments */
    .logo-container {
        gap: 15px;
    }
    
    .logo {
        max-height: 60px;
        max-width: 140px;
    }
    
    /* Header adjustments */
    header h1 {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
    
    /* Form improvements */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    select {
        padding: 18px 16px; /* Larger tap targets */
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    label {
        font-size: 16px;
        margin-bottom: 10px;
    }
    
    /* Modal improvements */
    .modal-content {
        width: 95%;
        margin: 20% auto;
        padding: 20px;
        max-height: 70vh;
    }
    
    .close {
        right: 15px;
        top: 15px;
        font-size: 24px;
        width: 35px;
        height: 35px;
    }
    
    /* File info improvements */
    .file-info-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .file-name {
        min-width: auto;
        width: 100%;
    }
    
    .file-size {
        align-self: flex-start;
    }
    
    /* Success modal adjustments */
    #referenceNumber {
        font-size: 18px;
        word-break: break-all;
    }
    
    .thank-you-logos {
        gap: 15px;
        flex-direction: column;
    }
    
    .thank-you-logo {
        max-height: 50px;
        max-width: 120px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
        margin: 5px auto;
    }
    
    .form-container, .management-info-box, .healthcare-info-box {
        padding: 15px;
    }
    
    .welcome-message p:first-child {
        font-size: 0.9rem;
        padding: 12px;
    }
    
    .info-box-title {
        font-size: 1.1em;
    }
    
    /* Ultra-mobile optimizations */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    select {
        padding: 20px 16px;
    }
    
    button[type="submit"] {
        padding: 18px 24px;
        font-size: 16px;
    }
    
    .modal-content {
        margin: 10% auto;
        padding: 15px;
    }
    
    .file-item {
        padding: 10px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #000000;
        --secondary-color: #0000ff;
        --success-color: #008000;
        --danger-color: #ff0000;
        --light-color: #ffffff;
        --dark-color: #000000;
    }
    
    input, select, button {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* FIXED Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #64b5f6;
        --secondary-color: #90a4ae;
        --success-color: #81c784;
        --danger-color: #f28b82;
        --light-color: #424242;
        --dark-color: #ffffff;
        --ferikind-blue: #64b5f6; /* Ensure this is properly defined */
        --mankind-orange: #ff9944;
    }
    
    body {
        background-color: #121212;
        color: #ffffff;
    }
    
    /* FIXED: Be specific instead of using generic .container > * */
    .logos-section {
        background-color: #1e1e1e !important;
        color: #ffffff;
    }
    
    .form-container {
        background-color: #1e1e1e !important;
        color: #ffffff;
    }
    
    .management-info-box,
    .healthcare-info-box {
        background-color: #1e1e1e !important;
        color: #ffffff;
    }
    
    .welcome-message {
        background-color: #1e1e1e !important;
        color: #ffffff;
    }
    
    .welcome-message p:first-child {
        background-color: #2d2d2d !important;
        color: var(--ferikind-blue) !important;
    }
    
    /* FIXED: Specifically target header elements */
    header {
        color: #ffffff;
    }
    
    header h1 {
        color: var(--ferikind-blue) !important;
        /* Fallback for dark mode */
        color: #64b5f6 !important;
    }
    
    .subtitle {
        color: var(--secondary-color) !important;
        /* Fallback for dark mode */
        color: #90a4ae !important;
    }
    
    /* Form elements in dark mode */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    select {
        background-color: #2d2d2d;
        color: #ffffff;
        border-color: #444;
    }
    
    input[type="file"] {
        background-color: #2d2d2d;
        color: #ffffff;
        border-color: #444;
    }
    
    label {
        color: #ffffff;
    }
    
    .field-info,
    .file-info {
        color: var(--secondary-color);
    }
    
    /* File items in dark mode */
    .file-item {
        background-color: #2d2d2d;
        color: #ffffff;
    }
    
    .file-size {
        background-color: rgba(255, 255, 255, 0.1);
        color: var(--secondary-color);
    }
    
    /* Reference section in dark mode */
    .reference-section {
        background-color: #2d2d2d;
        color: #ffffff;
    }
    
    #referenceNumber {
        color: var(--ferikind-blue);
    }
    
    /* Modal in dark mode */
    .modal-content {
        background-color: #1e1e1e;
        color: #ffffff;
    }
    
    /* Thank you signature */
    .thank-you-signature p {
        color: #ffffff;
    }
    
    /* Info box titles */
    .info-box-title {
        color: var(--ferikind-blue);
    }
    
    .healthcare-info-box .info-box-title {
        color: var(--success-color);
    }
}

/* Print styles */
@media print {
    .logos-section,
    .welcome-message,
    button,
    .modal {
        display: none !important;
    }
    
    body {
        background-color: white;
        color: black;
    }
    
    .container {
        max-width: 100%;
        padding: 0;
        margin: 0;
    }
    
    header h1 {
        color: #000 !important;
    }
    
    .subtitle {
        color: #666 !important;
    }
}

/* Focus management for accessibility */
.focused {
    outline: 2px solid var(--ferikind-blue);
    outline-offset: 2px;
}

/* Loading states */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid var(--ferikind-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}