/* ============================================================
   爱特文件管理器 — 宝塔面板风格
   Clean admin panel, table-style file listing, green accents
   ============================================================ */

/* ── Reset & Vars ── */
:root {
    --green: #20a53a;
    --green-hover: #1a8a30;
    --green-light: #e8f8ec;
    --red: #e64242;
    --red-light: #fef0f0;
    --blue: #1677ff;
    --blue-light: #e8f4fd;
    --orange: #f90;

    --header-bg: #2d2d2d;
    --sidebar-bg: #333;
    --sidebar-hover: #3c3c3c;
    --sidebar-active: #20a53a;
    --bg: #f0f2f5;
    --card-bg: #fff;
    --border: #e8e8e8;
    --border-light: #f0f0f0;
    --text: #333;
    --text-secondary: #888;
    --text-muted: #bbb;

    --radius: 3px;
    --shadow: 0 1px 3px rgba(0,0,0,.08);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --font-mono: 'SF Mono', 'Cascadia Code', 'Consolas', 'Courier New', monospace;
    --fs: 13px;
    --fs-sm: 12px;
    --fs-lg: 14px;
    --sidebar-w: 200px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { color: #4096ff; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ── Header ── */
.header {
    height: 48px;
    background: var(--header-bg);
    color: #ccc;
    display: flex;
    align-items: center;
    padding: 0 16px;
    flex-shrink: 0;
    z-index: 200;
    position: sticky;
    top: 0;
}
.header-logo {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    margin-right: 24px;
    white-space: nowrap;
}
.header-nav {
    display: flex;
    height: 100%;
}
.header-nav a {
    display: flex;
    align-items: center;
    padding: 0 16px;
    color: #bbb;
    font-size: var(--fs);
    border-bottom: 2px solid transparent;
    transition: all .15s;
    white-space: nowrap;
}
.header-nav a:hover,
.header-nav a.active {
    color: #fff;
    border-bottom-color: var(--green);
    text-decoration: none;
}
.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: var(--fs-sm);
    color: #999;
}
.header-actions a { color: #ccc; }
.header-actions a:hover { color: #fff; }

/* ── Layout ── */
.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: #ccc;
    flex-shrink: 0;
    overflow-y: auto;
    padding: 8px 0;
    transition: transform .2s;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.sidebar-group {
    padding: 12px 16px 4px;
    font-size: var(--fs-sm);
    color: #777;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px 8px 20px;
    color: #bbb;
    font-size: var(--fs);
    cursor: pointer;
    transition: all .1s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    text-decoration: none;
    border-left: 2px solid transparent;
}
.sidebar-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.sidebar-item.active {
    background: rgba(32,165,58,.15);
    color: var(--green);
    border-left-color: var(--green);
    font-weight: 500;
}
.sidebar-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .7; }
.sidebar-item.active svg { opacity: 1; }

/* ── Main content ── */
.main {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* ── Breadcrumb ── */
.breadcrumb {
    padding: 10px 16px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    font-size: var(--fs-sm);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
}
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--blue); }
.breadcrumb .sep { color: #ccc; margin: 0 2px; }
.breadcrumb .current { color: var(--text); font-weight: 500; }

/* ── Content area ── */
.content {
    padding: 16px;
    flex: 1;
}

/* ── Card / Panel ── */
.panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.panel-header {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-light);
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--fs);
    background: #fafafa;
}
.panel-body { padding: 16px; }

/* ── Toolbar ── */
.toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    padding: 10px 0;
}
.toolbar form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex: 1;
    min-width: 0;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px 14px;
    border: 1px solid #d9d9d9;
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    font-size: var(--fs-sm);
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
    user-select: none;
    text-decoration: none;
    line-height: 1.5;
}
.btn:hover { color: var(--blue); border-color: var(--blue); text-decoration: none; }
.btn:active { transform: scale(.97); }

.btn-primary {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}
.btn-primary:hover { background: var(--green-hover); border-color: var(--green-hover); color: #fff; }

.btn-danger { color: var(--red); }
.btn-danger:hover { color: var(--red); border-color: var(--red); background: var(--red-light); }

.btn-xs { padding: 2px 8px; font-size: 11px; border-radius: 2px; }
.btn-sm { padding: 3px 10px; font-size: var(--fs-sm); }
.btn-icon {
    padding: 4px; border: none; background: transparent;
    cursor: pointer; color: var(--text-secondary); border-radius: var(--radius);
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px;
}
.btn-icon:hover { background: rgba(0,0,0,.06); color: var(--text); }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.btn-group .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-group .btn + .btn { margin-left: -1px; }

/* ── Inputs ── */
.input {
    padding: 5px 10px;
    border: 1px solid #d9d9d9;
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    font-size: var(--fs-sm);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    line-height: 1.5;
}
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(22,119,255,.12); }
.input-sm { padding: 3px 8px; font-size: 11px; }
.input-mono { font-family: var(--font-mono); }

.select {
    padding: 5px 10px;
    border: 1px solid #d9d9d9;
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    font-size: var(--fs-sm);
    outline: none;
    cursor: pointer;
}
.select:focus { border-color: var(--blue); }

.textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #d9d9d9;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    line-height: 1.6;
    resize: vertical;
    outline: none;
    tab-size: 4;
}
.textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(22,119,255,.12); }

/* ── File Table ── */
.file-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
.file-table th {
    padding: 9px 12px;
    background: #fafafa;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-weight: 500;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    white-space: nowrap;
    user-select: none;
}
.file-table td {
    padding: 7px 12px;
    border-bottom: 1px solid var(--border-light);
    font-size: var(--fs-sm);
    vertical-align: middle;
}
.file-table tr:hover td { background: #f5f9ff; }

.file-table .col-cb { width: 36px; text-align: center; }
.file-table .col-name { }
.file-table .col-size { width: 90px; text-align: right; }
.file-table .col-perms { width: 80px; text-align: center; font-family: var(--font-mono); font-size: var(--fs-sm); }
.file-table .col-owner { width: 70px; text-align: center; }
.file-table .col-time { width: 140px; text-align: right; font-size: var(--fs-sm); }
.file-table .col-actions { width: 180px; text-align: right; white-space: nowrap; }

.file-table .file-icon {
    display: inline-block;
    width: 18px;
    text-align: center;
    margin-right: 6px;
    font-size: 15px;
    vertical-align: -1px;
}
.file-table .file-icon.dir { color: var(--orange); }
.file-table .file-icon.img { color: #722ed1; }
.file-table .file-icon.zip { color: #fa8c16; }
.file-table .file-icon.code { color: var(--blue); }
.file-table .file-icon.txt { color: var(--text-secondary); }

.file-table .file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-table .file-name a { color: var(--text); font-weight: 500; }
.file-table .file-name a:hover { color: var(--blue); }
.file-table .file-name .link-arrow { color: var(--blue); margin-left: 4px; font-size: 11px; }

.file-table .actions {
    display: flex;
    gap: 0;
    justify-content: flex-end;
}
.file-table .actions a {
    color: var(--text-secondary);
    padding: 2px 7px;
    font-size: 11px;
    border-radius: 2px;
    white-space: nowrap;
}
.file-table .actions a:hover { background: #e8f4fd; color: var(--blue); text-decoration: none; }
.file-table .actions a.danger:hover { background: var(--red-light); color: var(--red); }

/* ── Disk bar ── */
.disk-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    margin-bottom: 10px;
    align-items: center;
}
.disk-bar a {
    padding: 2px 8px;
    border: 1px solid #d9d9d9;
    border-radius: 2px;
    background: #fff;
    font-size: 11px;
    color: var(--text-secondary);
}
.disk-bar a:hover { border-color: var(--blue); color: var(--blue); text-decoration: none; }

/* ── Batch bar ── */
.batch-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
    flex-wrap: wrap;
}

/* ── Form rows ── */
.form-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.form-label {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    flex-shrink: 0;
    min-width: 60px;
}

/* ── Alerts ── */
.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; font-size: var(--fs-sm); }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.alert a { font-weight: 500; }

/* ── Empty ── */
.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: var(--fs); }

/* ── Result list ── */
.result-list { }
.result-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-bottom: 1px solid var(--border-light);
    font-size: var(--fs-sm);
}
.result-row .icon { width: 18px; text-align: center; font-weight: 700; flex-shrink: 0; }
.result-row .icon.ok { color: var(--green); }
.result-row .icon.fail { color: var(--red); }

/* ── Modal ── */
.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn .15s;
}
.modal {
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 6px 24px rgba(0,0,0,.15);
    max-width: 90vw;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalIn .2s ease;
    min-width: 400px;
}
.modal-lg { width: 960px; max-width: 95vw; }
.modal-header {
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-light);
    font-weight: 500;
    font-size: var(--fs-lg);
}
.modal-close {
    width: 28px; height: 28px;
    border: none; background: none; cursor: pointer;
    color: var(--text-secondary); font-size: 18px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius);
}
.modal-close:hover { background: #f0f0f0; color: var(--text); }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-light);
    text-align: right;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ── Toast ── */
.toasts {
    position: fixed;
    top: 60px;
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    padding: 10px 16px;
    border-radius: var(--radius);
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
    font-size: var(--fs-sm);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideIn .2s ease;
    max-width: 360px;
    border-left: 3px solid var(--blue);
}
.toast-ok { border-left-color: var(--green); }
.toast-err { border-left-color: var(--red); }
.toast-out { animation: slideOut .15s ease forwards; }

/* ── Context menu ── */
.ctx-menu {
    position: fixed;
    z-index: 1500;
    min-width: 160px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    border: 1px solid var(--border-light);
    padding: 4px;
    animation: fadeIn .1s;
}
.ctx-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: 2px;
    cursor: pointer;
    font-size: var(--fs-sm);
    color: var(--text);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.ctx-item:hover { background: #f5f5f5; }
.ctx-sep { height: 1px; background: var(--border-light); margin: 4px 8px; }

/* ── Code viewer (syntax highlighting) ── */
.code-wrap {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    line-height: 1.7;
    background: #fafafa;
    max-height: 70vh;
}
.code-lines {
    padding: 8px 0;
    background: #f0f0f0;
    color: #999;
    text-align: right;
    user-select: none;
    flex-shrink: 0;
    border-right: 1px solid #e0e0e0;
    min-width: 48px;
}
.code-lines span {
    display: block;
    padding: 0 10px;
    font-size: 11px;
    line-height: 1.7;
}
.code-content {
    padding: 8px 12px;
    overflow: auto;
    flex: 1;
    white-space: pre-wrap;
    word-break: break-all;
}
.code-content pre {
    margin: 0;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

/* ── Syntax colors (light theme) ── */
.syn-kw  { color: #d73a49; font-weight: 600; }  /* keyword */
.syn-str { color: #032f62; }                      /* string */
.syn-cmt { color: #6a737d; font-style: italic; }  /* comment */
.syn-num { color: #005cc5; }                      /* number */
.syn-fn  { color: #6f42c1; }                      /* function */
.syn-var { color: #e36209; }                      /* variable/php var */
.syn-tag { color: #22863a; }                      /* html tag */
.syn-attr { color: #6f42c1; }                     /* html attr */
.syn-op  { color: #d73a49; }                      /* operator */
.syn-bool { color: #005cc5; }                     /* boolean/null */
.syn-plain { color: #24292e; }

/* ── Editor ── */
.editor-wrap {
    display: flex;
    border: 1px solid #d9d9d9;
    border-radius: var(--radius);
    overflow: hidden;
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    line-height: 1.7;
}
.editor-wrap:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(22,119,255,.12); }
.editor-lines {
    padding: 10px 0;
    background: #f0f0f0;
    color: #999;
    text-align: right;
    user-select: none;
    flex-shrink: 0;
    border-right: 1px solid #e0e0e0;
    min-width: 50px;
}
.editor-lines span {
    display: block;
    padding: 0 10px;
    font-size: 11px;
    line-height: 1.7;
}
.editor-textarea {
    flex: 1;
    border: none;
    outline: none;
    padding: 10px 12px;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    resize: none;
    tab-size: 4;
    background: #fff;
    overflow: auto;
}

/* ── Shell ── */
.shell {
    background: #1e1e1e;
    color: #d4d4d4;
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    border-radius: var(--radius);
    overflow: hidden;
}
.shell-out { padding: 14px; max-height: 500px; overflow-y: auto; white-space: pre-wrap; line-height: 1.5; }
.shell-in { display: flex; border-top: 1px solid #333; }
.shell-in span {
    padding: 10px 14px;
    color: #6a9955;
    user-select: none;
}
.shell-in input {
    flex: 1;
    background: none;
    border: none;
    color: #d4d4d4;
    font-family: inherit;
    font-size: inherit;
    padding: 10px 0;
    outline: none;
}

/* ── Checkbox row ── */
.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: var(--fs-sm);
    border-bottom: 1px solid var(--border-light);
}

/* ── Login page (dark overlay) ── */
.login-screen {
    position: fixed; inset: 0;
    background: #1a1a2e;
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
}
.login-box {
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 8px;
    padding: 36px 32px;
    width: 340px;
    max-width: 90vw;
    animation: modalIn .25s ease;
}
.login-box h2 { color: #fff; text-align: center; margin-bottom: 24px; font-weight: 500; }
.login-box label { color: rgba(255,255,255,.6); font-size: var(--fs-sm); display: block; margin-bottom: 6px; }
.login-box .input {
    width: 100%;
    margin-bottom: 16px;
    background: rgba(255,255,255,.08);
    border-color: rgba(255,255,255,.12);
    color: #fff;
}
.login-box .input:focus { border-color: var(--green); box-shadow: 0 0 0 2px rgba(32,165,58,.2); }
.login-box .btn-login {
    width: 100%;
    padding: 9px;
    border: none;
    border-radius: var(--radius);
    background: var(--green);
    color: #fff;
    font-size: var(--fs);
    font-weight: 500;
    cursor: pointer;
}
.login-box .btn-login:hover { background: var(--green-hover); }

/* ── Animations ── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(-20px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
@keyframes slideOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(30px); } }

/* ── Loading ── */
.spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border: 2px solid #e0e0e0;
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin .5s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utility ── */
.text-mono { font-family: var(--font-mono); }
.text-sm { font-size: var(--fs-sm); }
.text-muted { color: var(--text-secondary); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ml-auto { margin-left: auto; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap8 { gap: 8px; }
.gap4 { gap: 4px; }
.items-center { align-items: center; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 48px; left: 0; bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        box-shadow: 4px 0 12px rgba(0,0,0,.15);
    }
    .sidebar.open { transform: translateX(0); }
    .content { padding: 10px; }
    .file-table .col-perms,
    .file-table .col-owner,
    .file-table .col-time { display: none; }
    .file-table .col-actions { width: auto; }
    .modal { min-width: auto; width: 95vw; }
}
