/* ============================================================
   ส่วนผู้ดูแลระบบกลาง (/superadmin) — ใช้กับ SuperAdminLayout และหน้าใน Components/Pages/SuperAdmin
   แบบ: เมนูแถบซ้ายสีเข้ม เนื้อหาเป็นการ์ดสีขาวบนพื้นเทาอ่อน
   ใช้สีและตัวแปรจาก app.css (--brand, --line, --muted ...) โหลดต่อจาก app.css ใน App.razor
   ============================================================ */
.sa { flex: 1; display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sa-side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
           background: #18212e; color: #c6d0dc; padding: 20px 14px; }
.sa-brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-size: 1.5rem;
            font-weight: 700; padding: 0 8px 18px; flex-wrap: wrap; }
.sa-brand svg { width: 30px; height: 30px; fill: #4d9bff; }
.sa-brand b { color: #4d9bff; }
.sa-tag { font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #ffcf66;
          border: 1px solid rgba(255, 207, 102, .5); border-radius: 999px; padding: 1px 8px; }
.sa-nav { display: flex; flex-direction: column; gap: 2px; }
.sa-nav a { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px;
            color: #c6d0dc; text-decoration: none; }
.sa-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sa-nav a.active { background: rgba(77, 155, 255, .16); color: #fff; font-weight: 700; }
.sa-nav a.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px;
                           border-radius: 0 3px 3px 0; background: #4d9bff; }
.sa-nav .icon { flex: none; }
.sa-me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px;
         border-top: 1px solid rgba(255, 255, 255, .08); }
.sa-me .avatar { background: #4d9bff; color: #fff; flex: none; }
.sa-me-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.sa-me-info strong { color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sa-me-info span { font-size: .8rem; color: #8d9aab; }
.sa-side-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 8px; }
.sa-side-foot form { margin: 0; }
.sa-side-foot .lang { flex: none; border-color: rgba(255, 255, 255, .15); }
.sa-side-foot .lang a { color: #c6d0dc; }
.sa-side-foot .lang a.active { background: #4d9bff; color: #fff; }
.sa-logout { font: inherit; font-size: .9rem; display: inline-flex; align-items: center; gap: 6px; border: 0;
             background: none; color: #c6d0dc; cursor: pointer; padding: 6px 8px; border-radius: 6px; }
.sa-logout:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.sa-main { width: 100%; max-width: 1280px; padding: 28px 32px 48px; }
.sa-back { margin: 0 0 8px; }
.sa-back a { color: var(--muted); text-decoration: none; font-size: .92rem; }
.sa-back a:hover { color: var(--brand); }
.sa-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.sa-head h1 { margin: 0; font-size: 1.75rem; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sa-head h1 .badge { font-size: .8rem; }
.sa-head form { margin: 0; }
.sa-sub { margin: 4px 0 0; color: var(--muted); }
.sa-outline { border: 1px solid #f1c2bd; }

/* การ์ดตัวเลข */
.sa-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 16px; }
.sa-kpi { position: relative; display: flex; flex-direction: column; gap: 2px; background: #fff; border: 1px solid var(--line);
          border-radius: 12px; padding: 16px 18px; color: var(--text); text-decoration: none; }
a.sa-kpi:hover { border-color: #b9cde3; box-shadow: 0 2px 10px rgba(15, 108, 189, .08); }
.sa-kpi-icon { position: absolute; top: 14px; right: 14px; width: 38px; height: 38px; border-radius: 10px;
               display: flex; align-items: center; justify-content: center; background: #eaf3fc; color: var(--brand); }
.sa-kpi-label { color: var(--muted); font-size: .9rem; }
.sa-kpi strong { font-size: 2rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.sa-kpi strong.sa-kpi-date { font-size: 1.4rem; padding: 4px 0; }
.sa-kpi-sub { color: var(--muted); font-size: .82rem; }
.sa-kpis.small .sa-kpi strong { font-size: 1.6rem; }

/* การ์ดเนื้อหา: 2 คอลัมน์บนจอกว้าง */
.sa-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; align-items: start; }
.sa-grid.wide-first { grid-template-columns: minmax(0, 1fr) 320px; }
.sa-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin: 0 0 16px; }
.sa-grid > .sa-card { margin: 0; }
.sa-card.flush { padding: 0; overflow: hidden; }
.sa-card.sa-narrow { max-width: 520px; }
.sa-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sa-card-head h2 { margin: 0; font-size: 1.08rem; display: flex; align-items: center; gap: 8px; }
.sa-card-head .muted { font-size: .88rem; }
.sa-more { display: inline-flex; align-items: center; gap: 2px; color: var(--brand); text-decoration: none; font-size: .9rem; }
.sa-more .icon { width: 16px; height: 16px; }
.sa-empty { margin: 8px 0; }
.sa-card.flush .sa-empty { padding: 16px 20px; }
.sa-table-wrap { overflow-x: auto; }
.muted.small { font-size: .82rem; }

/* กราฟแท่ง 14 วัน: สีเดียว (สีแบรนด์) แท่งบาง มุมบนมน 4px ชิดเส้นฐาน
   ชี้เมาส์ = แท่งเข้มขึ้น + title บอกวันที่/จำนวน, ตัวเลขแสดงเฉพาะแท่งสูงสุด */
.sa-chart { display: flex; align-items: flex-end; gap: 4px; height: 196px; padding-top: 8px; border-bottom: 1px solid var(--line); }
.sa-bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
              gap: 4px; cursor: default; border-radius: 6px 6px 0 0; }
.sa-bar-col:hover { background: #f3f7fb; }
.sa-bar { width: 60%; max-width: 22px; min-height: 2px; background: var(--brand); border-radius: 4px 4px 0 0; }
.sa-bar.zero { background: #d8dee6; }
.sa-bar-col:hover .sa-bar:not(.zero) { background: #0b4f8a; }
.sa-bar-val { font-size: .78rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.sa-bar-day { font-size: .75rem; color: var(--muted); padding-bottom: 4px; font-variant-numeric: tabular-nums; }

/* รายการในการ์ด (ต้องดูแล / สมัครล่าสุด / บันทึกล่าสุด) */
.sa-list { list-style: none; margin: 0; padding: 0; }
.sa-list li { border-top: 1px solid #eef1f4; }
.sa-list li:first-child { border-top: 0; }
.sa-list li > a, .sa-log li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 4px;
                              color: var(--text); text-decoration: none; }
.sa-list li > a:hover { background: #f5f9fd; }
.sa-list-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sa-list-main .muted { font-size: .85rem; }
.sa-log li { justify-content: flex-start; align-items: flex-start; }
.sa-log-dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; margin: 8px 8px 0 0;
              background: var(--brand); vertical-align: middle; }
td .sa-log-dot { margin-top: 0; }
.sa-log-dot.ok { background: #1f8a4c; }
.sa-log-dot.bad { background: #b42318; }

/* แท็บกรองแบบ Outlook: เส้นฟ้าใต้แท็บที่เลือก */
.sa-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.sa-tabs a { position: relative; padding: 8px 14px; color: var(--text); text-decoration: none; white-space: nowrap; border-radius: 6px 6px 0 0; }
.sa-tabs a:hover { background: #f0f0f0; }
.sa-tabs a.active { font-weight: 700; }
.sa-tabs a.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px;
                           border-radius: 3px; background: var(--brand); }
.sa-count { display: inline-block; min-width: 22px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: #eef1f4;
            color: var(--muted); font-size: .78rem; text-align: center; font-weight: 400; }

.sa-filter { margin: 0; }
.sa-filter select { font: inherit; font-size: .95rem; padding: 7px 12px; border: 1px solid #dfe1e5; border-radius: 8px; background: #fff; }
.sa-pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 8px 0; }

/* ข้อมูลติดต่อ */
.sa-dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
.sa-dl dt { color: var(--muted); }
.sa-dl dd { margin: 0; overflow-wrap: anywhere; }

/* ฟอร์มในการ์ด */
.sa-form { max-width: none; }
.sa-form .btn { align-self: flex-start; }
.sa-inline-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin: 14px 0 4px; }
.sa-inline-form label { display: flex; flex-direction: column; gap: 4px; flex: 1 1 200px; }
.sa-inline-form input { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.sa-danger { border-color: #f1c2bd; background: #fffafa; }
.sa-danger h2 { color: #b42318; }
.sa-danger p { margin: 0; color: #5d6676; }

.avatar.sm { width: 28px; height: 28px; font-size: .85rem; margin-right: 8px; vertical-align: middle; }

/* ป้าย "Super Admin" ในหน้าเข้าสู่ระบบ */
.sa-login-tag { align-self: center; display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px;
                background: #18212e; color: #ffcf66; font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.sa-login-tag .icon { width: 16px; height: 16px; }

/* จอแคบ: เมนูซ้ายกลายเป็นแถบบน เลื่อนซ้าย-ขวาได้ */
@media (max-width: 900px) {
    .sa { grid-template-columns: minmax(0, 1fr); }
    .sa-side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 16px; gap: 8px; }
    .sa-brand { padding: 0; font-size: 1.25rem; }
    .sa-nav { order: 3; flex-direction: row; width: 100%; overflow-x: auto; }
    .sa-nav a { white-space: nowrap; padding: 8px 10px; }
    .sa-nav a.active::before { display: none; }
    .sa-me { display: none; }
    .sa-side-foot { margin-left: auto; padding: 0; }
    .sa-main { padding: 20px 16px 40px; }
    .sa-grid, .sa-grid.wide-first { grid-template-columns: minmax(0, 1fr); }
    .sa-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .sa-kpi { padding: 12px 14px; }
    .sa-kpi-icon { display: none; }
    .sa-kpi strong { font-size: 1.5rem; }
}

/* ตารางในส่วนผู้ดูแลระบบ: ช่องแคบลงให้พอดีจอ (ไม่ต้องเลื่อนซ้าย-ขวาบนจอปกติ)
   แถบพื้นที่ในตารางไม่ต้องมีคำว่า "พื้นที่เก็บเอกสาร" ซ้ำ (หัวคอลัมน์บอกแล้ว) */
.sa-main .result-table th, .sa-main .result-table td { padding-left: 14px; padding-right: 14px; }
.sa-main .result-table th:first-child, .sa-main .result-table td:first-child { padding-left: 20px; }
.sa-main .admin-storage { min-width: 170px; }
.sa-main .admin-storage .storage-bar-text span:first-child { display: none; }
.sa-main .admin-storage .storage-bar-text { justify-content: flex-start; }
.sa-tabs { overflow-y: hidden; }
.sa-logout { white-space: nowrap; }

/* หน้าต่างยืนยัน (dialog) ในส่วนผู้ดูแลระบบ: ช่องกรอกในหน้าต่าง + ปุ่มลบในการ์ดโซนอันตราย */
.sa-danger-actions { margin: 12px 0 0; }
.confirm-dialog .modal-field input { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.confirm-dialog p { margin: 0; }
td dialog.modal { font-weight: 400; }

/* หน้าที่เก็บไฟล์ (X05): การ์ดเรียงลงล่างคอลัมน์เดียว อ่านจากบนลงล่าง */
.sa-storage { max-width: 720px; }
.sa-storage .sa-card p:first-of-type { margin-top: 0; }
.sa-storage .hint { display: block; margin: 8px 0 0; }
.sa-actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* ตัวเลือกที่เก็บไฟล์: radio เป็นกล่องเรียงลงล่าง ชื่อตัวหนา + คำอธิบายบรรทัดล่าง */
.sa-options { display: flex; flex-direction: column; gap: 8px; }
.sa-options label.choice { align-items: flex-start; padding: 12px 14px; border-radius: 8px; }
.sa-options label.choice input { margin-top: 4px; flex: none; }
.sa-options label.choice > span { display: flex; flex-direction: column; gap: 2px; }
.sa-options label.choice .hint { margin: 0; }
.sa-options label.choice.disabled { opacity: .6; cursor: not-allowed; }
/* หน้าต่างแจ้งผลสำเร็จ: กว้างพอดีข้อความ หัวข้อสีเขียว (confirm-dialog ปกติหัวข้อสีแดง) */
.modal.sa-result { width: min(440px, 100%); }
.modal.sa-result .modal-head h2 { color: #17703c; }
.modal.sa-result .actions { justify-content: flex-end; }
