/**
 * Auto-Refresh Control - Floating Widget
 * Portal do Contribuinte PGE/AM
 * Design sóbrio e discreto para controle de atualização automática
 */

/* ==========================================================================
   CONTAINER PRINCIPAL
   ========================================================================== */
.auto-refresh-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1040; /* Abaixo de modals (1050) e acima de conteúdo normal */
    pointer-events: none; /* Permite cliques através do container */
}

.auto-refresh-floating-control {
    pointer-events: auto; /* Habilita cliques no controle */
    position: relative;
}

/* ==========================================================================
   PILL - DESIGN MINIMALISTA
   ========================================================================== */
.auto-refresh-pill {
    background-color: #FFFFFF;
    border: 1px solid #E0E0E0;
    border-radius: 50px;
    padding: 8px 16px;
    box-shadow: 0 2px 8px rgba(0, 24, 48, 0.1);
    transition: all 0.3s ease;
    max-width: 220px;
}

.auto-refresh-pill:hover {
    box-shadow: 0 4px 12px rgba(0, 24, 48, 0.15);
    border-color: #3B6682;
}

/* ==========================================================================
   ÍCONE E LABEL
   ========================================================================== */
.auto-refresh-icon {
    color: #777777;
    font-size: 14px;
    transition: all 0.3s ease;
}

.auto-refresh-icon.spinning {
    animation: spin-smooth 2s linear infinite;
}

@keyframes spin-smooth {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.auto-refresh-label {
    font-size: 13px;
    color: #001830;
    font-weight: 500;
    min-width: 70px;
    text-align: center;
    user-select: none;
}

/* ==========================================================================
   SWITCH - DESIGN MINIMALISTA
   ========================================================================== */
.auto-refresh-switch {
    cursor: pointer;
    width: 36px;
    height: 20px;
    border: 1px solid #E0E0E0;
    background-color: #F5F5F5;
}

.auto-refresh-switch:checked {
    background-color: #3B6682;
    border-color: #3B6682;
}

.auto-refresh-switch:focus {
    box-shadow: 0 0 0 3px rgba(59, 102, 130, 0.15);
    border-color: #3B6682;
}

/* ==========================================================================
   BARRA DE PROGRESSO - MINIMALISTA
   ========================================================================== */
.auto-refresh-progress {
    height: 2px;
    background-color: #F5F5F5;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
    transition: opacity 0.3s ease;
}

.auto-refresh-progress-bar {
    height: 100%;
    background-color: #3B6682;
    transition: width 1s linear;
    border-radius: 2px;
}

/* ==========================================================================
   TOOLTIP - INFORMAÇÕES ADICIONAIS
   ========================================================================== */
.auto-refresh-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background-color: #001830;
    color: #FFFFFF;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 24, 48, 0.2);
}

.auto-refresh-tooltip::before {
    content: '';
    position: absolute;
    top: 100%;
    right: 20px;
    border: 5px solid transparent;
    border-top-color: #001830;
}

/* ==========================================================================
   ESTADOS HOVER E FOCUS
   ========================================================================== */
.auto-refresh-pill:hover .auto-refresh-icon {
    color: #3B6682;
}

/* ==========================================================================
   RESPONSIVIDADE
   ========================================================================== */
@media (max-width: 768px) {
    .auto-refresh-container {
        bottom: 10px;
        right: 10px;
    }

    .auto-refresh-pill {
        padding: 6px 12px;
        max-width: 180px;
    }

    .auto-refresh-label {
        font-size: 12px;
        min-width: 60px;
    }

    .auto-refresh-icon {
        font-size: 12px;
    }

    .auto-refresh-switch {
        width: 32px;
        height: 18px;
    }

    .auto-refresh-tooltip {
        font-size: 11px;
        padding: 6px 10px;
    }
}

@media (max-width: 480px) {
    .auto-refresh-pill {
        padding: 6px 10px;
        max-width: 150px;
    }

    .auto-refresh-label {
        display: none; /* Oculta o label em telas muito pequenas */
    }
}

/* ==========================================================================
   ACESSIBILIDADE
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    .auto-refresh-pill,
    .auto-refresh-icon,
    .auto-refresh-progress-bar,
    .auto-refresh-tooltip {
        transition: none;
    }

    .auto-refresh-icon.spinning {
        animation: none;
    }

    .auto-refresh-pill:hover {
        transform: none;
    }
}

/* Foco visível para navegação por teclado */
.auto-refresh-switch:focus-visible {
    outline: 2px solid #3B6682;
    outline-offset: 2px;
}

@media (prefers-contrast: high) {
    .auto-refresh-pill {
        border-width: 2px;
    }

    .auto-refresh-switch {
        border-width: 2px;
    }

    .auto-refresh-tooltip {
        border: 2px solid #FFFFFF;
    }
}

/* ==========================================================================
   ANIMAÇÃO DE ENTRADA
   ========================================================================== */
@keyframes slideInFromBottom {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auto-refresh-floating-control {
    animation: slideInFromBottom 0.4s ease-out;
}

/* ==========================================================================
   AJUSTE PARA SIDEBAR ABERTA
   ========================================================================== */
@media (min-width: 769px) {
    body.sidebar-expanded .auto-refresh-container {
        right: 20px; /* Mantém na mesma posição mesmo com sidebar aberta */
    }
}
