/* --- 100% 恢复原始精致布局 CSS (彻底修复媒体查询与括号问题) --- */

/* 极简路径切换组件样式 */
#toggle-input-btn {
    transition: all 0.3s ease;
    opacity: 0.6;
    filter: grayscale(1);
}

#toggle-input-btn:hover {
    opacity: 1;
    filter: grayscale(0);
    transform: scale(1.1);
}

#branch-container, #dir-container {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.electric-inner input {
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

:root {
    --primary-color: #4a90e2;
    --text-color: #ffffff;
    --electric-color: #4facfe;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
}

/* ==========================================
   进度条与扫光动画定义
   ========================================== */
@keyframes progress-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: radial-gradient(circle at top, rgba(59, 130, 246, 0.1), transparent 35%),
                linear-gradient(180deg, #020617 0%, #08111f 55%, #020617 100%);
    margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; min-height: 100vh; color: var(--text-color); overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 模态框打开时锁定底层背景滚动 */
body.modal-open {
    overflow: hidden !important;
}

.bg-glow { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: none; pointer-events: none; z-index: 0; }

.container {
    background: rgba(255, 255, 255, 0.03); backdrop-filter: blur(20px) saturate(180%); border: 1px solid var(--glass-border); padding: 10px; border-radius: 16px; box-shadow: 0 10px 35px rgba(0, 0, 0, 0.5); width: 95%; max-width: 600px; margin: 8px auto; position: relative; z-index: 1; box-sizing: border-box; transition: all 0.4s ease;
    overflow: hidden;
}

/* 整体容器跑马灯特效 */
.container.effects-active::before {
    content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
    background: conic-gradient(transparent 0deg, transparent 155deg, #4facfe 160deg, #00f2fe 210deg, transparent 215deg, transparent 360deg);
    animation: rotate 20s linear infinite; z-index: -1; opacity: 1;
    will-change: transform, opacity; transform: translate3d(0,0,0); backface-visibility: hidden;
}
.container.effects-active::after {
    content: ''; position: absolute; inset: 2px; background: rgba(15, 15, 25, 0.95); border-radius: 14px; z-index: -1; backdrop-filter: blur(20px);
}

/* --- PC 端单列居中布局 (方案 A 正确实现) --- */
@media (min-width: 1024px) {
    .container { 
        max-width: 580px; 
        margin: 40px auto; 
        padding: 28px 32px; 
        display: block; 
        border-radius: 20px; 
    }
    .pc-header { 
        position: relative; 
        margin-bottom: 20px;
    }
    .panel-popover {
        right: 0;
        top: 55px;
        width: 300px;
    }
}

.settings-trigger {
    position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; background: rgba(255, 255, 255, 0.05); backdrop-filter: blur(10px); border: 1px solid var(--glass-border); border-radius: 8px; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 100; transition: all 0.3s ease; color: var(--electric-color); font-size: 16px;
}
.settings-trigger:hover { background: rgba(79, 172, 254, 0.15); transform: rotate(90deg); }

/* 面板模式样式 */
.panel-inline { grid-column: 1 / -1; background: rgba(255, 255, 255, 0.02); border: 1px solid rgba(255, 255, 255, 0.05); border-radius: 12px; margin-bottom: 10px; overflow: hidden; max-height: 0; opacity: 0; transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1); padding: 0 12px; display: none; position: relative; }

.panel-inline.effects-active::before, .panel-popover.effects-active::before {
    content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
    background: conic-gradient(transparent 0deg, transparent 155deg, #4facfe 160deg, #00f2fe 210deg, transparent 215deg, transparent 360deg);
    animation: rotate 20s linear infinite; z-index: -1; opacity: 0.8;
    will-change: transform, opacity; transform: translate3d(0,0,0); backface-visibility: hidden;
}
.panel-inline.effects-active::after, .panel-popover.effects-active::after {
    content: ''; position: absolute; inset: 2px; background: rgba(20, 20, 35, 0.98); border-radius: 10.5px; z-index: -1;
}
.panel-inline.active-mode { display: block; }
.panel-inline.open { max-height: 800px; opacity: 1; padding: 12px; margin-top: 8px; border-color: rgba(79, 172, 254, 0.2); }

.panel-popover { position: absolute; top: 50px; right: 12px; width: 270px; background: rgba(15, 15, 25, 0.95); backdrop-filter: blur(25px); border: 1px solid var(--glass-border); border-radius: 12px; padding: 16px; box-shadow: 0 10px 40px rgba(0,0,0,0.6); z-index: 2000; display: none; opacity: 0; transform: translateY(-10px); transition: all 0.3s ease; pointer-events: none; overflow: hidden; }
.panel-popover.active-mode { display: none; }
.panel-popover.open { display: block; opacity: 1; transform: translateY(0); pointer-events: auto; }

/* 面板内容样式 */
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 8px; }
.panel-header h2 { margin: 0; font-size: 0.95em; color: var(--electric-color); letter-spacing: 0.5px; }
.close-btn { cursor: pointer; font-size: 20px; color: rgba(255,255,255,0.3); }

.setting-group { margin-bottom: 10px; }
.setting-group label { color: rgba(255,255,255,0.6); font-size: 0.72em; margin-bottom: 5px; display: block; font-weight: 600; text-transform: uppercase; }

.mode-tabs { display: flex; gap: 4px; background: rgba(255, 255, 255, 0.03); padding: 3px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.05); }
.mode-tab-btn { flex: 1; padding: 6px; text-align: center; cursor: pointer; border: 1px solid transparent; background: transparent; font-size: 0.7em; color: rgba(255, 255, 255, 0.4); border-radius: 6px; transition: all 0.3s ease; }
.mode-tab-btn.active { color: #ffffff; background: rgba(79, 172, 254, 0.15); border-color: rgba(79, 172, 254, 0.2); }

/* 核心 UI 样式 */
h1 { text-align: center; margin-bottom: 10px; font-size: 1.32em; font-weight: 700; background: linear-gradient(75deg, #4facfe, #00f2fe, #a974ff, #ff45da); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: 0 2px 10px rgba(79, 172, 254, 0.3); user-select: none; }
.security-tip { background: rgba(79, 172, 254, 0.08); border: 1px solid rgba(79, 172, 254, 0.15); color: #4facfe; padding: 6px 10px; border-radius: 8px; margin-bottom: 8px; font-size: 0.76em; }
.electric-wrapper { position: relative; padding: 1.5px; border-radius: 10px; margin-bottom: 8px; overflow: hidden; background: rgba(255, 255, 255, 0.04); transition: all 0.3s ease; }
.repo-url-wrapper { position: relative; overflow: visible !important; }
.repo-url-wrapper::after {
    content: "▼"; position: absolute; right: 0; top: 0; bottom: 0; width: 35px;
    display: flex; align-items: center; justify-content: center;
    font-size: 9px; color: rgba(255, 255, 255, 0.3); pointer-events: auto; 
    transition: color 0.3s; cursor: pointer; z-index: 20;
}
.repo-url-wrapper:hover::after { color: var(--electric-color); }

/* 隐藏原生 datalist 箭头 */
input::-webkit-calendar-picker-indicator { display: none !important; }

/* 顶层悬浮气泡下拉列表 */
.custom-dropdown {
    position: fixed; 
    background: rgba(10, 10, 15, 0.98); backdrop-filter: blur(20px);
    border: 1px solid rgba(79, 172, 254, 0.4); border-radius: 6px;
    z-index: 9999; max-height: 100px; overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8); display: none;
    pointer-events: auto;
}
.custom-dropdown.active { display: block; }
.dropdown-item {
    padding: 8px 12px; font-size: 14px; color: #ffffff;
    cursor: pointer; transition: all 0.2s; border-bottom: 1px solid rgba(255,255,255,0.02);
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.dropdown-item:hover { background: rgba(79, 172, 254, 0.1); }
.url-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.delete-history { 
    color: rgba(255, 255, 255, 0.3); font-size: 16px; padding: 0 4px; 
    transition: all 0.2s; border-radius: 4px; line-height: 1;
}
.delete-history:hover { color: #ff4b2b; background: rgba(255, 75, 43, 0.1); }
.dropdown-item:last-child { border-bottom: none; }
.electric-wrapper::before { content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; background: conic-gradient(transparent 0deg, transparent 155deg, #4facfe 160deg, #00f2fe 210deg, transparent 215deg, transparent 360deg); animation: rotate 20s linear infinite; opacity: 0; transition: opacity 0.3s ease; z-index: -1; }
.electric-wrapper.active::before, .electric-wrapper:focus-within::before { opacity: 1; }

.electric-inner { background: #0f0f0f; border-radius: 9px; width: 100%; height: 100%; display: block; position: relative; z-index: 1; }
input[type="text"], input[type="password"], input[type="file"] { width: 100%; padding: 7px 9px; border: none; border-radius: 9px; box-sizing: border-box; font-size: 0.86em; background: rgba(255, 255, 255, 0.03); color: #ffffff; outline: none; height: 32px; }
.password-wrapper { position: relative; display: flex; align-items: center; width: 100%; }
.toggle-password { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: transparent; border: none; color: rgba(255, 255, 255, 0.3); cursor: pointer; font-size: 0.85em; padding: 4px; z-index: 20; }
label { display: block; margin-bottom: 4px; font-weight: 600; color: rgba(255, 255, 255, 0.7); font-size: 0.78em; }
.tabs { display: flex; margin-bottom: 8px; background: rgba(255, 255, 255, 0.04); border-radius: 10px; padding: 3px; }
.tab-button { flex-grow: 1; padding: 6px 0; text-align: center; cursor: pointer; border: none; background: transparent; font-size: 0.83em; color: rgba(255, 255, 255, 0.5); border-radius: 7px; transition: all 0.3s ease; font-weight: 600; }
.tab-button.active { color: #ffffff; background: rgba(79, 172, 254, 0.15); border-bottom: 2px solid #4facfe; }
.tab-content { display: none; padding: 2px 0; }
.tab-content.active { display: block; }
button.action-button { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); color: white; padding: 8px 14px; border: none; border-radius: 9px; cursor: pointer; width: 100%; font-size: 0.92em; font-weight: bold; transition: all 0.3s ease; position: relative; overflow: hidden; height: 32px; display: flex; align-items: center; justify-content: center; }
button.action-button .progress-bg { 
    position: absolute; left: 0; top: 0; height: 100%; width: 0%; 
    background: linear-gradient(90deg, #2ecc71, #27ae60);
    transition: width 0.3s ease; z-index: 0; opacity: 1;
    box-shadow: 2px 0 10px rgba(46, 204, 113, 0.4);
}
button.action-button .progress-bg::after {
    content: ""; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: progress-shimmer 2s infinite;
}

button.action-button .button-text { position: relative; z-index: 1; }
button.danger-button { background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%); }
#log-output { background: rgba(0, 0, 0, 0.4); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 10px; padding: 9px; max-height: 200px; overflow-y: auto; white-space: pre-wrap; font-family: 'Consolas', 'Monaco', monospace; font-size: 0.73em; color: #00f2fe; margin-top: 6px; }

/* 文件查看编辑模态框样式 */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.7); display: none; align-items: center; justify-content: center; z-index: 3000; }
.modal-overlay.active { display: flex; }
.modal-content { background: rgba(15, 15, 25, 0.98); backdrop-filter: blur(25px); border: 1px solid rgba(79, 172, 254, 0.2); border-radius: 12px; padding: 15px; width: 92%; max-width: 900px; min-width: 300px; max-height: 90vh; box-shadow: 0 10px 50px rgba(0, 0, 0, 0.8); display: flex; flex-direction: column; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); padding-bottom: 8px; }
.modal-header h2 { margin: 0; font-size: 0.95em; color: var(--electric-color); letter-spacing: 0.5px; }
#fileNameInput { background: transparent; border: 1px solid transparent; color: #fff; font-size: 1em; width: 100%; outline: none; padding: 4px 8px; border-radius: 4px; transition: all 0.3s; }
#fileNameInput:focus { border-color: rgba(79, 172, 254, 0.5); background: rgba(255, 255, 255, 0.05); }
#fileNameInput:disabled { color: #888; cursor: default; }

.file-preview, #filePreview {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.6;
    min-height: 300px;
    color: #e0e0e0;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: auto;
    display: block;
}

.editor-container {
    display: flex;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(79, 172, 254, 0.3);
    border-radius: 8px;
    height: 500px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    overflow: hidden;
}

#fileEditor {
    flex: 1;
    background: transparent;
    color: #fff;
    border: none;
    padding: 10px;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    tab-size: 4;
    width: 100%;
    box-sizing: border-box;
    overflow: auto;
}

.line-numbers {
    width: 45px;
    padding: 10px 0;
    text-align: right;
    background: rgba(0, 0, 0, 0.3);
    color: #555;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    line-height: 1.5;
    user-select: none;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
    padding-right: 8px;
    box-sizing: border-box;
}

.editor-container.wrap-on #fileEditor {
    white-space: pre-wrap;
    word-break: break-all;
}
.editor-container.wrap-off #fileEditor {
    white-space: pre;
    word-break: normal;
}

#fileEditor.wrap-on {
    white-space: pre-wrap;
    word-break: break-word;
}
#fileEditor.wrap-off {
    white-space: pre;
    word-break: normal;
}

.modal-content.editing-mode {
    width: 98vw;
    max-width: 98vw;
    height: 98vh;
    max-height: 98vh;
    margin: 1vh auto;
    border-radius: 12px;
}
.modal-body { flex: 1; overflow-y: auto; margin-bottom: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: rgba(15, 15, 25, 0.98); padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, 0.1); margin-top: 10px; }
.btn-edit, .btn-save, .btn-cancel, .btn-close { padding: 8px 16px; border-radius: 6px; cursor: pointer; font-weight: bold; border: none; transition: all 0.3s ease; }
.btn-edit { background: #4facfe; color: white; }
.btn-save { background: #2ecc71; color: white; }
.btn-cancel { background: #95a5a6; color: white; }
.btn-close { background: rgba(255,255,255,0.1); color: white; }

/* 顶部固定搜索工具栏 */
.search-toolbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 15, 25, 0.98);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(79, 172, 254, 0.25);
    padding: 6px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-bottom: 8px;
    min-height: 34px;
    box-sizing: border-box;
}

.search-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 auto;
    min-width: 0;
}

.search-row:first-child {
    flex: 1 1 100%;
}

.search-input-group {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    padding: 0 6px;
    flex: 1;
    height: 24px;
    box-sizing: border-box;
}

.search-input-group input {
    background: transparent;
    border: none;
    height: 20px;
    font-size: 0.75em;
    padding: 0 4px;
    width: 100%;
    color: #fff;
    outline: none;
}

.search-input-group input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.search-input-group .match-counter {
    font-size: 0.7em;
    color: #4facfe;
    white-space: nowrap;
    padding-left: 4px;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    opacity: 0.8;
}

.search-btn {
    background: rgba(79, 172, 254, 0.08);
    border: 1px solid rgba(79, 172, 254, 0.2);
    color: #4facfe;
    padding: 0 8px;
    border-radius: 4px;
    font-size: 0.75em;
    cursor: pointer;
    transition: all 0.2s ease;
    height: 24px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    font-weight: 500;
}

.search-btn:hover {
    background: rgba(79, 172, 254, 0.15);
    border-color: rgba(79, 172, 254, 0.4);
}

.search-btn.primary {
    background: rgba(46, 204, 113, 0.15);
    border-color: rgba(46, 204, 113, 0.3);
    color: #2ecc71;
}

.search-btn.primary:hover {
    background: rgba(46, 204, 113, 0.25);
    border-color: rgba(46, 204, 113, 0.5);
}

.search-btn.wrap-btn-on {
    background: rgba(46, 204, 113, 0.15);
    border-color: rgba(46, 204, 113, 0.4);
    color: #2ecc71;
    font-weight: bold;
}

.search-btn.wrap-btn-on:hover {
    background: rgba(46, 204, 113, 0.28);
    border-color: rgba(46, 204, 113, 0.6);
}

.search-btn.wrap-btn-off {
    background: rgba(150, 150, 150, 0.08);
    border-color: rgba(150, 150, 150, 0.25);
    color: #888;
}

.search-btn.wrap-btn-off:hover {
    background: rgba(150, 150, 150, 0.15);
    border-color: rgba(150, 150, 150, 0.45);
}

/* 自定义极简科技感滚动条 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
    background: rgba(79, 172, 254, 0.3);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(79, 172, 254, 0.6);
}
