/**
 * HVAC Community Events: UX Enhancements
 * 
 * Enhanced user experience with modern notifications, loading states, and mobile optimizations
 * 
 * @version 1.0.0
 */

/* ========================================
   NOTIFICATION SYSTEM 
======================================== */

/* Toast Notification Container */
.hvac-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
    pointer-events: none;
}

/* Toast Notification */
.hvac-toast {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 16px 20px;
    pointer-events: all;
    transform: translateX(100%);
    transition: all 0.3s ease;
    border-left: 4px solid #3b82f6;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    position: relative;
    max-width: 100%;
    word-wrap: break-word;
}

.hvac-toast.show {
    transform: translateX(0);
}

.hvac-toast.hiding {
    transform: translateX(100%);
    opacity: 0;
}

/* Toast Types */
.hvac-toast.success {
    border-left-color: #10b981;
}

.hvac-toast.error {
    border-left-color: #ef4444;
}

.hvac-toast.warning {
    border-left-color: #f59e0b;
}

.hvac-toast.info {
    border-left-color: #3b82f6;
}

/* Toast Icon */
.hvac-toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.hvac-toast.success .hvac-toast-icon::before {
    content: "✓";
    color: #10b981;
    font-weight: bold;
    font-size: 16px;
}

.hvac-toast.error .hvac-toast-icon::before {
    content: "✗";
    color: #ef4444;
    font-weight: bold;
    font-size: 16px;
}

.hvac-toast.warning .hvac-toast-icon::before {
    content: "⚠";
    color: #f59e0b;
    font-weight: bold;
    font-size: 16px;
}

.hvac-toast.info .hvac-toast-icon::before {
    content: "ℹ";
    color: #3b82f6;
    font-weight: bold;
    font-size: 16px;
}

/* Toast Content */
.hvac-toast-content {
    flex: 1;
}

.hvac-toast-title {
    font-weight: 600;
    font-size: 14px;
    color: #1f2937;
    margin-bottom: 4px;
}

.hvac-toast-message {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.4;
}

/* Toast Close Button */
.hvac-toast-close {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.hvac-toast-close:hover {
    background: #f3f4f6;
    color: #374151;
}

/* ========================================
   LOADING STATES 
======================================== */

/* Loading Overlay */
.hvac-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
}

/* Inline Loading Spinner */
.hvac-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #6b7280;
}

.hvac-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: hvac-spin 1s linear infinite;
}

.hvac-spinner.large {
    width: 40px;
    height: 40px;
    border-width: 3px;
}

@keyframes hvac-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Button Loading State */
.hvac-btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.hvac-btn.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: hvac-spin 1s linear infinite;
    color: inherit;
}

/* ========================================
   ENHANCED BUTTONS 
======================================== */

.hvac-btn {
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}

.hvac-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.hvac-btn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.hvac-btn:not(:disabled):active {
    transform: translateY(0);
}

/* ========================================
   ENHANCED FORM ELEMENTS 
======================================== */

/* Input Focus States */
.hvac-input:focus,
.hvac-select:focus,
.hvac-textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
}

/* Input Error States */
.hvac-input.error,
.hvac-select.error,
.hvac-textarea.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Field Error Message */
.hvac-field-error {
    color: #ef4444;
    font-size: 12px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.hvac-field-error::before {
    content: "⚠";
    font-size: 14px;
}

/* ========================================
   MOBILE RESPONSIVENESS 
======================================== */

/* Mobile Toast Adjustments */
@media (max-width: 640px) {
    .hvac-toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .hvac-toast {
        margin: 0;
        max-width: 100%;
    }
}

/* Mobile Form Improvements */
@media (max-width: 767px) {
    /* Larger touch targets */
    .hvac-btn {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .hvac-input,
    .hvac-select,
    .hvac-textarea {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
    }
    
    /* Full width buttons on mobile */
    .hvac-dashboard-nav {
        flex-direction: column;
        gap: 8px;
    }
    
    .hvac-dashboard-nav .hvac-btn {
        width: 100%;
        text-align: center;
    }
    
    /* Improved stats layout on mobile */
    .hvac-stats-row {
        flex-direction: column;
        margin: 0;
    }
    
    .hvac-stat-col {
        padding: 5px 0;
        min-width: 100%;
    }
    
    /* Card improvements for mobile */
    .hvac-stat-card,
    .hvac-certificate-card,
    .hvac-event-card {
        margin-bottom: var(--hvac-spacing-md);
        padding: var(--hvac-spacing-md);
    }
    
    /* Table responsiveness */
    .hvac-table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .hvac-table-responsive table {
        min-width: 600px;
    }
}

/* ========================================
   ACCESSIBILITY ENHANCEMENTS 
======================================== */

/* Focus Visible for Keyboard Navigation */
.hvac-btn:focus-visible,
.hvac-input:focus-visible,
.hvac-select:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Screen Reader Only Text */
.hvac-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .hvac-toast {
        border: 2px solid;
    }
    
    .hvac-btn {
        border: 2px solid;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .hvac-toast,
    .hvac-btn,
    .hvac-spinner {
        animation: none;
        transition: none;
    }
}

/* ========================================
   UTILITY CLASSES 
======================================== */

.hvac-hidden { display: none !important; }
.hvac-invisible { visibility: hidden !important; }
.hvac-text-center { text-align: center !important; }
.hvac-text-left { text-align: left !important; }
.hvac-text-right { text-align: right !important; }
.hvac-mb-0 { margin-bottom: 0 !important; }
.hvac-mt-0 { margin-top: 0 !important; }
.hvac-p-0 { padding: 0 !important; }

/* Focus Management Styles - WCAG 2.1 Compliance */
/* Added for keyboard accessibility and screen reader support */

/* Button Focus Styles */
.hvac-button:focus,
.hvac-content .button:focus,
.hvac-content button:focus,
.hvac-content input[type="submit"]:focus,
.hvac-email-submit:focus,
.hvac-filter-submit:focus,
.hvac-certificate-actions button:focus,
.hvac-certificate-actions a:focus {
    outline: 2px solid #005fcc;
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(0, 95, 204, 0.2);
    border-radius: 4px;
}

/* Input Focus Styles */
.hvac-form-input:focus,
.hvac-content input[type="text"]:focus,
.hvac-content input[type="email"]:focus,
.hvac-content input[type="password"]:focus,
.hvac-content input[type="url"]:focus,
.hvac-content textarea:focus,
.hvac-content select:focus,
.hvac-email-form-row input:focus,
.hvac-email-form-row textarea:focus,
.hvac-filter-group input:focus,
.hvac-filter-group select:focus {
    outline: 2px solid #005fcc;
    outline-offset: 2px;
    border-color: #005fcc;
    box-shadow: 0 0 0 3px rgba(0, 95, 204, 0.2);
}

/* Link Focus Styles */
.hvac-content a:focus,
.hvac-event-link:focus,
.hvac-certificate-link:focus,
.hvac-attendee-profile-icon:focus,
.hvac-dashboard-nav a:focus,
.hvac-email-navigation a:focus {
    outline: 2px solid #005fcc;
    outline-offset: 2px;
    text-decoration: underline;
    background-color: rgba(0, 95, 204, 0.1);
    border-radius: 2px;
}

/* Interactive Element Focus Styles */
.hvac-attendee-checkbox:focus,
.hvac-select-all-container input[type="checkbox"]:focus,
.hvac-modal-close:focus,
.hvac-certificate-table tr:focus {
    outline: 2px solid #005fcc;
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(0, 95, 204, 0.2);
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .hvac-content *:focus {
        outline: 3px solid #000000;
        outline-offset: 2px;
        background-color: #ffff00;
        color: #000000;
    }
}

/* Focus-visible polyfill support */

/* Reset focus for mouse users while preserving keyboard accessibility */
.js-focus-visible :focus:not(.focus-visible) {
    outline: none;
    box-shadow: none;
}

/* Ensure focus is visible for keyboard users */
.js-focus-visible .focus-visible {
    outline: 2px solid #005fcc;
    outline-offset: 2px;
}
