/* ============================================
   SCHOOL NETWORK MONITOR - Dashboard Styles
   Dark theme with glassmorphism design
   ============================================ */

/* --- RESET & BASE --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --border-glass: rgba(255, 255, 255, 0.08);
    --text-primary: #f0f4ff;
    --text-secondary: #8b9dc3;
    --text-muted: #4a5568;
    --green: #00ff88;
    --green-dim: rgba(0, 255, 136, 0.15);
    --red: #ff4757;
    --red-dim: rgba(255, 71, 87, 0.15);
    --amber: #ffb800;
    --amber-dim: rgba(255, 184, 0, 0.15);
    --cyan: #00d4ff;
    --radius: 16px;
    --radius-sm: 8px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Animated background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(0, 212, 255, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(0, 255, 136, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(255, 71, 87, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* --- HEADER --- */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-glass);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    font-size: 32px;
    filter: drop-shadow(0 0 12px rgba(0, 212, 255, 0.5));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-4px);
    }
}

.logo h1 {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--cyan), var(--green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.badge-demo {
    background: var(--amber-dim);
    color: var(--amber);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    border: 1px solid rgba(255, 184, 0, 0.3);
    animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.last-update {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.update-dot {
    width: 8px;
    height: 8px;
    background: var(--green);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.5);
    }

    70% {
        box-shadow: 0 0 0 8px rgba(0, 255, 136, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(0, 255, 136, 0);
    }
}

.btn-collect {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.15), rgba(0, 255, 136, 0.1));
    border: 1px solid rgba(0, 212, 255, 0.3);
    color: var(--cyan);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    transition: var(--transition);
}

.btn-collect:hover {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.25), rgba(0, 255, 136, 0.2));
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.2);
}

.btn-collect:active {
    transform: translateY(0);
}

.btn-collect.loading .btn-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- STATS BAR --- */
.stats-bar {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 12px;
    padding: 20px 32px;
    overflow-x: auto;
}

.stat-card {
    flex: 1;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 18px 16px;
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    transition: var(--transition);
}

.stat-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.stat-number {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -1px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-online .stat-number {
    color: var(--green);
}

.stat-offline .stat-number {
    color: var(--red);
}

/* --- SCHOOL CARDS GRID --- */
.schools-grid {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    padding: 8px 32px 24px;
}

.school-card {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
    animation: fadeInUp 0.5s ease forwards;
    opacity: 0;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.school-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
    border-color: rgba(255, 255, 255, 0.12);
}

.school-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 12px;
    border-bottom: 1px solid var(--border-glass);
}

.school-name {
    display: flex;
    align-items: center;
    gap: 10px;
}

.school-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.school-name h3 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.school-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
}

.school-status.online {
    background: var(--green-dim);
    color: var(--green);
}

.school-status.offline {
    background: var(--red-dim);
    color: var(--red);
}

.school-status.partial {
    background: var(--amber-dim);
    color: var(--amber);
}

.status-pulse {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.school-status.online .status-pulse {
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.5);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(0, 255, 136, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(0, 255, 136, 0);
    }
}

.school-status.offline .status-pulse {
    animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.6);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(255, 71, 87, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 71, 87, 0);
    }
}

.school-links {
    padding: 14px 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.school-card-footer {
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.15);
    border-top: 1px solid var(--border-glass);
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
    display: flex;
    justify-content: flex-end;
}

.link-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: var(--transition);
}

.link-row:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-glass);
}

.link-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.link-status-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.link-status-icon.online {
    background: var(--green-dim);
}

.link-status-icon.offline {
    background: var(--red-dim);
}

.link-name {
    font-size: 13px;
    font-weight: 600;
}

.link-ip {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
}

.link-metrics {
    display: flex;
    gap: 12px;
    align-items: center;
}

.metric {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
}

.metric-value {
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.metric-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value.down {
    color: var(--cyan);
}

.metric-value.up {
    color: var(--green);
}

.metric-value.offline-text {
    color: var(--red);
}

/* --- HISTORY TIMELINE --- */
.history-section {
    position: relative;
    z-index: 1;
    padding: 8px 32px 24px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.history-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.history-controls {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    padding: 3px;
}

.chart-btn {
    padding: 6px 14px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    transition: var(--transition);
}

.chart-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.chart-btn.active {
    background: rgba(0, 212, 255, 0.15);
    color: var(--cyan);
}

.history-timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hist-snapshot {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
}

.hist-snapshot.hist-current {
    border-color: rgba(0, 212, 255, 0.2);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.05);
}

.hist-snapshot:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.hist-time {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-glass);
    background: rgba(255, 255, 255, 0.01);
}

.hist-time-hour {
    font-size: 15px;
    font-weight: 700;
    color: var(--cyan);
    font-variant-numeric: tabular-nums;
}

.hist-time-date {
    font-size: 12px;
    color: var(--text-muted);
}

.hist-schools {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1px;
    background: var(--border-glass);
}

.hist-school {
    padding: 12px 16px;
    background: var(--bg-secondary);
}

.hist-school-name {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
}

.hist-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.hist-status {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-left: auto;
}

.hist-status.online {
    background: var(--green);
}

.hist-status.offline {
    background: var(--red);
}

.hist-status.partial {
    background: var(--amber);
}

.hist-links-header {
    display: grid;
    grid-template-columns: 22px 1fr 50px 60px 60px;
    gap: 6px;
    padding: 2px 6px;
    margin-bottom: 2px;
}

.hist-col-label {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    text-align: right;
    letter-spacing: 0.5px;
}

.hist-col-label.dl-label {
    color: rgba(76, 175, 80, 0.6);
}

.hist-col-label.ul-label {
    color: rgba(33, 150, 243, 0.6);
}

.hist-link {
    display: grid;
    grid-template-columns: 22px 1fr 50px 60px 60px;
    gap: 6px;
    align-items: center;
    padding: 4px 6px;
    border-radius: 4px;
    transition: var(--transition);
}

.hist-link:hover {
    background: rgba(255, 255, 255, 0.03);
}

.hist-link-off {
    opacity: 0.5;
}

.hist-link-icon {
    font-size: 12px;
    text-align: center;
}

.hist-link-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hist-metric {
    font-size: 13px;
    font-weight: 700;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.hist-metric.lat {
    color: var(--text-muted);
}

.hist-metric.dl {
    color: #4CAF50;
}

.hist-metric.ul {
    color: #2196F3;
}

.hist-metric.off {
    color: var(--red);
    font-size: 11px;
    grid-column: 3 / -1;
    text-align: right;
}

/* --- ALERTS SECTION --- */
.alerts-section {
    position: relative;
    z-index: 1;
    padding: 0 32px 32px;
}

.alerts-section h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 14px;
}

.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 300px;
    overflow-y: auto;
}

.alert-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-glass);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    font-size: 13px;
    transition: var(--transition);
    animation: fadeInUp 0.3s ease forwards;
}

.alert-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.alert-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.alert-time {
    font-size: 11px;
    color: var(--text-muted);
    min-width: 70px;
    font-family: 'Courier New', monospace;
}

.alert-message {
    flex: 1;
    color: var(--text-secondary);
}

.alert-item.link_down {
    border-left: 3px solid var(--red);
}

.alert-item.link_up {
    border-left: 3px solid var(--green);
}

.alert-item.link_slow {
    border-left: 3px solid var(--amber);
}

.no-alerts {
    color: var(--text-muted);
    font-size: 13px;
    padding: 20px;
    text-align: center;
}

/* --- LOADING --- */
.loading-placeholder {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 60px;
    color: var(--text-secondary);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-glass);
    border-top-color: var(--cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* --- FOOTER --- */
.footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 12px;
    border-top: 1px solid var(--border-glass);
}

/* --- SCROLLBAR --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 12px;
        padding: 12px 16px;
    }

    .header-right {
        width: 100%;
        justify-content: space-between;
    }

    .stats-bar {
        padding: 12px 16px;
        gap: 8px;
    }

    .stat-card {
        padding: 12px 10px;
    }

    .stat-number {
        font-size: 22px;
    }

    .schools-grid {
        grid-template-columns: 1fr;
        padding: 8px 16px 24px;
    }

    .charts-section,
    .alerts-section {
        padding-left: 16px;
        padding-right: 16px;
    }

    .chart-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
}