/* =============================================================
   管理后台样式：布局、表格、统计卡、座位管理、登录
   ============================================================= */

/* -------------------------------------------------------------
   基础布局
   ---------------------------------------------------------- */
.admin-body {
    background: var(--bg);
    min-height: 100vh;
}

.admin-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    flex: 0 0 232px;
    width: 232px;
    background: #101828;
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 18px 12px 12px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 20px;
}
.sidebar-brand .brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .1);
    color: #9db0ff;
}
.sidebar-brand strong {
    display: block;
    font-size: 14.5px;
    letter-spacing: .01em;
}
.sidebar-brand small {
    display: block;
    font-size: 11.5px;
    color: rgba(255, 255, 255, .45);
    margin-top: 2px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow-y: auto;
    flex: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 9px;
    color: rgba(255, 255, 255, .68);
    font-size: 13.5px;
    font-weight: 500;
    transition: background .16s ease, color .16s ease;
}
.sidebar-link:hover {
    background: rgba(255, 255, 255, .07);
    color: #fff;
}
.sidebar-link.is-active {
    background: rgba(93, 118, 255, .22);
    color: #fff;
    font-weight: 600;
}
.sidebar-link .badge { margin-left: auto; }

.sidebar-foot {
    border-top: 1px solid rgba(255, 255, 255, .08);
    padding-top: 8px;
    margin-top: 8px;
}

.admin-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 26px;
    background: rgba(255, 255, 255, .82);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}
.admin-title h1 {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -.01em;
}
.admin-title p {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 2px;
}
.admin-topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.admin-user {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-soft);
}

.admin-content {
    padding: 22px 26px 48px;
    width: 100%;
    max-width: 1320px;
}

/* -------------------------------------------------------------
   统计卡 / 面板
   ---------------------------------------------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    transition: transform .18s ease, box-shadow .18s ease;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.stat-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12.5px;
    color: var(--text-muted);
    font-weight: 600;
}
.stat-value {
    font-size: 27px;
    font-weight: 700;
    letter-spacing: -.02em;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}
.stat-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 18px;
}
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 18px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.panel-head h2 {
    font-size: 15px;
    font-weight: 700;
}
.panel-head p {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 2px;
}
.panel-body { padding: 18px; }
.panel-body.tight { padding: 0; }
.panel-foot {
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 18px;
    align-items: start;
}

/* -------------------------------------------------------------
   工具栏 / 分段筛选
   ---------------------------------------------------------- */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.toolbar .field { margin: 0; }
.toolbar-spacer { flex: 1; }

.input-sm {
    padding: 9px 12px !important;
    font-size: 13.5px !important;
    border-radius: 9px !important;
    width: auto;
}
.search-box {
    position: relative;
    display: flex;
    align-items: center;
}
.search-box .icon {
    position: absolute;
    left: 11px;
    color: var(--text-muted);
    pointer-events: none;
}
.search-box input {
    padding-left: 34px !important;
    min-width: 210px;
}

.seg {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow-x: auto;
    max-width: 100%;
}
.seg a,
.seg button {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-soft);
    background: transparent;
    border: 0;
    cursor: pointer;
    white-space: nowrap;
    transition: background .16s ease, color .16s ease;
}
.seg a:hover,
.seg button:hover { background: var(--bg-soft); color: var(--text); }
.seg a.is-active,
.seg button.is-active {
    background: var(--primary);
    color: #fff;
}

/* -------------------------------------------------------------
   表格
   ---------------------------------------------------------- */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    min-width: 660px;
}
.data-table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: .02em;
    padding: 11px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background .14s ease; }
.data-table tbody tr:hover { background: #fafbff; }
.data-table .num { font-variant-numeric: tabular-nums; }
.data-table .actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.data-table .actions .btn { padding: 5px 10px; font-size: 12px; border-radius: 8px; }

.cell-main { font-weight: 600; }
.cell-sub {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}
.cell-empty { color: var(--text-muted); }

/* -------------------------------------------------------------
   座位管理
   ---------------------------------------------------------- */
.admin-classroom {
    background: linear-gradient(180deg, #fbfcff, #f3f6fd);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
}

.admin-podium {
    text-align: center;
    font-size: 12px;
    letter-spacing: .5em;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: 10px;
    padding: 8px 0;
    margin-bottom: 16px;
}

.admin-seat-grid {
    display: grid;
    grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
    gap: 12px;
}
.admin-seat-grid.is-swapping .admin-seat { cursor: crosshair; }

.admin-desk {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    box-shadow: var(--shadow-sm);
}
.admin-desk-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    padding: 0 2px 6px;
}
.admin-desk-code {
    font-weight: 700;
    color: var(--text-soft);
    letter-spacing: .04em;
}
.admin-desk-seats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.admin-seat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    min-height: 54px;
    padding: 6px 4px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-soft);
    font-size: 12.5px;
    cursor: pointer;
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease, background .16s ease;
    text-align: center;
}
.admin-seat:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 8px 18px -12px rgba(61, 90, 254, .7);
}
.admin-seat:active { transform: scale(.985); }
.admin-seat .seat-side {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: .1em;
}
.admin-seat .seat-name {
    font-weight: 600;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.admin-seat-taken {
    background: #eef2fb;
    border-color: #dbe3f6;
    color: var(--text);
}
.admin-seat-locked {
    background: #f0f1f4;
    border-style: dashed;
    color: var(--text-muted);
}
.admin-seat-locked .seat-name { color: var(--text-muted); }
.admin-seat.is-selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(61, 90, 254, .35);
    background: var(--primary-soft);
    color: var(--primary-dark);
}
.admin-seat.is-swap-source {
    border-color: var(--warn);
    box-shadow: 0 0 0 2px rgba(217, 139, 0, .3);
    background: var(--warn-soft);
}

.seat-legend {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-muted);
}
.seat-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-box {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface);
}
.legend-box.is-taken { background: #eef2fb; border-color: #dbe3f6; }
.legend-box.is-locked { background: #f0f1f4; border-style: dashed; }

/* -------------------------------------------------------------
   设置表单
   ---------------------------------------------------------- */
.settings-form { display: flex; flex-direction: column; gap: 18px; }
.settings-section + .settings-section {
    border-top: 1px solid var(--border);
    padding-top: 18px;
}
.settings-section h3 {
    font-size: 13.5px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text);
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}
.form-grid .field { margin-bottom: 0; }

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 11px 0;
    border-bottom: 1px dashed var(--border);
}
.switch-row:last-child { border-bottom: 0; }
.switch-copy strong { display: block; font-size: 13.5px; }
.switch-copy small { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.switch {
    position: relative;
    flex: 0 0 auto;
    width: 44px;
    height: 25px;
}
.switch input {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}
.switch .track {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 999px;
    background: #d5dbe7;
    transition: background .18s ease;
}
.switch .track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 19px;
    height: 19px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .25);
    transition: transform .18s ease;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(19px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 4px rgba(61, 90, 254, .18); }

/* -------------------------------------------------------------
   日志详情
   ---------------------------------------------------------- */
.log-detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 4px;
}
.log-json {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.7;
    color: var(--text-soft);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 180px;
    overflow: auto;
}
.log-json-title {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 4px;
}

/* -------------------------------------------------------------
   管理员登录页
   ---------------------------------------------------------- */
.admin-login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px 18px;
    background:
        radial-gradient(80% 60% at 15% 0%, #23304f 0%, #131a2b 52%, #0c111c 100%);
}

.admin-login-card {
    width: min(100%, 400px);
    background: var(--surface);
    border-radius: 20px;
    padding: 30px 28px 24px;
    box-shadow: 0 40px 80px -40px rgba(4, 9, 22, .9);
    animation: cardIn .45s cubic-bezier(.2, .8, .3, 1) both;
}
@keyframes cardIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: none; }
}
.admin-login-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}
.admin-login-head .brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary);
}
.admin-login-head h1 { font-size: 18px; font-weight: 700; }
.admin-login-head p { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.admin-login-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
    font-size: 12.5px;
    color: var(--text-muted);
}

.auth-error {
    margin-top: 12px;
    font-size: 13px;
    color: var(--danger);
    background: var(--danger-soft);
    border: 1px solid #f8d5d3;
    border-radius: 9px;
    padding: 9px 12px;
}

.modal-text {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-soft);
}

/* -------------------------------------------------------------
   响应式
   ---------------------------------------------------------- */
@media (max-width: 980px) {
    .admin-shell { flex-direction: column; }
    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        flex: none;
        padding: 12px 12px 8px;
    }
    .sidebar-brand { padding: 2px 6px 10px; }
    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        gap: 4px;
        padding-bottom: 4px;
        scrollbar-width: none;
    }
    .sidebar-nav::-webkit-scrollbar { display: none; }
    .sidebar-link { white-space: nowrap; padding: 8px 12px; font-size: 13px; }
    .sidebar-foot { display: none; }
    .admin-topbar {
        position: static;
        padding: 14px 16px;
        align-items: flex-start;
    }
    .admin-content { padding: 16px 14px 40px; }
    .admin-classroom { padding: 12px; }
    .admin-seat-grid { gap: 8px; }
    .admin-desk { padding: 6px; border-radius: 10px; }
    .admin-seat { min-height: 48px; font-size: 12px; padding: 5px 3px; }
    .log-detail { grid-template-columns: 1fr; }
    .panel-body { padding: 14px; }
}

@media (max-width: 640px) {
    .admin-title h1 { font-size: 16.5px; }
    .admin-title p { display: none; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .stat-card { padding: 13px 14px; }
    .stat-value { font-size: 22px; }
    .search-box input { min-width: 0; width: 100%; }
    .toolbar .search-box { flex: 1 1 100%; }
    .admin-desk-head .admin-desk-row { display: none; }
    .admin-seat { min-height: 44px; }
    .admin-seat .seat-name { font-size: 11.5px; }
}
