/*
 * Shared UI chrome: modals, toasts, confirm dialog. Loaded on every page.
 * Reuses the --ease-out / --ease-in-out / --dash-* tokens defined on
 * .dash-page (public/css/dashboard.css) where available, with safe
 * fallbacks so this also works on pages that don't load that stylesheet.
 */

/* Modal */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(20, 23, 28, 0.5);
    opacity: 0;
    transition: opacity 200ms var(--ease-out, ease);
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-backdrop.is-open {
    opacity: 1;
}

.modal-dialog {
    position: relative;
    width: 100%;
    max-width: 640px;
    max-height: 88vh;
    overflow-y: auto;
    background: #ffffff;
    border-radius: var(--dash-radius-md, 14px);
    box-shadow: 0 24px 60px rgba(20, 23, 28, 0.3);
    padding: 28px 26px;
    transform: scale(0.96);
    opacity: 0;
    transition: transform 200ms var(--ease-out, ease), opacity 200ms var(--ease-out, ease);
}

.modal-dialog-sm {
    max-width: 380px;
}

.modal-dialog-lg {
    max-width: 880px;
}

.modal-backdrop.is-open .modal-dialog {
    transform: scale(1);
    opacity: 1;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: none;
    color: var(--dash-text-muted, #6b7280);
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease;
}

.modal-close svg {
    width: 16px;
    height: 16px;
}

@media (hover: hover) and (pointer: fine) {
    .modal-close:hover {
        background: #f4f5f4;
        color: var(--dash-text, #14171c);
    }
}

.modal-title {
    margin: 0 22px 18px 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--dash-text, #14171c);
}

.modal-loading {
    padding: 24px 0;
    text-align: center;
    font-size: 13px;
    color: var(--dash-text-muted, #6b7280);
}

/* Confirm dialog */

.confirm-message {
    margin: 4px 0 20px;
    font-size: 14px;
    color: var(--dash-text, #14171c);
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Toasts */

.toast-container {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 360px;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    color: #ffffff;
    background: #14171c;
    box-shadow: 0 12px 28px rgba(20, 23, 28, 0.25);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 220ms var(--ease-out, ease), transform 220ms var(--ease-out, ease);
    pointer-events: auto;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background: #166534;
}

.toast-error {
    background: #b91c1c;
}

/* Activity log list */

.activity-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.activity-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--dash-border, #edefed);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-item-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 3px;
}

.activity-description {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--dash-text, #14171c);
}

.activity-time {
    flex-shrink: 0;
    font-size: 11.5px;
    color: var(--dash-text-muted, #6b7280);
}

.activity-meta {
    font-size: 12px;
    color: var(--dash-text-muted, #6b7280);
}

.activity-empty {
    padding: 24px 0;
    text-align: center;
    font-size: 13px;
    color: var(--dash-text-muted, #6b7280);
}

/* Required-field asterisk */

.required-asterisk {
    margin-left: 2px;
    color: #b91c1c;
}

/* Collapsible form sections — same interaction as the sidebar's Setup/
   Transactions/Reports groups (grid-template-rows collapse, not height). */

.form-section {
    border: 1px solid var(--dash-border, #edefed);
    border-radius: 10px;
    margin-bottom: 14px;
    overflow: hidden;
}

.form-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: #fafbfa;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    color: var(--dash-text, #14171c);
    cursor: pointer;
}

.form-section-header-static {
    cursor: default;
}

@media (hover: hover) and (pointer: fine) {
    .form-section-header:hover {
        background: #f4f5f4;
    }
}

.form-section-caret {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    transition: transform 200ms var(--ease-out, ease);
}

.form-section.is-open .form-section-caret {
    transform: rotate(180deg);
}

.form-section-body {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 220ms var(--ease-in-out, ease);
}

.form-section.is-open .form-section-body {
    grid-template-rows: 1fr;
}

.form-section-body-inner {
    overflow: hidden;
    min-height: 0;
    padding: 16px;
}

.form-section-body-inner > :last-child {
    margin-bottom: 0;
}

/*
 * DataTables, restyled to match the app instead of its default theme.
 * Shared here (not per-module) because every module's table uses it —
 * Category, Chart of Account, Opening Balance, and Activity Log.
 */

.dataTables_wrapper {
    font-size: 13.5px;
    color: var(--dash-text, #14171c);
}

.dataTables_wrapper .dataTables_info {
    padding-top: 14px;
    color: var(--dash-text-muted, #6b7280);
    font-size: 12.5px;
}

.dataTables_wrapper .dataTables_length {
    margin-bottom: 12px;
}

.dataTables_wrapper .dataTables_length select {
    margin: 0 6px;
    padding: 5px 8px;
    border: 1px solid var(--dash-border, #edefed);
    border-radius: 7px;
    font-size: 13px;
    font-family: inherit;
}

.dataTables_wrapper .dataTables_filter {
    margin-bottom: 12px;
    text-align: right;
    font-size: 13px;
}

.dataTables_wrapper .dataTables_filter label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--dash-text-muted, #6b7280);
}

.dataTables_wrapper .dataTables_filter input {
    padding: 7px 10px;
    border: 1px solid var(--dash-border, #edefed);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    color: var(--dash-text, #14171c);
    background: #ffffff;
}

.dataTables_wrapper .dataTables_filter input:focus {
    outline: none;
    border-color: #14171c;
    box-shadow: 0 0 0 1px #14171c;
}

.dataTables_wrapper .dataTables_paginate {
    padding-top: 14px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 5px 10px;
    margin-left: 4px;
    border: 1px solid var(--dash-border, #edefed) !important;
    border-radius: 7px;
    background: #ffffff !important;
    color: var(--dash-text, #14171c) !important;
    font-size: 12.5px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: #14171c !important;
    border-color: #14171c !important;
    color: #ffffff !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    color: var(--dash-text-soft, #8b93a0) !important;
    cursor: not-allowed;
}

@media (hover: hover) and (pointer: fine) {
    .dataTables_wrapper .dataTables_paginate .paginate_button:not(.disabled):not(.current):hover {
        background: #f4f5f4 !important;
        border-color: var(--dash-border, #edefed) !important;
        color: var(--dash-text, #14171c) !important;
    }
}

table.dataTable thead th {
    position: relative;
    padding-right: 20px !important;
}

table.dataTable thead th.sorting::after,
table.dataTable thead th.sorting_asc::after,
table.dataTable thead th.sorting_desc::after {
    position: absolute;
    right: 6px;
    color: var(--dash-text-soft, #8b93a0);
    font-size: 10px;
}

table.dataTable thead th.sorting::after {
    content: '\2195';
}

table.dataTable thead th.sorting_asc::after {
    content: '\2191';
    color: var(--dash-text, #14171c);
}

table.dataTable thead th.sorting_desc::after {
    content: '\2193';
    color: var(--dash-text, #14171c);
}

/*
 * Voucher status badge (Active / Cancel) — shared by Journal Voucher and
 * Payment Voucher, both of which soft-cancel rather than delete.
 */

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
}

.status-badge-active {
    color: #166534;
    background: #e9f8ef;
}

.status-badge-cancel {
    color: #b91c1c;
    background: #fdecec;
}

/* Monetary table cells — shared by Journal Voucher and Payment Voucher */

.amount-cell {
    font-variant-numeric: tabular-nums;
}
