/* ============================================================
   VPN Server Monitor - Styles
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* --- Text colors --- */
.text-blue { color: #2563eb; }
.text-green { color: #16a34a; }
.text-orange { color: #ea580c; }
.text-purple { color: #9333ea; }

/* --- Card --- */
.card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    padding: 16px;
}
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-6 { margin-top: 24px; }
.hidden { display: none !important; }

/* --- Header --- */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 50;
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.header-icon { font-size: 30px; }
.header-title { font-size: 20px; font-weight: 700; color: #1f2937; }
.header-subtitle { font-size: 12px; color: #6b7280; }
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* --- Sync status --- */
.sync-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
}
.sync-ok { background: #d1fae5; color: #065f46; }
.sync-loading { background: #dbeafe; color: #1e40af; }
.sync-error { background: #fee2e2; color: #991b1b; }

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}
.pulse-blue { background: #3b82f6; }
.pulse-green { background: #22c55e; }
.pulse-red { background: #ef4444; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* --- Cache badge --- */
.cache-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    background: #f3f4f6;
    font-size: 11px;
    color: #6b7280;
}

/* --- Buttons --- */
.btn-refresh {
    background: #2563eb;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-refresh:hover { background: #1d4ed8; }

.btn-load-more {
    background: #2563eb;
    color: white;
    padding: 12px 32px;
    border-radius: 9999px;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-load-more:hover { background: #1d4ed8; }
.btn-load-more:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Main layout --- */
.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* --- Stats grid --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
@media (min-width: 768px) {
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
.stat-card {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    transition: transform 0.3s ease;
}
.stat-card:hover { transform: translateY(-5px); }
.stat-icon { font-size: 30px; margin-bottom: 8px; }
.stat-value { font-size: 24px; font-weight: 700; }
.stat-label { font-size: 14px; color: #6b7280; }

/* --- Snapshot bar --- */
.snapshot-bar {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 14px;
    color: #4b5563;
}
.snapshot-left, .snapshot-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* --- Search --- */
.search-input {
    width: 100%;
    padding: 10px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}
.search-input:focus { border-color: #667eea; }

/* --- Section title --- */
.section-title {
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 16px;
}

/* --- Filters --- */
.filter-group { margin-bottom: 16px; }
.filter-group:last-child { margin-bottom: 0; }
.filter-label { font-size: 14px; color: #4b5563; margin-bottom: 8px; }
.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.filter-tag {
    padding: 8px 16px;
    border-radius: 20px;
    background: #f3f4f6;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    font-size: 14px;
}
.filter-tag:hover { background: #e5e7eb; }
.filter-tag.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* --- Charts --- */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}
@media (min-width: 1024px) {
    .charts-grid { grid-template-columns: 1fr 1fr; }
}
.chart-container { width: 100%; height: 300px; }

/* --- List header --- */
.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.list-count { font-size: 14px; color: #6b7280; }

/* --- Server list --- */
.server-list { display: flex; flex-direction: column; gap: 12px; }

.server-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}
.server-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transform: translateX(4px);
}
.server-card-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.server-card-info { flex: 1; min-width: 0; }
.server-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.server-flag { font-size: 24px; }
.server-country { font-weight: 700; color: #1f2937; }
.server-city { color: #6b7280; }
.server-host {
    font-size: 14px;
    color: #6b7280;
    font-family: monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.server-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    align-items: center;
}
.server-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
.server-side {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}
.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-info { background: #cce5ff; color: #004085; }
.badge-danger { background: #f8d7da; color: #721c24; }

/* --- Speed indicator --- */
.speed-indicator {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: bold;
    flex-shrink: 0;
    text-align: center;
    line-height: 1.2;
}
.speed-high { background: #d4edda; color: #155724; }
.speed-medium { background: #fff3cd; color: #856404; }
.speed-low { background: #f8d7da; color: #721c24; }
.speed-none { background: #e9ecef; color: #6c757d; }

/* --- Download button --- */
.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    position: relative;
    z-index: 10;
}
.btn-download-active {
    background: #2563eb;
    color: white;
}
.btn-download-active:hover {
    background: #1d4ed8;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}
.btn-download-disabled {
    background: #e9ecef;
    color: #adb5bd;
    cursor: not-allowed;
}

/* --- Copy button --- */
.btn-copy {
    background: #f3f4f6;
    color: #4b5563;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-copy:hover { background: #e5e7eb; }

/* --- Metrics --- */
.metrics { display: flex; flex-direction: column; gap: 16px; }
.metric-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}
.metric-label { font-size: 14px; color: #6b7280; }
.metric-value { font-size: 14px; font-weight: 700; }

/* --- Progress bar --- */
.progress-bar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
    width: 0%;
}
.bg-blue { background: #2563eb; }
.bg-green { background: #16a34a; }
.bg-orange { background: #ea580c; }

/* --- Loading --- */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    color: white;
}
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.85);
    color: white;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.toast.show { opacity: 1; }

/* --- Footer --- */
.footer {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    margin-top: 32px;
    padding: 24px;
    text-align: center;
}
.footer-text { font-size: 14px; color: #4b5563; }
.footer-link { color: #2563eb; text-decoration: underline; }
.footer-sub { font-size: 12px; color: #9ca3af; margin-top: 8px; }

/* --- Empty state --- */
.empty-state {
    text-align: center;
    padding: 32px;
    color: #9ca3af;
}

/* --- Animation --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeIn 0.5s ease forwards; }
