/* Dialog must stay hidden unless opened via showModal() */
dialog#components-reconnect-modal:not([open]) {
    display: none !important;
}

/* Hide all state-specific elements by default */
.components-reconnect-first-attempt-visible,
.components-reconnect-repeated-attempt-visible,
.components-reconnect-failed-visible,
.components-pause-visible,
.components-resume-failed-visible,
.reconnect-animation {
    display: none;
}

/* Show inner elements based on reconnect state classes */
#components-reconnect-modal.components-reconnect-show .components-reconnect-first-attempt-visible,
#components-reconnect-modal.components-reconnect-show .reconnect-animation,
#components-reconnect-modal.components-reconnect-paused .components-pause-visible,
#components-reconnect-modal.components-reconnect-resume-failed .components-resume-failed-visible,
#components-reconnect-modal.components-reconnect-retrying .components-reconnect-repeated-attempt-visible,
#components-reconnect-modal.components-reconnect-retrying .reconnect-animation,
#components-reconnect-modal.components-reconnect-failed .components-reconnect-failed-visible {
    display: block;
}

/* Dialog element styling */
#components-reconnect-modal {
    background-color: #fff;
    width: 22rem;
    margin: 20vh auto;
    padding: 2rem 2.5rem;
    border: 0;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    opacity: 0;
    font-family: 'Inter', sans-serif;
    transition: display 0.5s allow-discrete, overlay 0.5s allow-discrete;
    animation: reconnect-fadeOut 0.5s both;
}

#components-reconnect-modal[open] {
    animation: reconnect-slideUp 1.5s cubic-bezier(.05, .89, .25, 1.02) 0.3s,
               reconnect-fadeIn 0.5s ease-in-out 0.3s;
    animation-fill-mode: both;
}

#components-reconnect-modal::backdrop {
    background-color: rgba(0, 0, 0, 0.45);
    animation: reconnect-fadeIn 0.5s ease-in-out;
    opacity: 1;
}

/* Container layout */
.reconnect-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

#components-reconnect-modal p {
    margin: 0;
    text-align: center;
    color: var(--color-text-secondary, #475467);
    font-size: 14px;
    line-height: 1.5;
}

/* Buttons */
#components-reconnect-modal button {
    border: 0;
    background-color: var(--color-primary-500, #5776e0);
    color: #fff;
    padding: 8px 28px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

#components-reconnect-modal button:hover {
    background-color: var(--color-primary-600, #4562c7);
}

#components-reconnect-modal button:active {
    background-color: var(--color-primary-700, #3750b0);
}

/* Ripple animation */
.reconnect-animation {
    position: relative;
    width: 64px;
    height: 64px;
}

.reconnect-animation div {
    position: absolute;
    border: 3px solid var(--color-primary-500, #5776e0);
    opacity: 1;
    border-radius: 50%;
    animation: reconnect-ripple 1.5s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}

.reconnect-animation div:nth-child(2) {
    animation-delay: -0.5s;
}

/* Keyframes */
@keyframes reconnect-slideUp {
    0% { transform: translateY(30px) scale(0.95); }
    100% { transform: translateY(0); }
}

@keyframes reconnect-fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes reconnect-fadeOut {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes reconnect-ripple {
    0% {
        top: 32px;
        left: 32px;
        width: 0;
        height: 0;
        opacity: 0;
    }
    4.9% {
        top: 32px;
        left: 32px;
        width: 0;
        height: 0;
        opacity: 0;
    }
    5% {
        top: 32px;
        left: 32px;
        width: 0;
        height: 0;
        opacity: 1;
    }
    100% {
        top: 0;
        left: 0;
        width: 64px;
        height: 64px;
        opacity: 0;
    }
}
