/* Modern Loading Screen Styles */

:root {
    --localloop-primary: #E6E6FA;
    --localloop-secondary: #3CB371;
    --localloop-tertiary: #B19CD9;
    --localloop-danger: #FF6B6B;
    --localloop-success: #98FB98;
    --localloop-info: #87CEEB;
    --localloop-warning: #FFD93D;
    --localloop-light-bg: #F0FFF0;
    --localloop-dark-bg: #1B5E3D;
    --localloop-card-bg: #ffffff;
    --localloop-text-primary: #E6E6FA;
    --localloop-text-secondary: #D8BFD8;
    --localloop-border: #3CB371;
}

/* Loading Page Container */
#blazor-loading-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(360deg, #2e8b57, rgba(179, 69, 0, 0.82) 0%, rgb(66, 118, 125) 100%, #7c3aed 100%, #1b5e3d);
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    z-index: 9999;
    overflow: hidden;
}

/* Animated background particles */
#blazor-loading-page::before {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: drift 20s linear infinite;
    top: -50%;
    left: -50%;
}

#blazor-loading-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 80px 80px;
    animation: drift 30s linear infinite reverse;
    bottom: -50%;
    right: -50%;
}

@keyframes drift {
    0% {
        transform: translate(0, 0);
    }
    100% {
        transform: translate(50px, 50px);
    }
}

/* Loading container */
.loading-container {
    position: relative;
    z-index: 10;
    text-align: center;
    background: Transparent;
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 60px 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25),
                0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    max-width: 450px;
    width: 90%;
    animation: scaleIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* Logo section */
.loading-logo {
    margin-bottom: 30px;
    animation: fadeInDown 0.8s ease-out;
}

.loading-logo img {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Title */
.loading-title {
    font-size: 28px;
    font-weight: 700;
    color: #E6E6FA;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
    animation: fadeInUp 0.8s ease-out 0.1s both;
}

/* Subtitle */
.loading-subtitle {
    font-size: 14px;
    color: #D8BFD8;
    margin-bottom: 40px;
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

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

/* Spinner styles */
.spinner-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 30px;
    animation: fadeInUp 0.8s ease-out 0.3s both;
}

/* Modern spinner animation */
.spinner {
    width: 50px;
    height: 50px;
    position: relative;
    margin: 0 auto;
}

.spinner::before,
.spinner::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-radius: 50%;
}

.spinner::before {
    border-top: 3px solid #E6E6FA;
    border-right: 3px solid #E6E6FA;
    animation: spin 1s linear infinite;
}

.spinner::after {
    border-bottom: 3px solid #3CB371;
    border-left: 3px solid #3CB371;
    animation: spin 1.5s linear infinite reverse;
}

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

/* Status indicator */
.loading-status {
    font-size: 13px;
    color: #D8BFD8;
    margin-top: 20px;
    letter-spacing: 0.5px;
    font-weight: 500;
    animation: fadeInUp 0.8s ease-out 0.4s both;
}

/* Dot animation for status */
.dot {
    display: inline-block;
    margin-left: 2px;
    animation: dots 1.4s infinite;
}

.dot:nth-child(2) {
    animation-delay: 0.2s;
}

.dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dots {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-10px);
    }
}

/* Additional info */
.loading-info {
    display: flex;
    justify-content: space-around;
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid rgba(230,230,250,0.2);
    animation: fadeInUp 0.8s ease-out 0.5s both;
}

.info-item {
    text-align: center;
    flex: 1;
}

.info-icon {
    font-size: 20px;
    margin-bottom: 8px;
}

.info-label {
    font-size: 12px;
    color: #D8BFD8;
    font-weight: 500;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .loading-container {
        padding: 40px 20px;
        border-radius: 16px;
    }

    .loading-title {
        font-size: 24px;
    }

    .loading-subtitle {
        font-size: 13px;
        margin-bottom: 30px;
    }

    .loading-info {
        flex-direction: column;
        gap: 15px;
    }

    .info-item {
        border-bottom: 1px solid rgba(230,230,250,0.2);
        padding-bottom: 15px;
    }

    .info-item:last-child {
        border-bottom: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .loading-container {
        background: rgba(27, 94, 61, 0.95);
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75),
                    0 0 0 1px rgba(230, 230, 250, 0.05) inset;
    }

    .loading-title {
        color: #E6E6FA;
    }

    .loading-subtitle,
    .loading-status,
    .info-label {
        color: #D8BFD8;
    }

    .loading-info {
        border-top-color: rgba(230,230,250,0.15);
    }

    .info-item {
        border-bottom-color: rgba(230,230,250,0.15);
    }
}

/* Error state */
.loading-error {
    background: rgba(239, 68, 68, 0.1);
    border-left: 4px solid #ef4444;
    padding: 12px 16px;
    border-radius: 8px;
    margin-top: 20px;
    animation: slideInLeft 0.4s ease-out;
}

.loading-error-title {
    font-size: 14px;
    font-weight: 600;
    color: #dc2626;
    margin-bottom: 4px;
}

.loading-error-message {
    font-size: 13px;
    color: #991b1b;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Retry button */
.loading-retry-btn {
    background: linear-gradient(135deg, #2E8B57 0%, #1B5E3D 100%);
    color: #E6E6FA;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(46, 139, 87, 0.4);
}

.loading-retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(46, 139, 87, 0.6);
}

.loading-retry-btn:active {
    transform: translateY(0);
}

/* Connection indicator */
.connection-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #3CB371;
    font-weight: 500;
}

.connection-dot {
    width: 8px;
    height: 8px;
    background: #3CB371;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

/* Hidden state */
.loading-hidden {
    display: none !important;
}

/* ─── Session Loading Overlay (shown while Supabase session / role is being verified) ─── */
.session-loading-overlay {
    display: flex;
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1B5E3D 0%, #2E8B57 60%, #7C3AED 100%);
    justify-content: center;
    align-items: center;
    z-index: 9998;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

/* ─── Blazor Reconnect Modal ─── */
#components-reconnect-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1B5E3D 0%, #2E8B57 60%, #7C3AED 100%);
    justify-content: center;
    align-items: center;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: flex;
}

.reconnect-card {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 48px 40px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.reconnect-logo {
    width: 250px;
    height: auto;
    margin: 0 auto 32px;
    display: block;
    animation: fadeInScale 0.5s ease-out;
}

.reconnect-spinner-wrap {
    width: 48px;
    height: 48px;
    margin: 0 auto 24px;
}

#components-reconnect-modal.components-reconnect-failed .reconnect-spinner-wrap,
#components-reconnect-modal.components-reconnect-rejected .reconnect-spinner-wrap {
    display: none;
}

.reconnect-icon-error {
    display: none;
    width: 48px;
    height: 48px;
    margin: 0 auto 24px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    font-weight: 700;
}

#components-reconnect-modal.components-reconnect-failed .reconnect-icon-error,
#components-reconnect-modal.components-reconnect-rejected .reconnect-icon-error {
    display: flex;
}

.reconnect-spinner {
    width: 100%;
    height: 100%;
    border: 3px solid rgba(124, 58, 237, 0.2);
    border-top-color: #7C3AED;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.reconnect-title {
    font-size: 22px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 8px;
}

.reconnect-subtitle {
    font-size: 14px;
    color: #6b7280;
    margin: 0 0 20px;
}

/* State-specific text: hidden by default, shown by parent class */
.rc-show-only, .rc-failed-only, .rc-rejected-only {
    display: none;
}

#components-reconnect-modal.components-reconnect-show .rc-show-only { display: inline; }
#components-reconnect-modal.components-reconnect-failed .rc-failed-only { display: inline; }
#components-reconnect-modal.components-reconnect-rejected .rc-rejected-only { display: inline; }

.reconnect-retry-btn {
    display: none;
    background: linear-gradient(135deg, #7C3AED 0%, #2E8B57 100%);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.4);
}

.reconnect-retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.5);
}

.reconnect-retry-btn:active {
    transform: translateY(0);
}

#components-reconnect-modal.components-reconnect-failed .reconnect-failed-btn,
#components-reconnect-modal.components-reconnect-rejected .reconnect-rejected-btn {
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}