/* ============================================
   Synolon - 主样式文件 v2.2.0
   现代化暗黑主题设计系统
   
   样式索引 (按行号)
   ============================================
   
   [设计系统]
   - CSS变量/令牌    : ~15
   - 颜色系统        : ~20
   - 字体系统        : ~90
   - 间距/圆角       : ~110
   
   [全局样式]
   - 重置样式        : ~150
   - 滚动条          : ~180
   
   [布局组件]
   - 顶部栏          : ~200
   - 侧边栏          : ~350
   - 主内容区        : ~550
   - 工具面板        : ~600
   
   [通用组件]
   - Toast提示       : ~700
   - 响应式          : ~800
   
   ============================================ */

/* ===== 字体加载 - 可选在线字体，本地优先回退 ===== */
/* 在线字体作为可选增强，不影响离线使用 */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&family=Noto+Sans+SC:wght@400;500;600;700&display=swap');

/* ===== CSS变量 - 设计令牌 ===== */
:root {
    /* 颜色系统 - 暗黑主题 */
    --bg-base: #0c0d10;
    --bg-surface: #13151a;
    --bg-elevated: #1a1d24;
    --bg-overlay: #21252e;
    --bg-hover: #282d38;
    --bg-active: #2f3542;
    
    /* 边框 */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.1);
    --border-emphasis: rgba(255, 255, 255, 0.15);
    
    /* 文字 */
    --text-primary: #f0f2f5;
    --text-secondary: #9ba3b5;
    --text-tertiary: #6b7280;
    --text-disabled: #4b5563;
    
    /* 主色调 - 青蓝渐变 */
    --primary-50: #e6fcff;
    --primary-100: #b3f5ff;
    --primary-200: #80eeff;
    --primary-300: #4de7ff;
    --primary-400: #26e0ff;
    --primary-500: #00d4ff;
    --primary-600: #00b8db;
    --primary-700: #0099b8;
    --primary-800: #007a94;
    --primary-900: #005c70;
    
    /* 强调色 - 橙色 */
    --accent-50: #fff5eb;
    --accent-100: #ffe4cc;
    --accent-200: #ffc999;
    --accent-300: #ffad66;
    --accent-400: #ff9233;
    --accent-500: #ff7700;
    --accent-600: #cc5f00;
    --accent-700: #994700;
    
    /* 状态色 */
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.1);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.1);
    
    /* 间距 */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 24px;
    --space-2xl: 32px;
    --space-3xl: 48px;
    
    /* 圆角 */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-2xl: 16px;
    
    /* 阴影 */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(0, 212, 255, 0.15);
    
    /* 过渡 */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.35s ease;
    
    /* 布局 */
    --sidebar-width: 260px;
    --sidebar-collapsed: 64px;
    --topbar-height: 60px;
    
    /* 字体 */
    --font-sans: 'IBM Plex Sans', 'Noto Sans SC', 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'IBM Plex Mono', 'SF Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, 'Courier New', monospace;
}

/* ===== 亮色主题 ===== */
[data-theme="light"] {
    --bg-base: #f8f9fc;
    --bg-surface: #ffffff;
    --bg-elevated: #ffffff;
    --bg-overlay: #f3f4f6;
    --bg-hover: #e5e7eb;
    --bg-active: #d1d5db;
    
    --border-subtle: rgba(0, 0, 0, 0.04);
    --border-default: rgba(0, 0, 0, 0.08);
    --border-emphasis: rgba(0, 0, 0, 0.12);
    
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-tertiary: #9ca3af;
    --text-disabled: #d1d5db;
    
    --primary-500: #0099cc;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 20px rgba(0, 153, 204, 0.1);
}

/* ===== 重置和基础 ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-emphasis);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* ===== 选中文本 ===== */
::selection {
    background: var(--primary-500);
    color: white;
}

/* ===== 侧边栏 ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-default);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width var(--transition-normal), transform var(--transition-normal);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar.collapsed .logo span,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .version-info {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: var(--space-md);
}

.sidebar.collapsed .nav-item svg,
.sidebar.collapsed .logo-img {
    margin-right: 0;
}

.sidebar.collapsed .sidebar-header {
    padding: var(--space-md) var(--space-sm);
}

.sidebar.collapsed .logo {
    justify-content: center;
    padding: var(--space-sm);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg) var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
    min-height: var(--topbar-height);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    cursor: pointer;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.logo:hover {
    background: var(--bg-hover);
}

.logo:active {
    transform: scale(0.98);
}

.logo-img {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    transition: margin var(--transition-normal);
}

.logo span {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-400), var(--accent-500));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
    transition: opacity var(--transition-normal);
}

/* 导航容器 - 可滚动 */
.nav-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-overlay) transparent;
}

.nav-container::-webkit-scrollbar {
    width: 6px;
}

.nav-container::-webkit-scrollbar-track {
    background: transparent;
}

.nav-container::-webkit-scrollbar-thumb {
    background: var(--bg-overlay);
    border-radius: 3px;
}

.nav-container::-webkit-scrollbar-thumb:hover {
    background: var(--bg-hover);
}

.nav-section {
    padding: var(--space-lg) var(--space-md);
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    padding: 0 var(--space-md);
    margin-bottom: var(--space-sm);
    white-space: nowrap;
    transition: opacity var(--transition-normal);
}

.nav-item {
    display: flex;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-xs);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.15), rgba(0, 212, 255, 0.05));
    color: var(--primary-400);
    border-left: 2px solid var(--primary-500);
    margin-left: -1px;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    margin-right: var(--space-md);
    flex-shrink: 0;
    transition: margin var(--transition-normal);
}

.nav-item span {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    transition: opacity var(--transition-normal);
}

.sidebar-footer {
    margin-top: auto;
    padding: var(--space-lg);
    border-top: 1px solid var(--border-subtle);
}

.version-info {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-align: center;
    transition: opacity var(--transition-normal);
}

/* ===== 主内容区 ===== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition-normal);
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed);
}

/* ===== 顶部工具栏 ===== */
.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--space-xl);
    z-index: 50;
    backdrop-filter: blur(8px);
}

.mobile-menu-btn {
    display: none;
    position: absolute;
    left: var(--space-lg);
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-md);
    align-items: center;
    justify-content: center;
}

.mobile-menu-btn svg {
    width: 24px;
    height: 24px;
}

/* 主题按钮固定右侧 */
.topbar-actions {
    position: absolute;
    right: var(--space-xl);
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

/* ===== 网络状态指示器 ===== */
.network-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: default;
    transition: all 0.3s ease;
}

.network-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 6px rgba(52, 211, 153, 0.5);
    transition: all 0.3s ease;
}

.network-label {
    color: var(--text-tertiary);
    font-size: 12px;
}

.network-status.offline .network-dot {
    background: #f59e0b;
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
    animation: offline-pulse 2s ease-in-out infinite;
}

.network-status.offline .network-label {
    color: #f59e0b;
}

@keyframes offline-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ===== 离线提示条 ===== */
.offline-banner {
    display: none;
    background: rgba(245, 158, 11, 0.12);
    border-bottom: 1px solid rgba(245, 158, 11, 0.25);
    color: #f59e0b;
    font-size: 12px;
    text-align: center;
    padding: 6px 16px;
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    z-index: 999;
    transition: all 0.3s ease;
}

.offline-banner.show {
    display: block;
}

/* ===== 顶部信息区 ===== */
.topbar-info {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.info-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-md);
    background: var(--bg-overlay);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
    white-space: nowrap;
    flex-shrink: 0;
}

.info-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
}

.info-item:active {
    transform: scale(0.98);
}

.info-item svg {
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.info-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--primary-400);
}

.info-ts {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-tertiary);
    padding-left: var(--space-sm);
    border-left: 1px solid var(--border-subtle);
}

.info-divider {
    width: 1px;
    height: 24px;
    background: var(--border-default);
    flex-shrink: 0;
}

/* IP地址隐私保护 */
.ip-masked {
    letter-spacing: 1px;
}

#ipItem:hover .ip-masked,
#ipItem.revealed .ip-masked {
    color: var(--text-primary);
}

/* 时区选择器样式 */
.info-item-tz {
    position: relative;
}

.tz-dropdown-icon {
    width: 12px;
    height: 12px;
    color: var(--text-tertiary);
    margin-left: var(--space-xs);
    transition: transform var(--transition-fast);
}

.info-item-tz:hover .tz-dropdown-icon {
    color: var(--text-secondary);
}

.info-item-tz.open .tz-dropdown-icon {
    transform: rotate(180deg);
}

.tz-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 220px;
    max-height: 320px;
    overflow-y: auto;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
    padding: var(--space-sm) 0;
}

.tz-dropdown.show {
    display: block;
}

.tz-dropdown-title {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: var(--space-xs);
}

.tz-option {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tz-option:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.tz-option.selected {
    background: rgba(0, 212, 255, 0.1);
    color: var(--primary-400);
    font-weight: 500;
}

.tz-option.selected::before {
    content: '✓ ';
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg-hover);
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    background: var(--bg-active);
    color: var(--text-primary);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

.theme-toggle .moon-icon {
    display: none;
}

[data-theme="light"] .theme-toggle .sun-icon {
    display: none;
}

[data-theme="light"] .theme-toggle .moon-icon {
    display: block;
}

/* ===== 工具容器 ===== */
.tool-container {
    padding: var(--space-xl);
    max-width: 1400px;
    margin: 0 auto;
}

.tool-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tool-panel.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tool-header {
    margin-bottom: var(--space-xl);
}

.tool-info h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.tool-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===== 工具标签页 ===== */
.tool-tabs {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-xl);
    border-bottom: 1px solid var(--border-default);
    padding-bottom: var(--space-md);
    flex-wrap: wrap;
}

.tool-tab {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.tool-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.tool-tab.active {
    background: var(--primary-500);
    color: white;
    box-shadow: var(--shadow-glow);
}

.tool-tab svg {
    width: 18px;
    height: 18px;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

/* ===== Toast通知 ===== */
.toast-container {
    position: fixed;
    bottom: var(--space-xl);
    right: var(--space-xl);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    animation: slideIn 0.3s ease;
    max-width: 360px;
}

.toast.success {
    border-color: var(--success);
    background: linear-gradient(135deg, var(--success-bg), var(--bg-elevated));
}

.toast.error {
    border-color: var(--error);
    background: linear-gradient(135deg, var(--error-bg), var(--bg-elevated));
}

.toast.warning {
    border-color: var(--warning);
    background: linear-gradient(135deg, var(--warning-bg), var(--bg-elevated));
}

.toast.info {
    border-color: var(--info);
    background: linear-gradient(135deg, var(--info-bg), var(--bg-elevated));
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast.success .toast-icon {
    color: var(--success);
}

.toast.error .toast-icon {
    color: var(--error);
}

.toast.warning .toast-icon {
    color: var(--warning);
}

.toast.info .toast-icon {
    color: var(--info);
}

.toast-message {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-primary);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* ===== 响应式设计 ===== */

@media (max-width: 1400px) {
    .info-ts {
        display: none;
    }
}

@media (max-width: 1200px) {
    .topbar-info {
        gap: var(--space-sm);
    }
    
    .info-item {
        padding: var(--space-xs) var(--space-sm);
    }
    
    .info-divider {
        display: none;
    }
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .sidebar.collapsed ~ .main-content {
        margin-left: 0;
    }
    
    .mobile-menu-btn {
        display: flex;
    }
    
    .topbar-info {
        display: none;
    }
}

@media (max-width: 768px) {
    .tool-container {
        padding: var(--space-lg);
    }
    
    .tool-tabs {
        flex-wrap: wrap;
    }
    
    .tool-tab {
        flex: 1;
        min-width: 120px;
        justify-content: center;
    }
    
    .topbar {
        padding: 0 var(--space-lg);
    }
}

@media (max-width: 480px) {
    .tool-tab span {
        display: none;
    }
    
    .tool-tab {
        min-width: auto;
        padding: var(--space-md);
    }
}

/* ===== 返回起始页按钮 ===== */
.home-btn-container {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}

.home-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: 1px dashed var(--border-default);
    border-radius: var(--radius-lg);
    color: var(--text-tertiary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.home-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary-500);
    color: var(--primary-400);
}

.home-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.sidebar.collapsed .home-btn span {
    display: none;
}

.sidebar.collapsed .home-btn-container {
    padding: var(--space-sm);
}

.sidebar.collapsed .home-btn {
    padding: var(--space-sm);
    justify-content: center;
}
