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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* ==================== 登录页面 ==================== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    width: 90%;
    max-width: 400px;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
    font-weight: 600;
}

/* ==================== 导航栏 ==================== */
.navbar {
    background: #2c3e50;
    color: white;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.navbar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    padding: 15px 0;
}

.nav-menu {
    display: flex;
    list-style: none;
    flex-wrap: wrap;
}

.nav-menu li {
    position: relative;
}

.nav-menu a {
    display: block;
    padding: 20px 15px;
    color: white;
    text-decoration: none;
    transition: background 0.3s;
    font-weight: 500;
}

.nav-menu a:hover, .nav-menu a.active {
    background: #34495e;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 500;
}

.logout-btn {
    padding: 8px 15px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
    font-weight: 500;
}

.logout-btn:hover {
    background: #c0392b;
}

/* ==================== 主内容区域 ==================== */
.main-container {
    max-width: 1600px;
    margin: 20px auto;
    padding: 0 20px;
}

.page-header {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.page-title {
    font-size: 28px;
    margin-bottom: 10px;
    color: #2c3e50;
    font-weight: 600;
}

/* ==================== 统计卡片 ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    border-color: #667eea;
}

.stat-card h3 {
    color: #7f8c8d;
    font-size: 14px;
    margin-bottom: 10px;
    font-weight: 500;
}

.stat-card .number {
    font-size: 36px;
    font-weight: bold;
    color: #2c3e50;
}

/* ==================== 图表容器 ==================== */
.chart-container {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.chart-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.chart-filters button {
    padding: 8px 20px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.chart-filters button.active {
    background: #667eea;
    color: white;
}

.chart-filters button:hover:not(.active) {
    background: #f8f9fa;
}

/* ==================== 表格样式 ==================== */
.table-container {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    overflow-x: auto;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.table-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

/* ✅ 新增：统一搜索框控件样式 */
.search-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* 统一下拉框和输入框样式 */
.search-controls select,
.search-controls input[type="text"] {
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    transition: border-color 0.3s, box-shadow 0.3s;
    height: 42px; /* 统一高度 */
    color: #333;
}

.search-controls select:focus,
.search-controls input[type="text"]:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-controls select {
    cursor: pointer;
    /* 下拉箭头图标 */
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667eea' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    padding-right: 45px;
}

/* 按钮高度与输入框保持一致 */
.search-controls button {
    height: 42px;
    padding: 0 20px;
    white-space: nowrap;
}

/* 按钮样式 */
.btn-small, .btn {
    padding: 8px 15px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 14px;
    font-weight: 500;
}

.btn-small:hover, .btn:hover {
    background: #5a67d8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-danger {
    background: #e74c3c;
}

.btn-danger:hover {
    background: #c0392b;
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.btn-success {
    background: #2ecc71;
}

.btn-success:hover {
    background: #27ae60;
}

/* 表格 */
table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ecf0f1;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
}

tr:hover {
    background: #f8f9fa;
}

/* ==================== 复选框 ==================== */
input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: #667eea;
}

/* ==================== 操作按钮 ==================== */
.action-btns {
    display: flex;
    gap: 5px;
}

.action-btn {
    padding: 5px 10px;
    font-size: 12px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
}

.edit-btn {
    background: #3498db;
    color: white;
}

.edit-btn:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

.delete-btn {
    background: #e74c3c;
    color: white;
}

.delete-btn:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

.block-btn {
    background: #f39c12;
    color: white;
}

.block-btn:hover {
    background: #e67e22;
    transform: translateY(-1px);
}

/* ==================== 模态框 ==================== */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    overflow-y: auto;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: #444444 #f1f1f1;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #2c3e50;
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
    transition: color 0.3s;
}

.close:hover {
    color: #000;
}

.modal-content .form-group {
    margin-bottom: 20px;
}

.modal-content .form-group:last-child {
    margin-bottom: 0;
    margin-top: 30px;
}

/* ==================== 表单元素 ==================== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

/* 统一所有输入框样式（排除checkbox/radio） */
.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.3s, box-shadow 0.3s;
    background: white;
    color: #333;
}

/* 焦点状态 */
.form-group input:not([type="checkbox"]):not([type="radio"]):focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #667eea !important;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 禁用/只读状态 */
.form-group input[disabled],
.form-group input[readonly],
.form-group select[disabled],
.form-group textarea[disabled] {
    background-color: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
}

/* 下拉框特殊样式 */
.form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667eea' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 16px;
    padding-right: 45px;
    cursor: pointer;
}

/* 文本域样式 */
.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.modal-content .form-group textarea {
    max-width: 100%;
    min-height: 120px;
    line-height: 1.5;
}

/* ==================== 提示消息 ==================== */
.alert {
    padding: 12px 15px;
    border-radius: 5px;
    margin-bottom: 20px;
    font-weight: 500;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

/* ==================== 分页样式 ==================== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.pagination button {
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    background: white;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.3s;
    font-weight: 500;
}

.pagination button.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.pagination button:hover:not(:disabled):not(.active) {
    background: #f8f9fa;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==================== 超链接按钮样式 ==================== */
.btn-link {
    color: #667eea;
    text-decoration: underline;
    font-weight: 500;
    cursor: pointer;
    background: none;
    border: none;
    font-size: inherit;
}

.btn-link:hover {
    color: #5a67d8;
}

/* ==================== 版本管理表格特殊列宽 ==================== */
#versionTable th:nth-child(2),
#versionTable td:nth-child(2) {
    min-width: 100px;
}

#versionTable th:nth-child(3),
#versionTable td:nth-child(3) {
    min-width: 200px;
    max-width: 300px;
    word-break: break-all;
}

#versionTable th:nth-child(5),
#versionTable td:nth-child(5) {
    min-width: 100px;
}

#versionTable th:nth-child(6),
#versionTable td:nth-child(6) {
    min-width: 60px;
}

#versionTable th:last-child,
#versionTable td:last-child {
    min-width: 400px;
}

/* ==================== Toast提示样式 ==================== */
#toastContainer {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    padding: 15px 20px;
    color: white;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    margin-bottom: 10px;
    animation: slideIn 0.3s ease;
    font-weight: 500;
    backdrop-filter: blur(10px);
}

.toast-success { background: rgba(46, 204, 113, 0.9); }
.toast-error { background: rgba(231, 76, 60, 0.9); }
.toast-warning { background: rgba(243, 156, 18, 0.9); }
.toast-info { background: rgba(52, 152, 219, 0.9); }

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

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

/* ==================== 加载动画 ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    z-index: 9998;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    backdrop-filter: blur(2px);
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    .navbar-content {
        flex-direction: column;
        padding: 10px;
    }
    
    .nav-menu {
        justify-content: center;
        margin-top: 10px;
    }
    
    .user-info {
        margin-top: 10px;
    }
    
    .table-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        width: 100%;
    }
    
    .search-box input {
        flex: 1;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    /* 移动端表格转卡片布局 */
    .table-container {
        background: transparent;
        box-shadow: none;
        padding: 0;
    }
    
    table {
        display: block;
    }
    
    thead {
        display: none;
    }
    
    tbody {
        display: block;
    }
    
    tr {
        display: block;
        background: white;
        margin-bottom: 10px;
        border-radius: 8px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        padding: 15px;
        transition: transform 0.2s;
    }
    
    tr:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    }
    
    td {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
        border: none;
        border-bottom: 1px solid #f0f0f0;
    }
    
    td:last-child {
        border-bottom: none;
    }
    
    td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #7f8c8d;
    }
    
    .action-btns {
        width: 100%;
        justify-content: flex-end;
        gap: 10px;
    }
    
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 5% auto;
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .login-box {
        padding: 30px 20px;
    }
    
    .stat-card .number {
        font-size: 28px;
    }
    
    .page-title {
        font-size: 24px;
    }
}

/* ==================== 按钮禁用状态 ==================== */
button:disabled, .btn:disabled, .btn-small:disabled, .action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}

/* ==================== 行删除动画 ==================== */
@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(-100%);
    }
}

.row-deleting {
    animation: fadeOut 0.3s forwards;
}

/* ==================== 移动端水平滚动导航栏（新策略） ==================== */

/* 平板端断点：≤1024px */
@media (max-width: 1024px) {
    .navbar-content {
        padding: 0;
        flex-wrap: wrap;
        position: relative;
    }
    
    .logo {
        padding: 15px;
        flex: 1;
        order: 1;
    }
    
    /* 可横向滚动的导航菜单 */
    .nav-menu {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex: 0 0 100%;
        order: 2;
        background: #34495e;
        padding: 0 10px;
        margin: 0;
        max-width: 100vw;
    }
    
    /* 隐藏滚动条 */
    .nav-menu::-webkit-scrollbar {
        display: none;
    }
    
    .nav-menu li {
        flex-shrink: 0;
    }
    
    .nav-menu a {
        padding: 12px 15px;
        white-space: nowrap;
        font-size: 14px;
        border-left: none;
        border-bottom: 3px solid transparent;
    }
    
    .nav-menu a:hover,
    .nav-menu a.active {
        background: #2c3e50;
        border-bottom-color: #667eea;
    }
    
    /* 移动端用户信息（在导航栏下方） */
    .user-info.mobile-only {
        display: flex !important;
        order: 3;
        width: 100%;
        justify-content: space-between;
        align-items: center;
        padding: 10px 15px;
        background: #1a252f;
        border-top: 1px solid #34495e;
    }
    
    /* 桌面端用户信息隐藏 */
    .user-info.desktop-only {
        display: none !important;
    }
}

/* 手机端断点：≤768px */
@media (max-width: 768px) {
    .nav-menu a {
        padding: 10px 12px;
        font-size: 13px;
    }
}

/* 桌面端断点：> 1024px */
@media (min-width: 1025px) {
    .user-info.mobile-only {
        display: none !important;
    }
}

/* ✅ 新增：IP悬浮提示样式 */
.ip-cell {
    cursor: help;
    position: relative;
    border-bottom: 1px dotted #667eea;
    text-decoration: none;
}

.ip-tooltip {
    position: fixed;
    background: #2c3e50;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transform: translateY(5px);
    transition: opacity 0.3s, transform 0.3s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.ip-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #2c3e50 transparent transparent transparent;
}

.ip-tooltip.show {
    opacity: 1;
    transform: translateY(0);
}