/**
 * 全能在线工具箱 - 全局样式文件
 * 支持浅色/深色主题切换
 * 响应式布局，适配 PC / 平板 / 手机
 */

/* ==================== CSS 变量定义 ==================== */
:root {
    /* 浅色主题配色 */
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --bg-tertiary: #e5e7eb;
    
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    
    --border-color: #d1d5db;
    --border-hover: #9ca3af;
    
    --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: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    --transition: all 0.3s ease;
}

/* 深色主题配色 */
[data-theme="dark"] {
    --bg-primary: #1f2937;
    --bg-secondary: #111827;
    --bg-tertiary: #374151;
    
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-tertiary: #9ca3af;
    
    --border-color: #4b5563;
    --border-hover: #6b7280;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    transition: var(--transition);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==================== 通用样式 ==================== */
a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-hover);
}

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    outline: none;
}

input,
textarea,
select {
    font-family: inherit;
    font-size: inherit;
    outline: none;
}

/* ==================== 顶部导航栏 ==================== */
.navbar {
    background-color: var(--bg-primary);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 0.75rem 1.5rem;
}

.navbar-container {
    width: 97%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.navbar-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto; /* 让控件靠右 */
    padding-right: 0; /* 移除右侧内边距，让控件更靠右 */
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--primary-color);
    padding-left: 8rem; /* 给网站名称添加更多左侧内边距，让它不那么靠左边 */
}

.navbar-brand svg {
    width: 32px;
    height: 32px;
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.navbar-link {
    color: var(--text-secondary);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.navbar-link:hover,
.navbar-link.active {
    color: var(--primary-color);
    background-color: var(--bg-tertiary);
}

/* 搜索框 */
.navbar-search {
    position: relative;
    flex: 1;
    max-width: 300px;
}

.navbar-search input {
    width: 100%;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    transition: var(--transition);
}

.navbar-search input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.navbar-search svg {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-tertiary);
}

/* 语言选择器 */
.navbar-lang {
    position: relative;
}

.navbar-lang select {
    padding: 0.5rem 2rem 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1rem;
    padding-right: 2rem;
}

.navbar-lang select:focus {
    border-color: var(--primary-color);
}

/* 主题切换按钮 */
.navbar-theme {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    transition: var(--transition);
}

.navbar-theme:hover {
    background-color: var(--bg-tertiary);
    color: var(--primary-color);
}

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

/* ==================== 分类导航栏 ==================== */
.category-nav {
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 60px;
    z-index: 999;
    display: flex;
    justify-content: center;
}

.category-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.category-item {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    color: var(--text-secondary);
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.category-item svg {
    width: 20px;
    height: 20px;
    color: var(--text-tertiary);
}

.category-item:hover,
.category-item.active {
    color: var(--primary-color);
    background-color: var(--bg-secondary);
}

/* 分类下拉菜单 */
.category-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    max-width: 400px;
    padding: 0.5rem;
    display: none;
    z-index: 1000;
}

.category-item:hover .category-dropdown {
    display: block;
}

.category-dropdown-item {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    white-space: nowrap;
}

.category-dropdown-item:hover {
    background-color: var(--bg-secondary);
    color: var(--primary-color);
}

/* 帮助中心按钮样式 */
.help-center-btn {
    background-color: var(--primary-color);
    color: #ffffff !important;
    border-radius: var(--radius-md);
    margin-left: auto;
}

.help-center-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}

.help-center-btn svg {
    color: #ffffff;
}

/* ==================== 搜索栏 ==================== */
.search-bar {
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
}

.search-container {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    display: flex;
    align-items: center;
}

.search-container svg {
    position: absolute;
    left: 1rem;
    width: 24px;
    height: 24px;
    color: var(--text-tertiary);
}

.search-container input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
}

.search-container input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.search-container input::placeholder {
    color: var(--text-tertiary);
}

/* ==================== 主内容区域 ==================== */
.main {
    flex: 1;
    padding: 2rem 1.5rem;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ==================== 首页分类卡片 ==================== */
.home-section {
    margin-bottom: 3rem;
}

.home-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.1rem;
}

.home-card {
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 1.1rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    cursor: pointer;
    border: 1px solid transparent;
}

.home-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.home-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background-color: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.home-card-icon svg {
    width: 24px;
    height: 24px;
}

.home-card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.home-card-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ==================== 工具页面 ==================== */
.tool-page {
    display: none;
}

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

/* 全屏工具页面 */
.tool-page.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    background-color: var(--bg-secondary);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2rem;
}

.tool-page.fullscreen .tool-content {
    max-width: 1400px;
    margin: 0 auto;
}

/* 当工具页面全屏时，隐藏 body 滚动条 */
body.tool-open {
    overflow: hidden;
}

/* 专门放宽 Crontab 工具页内容宽度与输出可读性 */
#tool-crontab .tool-content {
    max-width: 1200px;
}
#crontabOutput {
    min-height: 420px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    overflow: auto;
}

/* 常用端口对照表页面更宽一些，输出更高、等宽不换行 */
#tool-portList .tool-content {
    max-width: 1600px;
}
#portListOutput {
    min-height: 360px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    overflow: auto;
}

/* 虚拟地址输出更长一些 */
.tool-input-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}
.tool-input-row .tool-input-group {
    flex: 1;
    margin-bottom: 0;
}

.tool-kv {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 0.5rem 1rem;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-secondary);
    min-height: 360px;
}
.tool-kv .kv-label {
    font-weight: 600;
    color: var(--text-primary);
}
.tool-kv .kv-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    cursor: pointer;
    word-break: break-all;
}
.tool-kv .kv-value:hover {
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.tool-header {
    margin-bottom: 2rem;
}

.tool-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.tool-desc {
    color: var(--text-secondary);
}

.tool-back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    transition: var(--transition);
}

.tool-back:hover {
    color: var(--primary-color);
}

/* 工具容器 */
.tool-container {
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
}

/* 输入输出区域 */
.tool-section {
    margin-bottom: 2rem;
}

.tool-section:last-child {
    margin-bottom: 0;
}

.tool-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.tool-textarea {
    width: 100%;
    min-height: 200px;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    resize: vertical;
    transition: var(--transition);
}

.tool-output-group .tool-textarea {
    font-size: 1rem;
    line-height: 1.8;
}

.uuid-output {
    font-size: 1.5rem !important;
    line-height: 2.2 !important;
    letter-spacing: 0.02em;
    padding-top: 1.35rem;
    padding-bottom: 1.35rem;
    min-height: 25rem !important;
}

.diff-output pre {
    white-space: pre-wrap;
}
.diff-added {
    color: #16a34a;
}
.diff-removed {
    color: #dc2626;
}

.tool-inline-nowrap {
    display: flex;
    gap: 1rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    align-items: center;
}

.tool-inline-nowrap .tool-option {
    white-space: nowrap;
}
.tool-textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* IP 信息工具输出框更大一些 */
#ipInfoOutput {
    min-height: 360px;
}

.tool-lines {
    width: 100%;
    min-height: 200px;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.95rem;
    line-height: 1.8;
    white-space: pre-wrap;
    overflow: auto;
}
.tool-lines .line {
    padding: 0.1rem 0.25rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
}
.tool-lines .line:hover {
    background-color: var(--bg-tertiary);
}

/* 常用端口对照表三列表格 */
.port-grid {
    display: grid;
    grid-template-columns: 160px 140px 1fr;
    gap: 0.5rem 1rem;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-secondary);
    min-height: 360px;
}
.port-grid .hdr {
    font-weight: 700;
    color: var(--text-primary);
}
.port-grid .cell {
    align-self: center;
    word-break: break-word;
}
.port-grid .cell.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.grid-select {
    display: grid;
    grid-template-columns: repeat(3, minmax(100px, 1fr));
    gap: 0.5rem;
    padding: 0.4rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-secondary);
    max-height: 240px;
    overflow: auto;
}
.grid-option {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--bg-primary);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    font-size: 0.85rem;
}
.grid-option:hover {
    background-color: var(--bg-tertiary);
}
.grid-option.active {
    border-color: var(--primary-color);
    background-color: rgba(59,130,246,0.1);
    color: var(--text-primary);
}

/* 国家/城市两列对齐排版 */
.tool-input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: start;
}
.tool-input-row .tool-input-group {
    margin-bottom: 0;
}
.tool-input-row .grid-select {
    min-height: 180px;
}

.tool-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    transition: var(--transition);
}

.tool-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* 工具内容区域 */
.tool-content {
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
}

/* 输入输出组 */
.tool-input-group,
.tool-output-group {
    margin-bottom: 1.5rem;
}

.tool-input-group label,
.tool-output-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

/* 按钮组 */
.tool-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    background-color: var(--primary-color);
    color: white;
}

.tool-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

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

/* 按钮组 */
.tool-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    transition: var(--transition);
    white-space: nowrap;
}

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

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

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: var(--border-color);
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #059669;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn svg {
    width: 16px;
    height: 16px;
}

/* 结果区域 */
.tool-result {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1rem;
    min-height: 100px;
    max-height: 400px;
    overflow-y: auto;
}

.tool-result pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
}

/* 工具选项 */
.tool-options {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.tool-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tool-option label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.tool-option input[type="checkbox"],
.tool-option input[type="radio"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.tool-option select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
}

/* ==================== 隐私政策页面 ==================== */
.privacy-page {
    max-width: 800px;
    margin: 0 auto;
}

.privacy-section {
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.privacy-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.privacy-section p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.privacy-section p:last-child {
    margin-bottom: 0;
}

/* ==================== 页脚 ==================== */
.footer {
    background-color: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    margin-top: auto;
}

.footer-container {
    max-width: 1400px;
    margin: 0 auto;
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer-links a:hover {
    color: var(--primary-color);
}

.footer-security {
    color: var(--text-tertiary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.footer-copyright {
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

/* ==================== 提示消息 ==================== */
.toast {
    position: fixed;
    top: 80px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    background-color: var(--success-color);
    color: white;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    animation: slideIn 0.3s ease;
}

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

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

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    .navbar-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .navbar-nav {
        justify-content: space-between;
    }
    
    .navbar-search {
        max-width: 100%;
        order: 3;
        width: 100%;
    }
    
    .home-grid {
        grid-template-columns: 1fr;
    }
    
    .tool-container {
        padding: 1rem;
    }
    
    .tool-buttons {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .tool-options {
        flex-direction: column;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .main {
        padding: 1rem;
    }
    
    .tool-title {
        font-size: 1.5rem;
    }
    
    .tool-textarea {
        min-height: 150px;
    }
    #ipInfoOutput {
        min-height: 260px;
    }
    .tool-kv {
        grid-template-columns: 140px 1fr;
        min-height: 260px;
    }
    .grid-select {
        grid-template-columns: repeat(2, minmax(90px, 1fr));
        max-height: 200px;
    }
}

/* ==================== 工具特定样式 ==================== */

/* 计算器 */
.calculator-container {
    width: fit-content;
    max-width: 100%;
    margin: 0 auto;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.calculator-mode-switch {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.calc-mode-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    border-radius: var(--radius-md);
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid transparent;
    transition: var(--transition);
    cursor: pointer;
}

.calc-mode-btn:hover {
    background-color: var(--border-color);
}

.calc-mode-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.calculator-display {
    background-color: var(--bg-primary);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    text-align: right;
    position: relative;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.05);
}

.calculator-display input {
    width: 100%;
    background: transparent;
    border: none;
    font-size: 2.8rem;
    font-weight: 600;
    text-align: right;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
    padding-right: 4rem; /* 留出复制按钮的空间 */
}

.calc-copy-btn {
    position: absolute;
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    background-color: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    opacity: 0.7; /* 默认稍微透明一点，减少视觉干扰 */
}

.calc-copy-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-50%) scale(1.05);
    opacity: 1; /* 鼠标悬浮时恢复完全不透明 */
}

.calculator-buttons {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.calc-basic-buttons,
.calc-scientific-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    width: 320px;
    max-width: 100%;
}

.calc-btn {
    padding: 1.2rem 0.5rem;
    font-size: 1.6rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid transparent;
    transition: var(--transition);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.calc-btn:hover {
    background-color: var(--border-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.calc-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.calc-btn.calc-op {
    background-color: var(--primary-color);
    color: white;
    font-size: 1.8rem;
}

.calc-btn.calc-op:hover {
    background-color: var(--primary-hover);
}

.calc-btn.calc-equals {
    background-color: var(--success-color);
    color: white;
    grid-column: span 2;
    font-size: 1.8rem;
}

.calc-btn.calc-equals:hover {
    background-color: #059669;
}

.calc-btn.calc-clear {
    background-color: var(--danger-color);
    color: white;
}

.calc-btn.calc-clear:hover {
    background-color: #dc3545;
}

.calc-btn.calc-sci {
    background-color: var(--info-color);
    color: white;
    font-size: 1.1rem;
    padding: 0.8rem 0.2rem;
    white-space: nowrap;
}

.calc-btn.calc-sci:hover {
    background-color: #0dcaf0;
}

/* 颜色选择器 */
.color-preview {
    width: 100%;
    height: 100px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

/* 图片预览 */
.image-preview {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

/* 二维码 */
.qrcode-container {
    display: flex;
    justify-content: center;
    padding: 2rem;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.qrcode-container canvas,
.qrcode-container img {
    max-width: 100%;
}

/* 端口表格 */
.port-table {
    width: 100%;
    border-collapse: collapse;
}

.port-table th,
.port-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.port-table th {
    background-color: var(--bg-secondary);
    font-weight: 600;
}

.port-table tr:hover {
    background-color: var(--bg-secondary);
}

/* Diff 对比 */
.diff-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.diff-added {
    background-color: rgba(16, 185, 129, 0.2);
}

.diff-removed {
    background-color: rgba(239, 68, 68, 0.2);
}

/* 正则测试 */
.regex-match {
    background-color: rgba(59, 130, 246, 0.2);
    padding: 0 2px;
    border-radius: 2px;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* 隐藏元素 */
.hidden {
    display: none !important;
}
