/**
 * HVAC Communication Templates Styling
 * 
 * Styles for the email template management system
 * 
 * @version 1.0.0
 */

/* Template Management Container */
.hvac-template-manager {
    background: var(--hvac-background-white);
    border-radius: var(--hvac-radius-lg);
    box-shadow: var(--hvac-shadow-md);
    padding: var(--hvac-spacing-6);
    margin-bottom: var(--hvac-spacing-6);
    border: 1px solid var(--hvac-border);
}

.hvac-template-manager h3 {
    color: var(--hvac-theme-text-dark);
    font-size: var(--hvac-font-size-lg);
    font-weight: var(--hvac-font-weight-semibold);
    margin: 0 0 var(--hvac-spacing-4) 0;
    display: flex;
    align-items: center;
    gap: var(--hvac-spacing-2);
}

.hvac-template-manager h3::before {
    content: '📝';
    font-size: var(--hvac-font-size-xl);
}

/* Template Actions */
.hvac-template-actions {
    display: flex;
    gap: var(--hvac-spacing-3);
    margin-bottom: var(--hvac-spacing-4);
    flex-wrap: wrap;
    align-items: center;
}

.hvac-template-toggle {
    background: var(--hvac-primary);
    color: white;
    border: none;
    padding: var(--hvac-spacing-2) var(--hvac-spacing-4);
    border-radius: var(--hvac-radius-md);
    font-size: var(--hvac-font-size-sm);
    font-weight: var(--hvac-font-weight-medium);
    cursor: pointer;
    transition: all var(--hvac-transition-fast);
    display: flex;
    align-items: center;
    gap: var(--hvac-spacing-1);
}

.hvac-template-toggle:hover {
    background: var(--hvac-primary-dark);
    transform: translateY(-1px);
}

.hvac-template-toggle.active {
    background: var(--hvac-success);
}

/* Template List */
.hvac-template-list {
    margin-bottom: var(--hvac-spacing-4);
}

.hvac-template-selector {
    display: flex;
    gap: var(--hvac-spacing-3);
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: var(--hvac-spacing-4);
}

.hvac-template-dropdown {
    min-width: 200px;
    padding: var(--hvac-spacing-2) var(--hvac-spacing-3);
    border: 2px solid var(--hvac-border);
    border-radius: var(--hvac-radius-md);
    font-size: var(--hvac-font-size-sm);
    background: var(--hvac-background-white);
    cursor: pointer;
    transition: border-color var(--hvac-transition-fast);
}

.hvac-template-dropdown:focus {
    border-color: var(--hvac-primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--hvac-primary-light);
}

.hvac-template-category-filter {
    min-width: 150px;
    padding: var(--hvac-spacing-2) var(--hvac-spacing-3);
    border: 2px solid var(--hvac-border);
    border-radius: var(--hvac-radius-md);
    font-size: var(--hvac-font-size-sm);
    background: var(--hvac-background-white);
}

.hvac-template-actions-buttons {
    display: flex;
    gap: var(--hvac-spacing-2);
}

.hvac-btn-load, .hvac-btn-edit, .hvac-btn-delete, .hvac-btn-save {
    padding: var(--hvac-spacing-2) var(--hvac-spacing-3);
    border: none;
    border-radius: var(--hvac-radius-sm);
    font-size: var(--hvac-font-size-sm);
    font-weight: var(--hvac-font-weight-medium);
    cursor: pointer;
    transition: all var(--hvac-transition-fast);
    display: flex;
    align-items: center;
    gap: var(--hvac-spacing-1);
}

.hvac-btn-load {
    background: var(--hvac-accent);
    color: white;
}

.hvac-btn-load:hover {
    background: var(--hvac-accent-dark);
}

.hvac-btn-edit {
    background: var(--hvac-warning);
    color: white;
}

.hvac-btn-edit:hover {
    background: var(--hvac-warning-dark);
}

.hvac-btn-delete {
    background: var(--hvac-error);
    color: white;
}

.hvac-btn-delete:hover {
    background: var(--hvac-error-dark);
}

.hvac-btn-save {
    background: var(--hvac-success);
    color: white;
}

.hvac-btn-save:hover {
    background: var(--hvac-success-dark);
}

/* Template Form */
.hvac-template-form {
    background: var(--hvac-background-subtle);
    padding: var(--hvac-spacing-5);
    border-radius: var(--hvac-radius-md);
    border: 1px solid var(--hvac-border-light);
    margin-bottom: var(--hvac-spacing-4);
    display: none;
}

.hvac-template-form.active {
    display: block;
    animation: hvac-fadeIn 0.3s ease-out;
}

@keyframes hvac-fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.hvac-template-form-row {
    margin-bottom: var(--hvac-spacing-4);
}

.hvac-template-form-row label {
    display: block;
    margin-bottom: var(--hvac-spacing-2);
    font-weight: var(--hvac-font-weight-semibold);
    color: var(--hvac-theme-text-dark);
    font-size: var(--hvac-font-size-sm);
}

.hvac-template-form-row input[type="text"],
.hvac-template-form-row select,
.hvac-template-form-row textarea {
    width: 100%;
    padding: var(--hvac-spacing-3);
    border: 2px solid var(--hvac-border);
    border-radius: var(--hvac-radius-md);
    font-size: var(--hvac-font-size-md);
    font-family: var(--hvac-font-family);
    background: var(--hvac-background-white);
    transition: border-color var(--hvac-transition-fast);
    box-sizing: border-box;
}

.hvac-template-form-row input[type="text"]:focus,
.hvac-template-form-row select:focus,
.hvac-template-form-row textarea:focus {
    border-color: var(--hvac-primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--hvac-primary-light);
}

.hvac-template-form-row textarea {
    min-height: 200px;
    resize: vertical;
    font-family: 'Courier New', monospace;
    line-height: 1.6;
}

/* Required field indicator */
.hvac-required {
    color: var(--hvac-error);
    font-weight: bold;
}

/* Placeholder Helper */
.hvac-placeholder-helper {
    background: var(--hvac-info-light);
    border: 1px solid var(--hvac-accent);
    border-radius: var(--hvac-radius-md);
    padding: var(--hvac-spacing-4);
    margin-bottom: var(--hvac-spacing-4);
}

.hvac-placeholder-helper h4 {
    color: var(--hvac-accent);
    font-size: var(--hvac-font-size-md);
    font-weight: var(--hvac-font-weight-semibold);
    margin: 0 0 var(--hvac-spacing-3) 0;
    display: flex;
    align-items: center;
    gap: var(--hvac-spacing-2);
}

.hvac-placeholder-helper h4::before {
    content: '💡';
}

.hvac-placeholder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--hvac-spacing-2);
}

.hvac-placeholder-item {
    background: var(--hvac-background-white);
    border: 1px solid var(--hvac-border-light);
    border-radius: var(--hvac-radius-sm);
    padding: var(--hvac-spacing-2) var(--hvac-spacing-3);
    cursor: pointer;
    transition: all var(--hvac-transition-fast);
    font-size: var(--hvac-font-size-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hvac-placeholder-item:hover {
    background: var(--hvac-primary-light);
    border-color: var(--hvac-primary);
    transform: translateY(-1px);
}

.hvac-placeholder-code {
    font-family: 'Courier New', monospace;
    font-weight: var(--hvac-font-weight-bold);
    color: var(--hvac-primary);
}

.hvac-placeholder-desc {
    color: var(--hvac-theme-text-light);
    font-size: var(--hvac-font-size-xs);
}

/* Form Actions */
.hvac-template-form-actions {
    display: flex;
    gap: var(--hvac-spacing-3);
    justify-content: flex-end;
    align-items: center;
    margin-top: var(--hvac-spacing-5);
    padding-top: var(--hvac-spacing-4);
    border-top: 1px solid var(--hvac-border-light);
}

.hvac-template-form-actions button {
    padding: var(--hvac-spacing-3) var(--hvac-spacing-5);
    border: none;
    border-radius: var(--hvac-radius-md);
    font-size: var(--hvac-font-size-md);
    font-weight: var(--hvac-font-weight-semibold);
    cursor: pointer;
    transition: all var(--hvac-transition-fast);
    min-width: 120px;
}

.hvac-btn-primary {
    background: var(--hvac-primary);
    color: white;
}

.hvac-btn-primary:hover {
    background: var(--hvac-primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--hvac-shadow-md);
}

.hvac-btn-secondary {
    background: var(--hvac-theme-text-light);
    color: white;
}

.hvac-btn-secondary:hover {
    background: var(--hvac-theme-text);
}

/* Loading State */
.hvac-loading {
    opacity: 0.6;
    pointer-events: none;
}

.hvac-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: hvac-spin 1s linear infinite;
    display: inline-block;
    margin-right: var(--hvac-spacing-2);
}

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

/* Messages */
.hvac-template-message {
    padding: var(--hvac-spacing-3) var(--hvac-spacing-4);
    border-radius: var(--hvac-radius-md);
    margin-bottom: var(--hvac-spacing-4);
    font-size: var(--hvac-font-size-sm);
    font-weight: var(--hvac-font-weight-medium);
    display: flex;
    align-items: center;
    gap: var(--hvac-spacing-2);
}

.hvac-template-message.success {
    background: var(--hvac-success-light);
    color: var(--hvac-success-dark);
    border: 1px solid var(--hvac-success);
}

.hvac-template-message.success::before {
    content: '✓';
    font-weight: bold;
}

.hvac-template-message.error {
    background: var(--hvac-error-light);
    color: var(--hvac-error-dark);
    border: 1px solid var(--hvac-error);
}

.hvac-template-message.error::before {
    content: '⚠';
    font-weight: bold;
}

/* Empty State */
.hvac-template-empty {
    text-align: center;
    padding: var(--hvac-spacing-8);
    color: var(--hvac-theme-text-light);
}

.hvac-template-empty-icon {
    font-size: 3rem;
    margin-bottom: var(--hvac-spacing-4);
    opacity: 0.5;
}

.hvac-template-empty h4 {
    font-size: var(--hvac-font-size-lg);
    margin-bottom: var(--hvac-spacing-2);
    color: var(--hvac-theme-text);
}

.hvac-template-empty p {
    font-size: var(--hvac-font-size-md);
    line-height: 1.6;
}

/* Responsive Design */
@media (max-width: 768px) {
    .hvac-template-selector {
        flex-direction: column;
        align-items: stretch;
    }
    
    .hvac-template-dropdown,
    .hvac-template-category-filter {
        min-width: auto;
        width: 100%;
    }
    
    .hvac-template-actions-buttons {
        flex-wrap: wrap;
        gap: var(--hvac-spacing-2);
    }
    
    .hvac-template-actions-buttons button {
        flex: 1;
        min-width: auto;
    }
    
    .hvac-placeholder-grid {
        grid-template-columns: 1fr;
    }
    
    .hvac-template-form-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .hvac-template-form-actions button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .hvac-template-manager {
        padding: var(--hvac-spacing-4);
    }
    
    .hvac-template-form {
        padding: var(--hvac-spacing-4);
    }
    
    .hvac-template-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .hvac-template-toggle {
        width: 100%;
        justify-content: center;
    }
}

/* Integration with Email Form */
.hvac-email-form .hvac-template-manager {
    margin-bottom: var(--hvac-spacing-6);
    border: 2px solid var(--hvac-primary-light);
}

.hvac-email-form .hvac-template-manager h3 {
    color: var(--hvac-primary);
}

/* WordPress Editor Integration */
.hvac-template-content-wp-editor {
    border: 2px solid var(--hvac-border);
    border-radius: var(--hvac-radius-md);
    overflow: hidden;
}

.hvac-template-content-wp-editor iframe {
    border: none;
    width: 100%;
    min-height: 200px;
}

/* Accessibility Improvements */
.hvac-template-manager button:focus,
.hvac-template-manager select:focus,
.hvac-template-manager input:focus {
    outline: 2px solid var(--hvac-primary);
    outline-offset: 2px;
}

.hvac-template-manager [aria-disabled="true"] {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Print Styles */


/* 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;
}

@media print {
    .hvac-template-manager {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .hvac-template-actions,
    .hvac-template-form-actions {
        display: none;
    }
}