/* ============================================
   SISTEMA DE ESTATÍSTICAS - STYLES
   ============================================ */

/* Statistics Management Container */
.estatisticas-management {
    padding: 2rem;
    background: transparent;
    min-height: 100vh;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.estatisticas-management.active {
    opacity: 1;
    transform: translateY(0);
}

/* Statistics Header */
.statistics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: transparent;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.statistics-header h3 {
    margin: 0;
    color: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.statistics-header i {
    color: var(--accent-color, #3b82f6);
}

.statistics-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.period-selector select,
.btn-refresh-stats {
    padding: 0.5rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.btn-refresh-stats {
    background: var(--accent-color, #3b82f6);
    color: white;
    border-color: var(--accent-color, #3b82f6);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-refresh-stats:hover {
    background: var(--accent-hover, #2563eb);
    transform: translateY(-1px);
}

/* Statistics Overview Cards */
.statistics-overview {
    margin-bottom: 2rem;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: transparent;
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--card-accent, #3b82f6), var(--card-accent-light, #60a5fa));
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.stat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
    background: var(--card-accent, #3b82f6);
    flex-shrink: 0;
}

.page-views-card .stat-icon { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.time-on-page-card .stat-icon { background: linear-gradient(135deg, #059669, #047857); }
.leads-card .stat-icon { background: linear-gradient(135deg, #dc2626, #b91c1c); }
.woocommerce-card .stat-icon { background: linear-gradient(135deg, #7c3aed, #5b21b6); }

.stat-info {
    flex: 1;
    margin-left: 1rem;
}

.stat-info h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    color: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.stat-number {
    display: block;
    font-size: 1.875rem;
    font-weight: 700;
    color: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.2;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 0.25rem;
}

.stat-change {
    font-size: 0.75rem;
    color: #64748b;
}

.change-indicator {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-weight: 500;
    margin-right: 0.25rem;
}

.change-indicator.positive {
    background: #dcfce7;
    color: #166534;
}

.change-indicator.negative {
    background: #fef2f2;
    color: #dc2626;
}

.change-indicator.neutral {
    background: #f1f5f9;
    color: #64748b;
}

.stat-chart {
    margin-top: 1rem;
    height: 40px;
}

/* Statistics Tabs */
.statistics-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding: 0.5rem;
    background: linear-gradient(135deg, #3b82f6, #1e40af);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

.stats-tab-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.stats-tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.stats-tab-btn.active {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

.stats-tab-btn i {
    font-size: 1rem;
}

/* Tab Content */
.stats-tab-content {
    display: none;
    animation: fadeInUp 0.3s ease;
    background: transparent;
    border-radius: 12px;
    padding: 1rem 0;
}

.stats-tab-content.active {
    display: block;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Section Headers */
.stats-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f1f5f9;
}

.stats-section-header h4 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.stats-controls {
    display: flex;
    gap: 0.75rem;
}

.btn-export-data {
    padding: 0.5rem 1rem;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-export-data:hover {
    background: #059669;
    transform: translateY(-1px);
}

/* Tables */
.pages-table-container,
.products-table-container {
    background: transparent;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.pages-stats-table,
.products-stats-table {
    width: 100%;
    border-collapse: collapse;
}

.pages-stats-table th,
.pages-stats-table td,
.products-stats-table th,
.products-stats-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
}

.pages-stats-table th,
.products-stats-table th {
    background: linear-gradient(135deg, #374151, #1f2937);
    font-weight: 600;
    color: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.pages-stats-table tr:hover,
.products-stats-table tr:hover {
    background: #f8fafc;
}

/* Links in tables */
.pages-stats-table a,
.products-stats-table a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.pages-stats-table a:hover,
.products-stats-table a:hover {
    color: #60a5fa;
    text-decoration: underline;
}

.loading-row td {
    text-align: center;
    padding: 2rem;
}

.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: #64748b;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid var(--accent-color, #3b82f6);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Charts */
.chart-wrapper {
    background: transparent;
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

.page-views-chart-container,
.leads-chart-container {
    margin-bottom: 2rem;
}

.page-views-chart-container h5,
.leads-chart-container h5,
.woo-chart-container h5,
.top-pages-container h5 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Leads Section */
.leads-notice {
    padding: 1rem;
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    color: #92400e;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.leads-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.leads-stat-card {
    background: transparent;
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.leads-stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.leads-stat-card .stat-content h6 {
    margin: 0 0 0.25rem 0;
    font-size: 0.75rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.leads-stat-card .stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
}

.sources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.source-item {
    background: transparent;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.source-item .source-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
}

.source-info {
    display: flex;
    flex-direction: column;
}

.source-name {
    font-size: 0.875rem;
    color: var(--text-primary, #1e293b);
    font-weight: 500;
}

.source-count {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--accent-color, #3b82f6);
}

/* WooCommerce Section */
.woo-status {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.woo-status.active {
    background: #dcfce7;
    color: #166534;
}

.woo-status.sample {
    background: #fef3c7;
    color: #92400e;
}

.woo-status.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Loading and Error States */
.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
    color: #64748b;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-row td {
    border: none !important;
}

.loading-row:hover {
    background: transparent !important;
}

.error-state {
    text-align: center;
    padding: 2rem;
    color: #ef4444;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    margin: 1rem 0;
}

.no-data-state {
    text-align: center;
    padding: 3rem 2rem;
    color: #64748b;
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    margin: 1rem 0;
}

.woo-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.woo-stat-card {
    background: transparent;
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.woo-stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: linear-gradient(135deg, #7c3aed, #5b21b6);
}

.woo-stat-card .stat-content h6 {
    margin: 0 0 0.25rem 0;
    font-size: 0.75rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.woo-stat-card .stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
}

.woo-charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.woo-chart-container {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Responsive Design */
@media (max-width: 768px) {
    .estatisticas-management {
        padding: 1rem;
    }
    
    .statistics-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .statistics-header-actions {
        justify-content: space-between;
    }
    
    .stats-row {
        grid-template-columns: 1fr;
    }
    
    .statistics-tabs {
        flex-direction: column;
    }
    
    .stats-tab-btn {
        justify-content: flex-start;
    }
    
    .stats-section-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .woo-charts-grid {
        grid-template-columns: 1fr;
    }
    
    .pages-stats-table,
    .products-stats-table {
        font-size: 0.875rem;
    }
    
    .pages-stats-table th,
    .pages-stats-table td,
    .products-stats-table th,
    .products-stats-table td {
        padding: 0.75rem 0.5rem;
    }
}

@media (max-width: 480px) {
    .stat-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .stat-info {
        margin-left: 0;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    /* Hide some table columns on very small screens */
    .pages-stats-table th:nth-child(4),
    .pages-stats-table td:nth-child(4),
    .pages-stats-table th:nth-child(5),
    .pages-stats-table td:nth-child(5) {
        display: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .estatisticas-management {
        background: transparent;
    }
    
    .statistics-header,
    .stat-card,
    .chart-wrapper,
    .pages-table-container,
    .products-table-container,
    .leads-stat-card,
    .woo-stat-card,
    .source-item,
    .woo-chart-container {
        background: transparent;
        border-color: rgba(255, 255, 255, 0.3);
    }
    
    .pages-stats-table th,
    .products-stats-table th {
        background: linear-gradient(135deg, #374151, #1f2937);
        color: white;
    }
    
    .pages-stats-table tr:hover,
    .products-stats-table tr:hover {
        background: #334155;
    }
    
    .pages-stats-table a,
    .products-stats-table a {
        color: #e2e8f0;
    }
    
    .pages-stats-table a:hover,
    .products-stats-table a:hover {
        color: #60a5fa;
    }
}
