/* Modern NetScope Design System */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --accent: #3b82f6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --bg-primary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-hover: #f8fafc;
    
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 移动端滚动优化 */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    touch-action: manipulation;
}

/* 防止移动端双击缩放 */
button, a, input {
    touch-action: manipulation;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding-bottom: 3rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Navbar */
.navbar {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-icon {
    width: 1.5rem;
    height: 1.5rem;
    color: var(--primary);
}

.nav-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.nav-title .accent {
    color: var(--primary);
}

.icon-btn {
    padding: 0.5rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.icon-btn i {
    width: 1.25rem;
    height: 1.25rem;
}

/* Main Container */
.main-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* IP Cards Grid */
.ip-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.ip-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
    box-shadow: var(--shadow-sm);
}

.ip-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-icon-bg {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    opacity: 0.08;
    transition: opacity 0.3s;
}

.ip-card:hover .card-icon-bg {
    opacity: 0.15;
}

.card-icon-bg i {
    width: 4rem;
    height: 4rem;
    color: var(--primary);
}

.card-icon-bg.domestic i {
    color: var(--success);
}

.card-icon-bg.exit i {
    color: #8b5cf6;
}

.card-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.card-value {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    word-break: break-all;
    min-height: 1.5rem;
}

.card-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.loading-shimmer {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.25rem;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

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

/* Map Section */
.map-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

/* Search Container */
.search-container {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    background: var(--bg-card);
}

.search-wrapper {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.125rem;
    height: 1.125rem;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 0.625rem 0.875rem 0.625rem 2.5rem;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    color: var(--text-primary);
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    background: var(--bg-card);
}

.search-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.625rem 1.25rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.search-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.search-btn i {
    width: 0.9rem;
    height: 0.9rem;
}

/* Query Result */
.query-result {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    display: none;
}

.query-result.active {
    display: block;
}

.query-result-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.query-result-item {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    transition: all 0.2s;
}

.query-result-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.query-result-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.query-result-value {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-all;
}

.query-result p {
    margin: 0;
    display: none;
}

/* Map Wrapper */
.map-wrapper {
    position: relative;
    height: 500px;
}

#map-container {
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 0;
}

/* Leaflet Customization */
.leaflet-container {
    font-family: inherit;
}

.leaflet-popup-content-wrapper {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.leaflet-popup-content {
    margin: 1rem 1.25rem;
    line-height: 1.5;
    font-size: 0.875rem;
}

.leaflet-control-layers {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}

/* Connectivity Section */
.connectivity-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-top: 1.25rem;
    box-shadow: var(--shadow-sm);
}

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

.section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title i {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--primary);
}

.section-title h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.retest-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: var(--bg-hover);
    color: var(--primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.retest-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.retest-btn i {
    width: 0.9rem;
    height: 0.9rem;
}

.service-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 0.625rem;
}

.service-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.625rem 0.5rem;
    text-align: center;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.service-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.service-item:active {
    transform: translateY(0);
}

.service-status {
    position: absolute;
    top: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background: var(--text-muted);
}

.service-status.online {
    background: var(--success);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.service-status.offline {
    background: var(--danger);
}

.service-status.loading {
    background: var(--warning);
    animation: pulse 1.5s infinite;
}

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

.service-name {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
    margin-top: 0.625rem;
}

.service-latency {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.service-ip {
    display: none;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-container {
        padding: 1.25rem;
    }
    
    .ip-cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

@media (max-width: 768px) {
    body {
        padding-bottom: 2rem;
    }
    
    .main-container {
        padding: 1rem 0.875rem;
    }
    
    .nav-container {
        padding: 0 0.875rem;
        height: 3.5rem;
    }
    
    .nav-title {
        font-size: 1.125rem;
    }
    
    .nav-icon {
        width: 1.375rem;
        height: 1.375rem;
    }
    
    .ip-cards-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }
    
    .ip-card {
        padding: 1rem 0.875rem;
    }
    
    .card-label {
        font-size: 0.6875rem;
    }
    
    .card-value {
        font-size: 0.875rem;
    }
    
    .map-section {
        border-radius: var(--radius-md);
    }
    
    .search-container {
        padding: 0.875rem;
        gap: 0.625rem;
    }
    
    .search-wrapper {
        min-width: 100%;
    }
    
    .search-input {
        font-size: 0.875rem;
        padding: 0.75rem 0.875rem 0.75rem 2.5rem;
    }
    
    .search-btn {
        width: 100%;
        justify-content: center;
        padding: 0.75rem 1.25rem;
        font-size: 0.875rem;
    }
    
    .query-result {
        padding: 0.875rem;
    }
    
    .query-result-content {
        grid-template-columns: 1fr;
        gap: 0.625rem;
    }
    
    .query-result-item {
        padding: 0.875rem;
    }
    
    .query-result-label {
        font-size: 0.6875rem;
    }
    
    .query-result-value {
        font-size: 0.875rem;
    }
    
    .map-wrapper {
        height: 380px;
    }
    
    .connectivity-section {
        padding: 0.875rem;
        margin-top: 1rem;
    }
    
    .section-header {
        gap: 0.625rem;
    }
    
    .section-title h2 {
        font-size: 0.9375rem;
    }
    
    .section-title i {
        width: 1.125rem;
        height: 1.125rem;
    }
    
    .retest-btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.8125rem;
    }
    
    .service-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.625rem;
    }
    
    .service-item {
        padding: 0.75rem 0.5rem;
    }
    
    .service-name {
        font-size: 0.8125rem;
    }
    
    .service-latency {
        font-size: 0.6875rem;
    }
    
    /* 优化地图控件在移动端的显示 */
    .leaflet-control-zoom {
        margin-top: 0.5rem !important;
        margin-right: 0.5rem !important;
    }
    
    .leaflet-control-layers {
        margin-top: 0.5rem !important;
        margin-right: 0.5rem !important;
    }
    
    .leaflet-popup-content-wrapper {
        max-width: 240px;
    }
    
    .leaflet-popup-content {
        margin: 0.75rem 1rem;
        font-size: 0.8125rem;
    }
}

@media (max-width: 480px) {
    .main-container {
        padding: 0.875rem 0.75rem;
    }
    
    .nav-container {
        padding: 0 0.75rem;
        height: 3.25rem;
    }
    
    .nav-title {
        font-size: 1rem;
    }
    
    .nav-icon {
        width: 1.25rem;
        height: 1.25rem;
    }
    
    .icon-btn {
        padding: 0.375rem;
    }
    
    .icon-btn i {
        width: 1.125rem;
        height: 1.125rem;
    }
    
    .ip-cards-grid {
        gap: 0.625rem;
    }
    
    .ip-card {
        padding: 0.875rem 0.75rem;
    }
    
    .card-label {
        font-size: 0.625rem;
        margin-bottom: 0.375rem;
    }
    
    .card-value {
        font-size: 0.8125rem;
    }
    
    .card-icon-bg {
        top: 0.375rem;
        right: 0.375rem;
    }
    
    .card-icon-bg i {
        width: 3.5rem;
        height: 3.5rem;
    }
    
    .search-container {
        padding: 0.75rem;
    }
    
    .search-input {
        font-size: 0.875rem;
        padding: 0.6875rem 0.75rem 0.6875rem 2.375rem;
    }
    
    .search-icon {
        left: 0.75rem;
        width: 1rem;
        height: 1rem;
    }
    
    .search-btn {
        padding: 0.6875rem 1rem;
        font-size: 0.875rem;
    }
    
    .search-btn i {
        width: 1rem;
        height: 1rem;
    }
    
    .query-result {
        padding: 0.75rem;
    }
    
    .query-result-item {
        padding: 0.75rem;
    }
    
    .map-wrapper {
        height: 320px;
    }
    
    .connectivity-section {
        padding: 0.75rem;
    }
    
    .section-title h2 {
        font-size: 0.875rem;
    }
    
    .section-title i {
        width: 1rem;
        height: 1rem;
    }
    
    .retest-btn {
        padding: 0.4375rem 0.75rem;
        font-size: 0.75rem;
    }
    
    .retest-btn i {
        width: 0.875rem;
        height: 0.875rem;
    }
    
    .service-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    .service-item {
        padding: 0.625rem 0.375rem;
    }
    
    .service-status {
        top: 0.375rem;
        width: 0.375rem;
        height: 0.375rem;
    }
    
    .service-name {
        font-size: 0.6875rem;
        margin-top: 0.5rem;
        margin-bottom: 0.25rem;
    }
    
    .service-latency {
        font-size: 0.625rem;
    }
    
    /* 移动端地图控件优化 */
    .leaflet-control-zoom {
        margin-top: 0.375rem !important;
        margin-right: 0.375rem !important;
    }
    
    .leaflet-control-zoom a {
        width: 28px !important;
        height: 28px !important;
        line-height: 28px !important;
        font-size: 18px !important;
    }
    
    .leaflet-control-layers {
        margin-top: 0.375rem !important;
        margin-right: 0.375rem !important;
    }
    
    .leaflet-popup-content-wrapper {
        max-width: 200px;
    }
    
    .leaflet-popup-content {
        margin: 0.625rem 0.875rem;
        font-size: 0.75rem;
        line-height: 1.4;
    }
}

@media (max-width: 360px) {
    .service-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .service-item {
        padding: 0.75rem 0.5rem;
    }
    
    .service-name {
        font-size: 0.75rem;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .icon-btn,
    .search-btn,
    .retest-btn,
    .service-item {
        -webkit-tap-highlight-color: transparent;
    }
    
    .icon-btn:active {
        background: var(--bg-hover);
        transform: scale(0.95);
    }
    
    .search-btn:active {
        transform: scale(0.98);
    }
    
    .retest-btn:active {
        transform: scale(0.98);
    }
    
    .service-item:active {
        transform: scale(0.98);
    }
    
    /* 增大触摸目标 */
    .icon-btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    .search-btn {
        min-height: 44px;
    }
    
    .retest-btn {
        min-height: 40px;
    }
    
    .service-item {
        min-height: 70px;
    }
}

/* 横屏模式优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .map-wrapper {
        height: 280px;
    }
    
    .ip-cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) and (orientation: landscape) {
    .map-wrapper {
        height: 240px;
    }
    
    .nav-container {
        height: 3rem;
    }
    
    .main-container {
        padding: 0.75rem;
    }
}
