@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');

/* Reset e Tema Global */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== PWA - Viewport e Status Bar ===== */
:root {
    --primary-color: #2B003A;
    --secondary-color: #D600AA;
    --safe-area-inset-top: env(safe-area-inset-top, 0px);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-inset-left: env(safe-area-inset-left, 0px);
    --safe-area-inset-right: env(safe-area-inset-right, 0px);
}

/* Garantir que o background roxo cubra toda a viewport incluindo status bar */
html {
    background-color: #2B003A;
    scroll-behavior: smooth;
    /* Crítico para iOS PWA - estender conteúdo atrás da status bar */
    height: 100%;
    width: 100%;
}

html, body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #2B003A;
    color: white;
    min-height: 100vh;
    min-height: -webkit-fill-available; /* iOS Safari */
    /* Garantir que o background roxo cubra a status bar */
    margin: 0;
    padding: 0;
}

/* Wrapper para conteúdo principal com gradiente */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #2B003A 0%, #1a0024 100%);
    z-index: -1;
    pointer-events: none;
}

/* Safe area para dispositivos com notch - aplicar ao conteúdo, não ao background */
#app, app, .app-content {
    /* Remover padding-top do app principal pois o header já tem safe-area */
    padding-top: 0;
    padding-bottom: var(--safe-area-inset-bottom);
    padding-left: 0;
    padding-right: 0;
}

/* Quando instalado como PWA standalone - iOS específico */
@media all and (display-mode: standalone) {
    html, body {
        /* Estender background roxo atrás da status bar */
        background-color: #2B003A;
    }
    
    body {
        /* Remover padding do body, aplicar apenas ao conteúdo */
        padding: 0;
    }
    
    /* Status bar overlay - garante que o topo seja roxo */
    body::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: max(var(--safe-area-inset-top), 44px); /* 44px = altura típica da status bar iOS */
        background-color: #2B003A;
        z-index: 9998;
        pointer-events: none;
    }
}

/* iOS Safari específico */
@supports (-webkit-touch-callout: none) {
    html {
        background-color: #2B003A;
        min-height: -webkit-fill-available;
    }
    
    body {
        background-color: #2B003A;
        min-height: -webkit-fill-available;
    }
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: #D600AA;
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover, .btn-link:hover {
    color: #ff00d4;
}

.btn-primary {
    color: #fff;
    background-color: #D600AA;
    border-color: #D600AA;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background-color: #ff00d4;
    border-color: #ff00d4;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(214, 0, 170, 0.4);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #D600AA;
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #ff00d4;
}

.validation-message {
    color: #ff00d4;
}

/* ===== BLAZOR RECONNECTION UI - PWA/SPA Experience ===== */
#components-reconnect-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(26, 0, 36, 0.95);
    backdrop-filter: blur(12px);
    animation: fadeIn 0.3s ease-out;
}

#components-reconnect-modal.components-reconnect-show {
    display: flex;
}

.components-reconnect-content {
    background: linear-gradient(145deg, rgba(43, 0, 58, 0.95) 0%, rgba(26, 0, 36, 0.98) 100%);
    border: 2px solid rgba(214, 0, 170, 0.4);
    border-radius: 24px;
    padding: 3rem 2.5rem;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Ícone de Status com Animação */
.reconnect-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    position: relative;
}

.reconnect-icon::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: linear-gradient(135deg, #D600AA, #ff00d4, #D600AA);
    background-size: 200% 200%;
    animation: gradientRotate 3s ease-in-out infinite;
    opacity: 0.6;
}

.reconnect-icon i {
    font-size: 2.8rem;
    z-index: 1;
    position: relative;
}

/* Estado: Tentando Reconectar */
#components-reconnect-modal .components-reconnect-show .reconnect-icon {
    background: rgba(214, 0, 170, 0.2);
}

#components-reconnect-modal .components-reconnect-show .reconnect-icon i {
    color: #D600AA;
    animation: spin 1.5s linear infinite;
}

/* Estado: Falhou */
#components-reconnect-modal.components-reconnect-failed .reconnect-icon {
    background: rgba(255, 107, 107, 0.2);
}

#components-reconnect-modal.components-reconnect-failed .reconnect-icon::before {
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f, #ff6b6b);
    background-size: 200% 200%;
}

#components-reconnect-modal.components-reconnect-failed .reconnect-icon i {
    color: #ff6b6b;
    animation: shake 0.5s ease-in-out;
}

/* Estado: Rejeitado */
#components-reconnect-modal.components-reconnect-rejected .reconnect-icon {
    background: rgba(255, 159, 67, 0.2);
}

#components-reconnect-modal.components-reconnect-rejected .reconnect-icon::before {
    background: linear-gradient(135deg, #ff9f43, #ee9c3f, #ff9f43);
    background-size: 200% 200%;
}

#components-reconnect-modal.components-reconnect-rejected .reconnect-icon i {
    color: #ff9f43;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

@keyframes gradientRotate {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

/* Textos */
.reconnect-title {
    color: white;
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0 0 0.75rem 0;
    letter-spacing: -0.5px;
}

.reconnect-message {
    color: rgba(255, 255, 255, 0.85);
    font-size: 1rem;
    line-height: 1.6;
    margin: 0 0 2rem 0;
}

/* Botão de Recarregar */
.reconnect-reload {
    background: linear-gradient(135deg, #D600AA 0%, #ff00d4 100%);
    color: white;
    border: none;
    padding: 1rem 2.5rem;
    border-radius: 16px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(214, 0, 170, 0.4);
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

.reconnect-reload:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(214, 0, 170, 0.6);
}

.reconnect-reload:active {
    transform: translateY(-1px);
}

.reconnect-reload i {
    font-size: 1.1rem;
}

/* Loading Spinner */
.reconnect-spinner {
    margin: 2rem auto 0 auto;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(214, 0, 170, 0.2);
    border-top-color: #D600AA;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Contador de Tentativas */
.reconnect-attempts {
    margin-top: 1.5rem;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.reconnect-attempts i {
    font-size: 0.9rem;
    color: #D600AA;
}

/* Progress Bar */
.reconnect-progress {
    margin-top: 1.5rem;
    height: 6px;
    background: rgba(214, 0, 170, 0.2);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.reconnect-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #D600AA, #ff00d4);
    border-radius: 10px;
    animation: progressPulse 1.5s ease-in-out infinite;
    width: 0%;
    transition: width 0.3s ease;
}

@keyframes progressPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* Mensagens Específicas por Estado */
#components-reconnect-modal h5 {
    display: none;
}

#components-reconnect-modal.components-reconnect-show h5:first-of-type {
    display: block;
}

#components-reconnect-modal.components-reconnect-failed h5:nth-of-type(2) {
    display: block;
}

#components-reconnect-modal.components-reconnect-rejected h5:nth-of-type(3) {
    display: block;
}

/* Responsividade Mobile */
@media (max-width: 480px) {
    .components-reconnect-content {
        padding: 2.5rem 2rem;
        border-radius: 20px;
    }

    .reconnect-icon {
        width: 70px;
        height: 70px;
        margin-bottom: 1.25rem;
    }

    .reconnect-icon i {
        font-size: 2.4rem;
    }

    .reconnect-title {
        font-size: 1.4rem;
    }

    .reconnect-message {
        font-size: 0.95rem;
        margin-bottom: 1.75rem;
    }

    .reconnect-reload {
        padding: 0.9rem 2rem;
        font-size: 0.95rem;
    }
}

/* Safe area para modal em PWA standalone */
@media all and (display-mode: standalone) {
    .components-reconnect-content {
        margin-top: var(--safe-area-inset-top, 0);
        margin-bottom: var(--safe-area-inset-bottom, 0);
    }
}

/* ===== PWA Offline Status ===== */
body.offline::before {
    content: "\26A0\FE0F Voce esta offline";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
    text-align: center;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 10000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    animation: slideDown 0.3s ease-out;
}

/* OLD ERROR UI - Mantido mas melhorado */
#blazor-error-ui {
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.95) 0%, rgba(238, 90, 111, 0.98) 100%);
    backdrop-filter: blur(10px);
    bottom: 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    display: none;
    left: 0;
    padding: 1rem 1.5rem;
    position: fixed;
    width: 100%;
    z-index: 10000;
    color: white;
    border-top: 2px solid rgba(255, 255, 255, 0.3);
    animation: slideInUp 0.3s ease-out;
}

@keyframes slideInUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

#blazor-error-ui::before {
    content: '\26A0\FE0F';
    font-size: 1.5rem;
    margin-right: 0.75rem;
}
