/* 修复后的完整 CSS */
:root {
    --primary: #4361ee;
    --primary-dark: #3a0ca3;
    --secondary: #4cc9f0;
    --success: #2a9d8f;
    --danger: #e63946;
    --dark: #0d1b2a;
    --light: #f8f9fa;
    --gray: #6c757d;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: linear-gradient(135deg, #1a2a6c, #2c3e50);
    color: white;
    min-height: 100vh;
    padding: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.header {
    text-align: center;
    padding: 8px 0;
    margin-bottom: 8px;
    position: relative;
    flex-shrink: 0;
}

.header h1 {
    font-size: 1.4rem;
    margin-bottom: 3px;
    background: linear-gradient(90deg, #4cc9f0, #4361ee);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header .subtitle {
    color: #b8c1ec;
    font-size: 0.8rem;
}

/* 修复容器布局 - 关键修复 */
.container {
    display: flex;
    flex: 1;
    gap: 12px;
    flex-direction: column;
    min-height: 0; /* 修复Chrome的flexbox bug */
    height: calc(100vh - 70px); /* 确保高度计算正确 */
    overflow: hidden;
}

/* 控制面板修复 */
.control-panel {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 12px;
    backdrop-filter: blur(10px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0; /* 防止在移动设备上被压缩 */
    max-height: 45vh; /* 限制高度 */
}

/* 视觉面板修复 - 确保画布可见 */
.visual-panel {
    flex: 1;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    min-height: 300px; /* 确保最小高度 */
}

.panel-title {
    font-size: 1.0rem;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid #4361ee;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.config-panel {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 12px;
}

.config-title {
    font-size: 0.9rem;
    margin-bottom: 6px;
    color: #4cc9f0;
}

.config-row {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.config-input {
    flex: 1;
    min-width: 80px;
    padding: 7px 9px;
    border-radius: 5px;
    border: none;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 0.85rem;
}

.config-btn {
    padding: 7px 10px;
    border-radius: 5px;
    border: none;
    background: linear-gradient(90deg, #4361ee, #3a0ca3);
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    min-width: 70px;
}

.config-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(67, 97, 238, 0.4);
}

.server-status {
    display: flex;
    align-items: center;
    padding: 5px 0;
    font-size: 0.85rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-offline {
    background: #e63946;
    box-shadow: 0 0 5px #e63946;
}

.status-online {
    background: #2a9d8f;
    box-shadow: 0 0 7px #2a9d8f;
}

.group-info {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 12px;
    font-size: 0.85rem;
}

.group-info-item {
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.input-group {
    margin-bottom: 12px;
}

label {
    display: block;
    margin-bottom: 5px;
    color: #b8c1ec;
    font-size: 0.85rem;
}

input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 5px;
    border: none;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 0.85rem;
}

button {
    width: 100%;
    padding: 10px;
    border-radius: 6px;
    border: none;
    background: linear-gradient(90deg, #4361ee, #3a0ca3);
    color: white;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 6px;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(67, 97, 238, 0.4);
}

button:disabled {
    background: linear-gradient(90deg, #6c757d, #495057);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 画布容器修复 - 关键修复 */
.canvas-container {
    position: relative;
    width: 100%;
    height: 100%; /* 确保高度100% */
    overflow: hidden;
    background: #0d1b2a;
    border-radius: 8px;
    flex: 1; /* 确保填满可用空间 */
}


#drawing-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%; /* 确保高度100% */
    cursor: default;
}

#drawing-canvas {
    z-index: 2;
    cursor: default;
}

#background-canvas {
    z-index: 1;
}

.coordinates-info {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 0.8rem;
    color: #b8c1ec;
    padding: 0 5px;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10;
}

/* 日志区域修复 */
.data-log {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100px;
    overflow: hidden;
}

#log-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    max-height: 200px;
    min-height: 100px;
}

.log-header {
    font-weight: bold;
    margin-bottom: 6px;
    color: #4cc9f0;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.log-entry {
    padding: 5px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-family: monospace;
    font-size: 0.8rem;
    white-space: pre-wrap;
    line-height: 1.4;
    word-wrap: break-word;
}

.log-entry:last-child {
    border-bottom: none;
}

.sent {
    color: #2a9d8f;
}

.received {
    color: #4361ee;
}

.fullscreen-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #4cc9f0;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    z-index: 10;
    font-size: 0.8rem;
    transition: all 0.2s;
    opacity: 0.25; /* 整体透明度 */
}

.fullscreen-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.05);
}

.map-controls {
    position: absolute;
    bottom: 40px; /* 避免与坐标信息重叠 */
    left: 10px;
    display: flex;
    gap: 8px;
    z-index: 10;
}

.column-group {
  display: flex;
  flex-direction: column;
}
 
.row-group {
  display: flex;
  margin-top: 2px;
  gap: 4px; /* 添加这一行来设置按钮之间的水平间距 */
}

.map-btn {
    padding: 6px 8px;          /* 控制按钮尺寸：上下内边距6px，左右内边距12px */
    background: rgba(0,0,0,0.5); /* 半透明黑色背景 */
    border: 1px solid #4cc9f0;  /* 1px蓝色边框 */
    border-radius: 4px;         /* 4px圆角 */
    color: white;               /* 白色文字 */
    cursor: pointer;            /* 鼠标悬停时显示手型指针 */
    font-size: 0.8rem;          /* 文字大小（相对单位） */
    transition: all 0.2s;       /* 所有属性变化添加0.2秒过渡动画 */
}
 
.map-btn:hover {
    background: rgba(0,0,0,0.7); /* 悬停时加深背景透明度 */
    transform: translateY(-1px); /* 悬停时上移1像素的浮动效果 */
}

/* 添加在style.css中 */
.web-fullscreen {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 1000;
    background: white;
}

.web-fullscreen .grid-overlay {
    width: 100% !important;
    height: 100% !important;
}

.web-fullscreen #drawing-canvas {
    width: 100% !important;
    height: 100% !important;
}

.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-image: 
        linear-gradient(rgba(100, 100, 150, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(100, 100, 150, 0.1) 1px, transparent 1px);
    background-size: 40px 40px;
    z-index: 3;
}

/* 配置对话框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #1e2a4a;
    border-radius: 12px;
    padding: 20px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-title {
    font-size: 1.2rem;
}

.close-modal {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.config-section {
    margin-bottom: 20px;
}

.config-section h3 {
    margin-bottom: 10px;
    color: #4cc9f0;
}

.config-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.config-item {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.config-item input {
    flex: 1;
    min-width: 100px;
}

.config-item button {
    width: 40px;
    flex-shrink: 0;
}

.add-item-btn {
    background: var(--success);
    border: none;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
}

.remove-item-btn {
    background: var(--danger);
    border: none;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
}

.save-config-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
    font-weight: bold;
}

.small-btn {
    padding: 3px 8px;
    font-size: 0.7rem;
    width: auto;
    margin-top: 0;
}

/* 移动设备优化 */
@media (min-width: 768px) {
    .container {
        flex-direction: row;
        height: calc(100vh - 80px);
    }
    
    .control-panel {
        width: 300px;
        max-height: none;
    }
}

@media (max-width: 767px) {
    body {
        padding: 5px;
    }
    
    .header h1 {
        font-size: 1.2rem;
    }
    
    .header .subtitle {
        font-size: 0.7rem;
    }
    
    .config-btn {
        min-width: 60px;
        padding: 7px 8px;
        font-size: 0.75rem;
    }
    
    .config-input {
        font-size: 0.8rem;
        min-width: 60px;
    }
    
    button {
        padding: 8px;
        font-size: 0.85rem;
    }
    
    .coordinates-info {
        font-size: 0.75rem;
    }
    
    .fullscreen-btn, .map-btn {
        padding: 5px 8px;
        font-size: 0.7rem;
    }
    
    .log-entry {
        font-size: 0.75rem;
    }
}

/* 横屏模式优化 */
@media (orientation: landscape) and (max-width: 900px) {
    .container {
        flex-direction: row;
        height: calc(100vh - 60px);
    }
    
    .control-panel {
        width: 40%;
        max-height: calc(100vh - 70px);
    }
    
    .visual-panel {
        min-height: auto;
    }
}

/* 竖屏模式优化 */
@media (orientation: portrait) and (max-width: 900px) {
    .container {
        flex-direction: column;
        height: calc(100vh - 70px);
    }
    
    .control-panel {
        max-height: 40vh;
    }
    
    .visual-panel {
        min-height: 50vh;
    }
}

/* 全屏模式下的控制按钮 */
.fullscreen-controls {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 100;
    display: none;
}

.zoom-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
    display: none;
}

.zoom-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid #4cc9f0;
    color: white;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* 触摸操作提示 */
.touch-hint {
    position: absolute;
    bottom: 50px;
    left: 0;
    width: 100%;
    text-align: center;
    color: #4cc9f0;
    font-size: 0.8rem;
    z-index: 5;
    background: rgba(0, 0, 0, 0.5);
    padding: 5px;
    display: none;
}

/* 添加配置文本区域样式 */
.config-textarea {
    width: 100%;
    padding: 10px;
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 0.9rem;
    min-height: 80px;
    resize: vertical;
}

.config-hint {
    font-size: 0.8rem;
    color: #b8c1ec;
    margin-bottom: 5px;
}

/* 新增：加载指示器 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.loader {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #4361ee;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

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


/* 新增注销按钮容器样式 */
.logout-container {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
}

/* 新增注销按钮样式 */
.logout-btn {
    display: inline-block;
    padding: 8px 15px;
    background: linear-gradient(90deg, #e63946, #d90429);
    color: white !important;
    text-decoration: none;
    border-radius: 20px;
    font-weight: 500;
    box-shadow: 0 3px 8px rgba(230, 57, 70, 0.4);
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
}

.logout-btn:hover {
    background: linear-gradient(90deg, #ef476f, #e63946);
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(230, 57, 70, 0.6);
}

.logout-btn i {
    margin-right: 5px;
}

/* 响应式调整 */
@media (max-width: 767px) {
    .logout-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

.btn-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-bottom: 12px;
}

.btn-group button {
    margin-top: 0;
    padding: 8px;
    font-size: 0.8rem;
}

/* 在 style.css 中添加以下样式 */
.btn-group button.active {
    background-color: #4CAF50;
    color: white;
    border: 2px solid #3e8e41;
}

.btn-group button:hover {
    background-color: #ddd;
}

.wake-lock-status-active {
    background-color: rgba(30, 60, 43, 0.7) !important;
    color: #6bc46e !important;
}

.wake-lock-status-inactive {
    background-color: rgba(60, 30, 30, 0.7) !important;
    color: #d46a6a !important;
}