body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f7f6;
    color: #333;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.header {
    background-color: #ffffff;
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-wrap: wrap; /* 允许换行 */
    gap: 10px;
    align-items: center;
    justify-content: center;
}

.footer {
    background-color: #ffffff;
    padding: 12px 20px;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.05);
}

.controls {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-grow: 1; /* 允许占据更多空间 */
    flex-wrap: wrap; /* 允许控件换行 */
    justify-content: center;
}

/* PC端默认布局：所有控件在一行 */
.search-input,
.search-btn,
.nav-btn,
.search-status {
    display: flex;
    align-items: center;
}

/* PC端样式 */
@media (min-width: 769px) {
    .controls {
        flex-direction: row;
        gap: 12px;
    }

    .search-input {
        width: 250px;
        min-width: 200px;
    }

    .search-btn,
    .nav-btn {
        padding: 8px 16px;
        font-size: 14px;
    }

    .search-status {
        margin: 0 10px;
        min-width: 80px;
        text-align: center;
    }
}

.button-group {
    display: none; /* 隐藏旧的按钮组 */
}

    /* 按钮悬停和焦点状态优化 */
    button:hover:not(:disabled) {
        background-color: #0056b3;
    }

    button:focus {
        outline: none;
        box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
    }

input[type="text"] {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    width: 200px; /* 增加宽度 */
    min-width: 150px; /* 确保最小宽度 */
    flex: 1; /* 允许伸缩 */
}

button {
    padding: 8px 15px;
    border: none;
    background-color: #007bff;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

button:hover:not(:disabled) {
    background-color: #0056b3;
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

    .search-status {
        font-size: 13px;
        color: #555;
        margin-left: 10px;
        min-width: 120px; /* 确保有足够空间显示状态 */
        text-align: right;
        font-weight: 500;
    }

.footer .file-info {
    font-size: 13px;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.file-path-display {
    max-width: 400px; /* 限制文件路径的显示宽度 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.loading-indicator {
    font-weight: bold;
    color: #007bff;
    display: none; /* 默认隐藏 */
}

.url-hint {
    font-size: 12px;
    color: #6c757d;
    cursor: help;
    background-color: #f8f9fa;
    padding: 2px 6px;
    border-radius: 12px;
    border: 1px solid #dee2e6;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.url-hint:hover {
    opacity: 1;
}

.log-container {
    flex-grow: 1;
    overflow: auto; /* 允许双向滚动 */
    padding: 15px 20px;
    background-color: #ffffff;
    border-radius: 5px;
    margin: 0 20px 15px 20px; /* 移除上方边距，只保留左右和下边距 */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.log-content {
    font-family: 'Consolas', 'Monaco', 'Andale Mono', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    white-space: pre; /* 保持原始格式，不自动换行 */
    overflow-x: auto; /* 允许水平滚动 */
    min-width: fit-content; /* 根据内容自适应宽度 */
}

/* 日志级别高亮 */
.log-error {
    color: #dc3545; /* 红色 */
    font-weight: bold;
}

.log-warn {
    color: #ffc107; /* 橙色 */
}

.log-info {
    color: #17a2b8; /* 蓝色 */
}

.log-debug, .log-trace {
    color: #6c757d; /* 灰色 */
}

/* 搜索匹配高亮 */
.log-search-match {
    background-color: #fff3cd; /* 淡黄色背景 */
    padding: 1px 0; /* 填充以使其更明显 */
    border-radius: 2px;
}

/* 当前选中搜索匹配高亮 */
.log-search-current {
    background-color: #007bff; /* 蓝色背景 */
    color: white; /* 白色文本 */
    border-radius: 2px;
    padding: 1px 0;
}

.error-message {
    color: #dc3545;
    font-weight: bold;
    padding: 10px;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin-top: 10px;
    display: none; /* 默认隐藏 */
}

/* 移动端响应式设计 */
@media (max-width: 768px) {
    .header {
        padding: 10px 15px;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

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

    /* 移动端两行布局 */
    .search-row {
        display: flex;
        gap: 8px;
        width: 100%;
    }

    .nav-row {
        display: flex;
        gap: 8px;
        width: 100%;
        justify-content: space-between;
        align-items: center;
    }

    .search-input {
        flex: 1;
        min-width: 0;
    }

    .search-btn {
        flex: 0 0 auto;
        min-width: 80px;
    }

    .nav-btn {
        flex: 1;
        min-width: 70px;
    }

    .search-status {
        flex: 2;
        text-align: center;
        min-width: 60px;
        margin: 0;
    }

    .search-btn,
    .nav-btn {
        font-size: 13px;
        padding: 10px 12px;
        font-weight: 500;
        border-radius: 6px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }

    input[type="text"] {
        flex: 1;
        min-width: 0;
    }

    #searchButton {
        flex: 0 0 auto;
        min-width: 80px;
    }

    #prevButton, #nextButton {
        flex: 1;
        min-width: 70px;
    }

    button {
        font-size: 13px;
        padding: 10px 12px;
        font-weight: 500;
        border-radius: 6px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }

    .search-status {
        flex: 2;
        text-align: center;
        margin: 0;
        min-width: 60px;
        font-weight: 500;
    }

    .footer {
        padding: 10px 15px;
    }

    .footer .file-info {
        flex-direction: column;
        align-items: center;
        gap: 8px;
        font-size: 12px;
        text-align: center;
    }

    .footer .file-path-display {
        max-width: 100%;
        word-break: break-all;
        white-space: normal;
        line-height: 1.4;
        text-align: center;
    }

    .url-hint {
        font-size: 11px;
        padding: 4px 8px;
        align-self: center;
    }

    .log-container {
        margin: 0 15px 10px 15px; /* 移除上方边距，只保留左右和下边距 */
        padding: 10px 15px;
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .log-content {
        font-size: 12px;
        line-height: 1.5;
        white-space: pre; /* 保持原始格式，不换行 */
        word-break: normal; /* 禁止自动换行 */
        overflow-x: auto; /* 允许水平滚动 */
        min-width: fit-content; /* 根据内容自适应宽度 */
        padding-bottom: 20px; /* 底部留白，方便滚动 */
    }

    /* 移动端按钮触摸优化 */
    button:active {
        transform: scale(0.98);
    }

    /* 移动端输入框优化 */
    input[type="text"]:focus {
        outline: none;
        border-color: #007bff;
        box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
    }

    /* 改善移动端滚动体验 */
    .log-container {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

    /* 移动端滚动条样式优化 */
    .log-container::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }

    .log-container::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 3px;
    }

    .log-container::-webkit-scrollbar-thumb {
        background: #c1c1c1;
        border-radius: 3px;
    }

    .log-container::-webkit-scrollbar-thumb:hover {
        background: #a8a8a8;
    }

    /* 移动端防止横屏时的布局问题 */
    @media (max-width: 768px) and (orientation: landscape) {
        .header {
            flex-direction: row;
            flex-wrap: wrap;
        }
        
        .controls {
            flex-direction: row;
            flex-wrap: wrap;
        }
        
        .file-info {
            flex-direction: row;
            flex-wrap: wrap;
        }
    }
}

/* 超小屏幕设备 (iPhone SE等) */
@media (max-width: 320px) {
    .header {
        padding: 8px 12px;
    }

    .footer {
        padding: 8px 12px;
    }

    .log-container {
        margin: 0 12px 8px 12px; /* 移除上方边距，只保留左右和下边距 */
        padding: 8px 12px;
    }

    .log-content {
        font-size: 11px;
        white-space: pre; /* 保持原始格式，不换行 */
        word-break: normal; /* 禁止自动换行 */
        overflow-x: auto; /* 允许水平滚动 */
        min-width: fit-content; /* 根据内容自适应宽度 */
    }

    .footer .file-info {
        font-size: 11px;
    }

    button {
        font-size: 12px;
        padding: 8px 10px;
        min-width: 70px;
    }
}