/**
 * MagzPress Analytics Dashboard Styles
 */

/* Main Analytics Page Layout */
.magzpress-analytics-page {
    background: #f1f1f1;
}

.magzpress-analytics-page .wrap {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin: 20px 20px 20px 0;
}

/* Analytics Header */
.magzpress-analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e2e4e7;
}

.magzpress-date-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.magzpress-period-selector {
    min-width: 150px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
}

.magzpress-custom-dates {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 15px;
}

.magzpress-custom-dates input[type="date"] {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.magzpress-export-controls {
    display: flex;
    gap: 10px;
}

/* Loading Overlay */
.magzpress-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.magzpress-loading-content {
    text-align: center;
    padding: 40px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.magzpress-loading-content .spinner {
    float: none;
    margin: 0 auto 20px;
}

/* Overview Cards */
.magzpress-analytics-overview {
    margin-bottom: 30px;
}

.magzpress-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.magzpress-overview-card {
    background: #fff;
    border: 1px solid #e2e4e7;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s ease;
}

.magzpress-overview-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.magzpress-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.magzpress-card-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #646970;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.magzpress-card-header .dashicons {
    font-size: 20px;
    color: #0073aa;
}

.magzpress-card-content {
    position: relative;
}

.magzpress-metric-value {
    font-size: 32px;
    font-weight: 700;
    color: #1d2327;
    line-height: 1;
    margin-bottom: 8px;
}

.magzpress-metric-change {
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 15px;
}

.magzpress-metric-change.positive {
    color: #00a32a;
}

.magzpress-metric-change.negative {
    color: #d63638;
}

.magzpress-metric-change.neutral {
    color: #646970;
}

.magzpress-sparkline {
    height: 40px;
    width: 100%;
}

/* Charts Section */
.magzpress-analytics-charts {
    margin-bottom: 30px;
}

.magzpress-chart-section {
    background: #fff;
    border: 1px solid #e2e4e7;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.magzpress-chart-container {
    position: relative;
}

.magzpress-main-chart {
    min-height: 400px;
    position: relative;
}

.magzpress-main-chart canvas {
    max-height: 400px !important;
    width: 100% !important;
}

.magzpress-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e2e4e7;
}

.magzpress-chart-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1d2327;
}

.magzpress-chart-controls {
    display: flex;
    gap: 20px;
}

.magzpress-chart-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 13px;
    color: #646970;
}

.magzpress-chart-toggle input[type="checkbox"] {
    margin-right: 8px;
}

.magzpress-chart-toggle:hover {
    color: #1d2327;
}

/* Tables Section */
.magzpress-analytics-tables {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.magzpress-table-section {
    background: #fff;
    border: 1px solid #e2e4e7;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.magzpress-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e2e4e7;
}

.magzpress-table-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1d2327;
}

.magzpress-table-controls select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    font-size: 12px;
}

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

.magzpress-table-container table {
    margin: 0;
    border: none;
}

.magzpress-table-container th,
.magzpress-table-container td {
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f1;
    vertical-align: middle;
}

.magzpress-table-container th {
    background: #f8f9fa;
    font-weight: 600;
    color: #646970;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.magzpress-table-container tbody tr:hover {
    background: #f8f9fa;
}

.magzpress-trend {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 3px;
}

.magzpress-trend.positive {
    color: #00a32a;
    background: rgba(0, 163, 42, 0.1);
}

.magzpress-trend.negative {
    color: #d63638;
    background: rgba(214, 54, 56, 0.1);
}

/* User Behavior Section */
.magzpress-user-behavior-section {
    background: #fff;
    border: 1px solid #e2e4e7;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.magzpress-user-behavior-section>h3 {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 600;
    color: #1d2327;
    padding-bottom: 15px;
    border-bottom: 1px solid #e2e4e7;
}

.magzpress-behavior-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 20px;
}

.magzpress-behavior-chart,
.magzpress-behavior-stats {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.magzpress-behavior-chart h4,
.magzpress-behavior-stats h4 {
    margin: 0 0 15px 0;
    font-size: 14px;
    font-weight: 600;
    color: #646970;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.magzpress-behavior-chart canvas {
    max-height: 200px;
}

.magzpress-behavior-stats {
    text-align: left;
}

.magzpress-engagement-metrics {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.magzpress-engagement-metric {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.magzpress-metric-label {
    font-size: 12px;
    color: #646970;
    font-weight: 500;
}

.magzpress-metric-value {
    font-size: 18px;
    font-weight: 600;
    color: #1d2327;
}

.magzpress-metric-bar {
    display: flex;
    height: 20px;
    border-radius: 10px;
    overflow: hidden;
    background: #e2e4e7;
}

.magzpress-new-users,
.magzpress-returning-users {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 500;
    color: #fff;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}

.magzpress-new-users {
    background: #0073aa;
}

.magzpress-returning-users {
    background: #00a32a;
}

/* Unified Analytics Dashboard Styles */
.magzpress-unified-analytics-dashboard {
    padding: 15px;
    background: #fff;
}

/* Compact Header */
.magzpress-compact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 12px 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e2e4e7;
}

.magzpress-period-selector select {
    min-width: 120px;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    font-size: 13px;
}

.magzpress-quick-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.magzpress-quick-actions .button {
    font-size: 12px;
    padding: 4px 8px;
    height: auto;
    line-height: 1.4;
}

.magzpress-quick-actions .dashicons {
    font-size: 14px;
    vertical-align: middle;
}

/* Compact Stats Grid */
.magzpress-compact-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.magzpress-stat-compact {
    background: #fff;
    border: 1px solid #e2e4e7;
    border-radius: 6px;
    padding: 15px;
    position: relative;
    transition: box-shadow 0.2s ease;
}

.magzpress-stat-compact:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.magzpress-stat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.magzpress-stat-header .dashicons {
    font-size: 16px;
    color: #646970;
}

.magzpress-stat-label {
    font-size: 12px;
    font-weight: 600;
    color: #646970;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.magzpress-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #1d2327;
    line-height: 1;
    margin-bottom: 8px;
}

.magzpress-stat-bar {
    height: 4px;
    background: #f0f0f1;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.magzpress-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.magzpress-stat-change {
    font-size: 11px;
    font-weight: 500;
}

.magzpress-stat-change.positive {
    color: #00a32a;
}

.magzpress-stat-change.negative {
    color: #d63638;
}

.magzpress-stat-change.neutral {
    color: #646970;
}

/* Compact Chart */
.magzpress-compact-chart {
    background: #fff;
    border: 1px solid #e2e4e7;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 25px;
}

.magzpress-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.magzpress-chart-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #1d2327;
}

.magzpress-chart-controls {
    display: flex;
    gap: 15px;
    font-size: 12px;
}

.magzpress-chart-controls label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    color: #646970;
}

.magzpress-chart-controls input[type="checkbox"] {
    margin: 0;
}

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

/* Top Content Section */
.magzpress-top-content {
    background: #fff;
    border: 1px solid #e2e4e7;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 25px;
}

.magzpress-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.magzpress-section-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #1d2327;
}

.magzpress-view-all {
    font-size: 12px;
    text-decoration: none;
    color: #0073aa;
}

.magzpress-view-all:hover {
    color: #005a87;
}

.magzpress-top-magazines-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.magzpress-top-magazine-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #e2e4e7;
}

.magzpress-magazine-info {
    flex: 1;
}

.magzpress-magazine-title {
    font-weight: 600;
    text-decoration: none;
    color: #1d2327;
    display: block;
    margin-bottom: 4px;
}

.magzpress-magazine-title:hover {
    color: #0073aa;
}

.magzpress-magazine-views {
    font-size: 12px;
    color: #646970;
}

.magzpress-magazine-actions {
    display: flex;
    gap: 8px;
}

.magzpress-magazine-actions .button {
    font-size: 11px;
    padding: 4px 8px;
    height: auto;
    line-height: 1.4;
}

.magzpress-no-data {
    text-align: center;
    color: #646970;
    font-style: italic;
    margin: 20px 0;
}

/* Quick Actions Section */
.magzpress-quick-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    border: 1px solid #e2e4e7;
    border-radius: 6px;
    padding: 15px;
}

.magzpress-action-buttons {
    display: flex;
    gap: 10px;
}

.magzpress-action-buttons .button {
    font-size: 12px;
    padding: 6px 12px;
    height: auto;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 6px;
}

.magzpress-action-buttons .dashicons {
    font-size: 14px;
}

.magzpress-refresh-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.magzpress-refresh-section .button {
    font-size: 12px;
    padding: 6px 10px;
    height: auto;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 6px;
}

.magzpress-last-updated {
    font-size: 11px;
    color: #646970;
    white-space: nowrap;
}

/* Loading States */
.magzpress-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 20px;
}

.magzpress-loading .spinner {
    float: none;
    margin: 0;
}

.magzpress-loading span {
    font-size: 13px;
    color: #646970;
}

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

    .magzpress-behavior-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .magzpress-analytics-header {
        flex-direction: column;
        gap: 20px;
        align-items: stretch;
    }

    .magzpress-date-controls {
        justify-content: center;
        flex-wrap: wrap;
    }

    .magzpress-overview-grid {
        grid-template-columns: 1fr;
    }

    .magzpress-behavior-grid {
        grid-template-columns: 1fr;
    }

    .magzpress-chart-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .magzpress-chart-controls {
        justify-content: center;
    }

    .magzpress-compact-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .magzpress-quick-actions {
        justify-content: center;
    }

    .magzpress-compact-stats {
        grid-template-columns: 1fr;
    }

    .magzpress-chart-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .magzpress-chart-controls {
        justify-content: center;
    }

    .magzpress-top-magazine-item {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .magzpress-magazine-actions {
        justify-content: center;
    }

    .magzpress-quick-actions {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .magzpress-action-buttons {
        justify-content: center;
    }
}

/* Accessibility */
.magzpress-chart-toggle:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
    border-radius: 3px;
}

.magzpress-overview-card:focus-within {
    box-shadow: 0 0 0 2px #0073aa;
}

/* Print Styles */
@media print {

    .magzpress-analytics-header,
    .magzpress-export-controls,
    .magzpress-chart-controls {
        display: none;
    }

    .magzpress-overview-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .magzpress-analytics-tables {
        grid-template-columns: 1fr;
    }

    .magzpress-behavior-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}