/* ============================================================
   ADS styles - Expenses: expense module (claims, admin, approvals, review)
   Split out of the former monolithic style.css WITHOUT code changes.
   Files are linked in numeric order (see Core/templates/_styles.html) so
   the cascade is identical to the old single file.
   ============================================================ */

/* ============================================================
   EXPENSE MODULE  styles
   Append to style.css. Reuses existing design tokens (ts-card,
   ts-btn, ts-table, ts-input, ts-select etc.) so it inherits your
   current theme automatically; only Expense-specific pieces below.
   ============================================================ */

.exp-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.exp-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.exp-summary-tile {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
}

.exp-tile-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    opacity: .65;
}

.exp-tile-value {
    font-size: 20px;
    font-weight: 700;
}

.exp-tile-amount {
    background: linear-gradient(135deg, rgba(99,102,241,.08), rgba(99,102,241,.02));
}

.exp-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: #e5e7eb;
    color: #374151;
}
.exp-badge-draft { background: #e5e7eb; color: #4b5563; }
.exp-badge-submitted { background: #fef3c7; color: #92400e; }
.exp-badge-approved { background: #d1fae5; color: #065f46; }
.exp-badge-pending-bank { background: #dbeafe; color: #1e40af; }
.exp-badge-accounted { background: #ede9fe; color: #5b21b6; }
.exp-badge-rejected { background: #fee2e2; color: #991b1b; }

.exp-entry-row {
    display: grid;
    grid-template-columns: 1fr 1fr 140px 120px 1.4fr auto auto;
    gap: 8px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dashed var(--border-color, #e5e7eb);
}
.exp-entry-row:last-child { border-bottom: none; }

.exp-entry-bill { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.exp-entry-bill input[type="file"] { display: none; }
.exp-bill-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 8px;
    background: rgba(99,102,241,.08); font-size: 12px; text-decoration: none;
}

.exp-total-row {
    text-align: right;
    font-size: 18px;
    font-weight: 700;
    margin-top: 12px;
}

.exp-editor-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.exp-view-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
}

@media (max-width: 768px) {
    .exp-entry-row {
        grid-template-columns: 1fr 1fr;
        grid-auto-rows: auto;
    }
    .exp-entry-bill, .exp-entry-row > button { grid-column: 1 / -1; }
}

/* ------------------------------------------------------------
   Expense Admin redesign - tabbed layout, quiet tables, pagination
   ------------------------------------------------------------ */
.exp-admin-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--gray-100);
    border-radius: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.exp-admin-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: 9px;
    border: none;
    background: transparent;
    color: var(--gray-600);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.exp-admin-tab:hover { color: var(--gray-900); background: rgba(255,255,255,.6); }

.exp-admin-tab.active {
    background: var(--white);
    color: var(--green-dark);
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.exp-admin-tab .exp-tab-count {
    font-size: 11px;
    font-weight: 700;
    background: var(--gray-200);
    color: var(--gray-700);
    padding: 1px 7px;
    border-radius: 999px;
    min-width: 18px;
    text-align: center;
}

.exp-admin-tab.active .exp-tab-count { background: var(--green-lite); color: var(--green-dark); }

.exp-admin-panel { display: none; }
.exp-admin-panel.active { display: block; }

/* Quiet, low-chrome "add new" row: collapsed by default behind a button
   so the table itself isn't competing with a form for attention. */
.exp-admin-add-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.exp-admin-add-form {
    display: none;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 16px;
}
.exp-admin-add-form.open { display: block; }

.exp-admin-clean-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.exp-admin-clean-table thead th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--gray-600);
    border-bottom: 1px solid var(--gray-200);
    font-weight: 700;
}
.exp-admin-clean-table tbody td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}
.exp-admin-clean-table tbody tr:last-child td { border-bottom: none; }
.exp-admin-clean-table tbody tr:hover { background: var(--gray-50); }

.exp-admin-name-cell { font-weight: 600; color: var(--gray-900); }
.exp-admin-sub { font-size: 12px; color: var(--gray-400); }

.exp-admin-limit-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--gray-100);
    color: var(--gray-700);
}
.exp-admin-limit-pill.exp-limit-set { background: rgba(99,102,241,.1); color: #4338ca; }
.exp-admin-limit-pill.exp-limit-none { color: var(--gray-400); background: transparent; }

.exp-admin-status-dot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
}
.exp-admin-status-dot::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--gray-400);
}
.exp-admin-status-dot.is-active { color: var(--green-dark); }
.exp-admin-status-dot.is-active::before { background: var(--green); }
.exp-admin-status-dot.is-inactive { color: var(--gray-400); }

.exp-admin-row-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

.exp-admin-audit-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.exp-admin-empty {
    text-align: center;
    padding: 36px 16px;
    color: var(--gray-400);
    font-size: 13.5px;
}
.exp-admin-empty i { font-size: 22px; display: block; margin-bottom: 8px; opacity: .5; }

@media (max-width: 768px) {
    .exp-admin-tabs { overflow-x: auto; flex-wrap: nowrap; }
    .exp-admin-tab { white-space: nowrap; }
}

/* ------------------------------------------------------------
   Expense module status/validation banners (.ts-alert*).
   These were referenced throughout the expense screens (draft
   save, submit, approve/reject messages) but never had rules
   defined, so they rendered as plain unstyled text - easy to
   miss, especially validation errors with no error color/border.
   ------------------------------------------------------------ */
.ts-alert {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
    border: 1px solid transparent;
}
.ts-alert-error {
    background: #fef2f2;
    border-color: #ef4444;
    color: #b91c1c;
}
.ts-alert-success {
    background: #ecfdf5;
    border-color: #10b981;
    color: #047857;
}
.ts-alert-warn {
    background: #fffbeb;
    border-color: #f59e0b;
    color: #92400e;
}
/* ============================================================
   Expense Approvals  modern/clean refresh
   Drop this at the END of style.css (it only overrides/extends
   existing classes  no HTML or JS changes required).
   ============================================================ */

/* --- Page header: icon in a soft chip instead of a bare glyph --- */
#page-expense-approvals .page-screen-title {
    display: flex;
    align-items: center;
    gap: 10px;
}
#page-expense-approvals .page-screen-title i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--green-lite);
    color: var(--green-dark);
    font-size: 15px;
}

/* --- Card: a touch more air, softer shadow, rounder corners --- */
#page-expense-approvals .ts-card {
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    padding: 22px 24px 18px;
    border: 1px solid var(--gray-100);
}

/* --- Toolbar: title + live pending count pill --- */
#page-expense-approvals .exp-admin-audit-toolbar {
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-100);
}
#page-expense-approvals .exp-admin-audit-toolbar h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900);
}
#page-expense-approvals .exp-admin-audit-toolbar h3 i {
    color: #d97706;
    font-size: 14px;
}

/* --- Table: card-row look instead of plain grid lines --- */
#page-expense-approvals .exp-admin-clean-table {
    border-spacing: 0 8px;
    border-collapse: separate;
}
#page-expense-approvals .exp-admin-clean-table thead th {
    padding: 6px 14px 12px;
    border-bottom: none;
    color: var(--gray-400);
    font-size: 10.5px;
    letter-spacing: .06em;
}
#page-expense-approvals .exp-admin-clean-table tbody tr {
    background: var(--white);
    transition: box-shadow .15s ease, transform .15s ease;
}
#page-expense-approvals .exp-admin-clean-table tbody tr:hover {
    background: var(--white);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}
#page-expense-approvals .exp-admin-clean-table tbody td {
    padding: 14px;
    border-bottom: 1px solid var(--gray-100);
    border-top: 1px solid var(--gray-100);
}
#page-expense-approvals .exp-admin-clean-table tbody td:first-child {
    border-left: 1px solid var(--gray-100);
    border-radius: 12px 0 0 12px;
}
#page-expense-approvals .exp-admin-clean-table tbody td:last-child {
    border-right: 1px solid var(--gray-100);
    border-radius: 0 12px 12px 0;
}

/* --- Employee cell: avatar initial + name/claim number stack --- */
#page-expense-approvals .exp-admin-name-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}
#page-expense-approvals .exp-admin-name-cell::before {
    content: attr(data-initial);
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 50%;
    background: var(--green-lite);
    color: var(--green-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}
#page-expense-approvals .exp-admin-sub {
    margin-left: 40px;
    font-size: 11.5px;
    letter-spacing: .02em;
}

/* --- Total column: make the amount pop --- */
#page-expense-approvals .exp-admin-clean-table td:nth-child(3) {
    font-weight: 700;
    color: var(--gray-900);
    font-variant-numeric: tabular-nums;
}

/* --- Submitted date: muted, monospace-ish feel --- */
#page-expense-approvals .exp-admin-clean-table td:nth-child(4) {
    color: var(--gray-600);
    font-size: 13px;
}

/* --- Review action button: pill with label, not a bare icon --- */
#page-expense-approvals .exp-admin-row-actions .ts-icon-btn {
    width: auto;
    height: auto;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--green-mid);
    background: var(--green-lite);
    color: var(--green-dark);
    font-size: 12.5px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
#page-expense-approvals .exp-admin-row-actions .ts-icon-btn::after {
    content: 'Review';
}
#page-expense-approvals .exp-admin-row-actions .ts-icon-btn:hover {
    background: var(--green);
    color: var(--white);
    border-color: var(--green);
}

/* --- Empty state: friendlier, centered, breathing room --- */
#page-expense-approvals .exp-admin-empty {
    padding: 56px 16px;
}
#page-expense-approvals .exp-admin-empty i {
    font-size: 30px;
    color: var(--green);
    opacity: .35;
    margin-bottom: 10px;
}
#page-expense-approvals .exp-admin-empty {
    font-size: 14px;
    color: var(--gray-600);
}

/* --- Pagination footer: separated, tidy --- */
#page-expense-approvals .tickets-pagination {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--gray-100);
}

/* --- Mobile: stack the toolbar, keep table scrollable --- */
@media (max-width: 640px) {
    #page-expense-approvals .exp-admin-audit-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }
    #page-expense-approvals .exp-admin-clean-table {
        font-size: 12.5px;
    }
    #page-expense-approvals .exp-admin-row-actions .ts-icon-btn::after {
        content: '';
    }
}

/* ============================================================
   Expense Claim Review (page-expense-view)  modern/clean refresh
   Scoped to #page-expense-view so nothing elsewhere is affected.
   Drop-in only  no HTML/JS changes required.
   ============================================================ */

/* --- Page title --- */
#page-expense-view .page-screen-title {
    display: flex;
    align-items: center;
    gap: 10px;
}
#page-expense-view .page-screen-title i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--green-lite);
    color: var(--green-dark);
    font-size: 15px;
}
#page-expense-view .page-screen-title #exp-view-number {
    color: var(--gray-600);
    font-weight: 600;
    font-size: 15px;
    margin-left: 2px;
}

/* --- All cards on this page: consistent modern shell --- */
#page-expense-view .ts-card {
    border-radius: 16px;
    border: 1px solid var(--gray-100);
    box-shadow: var(--shadow-sm);
    padding: 22px 24px;
    margin-bottom: 18px;
}
#page-expense-view .ts-card h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 16px 0;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 15px;
    font-weight: 700;
    color: var(--gray-900);
}
#page-expense-view .ts-card h3 i {
    color: var(--green);
    font-size: 13px;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--green-lite);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* --- Header summary card: label/value grid --- */
#exp-view-header.ts-card {
    background: linear-gradient(180deg, var(--gray-50), var(--white) 60%);
}
.exp-view-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 18px 22px;
}
.exp-view-grid > div strong {
    display: block;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--gray-400);
    font-weight: 700;
    margin-bottom: 6px;
}
.exp-view-grid > div {
    font-size: 14px;
    color: var(--gray-900);
    line-height: 1.5;
}
.exp-view-grid > div[style*="grid-column"] {
    padding-top: 14px;
    border-top: 1px dashed var(--gray-200);
}

/* --- Status badge: a little bigger + a dot, on this page only --- */
#exp-view-header .exp-badge {
    font-size: 12.5px;
    padding: 4px 12px 4px 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
#exp-view-header .exp-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .8;
}

/* --- Total amount: make it the visual anchor of the header --- */
#exp-view-header .exp-view-grid > div:nth-child(6) {
    font-size: 18px;
    font-weight: 800;
    color: var(--green-dark);
}

/* --- Entries / history tables --- */
#page-expense-view .ts-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13.5px;
}
#page-expense-view .ts-table thead th {
    text-align: left;
    padding: 10px 14px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--gray-400);
    font-weight: 700;
    border-bottom: 1px solid var(--gray-100);
    background: var(--gray-50);
}
#page-expense-view .ts-table thead th:first-child { border-radius: 10px 0 0 10px; }
#page-expense-view .ts-table thead th:last-child { border-radius: 0 10px 10px 0; }
#page-expense-view .ts-table tbody td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: top;
    color: var(--gray-700);
}
#page-expense-view .ts-table tbody tr:last-child td { border-bottom: none; }
#page-expense-view .ts-table tbody tr:hover td { background: var(--gray-50); }

/* Amount column (Expense Entries table = 4th column) */
#exp-view-items-tbody td:nth-child(4) {
    font-weight: 700;
    color: var(--gray-900);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Bills column: link chips instead of bare underlined text */
#exp-view-items-tbody td:last-child a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--green-lite);
    color: var(--green-dark);
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
    margin: 2px 0;
}
#exp-view-items-tbody td:last-child a:hover {
    background: var(--green);
    color: var(--white);
}

/* Approval history: give each action a colored dot in its own column */
#exp-view-history-tbody td:first-child {
    font-weight: 600;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 8px;
}
#exp-view-history-tbody td:first-child::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gray-400);
    flex: 0 0 8px;
}
/* Empty state for history table */
#page-expense-view .table-empty {
    text-align: center;
    padding: 32px 16px !important;
    color: var(--gray-400);
    font-style: normal;
}

/* --- Approve / Reject panel --- */
#exp-view-approve-card {
    border: 1px solid var(--green-mid);
    background: linear-gradient(180deg, var(--green-lite), var(--white) 55%);
}
#exp-view-approve-card h3 i {
    background: var(--green);
    color: var(--white);
}
#exp-view-approve-remarks.ts-textarea {
    border-radius: 12px;
    border: 1px solid var(--gray-200);
    padding: 12px 14px;
    font-size: 13.5px;
    background: var(--white);
}
#exp-view-approve-remarks.ts-textarea:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(14,161,111,.12);
}
#page-expense-view .exp-editor-actions {
    margin-top: 18px;
}
#page-expense-view .exp-editor-actions .ts-btn {
    padding: 10px 22px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 13.5px;
    box-shadow: var(--shadow-sm);
}
#page-expense-view .exp-editor-actions .ts-btn-danger {
    background: var(--white);
    border: 1px solid #fecaca;
    color: var(--red-dark);
}
#page-expense-view .exp-editor-actions .ts-btn-danger:hover {
    background: #fee2e2;
}
#page-expense-view .exp-editor-actions .ts-btn-primary {
    background: var(--green);
    border: 1px solid var(--green);
}
#page-expense-view .exp-editor-actions .ts-btn-primary:hover {
    background: var(--green-dark);
    transform: translateY(-1px);
}

/* --- Inline result message (approved/rejected/error) --- */
#exp-view-message .ts-alert {
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 13.5px;
    font-weight: 500;
}

/* --- Mobile --- */
@media (max-width: 640px) {
    .exp-view-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
    #page-expense-view .ts-card { padding: 16px; }
    #page-expense-view .ts-table { font-size: 12.5px; }
    #page-expense-view .exp-editor-actions { flex-direction: column; }
    #page-expense-view .exp-editor-actions .ts-btn { width: 100%; justify-content: center; }
}


/* ---- Claim editor: read-only header fields + lock note ---- */
#page-expense-editor .ts-input[readonly] {
    background: var(--gray-50, #f9fafb);
    color: var(--gray-700, #374151);
    cursor: default;
}
#page-expense-editor .ts-input:disabled,
#page-expense-editor .ts-textarea:disabled {
    background: var(--gray-50, #f9fafb);
    color: var(--gray-600, #4b5563);
    cursor: not-allowed;
}
.exp-header-lock-note { font-size: 12.5px; color: #92400e; margin-top: 6px; }

/* ---- Approval trail (timeline) ---- */
.exp-trail-pending {
    display: flex; align-items: center; gap: 8px; margin: 2px 0 14px; padding: 9px 12px;
    background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px;
    color: #92400e; font-size: 13px;
}
.exp-trail { list-style: none; margin: 0; padding: 0 0 0 4px; }
.exp-trail-item { position: relative; display: flex; gap: 12px; padding: 0 0 16px; }
.exp-trail-item::before {
    content: ''; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--gray-200, #e5e7eb);
}
.exp-trail-item:last-child { padding-bottom: 2px; }
.exp-trail-item:last-child::before { display: none; }
.exp-trail-dot {
    flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 12px;
    background: var(--gray-100, #f3f4f6); color: var(--gray-600, #4b5563); z-index: 1;
}
.exp-trail-item.is-info .exp-trail-dot { background: #dbeafe; color: #1d4ed8; }
.exp-trail-item.is-ok   .exp-trail-dot { background: #dcfce7; color: #15803d; }
.exp-trail-item.is-bad  .exp-trail-dot { background: #fee2e2; color: #b91c1c; }
.exp-trail-body { flex: 1; min-width: 0; }
.exp-trail-head { font-size: 13.5px; color: var(--gray-900, #111827); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.exp-trail-when { font-size: 12px; color: var(--gray-500, #6b7280); }
.exp-trail-meta { font-size: 12.5px; color: var(--gray-600, #4b5563); margin-top: 3px; }
.exp-trail-remarks {
    margin-top: 5px; font-size: 12.5px; color: var(--gray-700, #374151);
    background: var(--gray-50, #f9fafb); border-left: 3px solid var(--gray-300, #d1d5db);
    padding: 6px 10px; border-radius: 0 8px 8px 0; white-space: pre-wrap;
}
