/* ========================================
   ReconnectModal - Modern Mobile Native Style
   نظام جرد قطع الغيار - تسلا الخليج
   ======================================== */

/* Hide all state-specific content by default */
.components-reconnect-first-attempt-visible,
.components-reconnect-repeated-attempt-visible,
.components-reconnect-failed-visible,
.components-pause-visible,
.components-resume-failed-visible {
    display: none;
}

/* Show content based on state */
#components-reconnect-modal.components-reconnect-show .components-reconnect-first-attempt-visible,
#components-reconnect-modal.components-reconnect-retrying .components-reconnect-repeated-attempt-visible,
#components-reconnect-modal.components-reconnect-failed .components-reconnect-failed-visible,
#components-reconnect-modal.components-reconnect-paused .components-pause-visible,
#components-reconnect-modal.components-reconnect-resume-failed .components-resume-failed-visible {
    display: block;
}

/* Dialog Base */
#components-reconnect-modal {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    overflow: hidden;
    z-index: 999999;
}

#components-reconnect-modal::backdrop {
    background: transparent;
}

#components-reconnect-modal[open] {
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

/* Backdrop */
.reconnect-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    animation: reconnect-fadeIn 0.3s ease forwards;
}

/* Bottom Sheet */
.reconnect-sheet {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: linear-gradient(180deg, var(--color-white) 0%, var(--color-gray-50) 100%);
    border-radius: 24px 24px 0 0;
    padding: 12px 24px 32px;
    transform: translateY(100%);
    animation: reconnect-slideUp 0.4s cubic-bezier(0.32, 0.72, 0, 1) forwards;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
    text-align: center;
}

/* Handle */
.reconnect-handle {
    width: 36px;
    height: 4px;
    background: var(--color-gray-300);
    border-radius: 2px;
    margin: 0 auto 24px;
}

/* Icon Container */
.reconnect-icon {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reconnect-icon-circle {
    position: absolute;
    border: 3px solid var(--color-gray-200);
    border-radius: 50%;
    animation: reconnect-pulse 2s ease-in-out infinite;
}

.reconnect-icon-circle:nth-child(1) {
    width: 80px;
    height: 80px;
    animation-delay: 0s;
}

.reconnect-icon-circle:nth-child(2) {
    width: 56px;
    height: 56px;
    animation-delay: 0.2s;
}

.reconnect-icon-circle:nth-child(3) {
    width: 32px;
    height: 32px;
    animation-delay: 0.4s;
}

.reconnect-icon-signal {
    position: relative;
    width: 32px;
    height: 32px;
    color: var(--color-primary-600);
    animation: reconnect-signal 1.5s ease-in-out infinite;
}

/* Failed state icon */
#components-reconnect-modal.components-reconnect-failed .reconnect-icon-signal {
    color: var(--color-danger-500);
    animation: none;
}

#components-reconnect-modal.components-reconnect-failed .reconnect-icon-circle {
    border-color: rgba(239, 68, 68, 0.2);
    animation: none;
}

/* Title */
.reconnect-title {
    font-family: 'Tajawal', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-gray-800);
    margin: 0 0 8px;
}

/* Message */
.reconnect-message {
    font-family: 'Tajawal', sans-serif;
    font-size: 0.95rem;
    color: var(--color-gray-500);
    line-height: 1.6;
    margin: 0 0 20px;
}

/* Countdown */
.reconnect-countdown {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    background: var(--color-primary-600);
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: 14px;
    margin: 0 4px;
}

/* Primary Button */
.reconnect-btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    font-family: 'Tajawal', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--color-primary-600) 0%, var(--color-primary-700) 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
    margin-bottom: 12px;
}

.reconnect-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.reconnect-btn-primary:active {
    transform: translateY(0);
}

.reconnect-btn-primary svg {
    width: 18px;
    height: 18px;
}

/* Secondary Button */
.reconnect-btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 24px;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-gray-500);
    background: transparent;
    border: 1px solid var(--color-gray-200);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reconnect-btn-secondary:hover {
    background: var(--color-gray-100);
    color: var(--color-gray-700);
}

/* Status Indicator */
.reconnect-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
    padding: 10px 16px;
    background: rgba(37, 99, 235, 0.1);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: 8px;
}

.reconnect-status-dot {
    width: 8px;
    height: 8px;
    background: var(--color-primary-600);
    border-radius: 50%;
    animation: reconnect-blink 1.5s ease-in-out infinite;
}

.reconnect-status-text {
    font-family: 'Tajawal', sans-serif;
    font-size: 0.85rem;
    color: var(--color-primary-600);
}

/* Failed state status */
#components-reconnect-modal.components-reconnect-failed .reconnect-status {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}

#components-reconnect-modal.components-reconnect-failed .reconnect-status-dot {
    background: var(--color-danger-500);
    animation: none;
}

#components-reconnect-modal.components-reconnect-failed .reconnect-status-text {
    color: var(--color-danger-500);
}

/* Animations */
@keyframes reconnect-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes reconnect-slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes reconnect-pulse {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.05);
    }
}

@keyframes reconnect-signal {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.95);
    }
}

@keyframes reconnect-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Desktop Styles */
@media (min-width: 640px) {
    #components-reconnect-modal[open] {
        align-items: center;
    }
    
    .reconnect-sheet {
        border-radius: 20px;
        max-width: 380px;
        padding: 24px 32px 32px;
        animation: reconnect-scaleIn 0.3s cubic-bezier(0.32, 0.72, 0, 1) forwards;
    }
    
    .reconnect-handle {
        display: none;
    }
}

@keyframes reconnect-scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Safe area for iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .reconnect-sheet {
        padding-bottom: calc(32px + env(safe-area-inset-bottom));
    }
}
