/**
 * UI Polish CSS
 * Loading states, alignment fixes, and smooth transitions
 */

/* Global Loading Overlay */
.global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.loader-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

/* Spinner Animations */
.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

.spinner-small {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 0.5rem;
}

.spinner-inline {
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
    margin-right: 0.5rem;
    vertical-align: middle;
    opacity: 0.7;
}

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

/* Element Loading States */
.element-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: #666;
}

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

/* Message Containers */
.message-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    max-width: 400px;
}

/* Error Messages */
.error-message {
    background-color: #fff5f5;
    border: 1px solid #feb2b2;
    color: #c53030;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.3s ease-out;
}

.error-icon {
    font-size: 1.2rem;
    margin-right: 0.75rem;
}

.error-text {
    flex: 1;
    font-size: 0.95rem;
}

.error-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #c53030;
    cursor: pointer;
    padding: 0;
    margin-left: 0.5rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.error-close:hover {
    opacity: 1;
}

/* Success Messages */
.success-message {
    background-color: #f0fdf4;
    border: 1px solid #86efac;
    color: #16a34a;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.3s ease-out;
}

.success-icon {
    font-size: 1.2rem;
    margin-right: 0.75rem;
}

.success-text {
    flex: 1;
    font-size: 0.95rem;
}

.success-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #16a34a;
    cursor: pointer;
    padding: 0;
    margin-left: 0.5rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.success-close:hover {
    opacity: 1;
}

/* Animations */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

.fade-out {
    animation: fadeOut 0.3s ease-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6b7280;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-message {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #374151;
}

.empty-hint {
    font-size: 0.875rem;
    color: #9ca3af;
}

/* Alignment Fixes */

/* Fix dashboard metric cards alignment */
.metric-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.metric-label {
    font-size: 0.875rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Fix form alignment */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

/* Mobile Responsive Fixes */
@media (max-width: 768px) {
    /* Full width on mobile */
    body {
        padding: 0 !important;
    }
    
    .container, .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Stack form elements */
    .form-row {
        display: block;
    }
    
    .form-row > .col,
    .form-row > [class*="col-"] {
        padding-left: 0;
        padding-right: 0;
        margin-bottom: 1rem;
    }
    
    /* Message containers on mobile */
    .message-container {
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    /* Table responsive */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Button full width on mobile */
    .btn-block-mobile {
        display: block;
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* Touch-friendly elements */
button, .btn, input, select, textarea, a {
    min-height: 44px;
    min-width: 44px;
}

/* Smooth transitions */
* {
    transition: background-color 0.3s ease, 
                border-color 0.3s ease,
                box-shadow 0.3s ease;
}

/* Fix chart container heights */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Tooltips */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    white-space: nowrap;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.tooltip.show {
    opacity: 1;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

/* Button loading state */
.btn.loading {
    position: relative;
    color: transparent;
}

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

/* Fix System Stats text alignment */
#system-stats-content .stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e5e7eb;
}

#system-stats-content .stat-label {
    font-weight: 500;
    color: #374151;
}

#system-stats-content .stat-value {
    font-weight: 600;
    color: #1f2937;
}

/* Fix LLM Metrics alignment */
#llm-metrics-content .metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

/* Fix excessive spacing before job bank table */
#job-bank-content table {
    margin-top: 1rem !important;
}

/* Polish for tab navigation */
.nav-tabs {
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 1.5rem;
}

.nav-tabs .nav-link {
    border: none;
    border-bottom: 3px solid transparent;
    color: #6b7280;
    padding: 0.75rem 1.5rem;
    transition: all 0.2s;
}

.nav-tabs .nav-link:hover {
    color: #3b82f6;
    border-bottom-color: #dbeafe;
}

.nav-tabs .nav-link.active {
    color: #1e40af;
    border-bottom-color: #3b82f6;
    background: none;
}

/* Card hover effects */
.card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

/* Smooth page transitions */
.page-content {
    animation: pageLoad 0.3s ease-out;
}

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