/* global.css - 全局样式文件 */

/* 全局样式变量 */
:root {
    --accent-color: #3182ce;
    --accent-hover: #2c5282;
    --accent-success: #38a169;
    --accent-danger: #e53e3e;
    --accent-warning: #ed8936;
    --text-primary: #1a202c;
    --text-muted: #4a5568;
    --border-color: #e2e8f0;
    --bg-light: #f7fafc;
    --bg-white: #ffffff;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --radius: 0.5rem;
}

/* 全局重置与基础样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* 主容器 */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
}

/* 头部区域 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-white);
    padding: 1.5rem 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 0.25rem;
}

.header p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* 用户菜单 */
.user-menu {
    position: relative;
}

.user-menu button {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.2s;
}

.user-menu button:hover { background: var(--accent-hover); }

.user-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    min-width: 150px;
    z-index: 1000;
}

.user-menu-dropdown a {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.2s;
}

.user-menu-dropdown a:hover { background: var(--bg-light); }

/* 状态栏 */
.status-bar {
    background: var(--bg-white);
    padding: 0.75rem 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-dot {
    width: 0.75rem;
    height: 0.75rem;
    background: var(--accent-success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* 主布局 */
.main-layout {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 1rem;
}

/* 主内容区域 */
.main-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* 卡片样式 */
.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}

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

/* 按钮样式 */
.btn-primary {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.2s;
}

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

.btn-success {
    background: var(--accent-success);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.2s;
}

.btn-success:hover { background: #2f855a; }

.btn-danger {
    background: var(--accent-danger);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.2s;
}

.btn-danger:hover { background: #c53030; }

/* 按钮组 */
.btn-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* 设备选择 */
select {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: var(--bg-white);
}

/* 继电器网格 */
.relay-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
}

.relay-item {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

.relay-info {
    margin-bottom: 0.75rem;
}

.relay-info strong {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.status-text-on {
    color: var(--accent-success);
    font-size: 0.75rem;
}

.status-text-off {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* 侧边栏 */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* 命令面板 */
.cmd-panel {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.cmd-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cmd-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.cmd-controls {
    display: flex;
    gap: 0.5rem;
}

.cmd-btn {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.cmd-btn:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* 操作日志 */
.operation-log {
    flex: 1;
    padding: 1rem 1.5rem;
    overflow-y: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.75rem;
    line-height: 1.4;
}

.log-item { margin-bottom: 0.25rem; }

.log-time {
    color: var(--accent-color);
    margin-right: 0.5rem;
}

/* 命令输入区域 */
.cmd-input-area {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cmd-prompt {
    color: var(--accent-success);
    font-weight: 600;
    font-family: 'Consolas', 'Monaco', monospace;
}

.cmd-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.75rem;
}

.cmd-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .main-layout { grid-template-columns: 1fr; }
    .sidebar { order: -1; }
    .cmd-panel { max-height: 300px; }
}

/* 加载动画 */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s;
}

.loader-spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left: 4px solid var(--accent-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

.loader-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.loader-subtext {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* 提示框 */
.toast {
    position: fixed;
    top: 1rem;
    right: 1rem;
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 10000;
    animation: slideIn 0.3s ease-out;
}

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

.toast-info { background: var(--accent-color); color: white; }
.toast-success { background: var(--accent-success); color: white; }
.toast-warning { background: var(--accent-warning); color: white; }
.toast-error { background: var(--accent-danger); color: white; }
