/**
 * OSE Tools - UI Component Styles
 * Toast, Loading, Auto-refresh, Error handling styles
 */

/* ========================================
   Toast Notifications
   ======================================== */

.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    transform: translateX(120%);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    opacity: 0;
    border-left: 4px solid #3b82f6;
    min-width: 300px;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    color: #1f2937;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
}

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

.toast-close:hover {
    background: #f3f4f6;
    color: #1f2937;
}

/* Toast Types */
.toast-success {
    border-left-color: #10b981;
    background: linear-gradient(to right, #ecfdf5, white);
}

.toast-error {
    border-left-color: #ef4444;
    background: linear-gradient(to right, #fef2f2, white);
}

.toast-warning {
    border-left-color: #f59e0b;
    background: linear-gradient(to right, #fffbeb, white);
}

.toast-info {
    border-left-color: #3b82f6;
    background: linear-gradient(to right, #eff6ff, white);
}

.toast-loading {
    border-left-color: #8b5cf6;
    background: linear-gradient(to right, #f5f3ff, white);
}

.toast-loading .toast-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}


/* ========================================
   Loading Overlay
   ======================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    background: white;
    padding: 40px 60px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    animation: fadeInScale 0.3s ease;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
    border: 4px solid #e5e7eb;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-text {
    color: #374151;
    font-size: 16px;
    font-weight: 600;
    margin-top: 10px;
}


/* ========================================
   Auto-Refresh Toggle
   ======================================== */

.auto-refresh-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    user-select: none;
}

.auto-refresh-toggle:hover {
    border-color: #667eea;
    background: #eff6ff;
}

.auto-refresh-toggle input[type="checkbox"] {
    width: 40px;
    height: 22px;
    position: relative;
    appearance: none;
    background: #d1d5db;
    border-radius: 11px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.auto-refresh-toggle input[type="checkbox"]:checked {
    background: #667eea;
}

.auto-refresh-toggle input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.auto-refresh-toggle input[type="checkbox"]:checked::before {
    transform: translateX(18px);
}


/* ========================================
   Error Details
   ======================================== */

.error-details {
    background: #fef2f2;
    border: 2px solid #fecaca;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.error-message {
    color: #991b1b;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
}

.error-technical {
    margin-top: 10px;
}

.error-technical summary {
    color: #7f1d1d;
    font-size: 14px;
    cursor: pointer;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    border: 1px solid #fecaca;
    transition: all 0.2s;
    user-select: none;
}

.error-technical summary:hover {
    background: #fee2e2;
}

.error-technical pre {
    margin-top: 10px;
    padding: 15px;
    background: white;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: #7f1d1d;
    font-size: 12px;
    overflow-x: auto;
    line-height: 1.6;
}


/* ========================================
   Status Indicators
   ======================================== */

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
}

.status-indicator::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

.status-online {
    background: #d1fae5;
    color: #065f46;
}

.status-online::before {
    background: #10b981;
}

.status-offline {
    background: #fee2e2;
    color: #991b1b;
}

.status-offline::before {
    background: #ef4444;
    animation: none;
}

.status-warning {
    background: #fef3c7;
    color: #92400e;
}

.status-warning::before {
    background: #f59e0b;
}

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


/* ========================================
   Enhanced Button States
   ======================================== */

.btn {
    position: relative;
    overflow: hidden;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.btn.loading {
    color: transparent;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}


/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 768px) {
    .toast-container {
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .toast {
        min-width: auto;
    }
    
    .loading-spinner {
        padding: 30px 40px;
    }
    
    .spinner {
        width: 50px;
        height: 50px;
    }
}


/* ========================================
   Copy to Clipboard Button
   ======================================== */

.copy-btn {
    padding: 6px 12px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 12px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

.copy-btn:active {
    transform: scale(0.95);
}


/* ========================================
   Refresh Indicator
   ======================================== */

.refresh-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    font-size: 13px;
    color: #166534;
    margin-left: 10px;
}

.refresh-indicator.refreshing {
    background: #fef3c7;
    border-color: #fde68a;
    color: #92400e;
}

.refresh-indicator .refresh-icon {
    font-size: 14px;
}

.refresh-indicator.refreshing .refresh-icon {
    animation: spin 1s linear infinite;
}


/* ========================================
   Smooth Transitions
   ======================================== */

* {
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

button, a, input, textarea, select {
    transition: all 0.2s ease;
}

