/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* 页面切换 */
.page {
    display: none !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: -1 !important;
}

.page.active {
    display: flex !important;
    flex-direction: column;
    z-index: 10 !important;
}

/* 登录页面样式 */
#login-page {
    display: none !important;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: -1 !important;
}

#login-page.active {
    display: flex !important;
    z-index: 10 !important;
}

.login-container {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 500px;
    position: relative;
    z-index: 10;
}

.login-title {
    text-align: center;
    margin-bottom: 2rem;
    color: #333;
    font-size: 1.6rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-input {
    padding: 0.8rem;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-input:focus {
    outline: none;
    border-color: #667eea;
}

.btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.btn-primary {
    background-color: #667eea;
    color: white;
}

.btn-info {
    background-color: #17a2b8;
    color: white;
}

.btn-info:hover {
    background-color: #138496;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(23, 162, 184, 0.4);
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(220, 53, 69, 0.4);
}

.btn-primary:hover {
    background-color: #5a6fd8;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.error-message {
    color: #dc3545;
    text-align: center;
    min-height: 1.5rem;
    font-size: 0.9rem;
}

/* 主页面布局 */
#main-page {
    display: none !important;
    min-height: 100vh;
    flex-direction: column;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: -1 !important;
}

#main-page.active {
    display: flex !important;
    z-index: 10 !important;
}

/* 系统标题 */
.system-header {
    background: white;
    padding: 1rem 0;
    text-align: center;
}

.system-title {
    color: #667eea;
    font-size: 2rem;
    font-weight: bold;
    margin: 0;
    text-align: center;
}

/* 导航栏 */
.navbar {
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.nav-brand {
    font-size: 1.8rem;
    font-weight: bold;
    color: #667eea;
    white-space: nowrap;
}

.nav-menu {
    display: flex;
    gap: 2rem;
    flex: 1;
    justify-content: center;
}

.nav-btn {
    padding: 0.8rem 1.5rem;
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.3s;
    font-size: 1.3rem;
    font-weight: 500;
}

.nav-btn:hover,
.nav-btn.active {
    background-color: #667eea;
    color: white;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;
}

.user-details {
    display: flex;
    flex-direction: column;
    text-align: right;
    min-width: 120px;
}

.user-nickname {
    font-weight: 500;
    font-size: 1rem;
    color: #333;
}

.user-role {
    font-size: 0.85rem;
    color: #666;
    margin-top: 2px;
}

/* 修改密码弹窗样式 */
.form-group {
    margin-bottom: 1rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}

/* 主内容区 */
.main-content {
    flex: 1;
    padding: 2rem;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h2 {
    color: #333;
    font-size: 1.8rem;
}

/* 表格样式 */
.table-container {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed; /* 固定表格布局 */
}

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #eee;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

.data-table tr:hover {
    background-color: #f8f9fa;
}

/* 操作记录表格特定列宽设置 */
#operate-table-body td:nth-child(7), /* 开始执行时间 */
#operate-table-body td:nth-child(8), /* 更新时间 */
#operate-table-body th:nth-child(7),
#operate-table-body th:nth-child(8) {
    width: 100px; /* 设置固定宽度 */
    max-width: 100px;
}

/* 服务器状态表格特定列宽设置 */
#state-table-body td:nth-child(4), /* 运行时间 */
#state-table-body td:nth-child(5), /* 检查时间 */
#state-table-body th:nth-child(4),
#state-table-body th:nth-child(5) {
    width: 100px; /* 设置固定宽度 */
    max-width: 100px;
}

/* 操作控制栏样式 */
.operate-control-bar {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.current-env-hint {
    margin-top: 0;
    color: #666;
    font-size: 14px;
    text-align: center;
    padding: 0.5rem 1rem;
    background-color: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    min-width: 200px;
    display: block; /* 默认显示 */
}

.server-selector-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.server-selector-inline label {
    font-weight: 500;
    color: #333;
    white-space: nowrap;
}

.operation-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.form-select {
    padding: 0.9rem 1.2rem;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 1.1rem;
    background: white;
    cursor: pointer;
    min-width: 160px;
}

.records-section {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

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

.section-header h3 {
    color: #333;
    font-size: 1.3rem;
}

/* 日志控制栏布局 */
.log-control-bar {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    gap: 15px;
}

.log-control-left {
    flex: 1;
}

.server-selector-inline {
    flex: 0 0 auto;
    text-align: center;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.server-selector-inline label {
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    font-size: 1.1rem;
}

.server-selector-inline .form-select {
    font-size: 1.1rem;
    padding: 0.8rem 1.2rem;
    min-width: 200px;
}

.log-control-right {
    flex: 1;
    text-align: right;
}

#refresh-log {
    font-size: 1.1rem;
    padding: 0.8rem 1.5rem;
    white-space: nowrap;
}

/* 日志样式 */
.log-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
}

.log-content {
    background: #2d3748;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.4;
    max-height: 70vh;
    min-height: 500px;
    height: 70vh;
    overflow-y: auto;
    white-space: pre-wrap;
}

/* 分页样式 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding: 1rem;
}

.pagination button {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.3s;
}

.pagination button:hover:not(:disabled) {
    background-color: #667eea;
    color: white;
    border-color: #667eea;
}

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

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

/* 弹窗样式 */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
}

.modal-content {
    text-align: center;
}

.modal-content p {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    #login-page {
        padding: 1rem;
    }
    
    .login-container {
        padding: 1.5rem;
        max-width: 90%;
        margin: 1rem;
    }
    
    .login-title {
        font-size: 1.4rem;
    }
    
    .system-header {
        padding: 1rem;
        background: white;
    }
    
    .system-title {
        font-size: 1.5rem;
        color: #667eea;
    }
    
    .navbar {
        flex-direction: column;
        height: auto;
        padding: 1rem;
        gap: 1rem;
    }
    
    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
        gap: 1.5rem;
    }
    
    .nav-btn {
        font-size: 1.1rem;
        padding: 0.7rem 1.3rem;
        font-weight: 500;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .operate-control-bar {
        justify-content: center;
    }
    
    .control-group {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }
    
    .server-selector-inline,
    .operation-selector {
        justify-content: center;
    }
    
    .server-selector-inline label {
        font-size: 1rem;
    }
    
    .log-control-bar {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }
    
    .log-control-left {
        display: none;
    }
    
    .log-container {
        height: auto;
        min-height: 400px;
        padding: 1rem;
    }
    
    .log-content {
        max-height: 60vh;
        min-height: 300px;
        height: 60vh;
        font-size: 0.8rem;
    }
    
    .form-select {
        min-width: 200px;
        font-size: 1rem;
    }
    
    .page-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .data-table {
        font-size: 0.9rem;
        table-layout: auto; /* 移动端使用自动布局 */
    }
    
    .data-table th,
    .data-table td {
        padding: 0.5rem;
        white-space: normal; /* 移动端允许换行 */
    }
    
    /* 移动端时间列宽度调整 */
    #operate-table-body td:nth-child(7),
    #operate-table-body td:nth-child(8),
    #operate-table-body th:nth-child(7),
    #operate-table-body th:nth-child(8),
    #state-table-body td:nth-child(4),
    #state-table-body td:nth-child(5),
    #state-table-body th:nth-child(4),
    #state-table-body th:nth-child(5) {
        width: auto;
        max-width: none;
    }
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* 状态颜色 */
/* 服务器状态颜色 */
.status-running {
    color: #28a745;
    font-weight: bold;
}

.status-stopped {
    color: #dc3545;
    font-weight: bold;
}

.status-created {
    color: #17a2b8;
    font-weight: bold;
}

.status-paused {
    color: #6c757d;
    font-weight: bold;
}

.status-exited {
    color: #6f42c1;
    font-weight: bold;
}

.status-dead {
    color: #343a40;
    font-weight: bold;
}

.status-restarting {
    color: #fd7e14;
    font-weight: bold;
}

.status-removing {
    color: #e83e8c;
    font-weight: bold;
}

.status-other {
    color: #ffc107;
    font-weight: bold;
}

/* 操作记录状态颜色 */
.status-success {
    color: #28a745;
    font-weight: bold;
}

.status-failed {
    color: #dc3545;
    font-weight: bold;
}

.status-wait_to_execute {
    color: #17a2b8;
    font-weight: bold;
}

.status-executing {
    color: #fd7e14;
    font-weight: bold;
}

.status-starting {
    color: #007bff;
    font-weight: bold;
}

.status-canceled {
    color: #6c757d;
    font-weight: bold;
}