/* ===================================
   ANALYTICS PAGE - MOBILE OPTIMIZED
   =================================== */

.analytics-page {
    min-height: 100vh;
    padding: 30px 20px 80px;
    width: 100%;
}

.analytics-container {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* ===================================
   HEADER SECTION
   =================================== */

.analytics-header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    gap: 20px;
    flex-wrap: wrap;
}

.header-left .page-title {
    font-size: 2.2rem;
    font-weight: 900;
    background: linear-gradient(135deg, #00d4ff 0%, #ffffff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 0;
}

.header-left .page-title i {
    color: var(--primary);
    font-size: 2rem;
    filter: drop-shadow(0 0 10px rgba(0, 212, 255, 0.6));
}

.connection-status-box {
    background: linear-gradient(135deg, rgba(0, 150, 255, 0.08) 0%, rgba(0, 150, 255, 0.04) 100%);
    border: 2px solid rgba(0, 150, 255, 0.25);
    border-radius: 14px;
    padding: 12px 20px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: 0 0 10px currentColor;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.status-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 1px;
}

.status-text {
    font-size: 0.95rem;
    color: var(--text);
    font-weight: 700;
}

/* ===================================
   NETWORK STATS GRID
   =================================== */

.network-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
    width: 100%;
}

.network-stat-card {
    background: linear-gradient(145deg, rgba(13, 31, 45, 0.95) 0%, rgba(26, 58, 82, 0.85) 100%);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(0, 150, 255, 0.25);
    border-radius: 20px;
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.3s ease;
}

.network-stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 40px rgba(0, 150, 255, 0.2);
    border-color: rgba(0, 150, 255, 0.4);
}

.stat-icon-box {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    flex-shrink: 0;
}

.stat-icon-box.realms-icon {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
}

.stat-icon-box.players-icon {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
}

.stat-icon-box.peak-icon {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.stat-icon-box.load-icon {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.stat-info-box {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 0;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 1.2px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 900;
    color: var(--text);
    line-height: 1;
}

.stat-animated {
    animation: valueUpdate 0.5s ease;
}

@keyframes valueUpdate {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); color: var(--primary); }
}

/* ===================================
   NETWORK CHART
   =================================== */

.network-chart-wrapper {
    background: linear-gradient(145deg, rgba(13, 31, 45, 0.95) 0%, rgba(26, 58, 82, 0.85) 100%);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(0, 150, 255, 0.25);
    border-radius: 25px;
    padding: 30px;
    margin-bottom: 30px;
    overflow: visible;
    width: 100%;
}

/* ===================================
   REALMS SECTION
   =================================== */

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

.section-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
}

.section-title i {
    color: var(--primary);
    font-size: 1.5rem;
}

.realms-count {
    padding: 8px 18px;
    background: rgba(0, 150, 255, 0.1);
    border: 2px solid rgba(0, 150, 255, 0.2);
    border-radius: 50px;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 700;
}

/* ===================================
   REALMS GRID
   =================================== */

.realms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 25px;
    width: 100%;
    margin: 0 auto;
}

.realm-item {
    width: 100%;
}

.realm-card {
    background: linear-gradient(145deg, rgba(13, 31, 45, 0.95) 0%, rgba(26, 58, 82, 0.85) 100%);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(0, 150, 255, 0.25);
    border-radius: 20px;
    padding: 25px;
    transition: all 0.3s ease;
    width: 100%;
}

.realm-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 40px rgba(0, 150, 255, 0.2);
    border-color: var(--realm-color);
}

.realm-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 15px;
}

.realm-identity {
    display: flex;
    gap: 15px;
    align-items: flex-start;
    flex: 1;
    min-width: 0;
}

.realm-icon-box {
    width: 55px;
    height: 55px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: white;
    flex-shrink: 0;
}

.realm-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 0;
}

.realm-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.realm-name {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text);
    margin: 0;
}

.top-realm-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #000;
}

.top-realm-badge i {
    font-size: 0.7rem;
}

.realm-id {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.realm-timestamp {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.realm-timestamp i {
    font-size: 0.75rem;
}

.health-status-badge {
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.realm-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.realm-stat-box {
    background: rgba(0, 150, 255, 0.05);
    border: 1px solid rgba(0, 150, 255, 0.15);
    border-radius: 14px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
}

.realm-stat-box:hover {
    background: rgba(0, 150, 255, 0.08);
    border-color: rgba(0, 150, 255, 0.25);
}

.realm-stat-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
}

.realm-stat-data {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.realm-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 1px;
}

.realm-stat-value {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--text);
    line-height: 1;
}

.realm-load {
    margin-bottom: 20px;
}

.load-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.load-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 1px;
}

.load-value {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text);
}

.load-bar-bg {
    width: 100%;
    height: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.load-bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s ease;
    position: relative;
    overflow: hidden;
}

.load-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.expand-btn {
    width: 100%;
    padding: 14px;
    background: rgba(0, 150, 255, 0.1);
    border: 2px solid rgba(0, 150, 255, 0.2);
    border-radius: 12px;
    color: var(--primary);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: 'Poppins', sans-serif;
}

.expand-btn:hover {
    background: rgba(0, 150, 255, 0.2);
    border-color: rgba(0, 150, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 150, 255, 0.3);
}

.expand-btn:active {
    transform: translateY(0);
}

.expand-btn i {
    font-size: 0.9rem;
    transition: transform 0.3s ease;
}

.realm-card.expanded .expand-btn i {
    transform: rotate(180deg);
}

.realm-chart-wrapper {
    margin-top: 25px;
    background: linear-gradient(145deg, rgba(13, 31, 45, 0.95) 0%, rgba(26, 58, 82, 0.85) 100%);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(0, 150, 255, 0.25);
    border-radius: 20px;
    padding: 30px;
    overflow: visible;
    width: 100%;
}

/* ===================================
   CHART COMPONENTS - FIXED
   =================================== */

.detailed-chart {
    width: 100%;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
    gap: 20px;
    flex-wrap: wrap;
}

.chart-title-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.chart-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
}

.chart-title i {
    font-size: 1.3rem;
}

.chart-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

.time-period-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 5px;
    gap: 5px;
}

.time-period-selector button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
}

.time-period-selector button.active {
    background: var(--primary);
    color: #000;
    box-shadow: 0 4px 15px rgba(0, 150, 255, 0.4);
}

.time-period-selector button:hover:not(.active) {
    background: rgba(0, 150, 255, 0.15);
    color: var(--primary);
}

.time-period-selector button i {
    font-size: 0.9rem;
}

.chart-container {
    width: 100%;
    overflow: visible;
    margin-bottom: 25px;
    position: relative;
}

.chart-svg {
    width: 100%;
    height: auto;
    overflow: visible;
}

.chart-point {
    cursor: pointer;
    transition: all 0.2s ease;
}

.chart-point:hover {
    r: 11;
}

.chart-legend {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 14px;
    border: 1px solid rgba(0, 150, 255, 0.15);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 14px;
}

.legend-indicator {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.legend-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.legend-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.legend-value {
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--text);
    line-height: 1;
}

.chart-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
    gap: 20px;
    min-height: 400px;
}

.empty-chart-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.empty-chart-content i {
    font-size: 4rem;
    color: var(--primary);
    opacity: 0.5;
}

.empty-chart-content h4 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.empty-chart-content p {
    font-size: 1rem;
    color: var(--text-muted);
    margin: 0;
    max-width: 400px;
}

.empty-realms-state {
    background: linear-gradient(145deg, rgba(13, 31, 45, 0.95) 0%, rgba(26, 58, 82, 0.85) 100%);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(0, 150, 255, 0.25);
    border-radius: 25px;
    padding: 60px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 20px;
}

.empty-icon-box {
    width: 100px;
    height: 100px;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(0, 150, 255, 0.15) 0%, rgba(0, 150, 255, 0.08) 100%);
    border: 2px solid rgba(0, 150, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--primary);
}

.empty-realms-state h3 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    margin: 0;
}

.empty-realms-state p {
    font-size: 1rem;
    color: var(--text-muted);
    margin: 0;
    max-width: 500px;
}

.pulse-animation {
    position: relative;
    width: 60px;
    height: 60px;
    margin-top: 10px;
}

.pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid var(--primary);
    border-radius: 50%;
    opacity: 0;
    animation: pulsate 2s ease-out infinite;
}

.pulse-ring:nth-child(2) {
    animation-delay: 0.7s;
}

.pulse-ring:nth-child(3) {
    animation-delay: 1.4s;
}

@keyframes pulsate {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* ===================================
   LOADING STATE
   =================================== */

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    gap: 20px;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(0, 150, 255, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1.1rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* ===================================
   RESPONSIVE - TABLET
   =================================== */

@media (max-width: 968px) {
    .analytics-page {
        padding: 20px 15px 60px;
    }

    .analytics-header-section {
        flex-direction: column;
        align-items: flex-start;
    }

    .connection-status-box {
        width: 100%;
    }

    .network-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .realms-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .time-period-selector {
        width: 100%;
    }

    .time-period-selector button {
        flex: 1;
        justify-content: center;
    }
}

/* ===================================
   RESPONSIVE - MOBILE
   =================================== */

@media (max-width: 768px) {
    .analytics-page {
        padding: 15px 10px 50px;
    }

    .header-left .page-title {
        font-size: 1.6rem;
        gap: 10px;
    }

    .header-left .page-title i {
        font-size: 1.5rem;
    }

    .connection-status-box {
        padding: 10px 15px;
    }

    .network-stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .network-stat-card {
        padding: 18px;
    }

    .stat-icon-box {
        width: 50px;
        height: 50px;
        font-size: 1.3rem;
    }

    .stat-value {
        font-size: 1.6rem;
    }

    .network-chart-wrapper {
        padding: 20px 15px;
    }

    .section-title {
        font-size: 1.4rem;
    }

    .realms-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .realm-card {
        padding: 20px 15px;
    }

    .realm-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .health-status-badge {
        width: 100%;
        text-align: center;
    }

    .realm-icon-box {
        width: 48px;
        height: 48px;
        font-size: 1.3rem;
    }

    .realm-name {
        font-size: 1.2rem;
    }

    .realm-stats {
        gap: 12px;
    }

    .realm-stat-box {
        padding: 12px;
    }

    .realm-stat-value {
        font-size: 1.4rem;
    }

    .realm-chart-wrapper {
        padding: 20px 15px;
    }

    .chart-title {
        font-size: 1.2rem;
    }

    .chart-subtitle {
        font-size: 0.8rem;
    }

    .time-period-selector button {
        padding: 8px 12px;
        font-size: 0.85rem;
        gap: 6px;
    }

    .chart-legend {
        gap: 20px;
        padding: 15px;
    }

    .legend-indicator {
        width: 42px;
        height: 42px;
        font-size: 1rem;
    }

    .legend-value {
        font-size: 1.2rem;
    }

    .empty-chart-content i {
        font-size: 3rem;
    }

    .empty-chart-content h4 {
        font-size: 1.1rem;
    }
}

/* ===================================
   RESPONSIVE - SMALL MOBILE
   =================================== */

@media (max-width: 480px) {
    .analytics-page {
        padding: 12px 8px 40px;
    }

    .header-left .page-title {
        font-size: 1.4rem;
    }

    .network-stat-card {
        padding: 15px;
        gap: 15px;
    }

    .stat-icon-box {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .network-chart-wrapper {
        padding: 15px 10px;
    }

    .realm-card {
        padding: 15px;
    }

    .realm-icon-box {
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }

    .realm-name {
        font-size: 1.1rem;
    }

    .realm-stats {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .expand-btn {
        padding: 12px;
        font-size: 0.85rem;
    }

    .chart-title {
        font-size: 1.1rem;
    }

    .time-period-selector button {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .time-period-selector button span {
        display: none;
    }

    .chart-legend {
        gap: 15px;
    }

    .legend-indicator {
        width: 38px;
        height: 38px;
        font-size: 0.9rem;
    }

    .legend-value {
        font-size: 1.1rem;
    }
}

/* ===================================
   TOUCH DEVICE OPTIMIZATIONS
   =================================== */

@media (hover: none) and (pointer: coarse) {
    .chart-point {
        r: 10;
    }
}

/* ===================================
   ACCESSIBILITY
   =================================== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.realm-card:focus-visible,
.expand-btn:focus-visible,
.time-period-selector button:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 3px;
}