/**
 * Google Analytics Page Counter - WordPress Styles
 * Modern, responsive styling for the analytics widget
 */

/* Base Widget Styles */
.ga-page-counter-widget {
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    line-height: 1.5;
}

.ga-widget-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.4;
}

/* Stat Cards */
.ga-stat-card {
    transition: all 0.3s ease;
    cursor: default;
    position: relative;
    overflow: hidden;
}

.ga-stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(0,0,0,0.15) !important;
}

/* Animations */
@keyframes ga-pulse {
    0% { 
        opacity: 1; 
        transform: scale(1); 
    }
    50% { 
        opacity: 0.7; 
        transform: scale(1.1); 
    }
    100% { 
        opacity: 1; 
        transform: scale(1); 
    }
}

@keyframes widget-pulse {
    0% { 
        opacity: 1; 
        transform: scale(1); 
    }
    50% { 
        opacity: 0.6; 
        transform: scale(1.2); 
    }
    100% { 
        opacity: 1; 
        transform: scale(1); 
    }
}

/* Top Pages Styling */
.ga-top-pages .ga-page-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #dee2e6;
    transition: all 0.2s ease;
}

.ga-top-pages .ga-page-item:hover {
    background: rgba(0,123,255,0.05);
    padding-left: 10px;
    padding-right: 10px;
    margin-left: -10px;
    margin-right: -10px;
    border-radius: 6px;
}

.ga-top-pages .ga-page-item:last-child {
    border-bottom: none;
}

.ga-page-path {
    color: #495057;
    font-weight: 500;
    font-size: 14px;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ga-page-views {
    color: #007cba;
    font-weight: 600;
    font-size: 14px;
}

/* Widget Specific Styles */
.ga-widget-top-pages .ga-mini-page {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.2s ease;
}

.ga-widget-top-pages .ga-mini-page:hover {
    background-color: rgba(0,123,255,0.05);
    border-radius: 4px;
    padding-left: 6px;
    padding-right: 6px;
    margin-left: -6px;
    margin-right: -6px;
}

.ga-widget-top-pages .ga-mini-page:last-child {
    border-bottom: none;
}

.ga-mini-page-path {
    color: #495057;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 120px;
    font-size: 11px;
}

.ga-mini-page-views {
    color: #007cba;
    font-weight: 600;
    font-size: 10px;
}

/* Loading States */
.ga-loading .ga-stat-card {
    opacity: 0.7;
}

.ga-loading .ga-stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: loading-shine 1.5s infinite;
}

@keyframes loading-shine {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Error States */
.ga-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    font-size: 14px;
}

.ga-error .ga-error-title {
    font-weight: 600;
    margin-bottom: 5px;
}

.ga-error .ga-error-message {
    font-size: 12px;
    opacity: 0.8;
}

/* Configuration Messages */
.ga-config-needed {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    color: #495057;
}

.ga-config-needed h3 {
    margin: 0 0 10px 0;
    color: #343a40;
    font-size: 16px;
}

.ga-config-needed p {
    margin: 0 0 15px 0;
    font-size: 14px;
    opacity: 0.8;
}

.ga-config-needed .ga-setup-button {
    background: #007cba;
    color: white;
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 6px;
    display: inline-block;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.ga-config-needed .ga-setup-button:hover {
    background: #005a87;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,124,186,0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    .ga-analytics-display > div:first-child {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    
    .ga-stat-card {
        padding: 15px !important;
    }
    
    .ga-stat-card div:nth-child(2) div:first-child {
        font-size: 20px !important;
    }
    
    .ga-page-path {
        max-width: 50% !important;
        font-size: 13px !important;
    }
    
    .ga-page-views {
        font-size: 13px !important;
    }
}

@media (max-width: 480px) {
    .ga-page-counter-widget {
        margin: 15px 0;
    }
    
    .ga-stat-card {
        padding: 12px !important;
    }
    
    .ga-stat-card h4 {
        font-size: 12px !important;
    }
    
    .ga-stat-card div:nth-child(2) div:first-child {
        font-size: 18px !important;
    }
    
    .ga-top-pages .ga-page-item {
        padding: 8px 0 !important;
    }
}

/* WordPress Theme Compatibility */
.widget .ga-widget-container {
    margin: 0;
}

.widget .ga-widget-container * {
    box-sizing: border-box;
}

/* Admin Bar Compatibility */
body.admin-bar .ga-page-counter-widget {
    /* Ensure proper spacing when admin bar is present */
}

/* Dark Theme Support */
@media (prefers-color-scheme: dark) {
    .ga-config-needed {
        background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .ga-config-needed h3 {
        color: #f7fafc;
    }
    
    .ga-page-path {
        color: #e2e8f0;
    }
    
    .ga-mini-page-path {
        color: #e2e8f0;
    }
}

/* Print Styles */
@media print {
    .ga-page-counter-widget {
        background: white !important;
        color: black !important;
    }
    
    .ga-stat-card {
        background: #f8f9fa !important;
        color: black !important;
        break-inside: avoid;
    }
    
    .ga-page-item:hover,
    .ga-mini-page:hover {
        background: none !important;
    }
}

/* Accessibility Improvements */
.ga-stat-card:focus-within {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.ga-page-item:focus-within,
.ga-mini-page:focus-within {
    outline: 1px solid #007cba;
    outline-offset: 1px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .ga-stat-card {
        border: 2px solid currentColor !important;
    }
    
    .ga-page-item,
    .ga-mini-page {
        border-bottom-color: currentColor !important;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .ga-stat-card,
    .ga-page-item,
    .ga-mini-page {
        transition: none !important;
    }
    
    .ga-pulse,
    .widget-pulse,
    .loading-shine {
        animation: none !important;
    }
}

/* RTL Support */
[dir="rtl"] .ga-page-item,
[dir="rtl"] .ga-mini-page {
    direction: rtl;
}

[dir="rtl"] .ga-page-path,
[dir="rtl"] .ga-mini-page-path {
    text-align: right;
}

/* Custom Properties for Easy Theming */
:root {
    --ga-primary-color: #007cba;
    --ga-success-color: #28a745;
    --ga-warning-color: #ffc107;
    --ga-danger-color: #dc3545;
    --ga-light-bg: #f8f9fa;
    --ga-dark-bg: #343a40;
    --ga-border-color: #dee2e6;
    --ga-text-color: #495057;
    --ga-text-muted: #6c757d;
}

/* Override with theme colors if available */
.ga-page-counter-widget {
    --ga-primary-color: var(--wp-admin-theme-color, #007cba);
}
