/**
 * AJAX Loading and Message Styles - Executive Professional Design
 * File: assets/css/ajax.css
 */

/* ==========================================================================
   AJAX LOADING INDICATORS - EXECUTIVE STYLE
   ========================================================================== */

.ajax-loading {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--primary-charcoal);
    color: white;
    padding: 12px 20px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    box-shadow: var(--shadow-medium);
}

.ajax-loading.active {
    opacity: 1;
    transform: translateY(0);
}

.ajax-loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 8px;
    border: 2px solid transparent;
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ==========================================================================
   AJAX MESSAGES - EXECUTIVE PROFESSIONAL
   ========================================================================== */

.ajax-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(44, 62, 80, 0.15);
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 500px;
    width: calc(100vw - 40px);
}

.ajax-message.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.message-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    gap: 15px;
}

.message-text {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
}

.message-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-medium-gray);
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.message-close:hover {
    background: rgba(44, 62, 80, 0.1);
    color: var(--text-charcoal);
}

/* ==========================================================================
   MESSAGE TYPES - EXECUTIVE COLORS
   ========================================================================== */

.ajax-message-success {
    border-left: 4px solid #2e7d32;
}

.ajax-message-success .message-text {
    color: #1b5e20;
}

.ajax-message-error {
    border-left: 4px solid #c62828;
}

.ajax-message-error .message-text {
    color: #b71c1c;
}

.ajax-message-info {
    border-left: 4px solid var(--accent-navy);
}

.ajax-message-info .message-text {
    color: var(--primary-charcoal-dark);
}

.ajax-message-warning {
    border-left: 4px solid var(--secondary-steel);
}

.ajax-message-warning .message-text {
    color: var(--secondary-steel-dark);
}

/* ==========================================================================
   BUTTON LOADING STATES - EXECUTIVE STYLE
   ========================================================================== */

.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.btn-primary.loading::after {
    border-top-color: white;
}

.btn-outline.loading::after {
    border-top-color: var(--accent-navy);
}

/* ==========================================================================
   FORM LOADING STATES - EXECUTIVE STYLE
   ========================================================================== */

.form-loading {
    position: relative;
    pointer-events: none;
}

.form-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
    border-radius: inherit;
}

.form-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid var(--border-light);
    border-top-color: var(--accent-navy);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 11;
}

/* ==========================================================================
   AJAX ERROR STATES - EXECUTIVE STYLE
   ========================================================================== */

.ajax-error {
    border-color: #c62828 !important;
    background-color: rgba(198, 40, 40, 0.05);
}

.ajax-error-message {
    color: #b71c1c;
    font-size: 12px;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ajax-error-message::before {
    content: '⚠ ';
    font-size: 14px;
}

/* ==========================================================================
   UPLOAD PROGRESS - EXECUTIVE STYLE
   ========================================================================== */

.upload-progress {
    background: var(--border-light);
    border-radius: 4px;
    height: 8px;
    overflow: hidden;
    margin: 10px 0;
}

.upload-progress-bar {
    background: var(--accent-navy);
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.upload-status {
    font-size: 12px;
    color: var(--text-medium-gray);
    margin-top: 5px;
}

/* ==========================================================================
   PAGINATION LOADING - EXECUTIVE STYLE
   ========================================================================== */

.pagination-loading {
    text-align: center;
    padding: 40px 0;
}

.pagination-loading::after {
    content: '';
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-light);
    border-top-color: var(--accent-navy);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ==========================================================================
   SEARCH LOADING - EXECUTIVE STYLE
   ========================================================================== */

.search-loading {
    position: relative;
}

.search-loading::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border: 2px solid var(--border-light);
    border-top-color: var(--accent-navy);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ==========================================================================
   EXECUTIVE DARK MODE AJAX STYLES
   ========================================================================== */

[data-theme="dark"] .ajax-message {
    background: rgba(0, 0, 0, 0.9);
    color: var(--text-charcoal);
}

[data-theme="dark"] .form-loading::before {
    background: rgba(0, 0, 0, 0.8);
}

[data-theme="dark"] .ajax-error {
    background-color: rgba(198, 40, 40, 0.1);
}

/* ==========================================================================
   MOBILE RESPONSIVE AJAX STYLES
   ========================================================================== */

@media (max-width: 768px) {
    .ajax-loading {
        top: 10px;
        right: 10px;
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .ajax-message {
        top: 10px;
        width: calc(100vw - 20px);
        left: 10px;
        transform: translateY(-20px);
        border-radius: 6px;
    }
    
    .ajax-message.active {
        transform: translateY(0);
    }
    
    .message-content {
        padding: 12px 15px;
        gap: 10px;
    }
    
    .message-text {
        font-size: 13px;
    }
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */

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

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

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

.ajax-message[role="alert"] {
    /* Screen readers will announce this automatically */
}

@media (prefers-reduced-motion: reduce) {
    .ajax-loading,
    .ajax-message,
    .btn.loading::after,
    .form-loading::after,
    .upload-progress-bar {
        animation: none !important;
        transition: none !important;
    }
    
    .ajax-loading.active,
    .ajax-message.active {
        transform: none !important;
    }
}

/* ==========================================================================
   HIGH CONTRAST MODE
   ========================================================================== */

@media (prefers-contrast: high) {
    .ajax-message {
        border: 2px solid;
        box-shadow: none;
    }
    
    .ajax-loading {
        border: 1px solid white;
    }
}