/* SST Attendance - admin panel styles.
   Self-contained so the module does not inherit the ERP theme's assumptions. */

:root {
    --bg: #f4f6fa;
    --panel: #ffffff;
    --ink: #16233a;
    --ink-soft: #5d6b83;
    --line: #e2e7f0;
    --brand: #1f4fd8;
    --brand-dark: #163ba6;
    --ok: #12855c;
    --ok-bg: #e4f6ee;
    --warn: #a86400;
    --warn-bg: #fdf2dc;
    --bad: #c22f38;
    --bad-bg: #fdeaec;
    --info: #1f4fd8;
    --info-bg: #e8eeff;
    --muted-bg: #eef1f6;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(22, 35, 58, .08), 0 8px 24px rgba(22, 35, 58, .05);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 14px/1.5 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
    width: 232px;
    flex: 0 0 232px;
    background: #101a2f;
    color: #c3ccdd;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 18px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.brand-mark {
    background: var(--brand); color: #fff;
    font-weight: 700; font-size: 12px; letter-spacing: .5px;
    padding: 6px 8px; border-radius: 6px;
}
.brand-text { color: #fff; font-weight: 600; font-size: 15px; }

.sidebar nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.sidebar nav a {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; margin-bottom: 2px;
    border-radius: 8px; color: #c3ccdd; font-size: 13.5px;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav-icon { width: 18px; text-align: center; opacity: .9; font-size: 14px; }

.sidebar-foot { padding: 14px 18px; border-top: 1px solid rgba(255, 255, 255, .08); }
.back-erp { color: #8f9db8; font-size: 12.5px; }
.back-erp:hover { color: #fff; }

/* Hamburger for the mobile header; hidden on desktop where the sidebar is fixed. */
.nav-toggle {
    display: none;
    margin-left: auto;
    width: 40px;
    height: 36px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
}
.nav-toggle span {
    display: block;
    width: 17px;
    height: 2px;
    border-radius: 2px;
    background: #dfe6f2;
    transition: transform .18s ease, opacity .18s ease;
}
/* The three bars fold into an X while the menu is open. */
.sidebar.open .nav-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.sidebar.open .nav-toggle span:nth-child(2) { opacity: 0; }
.sidebar.open .nav-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

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

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 16px 24px;
    background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 19px; font-weight: 650; }
.subtitle { margin: 2px 0 0; color: var(--ink-soft); font-size: 12.5px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.who { text-align: right; line-height: 1.25; }
.who strong { display: block; font-size: 13px; }
.who small { color: var(--ink-soft); font-size: 11.5px; }

.content { padding: 22px 24px; flex: 1; }
.foot { padding: 14px 24px 22px; color: var(--ink-soft); font-size: 12px; }

/* ---------- cards & tiles ---------- */
.card {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.card-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-soft); }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.tiles {
    display: grid; gap: 14px; margin-bottom: 20px;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
}
.tile {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow);
}
.tile .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-soft); }
.tile .value { font-size: 27px; font-weight: 680; margin-top: 5px; line-height: 1.1; }
.tile .hint { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
.tile.alert { border-color: #f3c2c6; background: var(--bad-bg); }
.tile.alert .value { color: var(--bad); }
.tile.good .value { color: var(--ok); }
.tile.attention { border-color: #f0d9a8; background: var(--warn-bg); }
.tile.attention .value { color: var(--warn); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
    text-align: left; padding: 11px 14px;
    background: #f8fafd; border-bottom: 1px solid var(--line);
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-soft);
    white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid #f0f3f8; vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fafbfe; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 38px 18px; text-align: center; color: var(--ink-soft); }

.who-cell strong { display: block; font-size: 13px; }
.who-cell small { color: var(--ink-soft); font-size: 11.5px; }

/* ---------- badges ---------- */
.badge {
    display: inline-block; padding: 3px 9px; border-radius: 999px;
    font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.muted { background: var(--muted-bg); color: var(--ink-soft); }

/* ---------- forms & buttons ---------- */
label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: #33415c; }
label .opt { font-weight: 400; color: var(--ink-soft); }

input[type=text], input[type=password], input[type=number], input[type=date],
input[type=time], input[type=search], select {
    width: 100%; padding: 9px 11px; font-size: 13.5px; font-family: inherit;
    color: var(--ink); background: #fff;
    border: 1px solid #cfd7e5; border-radius: 8px;
    height: 40px; line-height: 1.2;
}
textarea {
    width: 100%; padding: 9px 11px; font-size: 13.5px; font-family: inherit;
    color: var(--ink); background: #fff;
    border: 1px solid #cfd7e5; border-radius: 8px;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31, 79, 216, .12);
}
input[disabled], select[disabled] { background: #f4f6fa; color: var(--ink-soft); }

.field { margin-bottom: 15px; }
.field .help { font-size: 11.5px; color: var(--ink-soft); margin-top: 4px; }
.grid { display: grid; gap: 15px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.check { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 11px; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; flex: 0 0 auto; }
.check label { margin: 0; font-weight: 500; font-size: 13px; }
.check .help { margin-top: 2px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 0 15px; height: 40px; border: 1px solid transparent; border-radius: 8px;
    background: var(--brand); color: #fff; font-size: 13.5px; font-weight: 600;
    font-family: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.ghost { background: #fff; color: #33415c; border-color: #cfd7e5; }
.btn.ghost:hover { background: #f4f6fa; }
.btn.danger { background: var(--bad); }
.btn.danger:hover { background: #a3252d; }
.btn.small { padding: 0 11px; height: 32px; font-size: 12.5px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.toolbar {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 18px;
}
.toolbar .field { margin: 0; position: relative; }
.toolbar .field .help { position: absolute; top: calc(100% + 4px); left: 0; width: max-content; margin-top: 0; z-index: 10; }
.toolbar .spacer { flex: 1; }

.alert {
    padding: 12px 16px; border-radius: var(--radius);
    margin: 18px 24px 0; font-size: 13.5px; border: 1px solid transparent;
}
.alert.success { background: var(--ok-bg); color: var(--ok); border-color: #b9e3d1; }
.alert.error { background: var(--bad-bg); color: var(--bad); border-color: #f3c2c6; }
.alert.info { background: var(--info-bg); color: var(--info); border-color: #c8d6ff; }

/* ---------- maps ---------- */
.map { height: 560px; width: 100%; border-radius: var(--radius); z-index: 0; }
.map.short { height: 380px; }
.map-legend {
    display: flex; flex-wrap: wrap; gap: 16px;
    padding: 12px 18px; border-top: 1px solid var(--line);
    font-size: 12.5px; color: var(--ink-soft);
}
.map-legend span { display: flex; align-items: center; gap: 6px; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.dot.inside { background: var(--ok); }
.dot.outside { background: var(--bad); }
.dot.stale { background: #98a4b8; }
.dot.mock { background: #7c3aed; }

.split { display: grid; gap: 20px; grid-template-columns: 300px 1fr; align-items: start; }
.people-list { max-height: 560px; overflow-y: auto; }
.person {
    display: block; width: 100%; text-align: left;
    padding: 11px 14px; border: 0; border-bottom: 1px solid #f0f3f8;
    background: #fff; cursor: pointer; font-family: inherit;
}
.person:hover { background: #f7f9fd; }
.person.active { background: var(--info-bg); }
.person strong { display: block; font-size: 13px; }
.person small { color: var(--ink-soft); font-size: 11.5px; }

.thumb {
    width: 34px; height: 34px; border-radius: 6px; object-fit: cover;
    border: 1px solid var(--line); background: #f4f6fa; cursor: zoom-in;
}

/* ---------- map style picker ---------- */
.style-grid {
    display: grid; gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.style-card {
    display: block; cursor: pointer; margin: 0;
    border: 2px solid var(--line); border-radius: 11px;
    padding: 10px; background: #fff; font-weight: 400;
}
.style-card:hover { border-color: #b9c5dc; }
.style-card.chosen { border-color: var(--brand); background: var(--info-bg); }
.style-card input { position: absolute; opacity: 0; pointer-events: none; }
.style-card .style-preview {
    display: block; width: 100%; height: 118px; overflow: hidden;
    border-radius: 7px; margin-bottom: 9px; background: #eef1f6;
}
.style-card .style-preview img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.style-card strong { display: block; font-size: 13px; margin-bottom: 3px; }
.style-card small { color: var(--ink-soft); font-size: 11.5px; line-height: 1.4; display: block; }

/* ---------- login ---------- */
.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 24px; background: linear-gradient(135deg, #101a2f, #1f4fd8);
}
.login-card {
    width: 100%; max-width: 388px; background: #fff;
    border-radius: 14px; padding: 32px; box-shadow: 0 20px 60px rgba(16, 26, 47, .3);
}
.login-card .brand { border: 0; padding: 0 0 20px; justify-content: center; }
.login-card h1 { margin: 0 0 5px; font-size: 19px; text-align: center; }
.login-card .lead { margin: 0 0 22px; text-align: center; color: var(--ink-soft); font-size: 13px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 6px; }
.login-note { margin-top: 20px; text-align: center; font-size: 12px; color: var(--ink-soft); }

/* ---------- modal ---------- */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(16, 26, 47, .55);
    display: none; align-items: center; justify-content: center; padding: 24px; z-index: 1000;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: #fff; border-radius: 12px; width: 100%; max-width: 560px;
    max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(16, 26, 47, .3);
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; }
.modal-foot {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 14px 20px; border-top: 1px solid var(--line);
}
.x-close { background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink-soft); }

/*
 * Mobile: the sidebar becomes a sticky header - brand on the left, hamburger
 * on the right - and the nav opens under it as a dropdown panel instead of
 * the old horizontally-scrolling strip (11 items made that unusable).
 */
@media (max-width: 900px) {
    .shell { flex-direction: column; }

    .sidebar {
        width: 100%;
        flex: none;
        height: auto;
        position: sticky;
        top: 0;
        z-index: 60;
        box-shadow: 0 2px 10px rgba(9, 15, 30, .35);
    }

    .brand { padding: 11px 16px; border-bottom: 0; }
    .nav-toggle { display: flex; }

    .sidebar nav {
        display: none;
        padding: 6px 10px 10px;
        border-top: 1px solid rgba(255, 255, 255, .08);
        max-height: calc(100vh - 60px);                /* long menus scroll inside the panel */
        overflow-y: auto;
    }

    .sidebar.open nav { display: block; }

    .sidebar nav a { padding: 11px 12px; font-size: 14px; }

    /* "Back to ERP" is reachable from the open menu instead of being cut. */
    .sidebar-foot { display: none; }
    .sidebar.open .sidebar-foot { display: block; padding: 10px 18px 14px; }

    .split { grid-template-columns: 1fr; }
    .topbar { flex-wrap: wrap; }
    .topbar, .content { padding-left: 16px; padding-right: 16px; }
}

@media print {
    .sidebar, .topbar-right, .toolbar, .foot, .btn { display: none !important; }
    .card { box-shadow: none; }
}
