/* Analytics Dashboard Styles */
.analytics-dashboard {
    padding: 20px;
    background-color: #f8f9fa;
    min-height: 100vh;
}

/* Header */
.dashboard-header {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content h1 {
    margin: 0;
    color: #333;
    font-size: 28px;
    font-weight: 600;
}

.header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.form-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Overview Stats */
.overview-section {
    margin-bottom: 30px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.stat-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
}

.stat-card:nth-child(1) .stat-icon { background: #28a745; }
.stat-card:nth-child(2) .stat-icon { background: #007bff; }
.stat-card:nth-child(3) .stat-icon { background: #ffc107; color: #333; }
.stat-card:nth-child(4) .stat-icon { background: #dc3545; }

.stat-content h3 {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    color: #333;
}

.stat-content p {
    margin: 5px 0;
    color: #666;
    font-size: 14px;
}

.growth-indicator {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 12px;
}

.growth-indicator.positive {
    background: #d4edda;
    color: #155724;
}

.growth-indicator.negative {
    background: #f8d7da;
    color: #721c24;
}

.growth-indicator.neutral {
    background: #e2e3e5;
    color: #383d41;
}

/* Charts Section */
.charts-section {
    margin-bottom: 30px;
}

.chart-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.chart-container {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
}

.chart-controls {
    display: flex;
    gap: 5px;
}

.chart-toggle {
    padding: 5px 10px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.chart-toggle.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

/* Analytics Section */
.analytics-section {
    margin-bottom: 30px;
}

.analytics-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.analytics-container {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.analytics-header {
    margin-bottom: 20px;
}

.analytics-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
}

.geographic-content {
    display: flex;
    gap: 20px;
}

.country-list {
    flex: 1;
}

.country-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.country-item:last-child {
    border-bottom: none;
}

.country-name {
    font-weight: 500;
}

.country-count {
    background: #f8f9fa;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    color: #666;
}

.world-map {
    flex: 1;
    height: 200px;
    background: #f8f9fa;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
}

.device-content {
    display: flex;
    gap: 20px;
}

.device-stats {
    flex: 1;
}

.device-stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.device-stat-item:last-child {
    border-bottom: none;
}

/* Activity Section */
.activity-section {
    margin-bottom: 30px;
}

.activity-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.activity-container {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.activity-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.activity-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
}

.live-indicator {
    background: #28a745;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.health-status {
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.healthy { background: #28a745; }
.status-indicator.warning { background: #ffc107; }
.status-indicator.critical { background: #dc3545; }

.activity-list {
    max-height: 300px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-info {
    flex: 1;
}

.activity-user {
    font-weight: 500;
    color: #333;
}

.activity-product {
    font-size: 12px;
    color: #666;
}

.activity-time {
    font-size: 12px;
    color: #999;
}

.health-metrics {
    display: grid;
    gap: 10px;
}

.health-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.metric-label {
    font-size: 14px;
    color: #666;
}

.metric-value {
    font-weight: 600;
    color: #333;
}

/* Products Section */
.products-section {
    margin-bottom: 30px;
}

.products-container {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.products-header h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 18px;
}

.products-list {
    display: grid;
    gap: 10px;
}

.product-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 4px;
}

.product-name {
    font-weight: 500;
    color: #333;
}

.product-downloads {
    background: #007bff;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

/* Error State */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

.error-content i {
    font-size: 48px;
    color: #dc3545;
    margin-bottom: 20px;
}

.error-content h3 {
    margin: 0 0 10px 0;
    color: #333;
}

.error-content p {
    color: #666;
    margin-bottom: 20px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 0;
    border-radius: 8px;
    width: 400px;
    max-width: 90%;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.export-options {
    margin-bottom: 20px;
}

.export-options label {
    display: block;
    margin-bottom: 10px;
    cursor: pointer;
}

.export-options input[type="radio"] {
    margin-right: 8px;
}

.export-range label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.export-range select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .analytics-dashboard {
        padding: 10px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .header-controls {
        justify-content: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-row,
    .analytics-row,
    .activity-row {
        grid-template-columns: 1fr;
    }
    
    .geographic-content,
    .device-content {
        flex-direction: column;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}