/* Loading Component Styles */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.show {
    opacity: 1;
    visibility: visible;
}

.loading-container {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 2rem;
    backdrop-filter: blur(12px) saturate(160%);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    text-align: center;
    min-width: 300px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 1rem;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid #06b6d4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    color: #e2e8f0;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 1rem;
}

.loading-progress {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #f97316, #dc2626);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
    animation: pulse 2s ease-in-out infinite;
}

.loading-subtext {
    color: #94a3b8;
    font-size: 14px;
    margin-top: 0.5rem;
}

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

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Inline loading for forms */
.form-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: #94a3b8;
    font-size: 14px;
    margin: 1rem 0;
}

.form-loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(148, 163, 184, 0.3);
    border-top: 2px solid #94a3b8;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* API Keys loading states */
.api-keys-loading {
    text-align: center;
    padding: 2rem;
    color: #94a3b8;
}

.api-keys-loading .loading-spinner {
    width: 32px;
    height: 32px;
    margin: 0 auto 1rem;
}

/* Stop job button */
.stop-btn {
    background: #6b7280;
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
    margin-left: 8px;
    vertical-align: middle;
}

.stop-btn:hover {
    background: #4b5563;
}

.stop-btn:active {
    background: #374151;
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.job-status-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Confirmation Modal */
.confirmation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.confirmation-overlay.show {
    opacity: 1;
    visibility: visible;
}

.confirmation-container {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 2rem;
    backdrop-filter: blur(12px) saturate(160%);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    text-align: center;
    min-width: 320px;
    max-width: 400px;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.confirmation-overlay.show .confirmation-container {
    transform: scale(1);
}

.confirmation-icon {
    font-size: 48px;
    margin-bottom: 1rem;
}

.confirmation-title {
    color: #e2e8f0;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.confirmation-message {
    color: #94a3b8;
    font-size: 16px;
    margin-bottom: 2rem;
    line-height: 1.5;
}

.confirmation-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirmation-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}

.cancel-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.cancel-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
}

.confirm-btn {
    background: linear-gradient(90deg, #dc2626, #b91c1c);
    color: white;
}

.confirm-btn:hover {
    background: linear-gradient(90deg, #b91c1c, #991b1b);
    transform: translateY(-1px);
}

/* Files Modal */
.files-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.files-overlay.show {
    opacity: 1;
    visibility: visible;
}

.files-container {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    backdrop-filter: blur(12px) saturate(160%);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.files-overlay.show .files-container {
    transform: scale(1);
}

.files-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.files-title {
    color: #e2e8f0;
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.files-close {
    color: #94a3b8;
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.files-close:hover {
    color: #e2e8f0;
}

.files-content {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.files-section {
    margin-bottom: 2rem;
}

.files-section:last-child {
    margin-bottom: 0;
}

.files-section h4 {
    color: #e2e8f0;
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.files-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: background-color 0.2s ease;
}

.file-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.file-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.file-path {
    color: #94a3b8;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    word-break: break-all;
    flex: 1;
}

.file-timestamp {
    color: #6b7280;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    margin-left: auto;
}

.files-loading {
    text-align: center;
    color: #94a3b8;
    padding: 2rem;
    font-style: italic;
}

.files-error {
    text-align: center;
    color: #f87171;
    padding: 2rem;
    font-style: italic;
}

.no-files {
    text-align: center;
    color: #6b7280;
    padding: 2rem;
    font-style: italic;
}

/* Enhanced Logs Modal */
.logs-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.log-type-toggle {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 4px;
}

.log-type-btn {
    padding: 6px 12px;
    background: transparent;
    border: none;
    color: #94a3b8;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.log-type-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

.logs-content {
    height: 400px;
    overflow-y: auto;
}

/* Job Card Metrics */
.metrics-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.metrics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.metrics-mobile-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #94a3b8;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.metrics-instances {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.instance-metrics-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.instance-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.instance-label {
    color: #e2e8f0;
    font-size: 12px;
    font-weight: 600;
}

.metrics-chart-container {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.metrics-chart {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    flex: 1;
    height: 60px;
    order: 2;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.metrics-values {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 0 0 120px;
    order: 1;
}

.metric-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.metric-label {
    color: #94a3b8;
    font-size: 11px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.metric-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.metric-value {
    color: #e2e8f0;
    font-size: 11px;
    font-weight: 600;
}

@media (max-width: 768px) {
    .metrics-mobile-btn {
        display: inline-block !important;
    }
    
    .metrics-instances {
        display: none;
    }
}

/* Mobile responsive */
@media (max-width: 480px) {
    .loading-container {
        margin: 0 20px;
        min-width: auto;
        padding: 1.5rem;
    }
    
    .loading-text {
        font-size: 14px;
    }
}