/* ============================================
   Statistics Page - Hálózati Statisztikák
   ============================================ */

/* ==================== HEADER ==================== */
.stats-header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    border-color: #3b82f6;
}

.stats-header .header-left h1 {
    color: #e0f2fe;
}

.stats-header .subtitle {
    color: #93c5fd;
}

.time-range-selector {
    display: flex;
    gap: 0.25rem;
    background: rgba(255,255,255,0.1);
    padding: 0.25rem;
    border-radius: 10px;
}

.time-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    transition: all 0.2s ease;
}

.time-btn:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.time-btn.active {
    background: white;
    color: #1e3a5f;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* ==================== SUMMARY CARDS ==================== */
.stats-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-card {
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}

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

.summary-icon {
    font-size: 1.75rem;
    flex-shrink: 0;
}

.summary-content {
    display: flex;
    flex-direction: column;
}

.summary-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary, #1a1a1a);
    line-height: 1;
}

.summary-label {
    font-size: 0.8rem;
    color: var(--text-secondary, #6b7280);
    margin-top: 0.25rem;
}

.summary-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.summary-bar.excellent { background: linear-gradient(90deg, #22c55e, #16a34a); }
.summary-bar.good { background: linear-gradient(90deg, #eab308, #ca8a04); }
.summary-bar.poor { background: linear-gradient(90deg, #f97316, #ea580c); }
.summary-bar.critical { background: linear-gradient(90deg, #ef4444, #dc2626); }
.summary-bar.offline { background: linear-gradient(90deg, #6b7280, #4b5563); }

/* ==================== FILTER BAR ==================== */
.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    flex: 1;
}

.search-box {
    position: relative;
    min-width: 250px;
    flex: 1;
    max-width: 400px;
}

.search-input {
    width: 100%;
    padding: 0.625rem 1rem 0.625rem 2.5rem;
    background: var(--bg-secondary, #f9fafb);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-primary, #1a1a1a);
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary, #6b7280);
}

.filter-select {
    padding: 0.625rem 2rem 0.625rem 1rem;
    background: var(--bg-secondary, #f9fafb);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-primary, #1a1a1a);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}

.view-toggle {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-secondary, #f3f4f6);
    padding: 0.25rem;
    border-radius: 8px;
}

.view-btn {
    padding: 0.5rem 0.75rem;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.view-btn:hover {
    background: var(--bg-card, #ffffff);
}

.view-btn.active {
    background: var(--bg-card, #ffffff);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ==================== TABLE ==================== */
.table-container {
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    overflow: hidden;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
}

.stats-table thead {
    background: var(--bg-secondary, #f9fafb);
}

.stats-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary, #6b7280);
    border-bottom: 1px solid var(--border, #e5e7eb);
}

.stats-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.stats-table th.sortable:hover {
    color: var(--text-primary, #1a1a1a);
    background: var(--bg-hover, #f3f4f6);
}

.stats-table th.sortable::after {
    content: ' ↕';
    opacity: 0.3;
}

.stats-table th.sortable.asc::after {
    content: ' ↑';
    opacity: 1;
}

.stats-table th.sortable.desc::after {
    content: ' ↓';
    opacity: 1;
}

.stats-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border, #e5e7eb);
    font-size: 0.9rem;
    color: var(--text-primary, #1a1a1a);
}

.stats-table tbody tr {
    transition: background 0.15s ease;
}

.stats-table tbody tr:hover {
    background: var(--bg-secondary, #f9fafb);
}

.stats-table tbody tr:last-child td {
    border-bottom: none;
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge.excellent {
    background: rgba(34, 197, 94, 0.15);
    color: #16a34a;
}

.status-badge.good {
    background: rgba(234, 179, 8, 0.15);
    color: #ca8a04;
}

.status-badge.poor {
    background: rgba(249, 115, 22, 0.15);
    color: #ea580c;
}

.status-badge.critical {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

.status-badge.offline {
    background: rgba(107, 114, 128, 0.15);
    color: #4b5563;
}

.status-badge.online {
    background: rgba(59, 130, 246, 0.15);
    color: #2563eb;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.status-badge.excellent .status-dot { background: #22c55e; }
.status-badge.good .status-dot { background: #eab308; }
.status-badge.poor .status-dot { background: #f97316; }
.status-badge.critical .status-dot { background: #ef4444; }
.status-badge.offline .status-dot { background: #6b7280; }
.status-badge.online .status-dot { background: #3b82f6; }

/* Signal Bars */
.signal-value {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.signal-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 16px;
}

.signal-bar {
    width: 4px;
    background: var(--border, #e5e7eb);
    border-radius: 1px;
}

.signal-bar.active.excellent { background: #22c55e; }
.signal-bar.active.good { background: #eab308; }
.signal-bar.active.poor { background: #f97316; }
.signal-bar.active.critical { background: #ef4444; }
.signal-bar.active.online { background: #3b82f6; }

.signal-bar:nth-child(1) { height: 4px; }
.signal-bar:nth-child(2) { height: 8px; }
.signal-bar:nth-child(3) { height: 12px; }
.signal-bar:nth-child(4) { height: 16px; }

/* Device Name Cell */
.device-name-cell {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.device-name {
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
}

.device-eui {
    font-size: 0.75rem;
    font-family: var(--font-mono, monospace);
    color: var(--text-tertiary, #9ca3af);
}

/* Action Buttons */
.table-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--border, #e5e7eb);
    background: var(--bg-card, #ffffff);
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: var(--bg-secondary, #f9fafb);
    border-color: var(--accent-primary, #3b82f6);
}

.action-btn.compare {
    color: #8b5cf6;
}

.action-btn.compare:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: #8b5cf6;
}

.action-btn.compare.selected {
    background: #8b5cf6;
    color: white;
    border-color: #8b5cf6;
}

/* ==================== GRID VIEW ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.stats-card {
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    padding: 1.25rem;
    position: relative;
    transition: all 0.2s ease;
    cursor: pointer;
}

.stats-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    border-color: var(--accent-primary, #3b82f6);
}

.stats-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.stats-card-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stats-card-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary, #1a1a1a);
}

.stats-card-type {
    font-size: 0.75rem;
    color: var(--text-secondary, #6b7280);
}

.stats-card-values {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.stats-card-value {
    display: flex;
    flex-direction: column;
}

.stats-card-value-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary, #9ca3af);
    margin-bottom: 0.25rem;
}

.stats-card-value-number {
    font-size: 1.25rem;
    font-weight: 700;
}

.stats-card-value-number.excellent { color: #22c55e; }
.stats-card-value-number.good { color: #eab308; }
.stats-card-value-number.poor { color: #f97316; }
.stats-card-value-number.critical { color: #ef4444; }
.stats-card-value-number.offline { color: #6b7280; }
.stats-card-value-number.online { color: #3b82f6; }

.stats-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border, #e5e7eb);
    font-size: 0.8rem;
    color: var(--text-secondary, #6b7280);
}

/* ==================== COMPARISON SECTION ==================== */
.comparison-section {
    margin-top: 2rem;
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    padding: 1.5rem;
}

.comparison-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.comparison-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-primary, #1a1a1a);
}

.comparison-devices {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.comparison-device-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary, #f3f4f6);
    border-radius: 20px;
    font-size: 0.85rem;
}

.comparison-device-tag .remove-btn {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.comparison-device-tag .remove-btn:hover {
    opacity: 1;
}

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

/* ==================== DETAIL MODAL ==================== */
.device-detail-modal {
    max-width: 700px !important;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border, #e5e7eb);
    margin-bottom: 1.5rem;
}

.detail-device-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-device-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
}

.detail-device-eui {
    font-family: var(--font-mono, monospace);
    font-size: 0.8rem;
    color: var(--text-tertiary, #9ca3af);
}

.detail-device-type {
    font-size: 0.85rem;
    color: var(--text-secondary, #6b7280);
}

.detail-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
}

.detail-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.detail-stat {
    background: var(--bg-secondary, #f9fafb);
    padding: 1rem;
    border-radius: 10px;
    text-align: center;
}

.detail-stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary, #6b7280);
    margin-bottom: 0.5rem;
}

.detail-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary, #1a1a1a);
}

.detail-chart-container {
    margin-bottom: 1.5rem;
}

.detail-chart-container h3 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    color: var(--text-primary, #1a1a1a);
}

.detail-chart-container canvas {
    max-height: 200px;
}

.detail-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border, #e5e7eb);
}

/* ==================== LOADING & EMPTY ==================== */
.loading-cell {
    text-align: center;
    padding: 3rem !important;
    color: var(--text-secondary, #6b7280);
}

.loader {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border, #e5e7eb);
    border-top-color: var(--accent-primary, #3b82f6);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-state h3 {
    margin: 0 0 0.5rem;
    color: var(--text-primary, #1a1a1a);
}

.empty-state p {
    color: var(--text-secondary, #6b7280);
    margin: 0;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
    .stats-summary-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .stats-header .header-right {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .time-range-selector {
        justify-content: center;
    }
    
    .filter-bar {
        flex-direction: column;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .search-box {
        max-width: none;
    }
    
    .stats-summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-table {
        font-size: 0.85rem;
    }
    
    .stats-table th,
    .stats-table td {
        padding: 0.75rem 0.5rem;
    }
    
    .device-eui {
        display: none;
    }
}

@media (max-width: 480px) {
    .stats-summary-cards {
        grid-template-columns: 1fr 1fr;
    }
    
    .summary-card {
        padding: 1rem;
    }
    
    .summary-value {
        font-size: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ==================== DARK MODE ==================== */
[data-theme="dark"] .stats-header {
    background: linear-gradient(135deg, #1e3a5f 0%, #1e40af 100%);
}

[data-theme="dark"] .summary-card {
    background: var(--bg-card, #1f2937);
    border-color: var(--border, #374151);
}

[data-theme="dark"] .filter-bar {
    background: var(--bg-card, #1f2937);
    border-color: var(--border, #374151);
}

[data-theme="dark"] .search-input,
[data-theme="dark"] .filter-select {
    background: var(--bg-secondary, #111827);
    border-color: var(--border, #374151);
    color: var(--text-primary, #f9fafb);
}

[data-theme="dark"] .table-container {
    background: var(--bg-card, #1f2937);
    border-color: var(--border, #374151);
}

[data-theme="dark"] .stats-table thead {
    background: var(--bg-secondary, #111827);
}

[data-theme="dark"] .stats-table th {
    border-color: var(--border, #374151);
}

[data-theme="dark"] .stats-table td {
    border-color: var(--border, #374151);
}

[data-theme="dark"] .stats-table tbody tr:hover {
    background: var(--bg-secondary, #111827);
}

[data-theme="dark"] .stats-card {
    background: var(--bg-card, #1f2937);
    border-color: var(--border, #374151);
}

[data-theme="dark"] .comparison-section {
    background: var(--bg-card, #1f2937);
    border-color: var(--border, #374151);
}

[data-theme="dark"] .detail-stat {
    background: var(--bg-secondary, #111827);
}

[data-theme="dark"] .action-btn {
    background: var(--bg-secondary, #111827);
    border-color: var(--border, #374151);
    color: var(--text-primary, #f9fafb);
}

[data-theme="dark"] .time-btn.active {
    background: var(--bg-card, #1f2937);
    color: #60a5fa;
}

[data-theme="dark"] .view-toggle {
    background: var(--bg-secondary, #111827);
}

[data-theme="dark"] .view-btn.active {
    background: var(--bg-card, #1f2937);
}

/* ==================== CLICKABLE SUMMARY CARDS ==================== */
.summary-card {
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.summary-card.active {
    transform: translateY(-3px);
}

.summary-card.total.active {
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5), 0 8px 24px rgba(0,0,0,0.15);
}

.summary-card.excellent.active {
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.5), 0 8px 24px rgba(0,0,0,0.15);
}

.summary-card.good.active {
    box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.5), 0 8px 24px rgba(0,0,0,0.15);
}

.summary-card.poor.active {
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.5), 0 8px 24px rgba(0,0,0,0.15);
}

.summary-card.critical.active {
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.5), 0 8px 24px rgba(0,0,0,0.15);
}

.summary-card.offline.active {
    box-shadow: 0 0 0 2px rgba(107, 114, 128, 0.5), 0 8px 24px rgba(0,0,0,0.15);
}