/* Device Attendance Guard - admin UI styles for Parts A, B and C.
 *
 * Everything below is built on RISE's OWN theme values, read directly out
 * of assets/css/app.all.css rather than picked by eye, so this plugin's
 * screens sit inside the product instead of next to it:
 *
 *   --dag-text        #4e5e6a   --bs-body-color, and .text-muted
 *   --dag-border      #f1f1f5   .btn-default's border, table.dataTable
 *                               thead th's border-top
 *   --dag-primary     #6690F4   .btn-primary / .bg-primary
 *   --dag-primary-dk  #4076f2   .btn-primary:hover
 *   --dag-success     #485BBD   .bg-success (this theme's "success" is an
 *                               indigo, NOT green - matching it matters)
 *   --dag-danger      #f5325c   .bg-danger
 *   --dag-info        #38a4f8   .bg-info
 *   --dag-input-bg    #f9f9f9   .general-form .form-control
 *   --dag-hover       #E6E6E6   .btn-default:hover
 *
 * The one value NOT taken from the theme is --dag-attention. RISE defines
 * no .bg-warning at all, so every "badge bg-warning" in this plugin used to
 * fall through to raw Bootstrap yellow (#ffc107) - the one colour on these
 * screens that visibly did not belong. This plugin genuinely has states
 * that are neither "fine" nor "failed" (a probation breach, an hour
 * shortfall, a pending approval, a draft payroll month), so rather than
 * mislabel those as info or danger there is one amber here, chosen to sit
 * with #f5325c and #38a4f8 in saturation and weight.
 *
 * Status pills are namespaced .dag-badge-* rather than overriding the
 * theme's own .badge utilities, so nothing here can leak into a core RISE
 * page that this plugin doesn't own.
 *
 * Breakpoint is 767px throughout - the same one RISE's own stylesheet uses
 * for its mobile rules.
 */

:root {
    --dag-text: #4e5e6a;
    --dag-text-soft: rgba(78, 94, 106, 0.65);
    --dag-border: #f1f1f5;
    --dag-border-strong: #e4e6ec;
    --dag-primary: #6690F4;
    --dag-primary-dk: #4076f2;
    --dag-success: #485BBD;
    --dag-danger: #f5325c;
    --dag-info: #38a4f8;
    --dag-attention: #e0912f;
    --dag-input-bg: #f9f9f9;
    --dag-hover: #E6E6E6;
    --dag-surface: #fbfbfd;
    --dag-surface-strong: #eff1f6;
    --dag-radius: 4px;
}

/* small helper/description line under a .page-title card header - matches
 * .page-title's own internal horizontal padding (see .page-title h4 in
 * app.all.css: "padding: 8px 16px") so it reads as a continuation of the
 * header rather than a separately-styled block. */
.dag-page-hint {
    padding: 14px 16px 4px;
    margin: 0;
    font-size: 13px;
    color: var(--dag-text);
    opacity: 0.75;
}

/* small muted section headers used to group the settings modals into
 * readable chunks. No exact core precedent for a "grouped settings within
 * one modal" pattern was found after a broad search of RISE's own views,
 * so this is a light, restrained judgment call rather than a from-scratch
 * component: a thin top border in the theme's own border colour plus the
 * same small-uppercase-muted treatment core already uses for secondary
 * labels elsewhere. */
.dag-settings-section {
    margin: 20px 0 10px;
    padding-top: 14px;
    border-top: 1px solid var(--dag-border);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dag-settings-section:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.dag-settings-counts {
    margin: 0 0 16px;
    font-size: 13px;
}

/* ------------------------------------------------------------------
   Status pills - one consistent set across all three parts.
   Namespaced so they can never affect a core RISE page.
   ------------------------------------------------------------------ */
.dag-badge {
    display: inline-block;
    padding: 0.35em 0.65em;
    font-size: 0.75em;
    font-weight: 600;
    line-height: 1;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: var(--dag-radius);
}

.dag-badge-ok { background-color: var(--dag-success); }
.dag-badge-alert { background-color: var(--dag-danger); }
.dag-badge-info { background-color: var(--dag-info); }
.dag-badge-pending { background-color: var(--dag-attention); }

.dag-badge-muted {
    background-color: var(--dag-input-bg);
    color: var(--dag-text);
    border: 1px solid var(--dag-border);
}

/* the one-time enrollment code shown after allocating a new device
 * (Views/modal_allocate.php) */
.dag-code {
    display: inline-block;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 3px;
    padding: 6px 14px;
    background: var(--dag-input-bg);
    border-radius: var(--dag-radius);
    margin-top: 6px;
    color: var(--dag-text);
}

/* ------------------------------------------------------------------
 * Standalone device-enrollment page (Views/enroll.php) - the one page in
 * this plugin that is NOT rendered inside the RISE admin layout (a staff
 * member opens it directly, outside the dashboard chrome), so it needs its
 * own complete, self-contained styling rather than relying on theme CSS.
 * It still uses the same tokens so it looks like the same product.
 * ------------------------------------------------------------------ */
.dag-enroll-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    background: var(--dag-surface);
    color: var(--dag-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.dag-enroll-card {
    width: 100%;
    max-width: 380px;
    background: #fff;
    border: 1px solid var(--dag-border);
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(78, 94, 106, 0.08);
    padding: 32px 28px;
}

.dag-enroll-card h2 {
    margin-top: 0;
    font-size: 20px;
}

.dag-code-input {
    text-transform: uppercase;
    letter-spacing: 4px;
    font-size: 20px;
    text-align: center;
}

.dag-enroll-message {
    margin-top: 16px;
    font-size: 14px;
}

.dag-enroll-message.dag-success { color: var(--dag-success); }
.dag-enroll-message.dag-error { color: var(--dag-danger); }

/* ---------------------------------------------------------------
   Part C - Payroll Generator: the month summary boxes
   --------------------------------------------------------------- */

.dag-pr-totals {
    margin: 0 0 18px 0;
}

.dag-pr-total-box {
    border: 1px solid var(--dag-border);
    border-radius: var(--dag-radius);
    padding: 10px 12px;
    margin-bottom: 10px;
    background: var(--dag-surface);
}

.dag-pr-total-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--dag-text);
    opacity: 0.7;
    margin-bottom: 2px;
}

.dag-pr-total-value {
    display: block;
    font-size: 17px;
    font-weight: 600;
    color: var(--dag-text);
    font-variant-numeric: tabular-nums;
}

.dag-pr-total-net {
    border-color: var(--dag-primary);
    background: rgba(102, 144, 244, 0.06);
}

.dag-pr-total-net .dag-pr-total-value {
    color: var(--dag-primary-dk);
}

/* a figure an admin can click to hand-edit on a draft run */
.dag-pr-editable {
    cursor: pointer;
    border-bottom: 1px dashed var(--dag-border-strong);
    padding-bottom: 1px;
}

.dag-pr-editable:hover {
    background: rgba(102, 144, 244, 0.08);
    border-bottom-color: var(--dag-primary);
}

/* a figure that HAS been hand-edited - the title attribute carries what
   it was originally computed as */
.dag-pr-override {
    color: var(--dag-attention);
    font-weight: 600;
}

.dag-pr-edit-input {
    min-width: 90px;
    padding: 2px 6px;
    height: auto;
    font-size: 13px;
}

/* the undo control next to a hand-edited payroll figure */
.dag-pr-restore {
    color: var(--dag-text);
    opacity: 0.5;
    margin-left: 4px;
}

.dag-pr-restore:hover {
    opacity: 1;
    color: var(--dag-attention);
}

.dag-pr-inline-link {
    margin-left: 6px;
    font-weight: 600;
    color: var(--dag-primary);
}

/* ---------------------------------------------------------------
   Salary Builder - the bulk editable grid.

   A real data-entry table, not a DataTable, because every row carries
   inputs and the whole page saves at once. That means it needs its own
   responsive behaviour: RISE's own tables lean on DataTables' responsive
   plugin to collapse columns, which isn't available here.

   Desktop: a normal table, horizontally scrollable if the viewport is
   genuinely too narrow for 12 columns.
   <= 767px (RISE's own mobile breakpoint): every row becomes a stacked
   card with each field labelled from its column header, so it stays
   usable one-handed on a phone instead of becoming a horizontal scroll.
   --------------------------------------------------------------- */

.dag-sb-wrap {
    border: 1px solid var(--dag-border);
    border-radius: var(--dag-radius);
    overflow-x: auto;
}

.dag-sb-table {
    margin-bottom: 0;
    font-size: 13px;
    color: var(--dag-text);
    min-width: 980px;
}

/* keep the 12 columns inside a normal laptop viewport: the text inputs are
 * the widest things in the row, so they carry the trim rather than the
 * numbers, which must stay fully readable. */
.dag-sb-table td input[type="text"] {
    min-width: 0;
    width: 100%;
}

/* The payout select carries the longest fixed string in the row
 * ("Bank Transfer"). A min-width alone loses to the auto table layout,
 * which starves this column to feed the width:100% text inputs beside it -
 * an explicit column width is what actually holds. */
.dag-sb-table td select {
    width: 100%;
}

.dag-sb-table th.dag-sb-payout,
.dag-sb-table td.dag-sb-payout {
    width: 140px;
}

.dag-sb-table td input.dag-sb-salary {
    min-width: 0;
    width: 100%;
}

/* wide enough for a full salary figure without clipping the last digit */
.dag-sb-table th.dag-sb-salary-col,
.dag-sb-table td.dag-sb-salary-col {
    width: 130px;
}

.dag-sb-calc,
.dag-sb-table thead th.dag-sb-calc {
    width: 1%;
}

.dag-sb-table thead th {
    background: var(--dag-input-bg);
    border-bottom: 1px solid var(--dag-border);
    border-top: none;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--dag-text);
    white-space: nowrap;
    padding: 12px 10px;
    vertical-align: middle;
}

.dag-sb-table tbody td {
    padding: 8px 10px;
    vertical-align: middle;
    border-bottom: 1px solid var(--dag-border);
    border-top: none;
}

.dag-sb-table tbody tr:last-child td {
    border-bottom: none;
}

.dag-sb-table tbody tr:hover {
    background: rgba(102, 144, 244, 0.04);
}

.dag-sb-table .form-control {
    height: auto;
    padding: 5px 8px;
    font-size: 13px;
    min-width: 70px;
}

.dag-sb-name {
    font-weight: 600;
    white-space: nowrap;
}

.dag-sb-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* the auto-calculated, read-only half of each row */
.dag-sb-calc {
    background: var(--dag-surface);
    white-space: nowrap;
}

.dag-sb-table thead th.dag-sb-calc {
    background: var(--dag-surface-strong);
}

.dag-sb-check {
    margin: 0;
    display: inline-block;
}

.dag-sb-footer {
    padding: 12px 4px 0 4px;
}

.dag-sb-paging {
    float: left;
}

.dag-sb-legend {
    float: right;
    font-size: 12px;
    color: var(--dag-text);
    opacity: 0.7;
}

@media screen and (max-width: 767px) {
    /* stacked-card layout: each row becomes its own block, each cell a
     * labelled line. The labels come from data-label attributes rendered
     * server-side, so they stay in sync with the real column headers. */
    .dag-sb-wrap {
        border: none;
        overflow-x: visible;
    }

    .dag-sb-table {
        min-width: 0;
    }

    .dag-sb-table thead {
        display: none;
    }

    .dag-sb-table,
    .dag-sb-table tbody,
    .dag-sb-table tr,
    .dag-sb-table td {
        display: block;
        width: 100%;
        /* without this a block-level <tr> adds its 1px borders ON TOP of
         * width:100% and pushes 2px past the wrapper */
        box-sizing: border-box;
    }

    .dag-sb-table tr {
        border: 1px solid var(--dag-border);
        border-radius: var(--dag-radius);
        margin-bottom: 14px;
        padding: 4px 0;
        background: #fff;
    }

    .dag-sb-table tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        border-bottom: 1px solid var(--dag-border);
        padding: 8px 12px;
    }

    .dag-sb-table tbody tr td:last-child {
        border-bottom: none;
    }

    .dag-sb-table tbody td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.4px;
        color: var(--dag-text);
        opacity: 0.7;
        font-weight: 600;
    }

    /* the employee's name heads the card rather than sitting in a row */
    .dag-sb-table tbody td.dag-sb-name {
        display: block;
        font-size: 15px;
        background: var(--dag-input-bg);
        border-radius: var(--dag-radius) var(--dag-radius) 0 0;
        padding: 10px 12px;
    }

    .dag-sb-table tbody td.dag-sb-name::before {
        display: none;
    }

    .dag-sb-table .form-control,
    .dag-sb-table td input[type="text"],
    .dag-sb-table td input.dag-sb-salary,
    .dag-sb-table td select {
        max-width: 60%;
        width: auto;
        min-width: 0;
    }

    .dag-sb-table tbody td.dag-sb-calc {
        background: var(--dag-surface);
    }

    .dag-sb-footer {
        text-align: center;
    }

    .dag-sb-paging,
    .dag-sb-legend {
        float: none;
        display: block;
        margin-bottom: 8px;
    }
}

/* On a payroll month's own page the figures table is a real DataTable, so
 * the theme handles it - these only keep the summary boxes readable when
 * they wrap onto two rows on a narrow screen. */
@media screen and (max-width: 767px) {
    .dag-pr-total-box {
        margin-bottom: 8px;
    }

    .dag-pr-total-value {
        font-size: 15px;
    }
}
