/* ========== 基础变量 ========== */
:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #1e3a8a;
    --success: #10b981;
    --success-light: #065f46;
    --warning: #f59e0b;
    --warning-light: #92400e;
    --danger: #ef4444;
    --danger-light: #991b1b;
    --text-primary: #ffffff;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --bg-body: #0f172a;
    --bg-sidebar: #1e293b;
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --border: #334155;
    --border-light: #475569;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.3);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}

.dark-mode {
    --bg-body: #0f172a;
    --bg-sidebar: #1e293b;
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --text-primary: #ffffff;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ========== 全局重置 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body { font-family: 'Segoe UI', 'Microsoft YaHei', system-ui, sans-serif; background: var(--bg-body); color: var(--text-primary); line-height: 1.6; font-size: 14px; overflow: hidden; }
button { cursor: pointer; font-family: inherit; }
input, select { font-family: inherit; font-size: inherit; }

/* ========== 应用容器 ========== */
.app-container { display: flex; min-height: 100vh; position: relative; }

/* 主内容包装器 */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 60px);
}

/* ========== 右上角联系方式 ========== */
.contact-badge {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2000;
    box-shadow: var(--shadow);
    transition: var(--transition);
}
.contact-badge:hover { transform: scale(1.1); box-shadow: var(--shadow-lg); }
.contact-badge i { color: white; font-size: 18px; }

.contact-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}
.contact-modal.show { display: flex; }

.contact-modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.contact-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.contact-modal-header h3 { display: flex; align-items: center; gap: 10px; color: var(--primary); }
.contact-modal-header h3 i { font-size: 20px; }
.contact-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 50%;
    font-size: 18px;
    transition: var(--transition);
}
.contact-close:hover { background: var(--bg-body); color: var(--text-primary); }

.contact-modal-body { padding: 24px; }

.contact-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.contact-item:last-child { border-bottom: none; }
.contact-item i {
    width: 40px;
    height: 40px;
    background: var(--primary-light);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 16px;
}
.contact-item .info { flex: 1; }
.contact-item .info .label { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.contact-item .info .value { font-size: 15px; color: var(--text-primary); font-weight: 500; }

/* ========== 左侧侧边栏 ========== */
.sidebar {
    width: 240px;
    min-width: 240px;
    height: 100vh;
    background: linear-gradient(180deg, var(--bg-sidebar) 0%, #0f172a 100%);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}
.sidebar-header i {
    font-size: 26px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* 导航组 */
.sidebar-nav { 
    flex: 1; 
    padding: 12px 0; 
    overflow-y: auto;
    scrollbar-width: thin;
}

.nav-group { margin-bottom: 4px; }

/* 可折叠导航组 */
.nav-group-title {
    padding: 12px 20px 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}
.nav-group-title:hover { background: rgba(255, 255, 255, 0.05); color: var(--text-secondary); }
.nav-group-title i { font-size: 14px; width: 16px; color: var(--text-muted); }
.nav-group-title .arrow {
    margin-left: auto;
    transition: transform 0.2s ease;
    font-size: 10px;
}
.nav-group.collapsed .nav-group-title .arrow { transform: rotate(-90deg); }
.nav-group.collapsed > .nav-group-items {
    display: none !important;
}

.nav-group-items { padding: 0 8px; }

.nav-link {
    width: 100%;
    padding: 14px 14px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
    text-align: left;
    position: relative;
    overflow: hidden;
}
.nav-link i { width: 20px; font-size: 15px; text-align: center; color: var(--text-muted); }
.nav-link:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    transform: translateX(4px);
}
.nav-link:hover i { color: var(--primary); }
.nav-link.active {
    background: var(--bg-card-hover);
    color: var(--primary);
    font-weight: 600;
    border-left: 3px solid var(--primary);
}
.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary);
}
.nav-link.active i { color: var(--primary); }

.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }

.theme-toggle {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius);
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}
.theme-toggle:hover { border-color: var(--primary); color: var(--primary); }

/* ========== 右侧主内容区 ========== */
.main-content {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-body);
    scrollbar-width: thin;
    max-width: 100%;
    display: flex;
    flex-direction: column;
}

/* 面板 */
.tab-panel {
    display: none;
    padding: 0;
    flex: 1;
}
.tab-panel.active { display: flex; flex-direction: column; }
.tab-panel.active { display: block; }

.panel-header {
    margin-bottom: 24px;
    padding: 20px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.panel-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.panel-header h2 i {
    color: var(--primary);
    font-size: 20px;
}

.panel-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* ========== 表单样式 ========== */
.tool-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    max-width: 100%;
    position: relative;
    overflow: hidden;
}
.tool-form::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
}

.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-group input,
.form-group select {
    width: 100%;
    padding: 14px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-body);
    color: var(--text-primary);
    transition: var(--transition);
    font-size: 15px;
    font-weight: 500;
}
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2), 0 0 20px rgba(59, 130, 246, 0.1);
    background: var(--bg-card);
}

.form-row {
    display: flex;
    gap: 16px;
}
.form-row .form-group { flex: 1; }

/* ========== 按钮 ========== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}
.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
    background: var(--bg-body);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

/* ========== 结果框 ========== */
.result-box {
    margin-top: 24px;
    padding: 24px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 2px solid var(--border);
    border-left: 4px solid var(--primary);
    box-shadow: var(--shadow-lg);
}
.result-box h4 {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}
.result-box .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    font-family: 'Courier New', monospace;
    text-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

/* ========== 科学计算器 ========== */
.calc-wrapper {
    max-width: 450px;
    margin: 0 auto;
    padding: 24px;
}

.calc-display {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    margin-bottom: 20px;
    font-size: 36px;
    font-weight: 700;
    text-align: right;
    box-shadow: var(--shadow-lg), 0 0 30px rgba(59, 130, 246, 0.2);
    color: var(--primary);
    font-family: 'Courier New', monospace;
    overflow-x: auto;
    position: relative;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}
.calc-display::before {
    content: '>';
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--success);
    font-size: 28px;
    opacity: 0.8;
}

.calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 2px solid var(--border);
    box-shadow: var(--shadow-lg);
}

.calc-btn {
    padding: 16px 10px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    font-size: 18px;
    font-weight: 600;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    color: var(--text-primary);
}
.calc-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    transition: left 0.5s;
}
.calc-btn:hover::before {
    left: 100%;
}

.calc-btn.number {
    background: var(--bg-body);
    border-color: var(--border);
}
.calc-btn.number:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    color: var(--primary);
}

.calc-btn.operator {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary);
    border-color: rgba(59, 130, 246, 0.5);
}
.calc-btn.operator:hover {
    background: var(--primary);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.5);
}

.calc-btn.function {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.5);
}
.calc-btn.function:hover {
    background: var(--success);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.5);
}

.calc-btn.clear {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.5);
}
.calc-btn.clear:hover {
    background: var(--danger);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.5);
}

.calc-btn.equals {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #ffffff;
    grid-row: span 2;
    border: none;
    font-size: 24px;
    font-weight: 700;
}
.calc-btn.equals:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.6);
}

/* ========== 单位换算 ========== */
.converter-box {
    display: flex;
    align-items: stretch;
    gap: 20px;
    margin: 24px 0;
}
.converter-input,
.converter-output {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.converter-input input,
.converter-output input {
    width: 100%;
    padding: 14px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-body);
    color: var(--text-primary);
    transition: var(--transition);
    font-size: 15px;
    font-weight: 500;
}
.converter-input input:focus,
.converter-output input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2), 0 0 20px rgba(59, 130, 246, 0.1);
    background: var(--bg-card);
}
.converter-equals {
    font-size: 32px;
    color: var(--primary);
    font-weight: 700;
    align-self: center;
    text-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

/* ========== 进制转换 ========== */
.base-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

/* ========== 计算选项卡 ========== */
.calc-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.calc-tab { padding: 10px 20px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-secondary); border-radius: var(--radius); font-size: 14px; cursor: pointer; transition: var(--transition); }
.calc-tab:hover { border-color: var(--primary); color: var(--primary); }
.calc-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ========== 国标内容样式 ========== */
.gb-tree { padding: 10px 0; }
.gb-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}
.gb-item:hover { background: var(--bg-body); }
.gb-item .gb-code {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    font-family: monospace;
}
.gb-item .gb-title {
    font-size: 14px;
    color: var(--text-primary);
    margin-top: 4px;
}
.gb-item .gb-category {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ========== 响应式 ========== */
@media (max-width: 900px) {
    .sidebar { position: fixed; left: -280px; z-index: 1000; transition: left 0.3s; }
    .sidebar.show { left: 0; }
    .main-content { margin-left: 0; }
    .form-row { flex-direction: column; }
    .base-grid { grid-template-columns: 1fr; }
    .converter-main { flex-direction: column; }
    .converter-equals { transform: rotate(90deg); }
}

@media (max-width: 600px) {
    .panel-header h2 { font-size: 20px; }
    .tool-form { padding: 16px; }
    .calc-display { padding: 16px; font-size: 24px; }
    .calc-buttons { grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 12px; }
    .calc-btn { padding: 12px; font-size: 16px; }
    .contact-modal-content { width: 95%; margin: 16px; }
    .footer-text { flex-direction: column; gap: 6px; }
}

/* 滚动条样式 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ========== 页脚备案信息 ========== */
.site-footer {
    width: 100%;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 18px 24px;
    flex-shrink: 0;
    margin-top: auto;
    position: relative;
}
.site-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
}

.footer-content {
    max-width: 100%;
    margin: 0 auto;
}

.footer-text {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    justify-content: center;
    font-size: 13px;
    color: var(--text-secondary);
}

.footer-item {
    display: inline-flex;
    align-items: center;
}

.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.footer-link:hover {
    color: var(--primary);
    text-decoration: none;
}

.footer-link i {
    font-size: 12px;
}
