/**
 * TeleWorld UI Components
 * 
 * Loading states, notifications, and interactive components
 * Based on Design Review Report recommendations
 */

/* ===== LOADING OVERLAY ===== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: var(--z-index-modal, 99999);
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

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

.loading-spinner {
    width: 56px;
    height: 56px;
    border: 4px solid rgba(139, 92, 246, 0.2);
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay p {
    color: #e2e8f0;
    margin-top: 1.5rem;
    font-size: 1.125rem;
    font-weight: 500;
    animation: pulse 1.5s ease-in-out infinite;
}

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

/* Small loading spinner for buttons */
.loading-spinner-sm {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ===== BUTTON LOADING STATES ===== */

.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
    cursor: not-allowed;
}

.btn-loading .btn-text {
    opacity: 0;
}

.btn-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ===== SUCCESS NOTIFICATIONS ===== */

.success-notification {
    position: fixed;
    top: 120px;
    right: 2rem;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: var(--z-index-notification, 99999);
    max-width: 400px;
}

.success-notification.show {
    transform: translateX(0);
    opacity: 1;
}

.success-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    font-weight: bold;
    font-size: 1.125rem;
    flex-shrink: 0;
}

.success-message {
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.4;
}

/* ===== ERROR NOTIFICATIONS ===== */

.error-notification {
    position: fixed;
    top: 120px;
    right: 2rem;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    padding: 1.25rem 1.5rem;
    border-radius: 12px;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: var(--z-index-notification, 99999);
    max-width: 420px;
}

.error-notification.show {
    transform: translateX(0);
    opacity: 1;
}

.error-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    font-size: 1.125rem;
    flex-shrink: 0;
}

.error-notification strong {
    font-size: 1rem;
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
}

.error-notification p {
    font-size: 0.875rem;
    margin: 0;
    line-height: 1.4;
    opacity: 0.95;
}

/* ===== INFO NOTIFICATIONS ===== */

.info-notification {
    position: fixed;
    top: 120px;
    right: 2rem;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 10px 30px rgba(59, 130, 246, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: var(--z-index-notification, 99999);
    max-width: 400px;
}

.info-notification.show {
    transform: translateX(0);
    opacity: 1;
}

/* ===== FORM VALIDATION STATES ===== */

.form-row.error input,
.form-row.error select,
.form-row.error textarea {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
}

.form-row.success input,
.form-row.success select,
.form-row.success textarea {
    border-color: #10b981 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2) !important;
}

.validation-message {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.validation-message.error {
    color: #ef4444;
}

.validation-message.success {
    color: #10b981;
}

.validation-message.warning {
    color: #f59e0b;
}

/* ===== TRUST BADGES ===== */

.trust-badges {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin-top: 2rem;
    padding: 1.5rem;
    background: rgba(30, 41, 59, 0.5);
    border-radius: 12px;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.trust-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #94a3b8;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.3s ease;
}

.trust-badge:hover {
    color: #e2e8f0;
}

.trust-badge-icon {
    font-size: 1.25rem;
    opacity: 0.9;
}

/* ===== SKELETON LOADERS ===== */

.skeleton {
    background: linear-gradient(
        90deg,
        rgba(30, 41, 59, 0.3) 25%,
        rgba(139, 92, 246, 0.1) 50%,
        rgba(30, 41, 59, 0.3) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
    border-radius: 8px;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-text:last-child {
    width: 70%;
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.skeleton-image {
    width: 100%;
    aspect-ratio: 1 / 1;
}

.skeleton-button {
    height: 44px;
    width: 120px;
}

/* ===== PROGRESS BARS ===== */

.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(30, 41, 59, 0.5);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #8b5cf6 0%, #a855f7 100%);
    border-radius: 9999px;
    transition: width 0.3s ease;
}

.progress-bar-animated .progress-bar-fill {
    background-size: 200% 100%;
    animation: progressShimmer 2s infinite;
}

@keyframes progressShimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ===== TOOLTIPS ===== */

.tooltip {
    position: absolute;
    background: rgba(15, 23, 42, 0.95);
    color: #e2e8f0;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    white-space: nowrap;
    z-index: var(--z-index-tooltip, 10000);
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s, transform 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tooltip.show {
    opacity: 1;
    transform: translateY(0);
}

.tooltip-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
}

.tooltip-arrow-top {
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 0 4px 4px 4px;
    border-color: transparent transparent rgba(15, 23, 42, 0.95) transparent;
}

/* ===== FOCUS INDICATORS ===== */

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid #8b5cf6;
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(139, 92, 246, 0.2);
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */

@media (max-width: 768px) {
    .success-notification,
    .error-notification,
    .info-notification {
        right: 1rem;
        left: 1rem;
        max-width: none;
        transform: translateY(-100px);
    }
    
    .success-notification.show,
    .error-notification.show,
    .info-notification.show {
        transform: translateY(0);
    }
    
    .trust-badges {
        flex-direction: column;
        gap: 1rem;
    }
}

/* ===== DARK MODE OVERLAY ===== */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: var(--z-index-modal-backdrop, 1040);
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

/* ===== ENHANCED BUTTON STATES ===== */

.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

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

/* ===== ANIMATED CHECKMARK ===== */

.checkmark {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #10b981;
    position: relative;
}

.checkmark::after {
    content: "";
    position: absolute;
    left: 8px;
    top: 4px;
    width: 6px;
    height: 12px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    animation: checkmarkDraw 0.3s ease forwards;
}

@keyframes checkmarkDraw {
    0% {
        height: 0;
    }
    100% {
        height: 12px;
    }
}

