/**
 * Analytics Dashboard Styles
 */

/* Analytics Header */
.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.time-range-selector {
    display: flex;
    gap: 0.5rem;
    background: var(--card-bg, #fff);
    padding: 0.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.time-btn {
    padding: 0.6rem 1.2rem;
    border: none;
    background: transparent;
    color: var(--text-color, #333);
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.time-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.time-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Analytics Metrics Grid */
.analytics-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: var(--card-bg, #fff);
    border-radius: 15px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.metric-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.metric-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    flex-shrink: 0;
}

.metric-info {
    flex: 1;
}

.metric-label {
    font-size: 0.85rem;
    color: var(--text-secondary, #6c757d);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
    margin: 0;
}

.metric-trend {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    display: inline-block;
    margin-top: 0.5rem;
}

.metric-trend.up {
    background: rgba(67, 233, 123, 0.1);
    color: #43e97b;
}

.metric-trend.down {
    background: rgba(245, 87, 108, 0.1);
    color: #f5576c;
}

.metric-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary, #6c757d);
    display: block;
    margin-top: 0.25rem;
}

/* Real-time Card Animation */
.realtime-card .pulse-icon {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.1);
    }
}

/* Charts Section */
.analytics-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-card {
    background: var(--card-bg, #fff);
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color, #e9ecef);
}

.chart-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-header i {
    color: #667eea;
}

.chart-container {
    position: relative;
    height: 300px;
}

/* Analytics Tables */
.analytics-tables {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.analytics-table-card {
    background: var(--card-bg, #fff);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.table-card-header {
    padding: 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.table-card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.analytics-table-card .table-container {
    max-height: 400px;
    overflow-y: auto;
}

/* Source and Page Cells */
.source-cell, .page-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.source-cell i, .page-cell i {
    font-size: 1.2rem;
    color: #667eea;
}

.page-cell {
    flex-direction: column;
    align-items: flex-start;
}

.page-title {
    font-weight: 600;
    color: var(--text-primary, #1e293b);
}

.page-url {
    font-size: 0.8rem;
    color: var(--text-secondary, #6c757d);
}

/* Bounce Rate Badge */
.bounce-rate {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
}

.bounce-rate.low {
    background: rgba(67, 233, 123, 0.1);
    color: #43e97b;
}

.bounce-rate.medium {
    background: rgba(255, 193, 7, 0.1);
    color: #ffc107;
}

.bounce-rate.high {
    background: rgba(245, 87, 108, 0.1);
    color: #f5576c;
}

/* Real-time Activity Feed */
.analytics-realtime {
    background: var(--card-bg, #fff);
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.realtime-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color, #e9ecef);
}

.realtime-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.realtime-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #43e97b;
}

.realtime-status i {
    animation: pulse 2s infinite;
}

.realtime-feed {
    max-height: 400px;
    overflow-y: auto;
}

.realtime-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color, #e9ecef);
    transition: background 0.2s ease;
}

.realtime-item:hover {
    background: rgba(102, 126, 234, 0.05);
}

.realtime-item:last-child {
    border-bottom: none;
}

.realtime-icon {
    width: 8px;
    height: 8px;
    flex-shrink: 0;
}

.realtime-icon i {
    font-size: 8px;
    color: #43e97b;
}

.realtime-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.realtime-page {
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    font-size: 0.9rem;
}

.realtime-time {
    font-size: 0.8rem;
    color: var(--text-secondary, #6c757d);
}

.realtime-empty {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary, #6c757d);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .analytics-charts {
        grid-template-columns: 1fr;
    }
    
    .analytics-tables {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .analytics-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .time-range-selector {
        overflow-x: auto;
    }
    
    .time-btn {
        white-space: nowrap;
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
    
    .analytics-metrics {
        grid-template-columns: 1fr;
    }
    
    .metric-card {
        padding: 1.25rem;
    }
    
    .metric-icon {
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
    }
    
    .metric-value {
        font-size: 1.75rem;
    }
    
    .chart-container {
        height: 250px;
    }
}

/* TikTok Analytics Section */
.tiktok-analytics-section {
    margin-top: 3rem;
    padding-top: 3rem;
    border-top: 3px solid var(--border-color, #e9ecef);
}

.tiktok-analytics-section .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.tiktok-analytics-section .section-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.tiktok-analytics-section .section-header .fa-tiktok {
    color: #fe2c55;
}

.tiktok-badge {
    padding: 0.5rem 1rem;
    background: rgba(254, 44, 85, 0.1);
    border: 2px solid #fe2c55;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fe2c55;
}

.tiktok-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.tiktok-metric-card {
    background: var(--card-bg, #fff);
    border-radius: 15px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.tiktok-metric-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    border-color: #fe2c55;
}

.tiktok-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.tiktok-table-card {
    background: var(--card-bg, #fff);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.tiktok-table-card .table-card-header {
    padding: 1.5rem;
    background: linear-gradient(135deg, #fe2c55 0%, #000000 100%);
    color: white;
}

/* Dark Mode Support */
.dark-mode .time-range-selector,
.dark-mode .metric-card,
.dark-mode .chart-card,
.dark-mode .analytics-table-card,
.dark-mode .analytics-realtime,
.dark-mode .tiktok-metric-card,
.dark-mode .tiktok-table-card {
    background: var(--dark-card-bg, #1e293b);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.dark-mode .tiktok-analytics-section {
    border-top-color: var(--dark-border, #334155);
}

.dark-mode .tiktok-analytics-section .section-header h2 {
    color: var(--dark-text, #f1f5f9);
}

.dark-mode .time-btn {
    color: var(--dark-text, #cbd5e1);
}

.dark-mode .time-btn:hover {
    background: rgba(102, 126, 234, 0.2);
}

.dark-mode .metric-label,
.dark-mode .metric-subtitle,
.dark-mode .realtime-time,
.dark-mode .page-url {
    color: var(--dark-text-secondary, #94a3b8);
}

.dark-mode .metric-value,
.dark-mode .chart-header h3,
.dark-mode .realtime-header h3,
.dark-mode .page-title,
.dark-mode .realtime-page {
    color: var(--dark-text, #f1f5f9);
}

.dark-mode .chart-header,
.dark-mode .realtime-header,
.dark-mode .realtime-item {
    border-color: var(--dark-border, #334155);
}

.dark-mode .realtime-item:hover {
    background: rgba(102, 126, 234, 0.1);
}
