/**
 * Direito Stats Widget CSS
 * Version: 1.0.1 - EFEITOS HOVER CORRIGIDOS
 */

/* Container principal */
.direito-stats-container {
    position: relative;
    max-width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    box-sizing: border-box;
}

.direito-stats-container *,
.direito-stats-container *::before,
.direito-stats-container *::after {
    box-sizing: border-box;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: inherit;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #444;
    border-top: 3px solid #00c851;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay span {
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
}

/* Barra de Busca */
.search-bar {
    width: 100%;
    margin-bottom: 20px;
}

.search-bar input {
    width: 100%;
    border: 1px solid #444;
    outline: none;
    font-size: 14px;
    background-color: #2a2a2a;
    color: #ffffff;
    padding: 12px 20px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.search-bar input:focus {
    border-color: #00c851;
    box-shadow: 0 0 0 2px rgba(0, 200, 81, 0.2);
}

.search-bar input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

/* Botões de Filtro - ESTILOS BASE CORRIGIDOS */
.filter-buttons {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-buttons-left {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.filter-buttons-right {
    display: flex;
    align-items: center;
    margin-left: auto;
}

.filter-buttons button {
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid #444;
    position: relative;
    overflow: hidden;
}

/* ========================================
   BOTÕES DE PERÍODO - EFEITOS HOVER CORRIGIDOS
======================================== */

/* Estados padrão dos botões de período */
.filter-buttons button[data-period] {
    background-color: #2a2a2a;
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid #444;
}

.filter-buttons button[data-period]:not(.active):hover {
    background-color: #00c851;
    border-color: #00c851;
    color: #ffffff;
}

.filter-buttons button[data-period].active {
    background-color: #00c851;
    border-color: #00c851;
    color: #000000;
    font-weight: 600;
}

/* EFEITOS HOVER DOS BOTÕES DE PERÍODO - APLICAÇÃO VIA DATA-ATTRIBUTE */
.direito-stats-container[data-period-hover-effect="grow"] .filter-buttons button[data-period]:hover {
    transform: scale(1.05) !important;
}

.direito-stats-container[data-period-hover-effect="elevate"] .filter-buttons button[data-period]:hover {
    transform: translateY(-3px) !important;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3) !important;
}

.direito-stats-container[data-period-hover-effect="grow_elevate"] .filter-buttons button[data-period]:hover {
    transform: scale(1.05) translateY(-3px) !important;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3) !important;
}

/* ========================================
   BOTÃO RESET - EFEITOS HOVER CORRIGIDOS  
======================================== */

/* Estados padrão do botão reset */
.filter-buttons .reset-btn {
    background-color: #dc3545;
    border-color: #dc3545;
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-buttons .reset-btn:hover {
    background-color: #c82333;
    border-color: #c82333;
}

.filter-buttons .reset-btn:active {
    background-color: #bd2130;
    border-color: #bd2130;
}

/* EFEITOS HOVER DO BOTÃO RESET - APLICAÇÃO VIA DATA-ATTRIBUTE */
.direito-stats-container[data-reset-hover-effect="grow"] .filter-buttons .reset-btn:hover {
    transform: scale(1.05) !important;
}

.direito-stats-container[data-reset-hover-effect="elevate"] .filter-buttons .reset-btn:hover {
    transform: translateY(-3px) !important;
    box-shadow: 0 5px 15px rgba(220, 53, 69, 0.4) !important;
}

.direito-stats-container[data-reset-hover-effect="grow_elevate"] .filter-buttons .reset-btn:hover {
    transform: scale(1.05) translateY(-3px) !important;
    box-shadow: 0 5px 15px rgba(220, 53, 69, 0.4) !important;
}

/* Ícone do botão reset - VISIBILIDADE GARANTIDA */
.filter-buttons .reset-btn i,
.filter-buttons .reset-btn svg {
    width: 16px;
    height: 16px;
    color: #ffffff !important;
    fill: #ffffff !important;
    display: inline-block !important;
    margin-right: 8px !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.filter-buttons .reset-btn svg path {
    fill: currentColor !important;
}

/* Mini Grifo - POSICIONAMENTO CORRIGIDO DEFINITIVAMENTE */
.mini-grifo-container {
    margin-top: -25px !important;
    margin-bottom: 20px;
}

/* Quando há título, aproximar ainda mais o grifo */
.title-container + .mini-grifo-container {
    margin-top: -20px !important;
}

/* Forçar proximidade máxima */
.widget-title + .mini-grifo-container .mini-grifo,
.title-container + .mini-grifo-container .mini-grifo {
    margin-top: -5px !important;
}

.mini-grifo {
    height: 3px;
    background-color: #00c851;
    width: 50px;
}

/* Reduzir ainda mais o espaçamento do título */
.title-container {
    margin-bottom: 5px !important;
}

.widget-title {
    margin-bottom: 0px !important;
    line-height: 1.2 !important;
}

/* ========================================
   CARDS DE ESTATÍSTICAS - EFEITOS HOVER CORRIGIDOS
======================================== */

/* Layout principal dos cards */
.stats-cards {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.stats-card {
    position: relative;
    transition: all 0.3s ease;
    overflow: hidden;
    background-color: #2a2a2a;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 25px;
    width: 100%;
    min-height: 120px;
}

/* EFEITOS HOVER DOS CARDS - APLICAÇÃO VIA DATA-ATTRIBUTE */
.direito-stats-container[data-card-hover-effect="grow"] .stats-card:hover {
    transform: scale(1.02) !important;
}

.direito-stats-container[data-card-hover-effect="elevate"] .stats-card:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3) !important;
    transform: translateY(-2px) !important;
}

.direito-stats-container[data-card-hover-effect="both"] .stats-card:hover {
    transform: scale(1.02) translateY(-2px) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3) !important;
}

/* FALLBACK - Efeitos via classes CSS diretas (caso o PHP não defina data-attributes) */
.stats-card.card-hover-grow:hover {
    transform: scale(1.02) !important;
}

.stats-card.card-hover-elevate:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3) !important;
    transform: translateY(-2px) !important;
}

.stats-card.card-hover-grow.card-hover-elevate:hover {
    transform: scale(1.02) translateY(-2px) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3) !important;
}

.stats-card h3 {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.4;
}

/* Barra de Progresso - MELHORADA */
.progress-bar {
    width: 100%;
    background-color: #444;
    margin: 15px 0 20px 0;
    overflow: hidden;
    position: relative;
    height: 12px;
    border-radius: 6px;
}

.progress-fill {
    width: 0%;
    height: 100%;
    transition: width 0.8s ease;
    position: relative;
    border-radius: 6px;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, 
        rgba(255,255,255,0.1) 25%, 
        transparent 25%, 
        transparent 50%, 
        rgba(255,255,255,0.1) 50%, 
        rgba(255,255,255,0.1) 75%, 
        transparent 75%, 
        transparent);
    background-size: 20px 20px;
    animation: progressStripes 2s linear infinite;
}

/* Desativar listras quando configurado */
.progress-fill.no-stripes::after {
    display: none;
}

@keyframes progressStripes {
    0% { background-position: 0 0; }
    100% { background-position: 20px 0; }
}

/* Informações das Estatísticas - LAYOUT MELHORADO */
.stats-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    flex-wrap: wrap;
    gap: 15px;
}

.stats-info span {
    color: #cccccc;
    font-weight: 500;
}

.stats-info .percentage {
    font-weight: bold;
    font-size: 20px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    margin-left: auto;
}

/* Layout responsivo para informações */
.stats-info .total,
.stats-info .corretas {
    flex: 0 0 auto;
}

/* Legenda */
.legend {
    margin-top: 30px;
    padding: 20px;
    background-color: rgba(42, 42, 42, 0.5);
    border-radius: 8px;
    border: 1px solid #444;
}

.legend h4 {
    color: #ffffff;
    margin: 0 0 15px 0;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.3s ease;
}

.legend h4:hover {
    color: #00c851;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    transition: transform 0.2s ease;
}

.legend-item:hover {
    transform: translateX(5px);
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.legend-item span {
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
}

/* Estados de Card Vazios */
.stats-card[data-empty="true"] {
    opacity: 0.6;
    background-color: #1a1a1a;
}

.stats-card[data-empty="true"] .progress-fill {
    background-color: #666 !important;
}

.stats-card[data-empty="true"] .percentage {
    color: #666 !important;
}

/* Animações de Entrada */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stats-card {
    animation: fadeInUp 0.6s ease-out;
}

.stats-card:nth-child(2) {
    animation-delay: 0.1s;
}

.stats-card:nth-child(3) {
    animation-delay: 0.2s;
}

.stats-card:nth-child(4) {
    animation-delay: 0.3s;
}

.stats-card:nth-child(5) {
    animation-delay: 0.4s;
}

/* Estados de Filtro */
.stats-card.filtered-out {
    opacity: 0;
    transform: scale(0.95);
    height: 0;
    padding: 0;
    margin: 0;
    border: none;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Mensagens de Status */
.no-data-message {
    text-align: center;
    padding: 40px 20px;
    color: #cccccc;
    background: rgba(42, 42, 42, 0.3);
    border: 2px dashed #444;
    border-radius: 8px;
    margin: 20px 0;
}

.no-data-message p {
    margin: 0;
    font-size: 16px;
    line-height: 1.5;
}

.login-required-message {
    text-align: center;
    padding: 40px 20px;
    color: #ffbb33;
    background: rgba(255, 187, 51, 0.1);
    border: 2px solid rgba(255, 187, 51, 0.3);
    border-radius: 8px;
    margin: 20px 0;
}

.login-required-message p {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.5;
}

/* ========================================
   MENSAGENS DO WIDGET
======================================== */
.direito-stats-message {
    padding: 12px 20px;
    margin-bottom: 15px;
    border-radius: 6px;
    font-weight: 500;
    text-align: center;
    font-size: 14px;
    line-height: 1.4;
    animation: fadeInDown 0.3s ease-out;
}

.direito-stats-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.direito-stats-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   RESPONSIVIDADE
======================================== */
@media (max-width: 768px) {
    .direito-stats-container {
        padding: 15px;
    }
    
    .filter-buttons {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .filter-buttons-left {
        order: 1;
        justify-content: center;
    }
    
    .filter-buttons-right {
        order: 2;
        margin-left: 0;
        justify-content: center;
    }
    
    .filter-buttons button {
        width: auto;
        justify-content: center;
        margin: 0;
    }
    
    .stats-card {
        padding: 20px;
    }
    
    .stats-info {
        flex-direction: row;
        align-items: center;
        gap: 10px;
        justify-content: space-between;
    }
    
    .stats-info .percentage {
        font-size: 18px;
        margin-left: auto;
    }
    
    .stats-card h3 {
        font-size: 16px;
    }
    
    .legend-items {
        gap: 8px;
    }
    
    .legend-item {
        gap: 10px;
    }
    
    .mini-grifo-container {
        margin-top: -20px !important;
    }
    
    .title-container + .mini-grifo-container {
        margin-top: -15px !important;
    }
}

@media (max-width: 480px) {
    .direito-stats-container {
        padding: 10px;
    }
    
    .search-bar input {
        font-size: 16px; /* Evita zoom no iOS */
        padding: 14px 16px;
    }
    
    .filter-buttons button {
        font-size: 13px;
        padding: 10px 14px;
    }
    
    .stats-card {
        padding: 18px;
        min-height: 100px;
    }
    
    .stats-card h3 {
        font-size: 15px;
        margin-bottom: 15px;
    }
    
    .stats-info {
        font-size: 14px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .stats-info .percentage {
        font-size: 18px;
        align-self: flex-end;
        margin-left: 0;
    }
    
    .progress-bar {
        height: 10px;
        margin: 12px 0 15px 0;
    }
    
    .progress-fill {
        height: 10px;
    }
    
    .legend {
        padding: 15px;
        margin-top: 20px;
    }
    
    .legend h4 {
        font-size: 14px;
    }
    
    .legend-item span {
        font-size: 13px;
    }
    
    .legend-color {
        width: 16px;
        height: 16px;
    }
    
    .mini-grifo-container {
        margin-top: -18px !important;
    }
    
    .title-container + .mini-grifo-container {
        margin-top: -15px !important;
    }
    
    .widget-title {
        margin-bottom: 0px !important;
        line-height: 1.1 !important;
    }
}

/* ========================================
   MODO ALTO CONTRASTE E PREFERÊNCIAS DE USUÁRIO
======================================== */
@media (prefers-contrast: high) {
    .stats-card {
        border-width: 2px;
    }
    
    .filter-buttons button {
        border-width: 2px;
    }
    
    .search-bar input {
        border-width: 2px;
    }
    
    .progress-fill::after {
        display: none;
    }
}

/* Animações Reduzidas */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .loading-spinner {
        animation: none;
        border: 3px solid #00c851;
        border-top-color: #444;
    }
}

/* Tema Claro (opcional) */
@media (prefers-color-scheme: light) {
    .direito-stats-container[data-theme="auto"] {
        background-color: #f8f9fa;
    }
    
    .direito-stats-container[data-theme="auto"] .search-bar input {
        background-color: #ffffff;
        color: #212529;
        border-color: #dee2e6;
    }
    
    .direito-stats-container[data-theme="auto"] .filter-buttons button {
        background-color: #ffffff;
        color: #212529;
        border-color: #dee2e6;
    }
    
    .direito-stats-container[data-theme="auto"] .stats-card {
        background-color: #ffffff;
        border-color: #dee2e6;
    }
    
    .direito-stats-container[data-theme="auto"] .stats-card h3 {
        color: #212529;
    }
    
    .direito-stats-container[data-theme="auto"] .stats-info span:not(.percentage) {
        color: #6c757d;
    }
    
    .direito-stats-container[data-theme="auto"] .progress-bar {
        background-color: #e9ecef;
    }
    
    .direito-stats-container[data-theme="auto"] .legend {
        background-color: rgba(248, 249, 250, 0.8);
        border-color: #dee2e6;
    }
    
    .direito-stats-container[data-theme="auto"] .legend h4,
    .direito-stats-container[data-theme="auto"] .legend-item span {
        color: #212529;
    }
}

/* Print Styles */
@media print {
    .direito-stats-container {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
    }
    
    .filter-buttons,
    .loading-overlay {
        display: none !important;
    }
    
    .stats-card {
        break-inside: avoid;
        background: white !important;
        border: 1px solid #000 !important;
        color: black !important;
    }
    
    .stats-card h3,
    .stats-info span,
    .legend h4,
    .legend-item span {
        color: black !important;
    }
    
    .progress-fill::after {
        display: none;
    }
}