/* /modules/personal/css/personal_accounting.css */
/* Accounting report (personal_accounting.php) */

.acc-page {
    --acc-accent: var(--apple-accent-color, #6c63ff);
    --acc-border: rgba(0, 0, 0, 0.08);
    --acc-muted-bg: rgba(15, 23, 42, 0.035);
    --acc-weekend-bg: rgba(100, 116, 139, 0.10);
    --acc-group-bg: color-mix(in srgb, var(--acc-accent) 10%, transparent);
    --acc-total-bg: rgba(15, 23, 42, 0.06);
    --acc-code-0: #2563eb; /* ПО */
    --acc-code-1: #dc2626; /* Б  */
    --acc-code-2: #d97706; /* НО */
    --acc-code-3: #ea580c; /* П  */
    --acc-code-4: #7c3aed; /* М  */
}

[data-bs-theme="dark"] .acc-page {
    --acc-border: rgba(255, 255, 255, 0.10);
    --acc-muted-bg: rgba(255, 255, 255, 0.03);
    --acc-weekend-bg: rgba(148, 163, 184, 0.10);
    --acc-group-bg: color-mix(in srgb, var(--acc-accent) 18%, transparent);
    --acc-total-bg: rgba(255, 255, 255, 0.06);
    --acc-code-0: #60a5fa;
    --acc-code-1: #f87171;
    --acc-code-2: #fbbf24;
    --acc-code-3: #fb923c;
    --acc-code-4: #a78bfa;
}

/* Primary buttons use the same accent gradient as the other Personal pages */
#personal-accounting-container .btn-primary,
#acc-export-modal .btn-primary {
    background: linear-gradient(135deg, color-mix(in srgb, var(--apple-accent-color, #6c63ff) 100%, white 25%), var(--apple-accent-color, #6c63ff)) !important;
    border-color: var(--apple-accent-color, #6c63ff) !important;
}

/* ---------- Filters ---------- */

.acc-badge-soft {
    background: color-mix(in srgb, var(--acc-accent) 15%, transparent);
    color: var(--acc-accent);
    font-weight: 600;
    font-size: 0.72rem;
}

/* Cards use backdrop-filter, which gives each one its own stacking context, so later
   cards (KPIs, results) would paint over dropdowns opened in the filters card.
   overflow: visible overrides the global `.card-glass { overflow: hidden }` from the
   register module's stylesheet, which would otherwise clip the dropdown at the card edge. */
.card.card-glass.acc-filters-card {
    position: relative;
    z-index: 5;
    overflow: visible;
}

/* Solid "Quick periods" menu: overrides the global translucent .dropdown-menu
   (users_management.css uses !important, so the ID selector is needed to win). */
[data-bs-theme] #acc-presets.dropdown-menu,
#acc-presets.dropdown-menu {
    background-color: var(--bs-body-bg) !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}

.acc-mode-buttons .btn {
    min-width: 6.5rem;
    border-radius: var(--bs-border-radius);
    white-space: nowrap;
}

.acc-mode-buttons .btn-check:checked + .btn {
    background: var(--acc-accent);
    border-color: var(--acc-accent);
    color: #fff;
    box-shadow: 0 1px 4px color-mix(in srgb, var(--acc-accent) 35%, transparent);
}

.acc-month-select {
    width: 9.5rem;
}

.acc-year-select {
    width: 6rem;
}

.acc-icon-btn {
    width: 32px;
    height: 31px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.acc-dates-input,
.acc-period-panel .flatpickr-input {
    min-width: 15rem;
}

.acc-mode-toggle {
    font-size: 0.75rem;
    text-decoration: none;
    color: var(--apple-secondary-text, #6c757d);
}

.acc-mode-toggle:hover {
    color: var(--acc-accent);
}

.acc-mode-toggle.acc-mode-exclude {
    color: var(--acc-code-1);
    font-weight: 600;
}

.acc-more-toggle .bi-chevron-down {
    display: inline-block;
    transition: transform 0.2s ease;
}

.acc-more-toggle:not(.collapsed) .bi-chevron-down {
    transform: rotate(180deg);
}

.acc-chip {
    border-radius: 999px;
}

.acc-page .btn-check:checked + .acc-chip {
    background: color-mix(in srgb, var(--acc-accent) 14%, transparent);
    border-color: var(--acc-accent);
    color: var(--acc-accent);
}

/* ---------- KPIs ---------- */

.acc-kpi .card-body {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.acc-kpi-label {
    font-size: 0.78rem;
    color: var(--apple-secondary-text, #6c757d);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.acc-kpi-value {
    font-size: 1.45rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.acc-kpi-hint {
    font-size: 0.72rem;
    color: var(--apple-secondary-text, #6c757d);
}

.acc-kpi-accent .acc-kpi-value {
    color: var(--acc-accent);
}

/* ---------- Tabs & toolbar ---------- */

.acc-tabs .nav-link {
    border-radius: 999px;
    padding: 0.35rem 0.9rem;
    color: var(--apple-text-color, inherit);
}

.acc-tabs .nav-link.active {
    background: var(--acc-accent);
    color: #fff;
}

.acc-toolbar:empty {
    display: none !important;
}

.acc-tool .form-select {
    min-width: 11rem;
}

.acc-expand-buttons .btn {
    border-radius: var(--bs-border-radius);
    white-space: nowrap;
}

.acc-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    padding-bottom: 0.3rem;
}

.acc-legend-weekend {
    padding: 0.05rem 0.45rem;
    border-radius: 0.35rem;
    background: var(--acc-weekend-bg);
}

/* ---------- Tables ---------- */

.acc-view {
    position: relative;
    min-height: 160px;
    transition: opacity 0.15s ease;
}

.acc-view.acc-loading {
    opacity: 0.45;
    pointer-events: none;
}

.acc-view.acc-loading::after {
    content: "";
    position: absolute;
    top: 60px;
    left: 50%;
    width: 2rem;
    height: 2rem;
    margin-left: -1rem;
    border: 0.25em solid var(--acc-accent);
    border-right-color: transparent;
    border-radius: 50%;
    animation: acc-spin 0.75s linear infinite;
}

@keyframes acc-spin {
    to { transform: rotate(360deg); }
}

.acc-empty {
    text-align: center;
    padding: 3rem 1rem;
}

.acc-table-wrap {
    max-height: 70vh;
    overflow: auto;
    border: 1px solid var(--acc-border);
    border-radius: 0.75rem;
}

.acc-table {
    --bs-table-bg: transparent;
    font-size: 0.86rem;
    font-variant-numeric: tabular-nums;
}

.acc-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--apple-card-bg-light, #fff);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--acc-border);
    font-weight: 600;
    font-size: 0.78rem;
    white-space: nowrap;
    vertical-align: bottom;
}

[data-bs-theme="dark"] .acc-table thead th {
    background: var(--apple-card-bg-dark, #1e1e22);
}

.acc-table tfoot th,
.acc-table tfoot td {
    position: sticky;
    bottom: 0;
    z-index: 1;
    background: var(--apple-card-bg-light, #fff);
}

[data-bs-theme="dark"] .acc-table tfoot th,
[data-bs-theme="dark"] .acc-table tfoot td {
    background: var(--apple-card-bg-dark, #1e1e22);
}

.acc-total-row > * {
    font-weight: 700;
    box-shadow: inset 0 1px 0 var(--acc-border);
}

.acc-total-col {
    font-weight: 600;
    background-color: var(--acc-muted-bg) !important;
}

.acc-label {
    font-weight: 500;
    white-space: nowrap;
}

.acc-zero {
    color: var(--apple-secondary-text, #adb5bd);
    opacity: 0.6;
}

.acc-count {
    display: inline-block;
    min-width: 1.5rem;
    margin-left: 0.4rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-align: center;
    background: var(--acc-muted-bg);
    color: var(--apple-secondary-text, #6c757d);
}

.acc-sortable {
    cursor: pointer;
    user-select: none;
}

.acc-sortable:hover {
    color: var(--acc-accent);
}

.acc-sortable::after {
    content: "";
    display: inline-block;
    margin-left: 0.25rem;
    opacity: 0.35;
}

.acc-sorted-asc::after { content: "▲"; font-size: 0.6rem; opacity: 1; }
.acc-sorted-desc::after { content: "▼"; font-size: 0.6rem; opacity: 1; }

.acc-summary-table th[data-sort] .d-block {
    display: inline-block !important;
}

.acc-summary-table thead th:not(:first-child) {
    text-align: right;
}

/* Summary: expandable rows */
.acc-row-l1.acc-expandable {
    cursor: pointer;
}

.acc-row-l1 > * {
    background: var(--acc-muted-bg) !important;
}

.acc-row-l1:not(.acc-expandable) > * {
    background: transparent !important;
}

.acc-chevron {
    display: inline-block;
    margin-right: 0.4rem;
    font-size: 0.75rem;
    transition: transform 0.15s ease;
}

.acc-row-l1[aria-expanded="true"] .acc-chevron {
    transform: rotate(90deg);
}

.acc-row-l2 .acc-label {
    padding-left: 2rem;
    font-weight: 400;
}

.acc-share-cell {
    min-width: 7.5rem;
}

.acc-share {
    display: inline-block;
    width: 3.5rem;
    height: 0.4rem;
    margin-right: 0.45rem;
    vertical-align: middle;
    border-radius: 999px;
    background: var(--acc-muted-bg);
    overflow: hidden;
}

.acc-share > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--acc-accent);
}

/* Pivot: sticky first column + heat map */
.acc-sticky-first th:first-child,
.acc-sticky-first td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--apple-card-bg-light, #fff);
}

.acc-sticky-first thead th:first-child {
    z-index: 3;
}

[data-bs-theme="dark"] .acc-sticky-first th:first-child,
[data-bs-theme="dark"] .acc-sticky-first td:first-child {
    background: var(--apple-card-bg-dark, #1e1e22);
}

.acc-heat {
    background-color: color-mix(in srgb, var(--acc-accent) calc(var(--acc-heat, 0) * 38%), transparent) !important;
}

/* Timesheet */
.acc-timesheet {
    font-size: 0.8rem;
}

.acc-timesheet > :not(caption) > * > * {
    border-color: var(--acc-border);
    padding: 0.25rem 0.35rem;
}

.acc-timesheet .acc-day {
    min-width: 2.1rem;
    text-align: center;
}

.acc-timesheet thead .acc-day span {
    display: block;
    font-size: 0.8rem;
}

.acc-timesheet thead .acc-day small {
    display: block;
    font-weight: 400;
    color: var(--apple-secondary-text, #6c757d);
}

.acc-timesheet .acc-weekend {
    background-color: var(--acc-weekend-bg) !important;
}

.acc-timesheet .acc-person {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--apple-card-bg-light, #fff);
}

[data-bs-theme="dark"] .acc-timesheet .acc-person {
    background: var(--apple-card-bg-dark, #1e1e22);
}

.acc-position {
    color: var(--apple-secondary-text, #6c757d);
    white-space: nowrap;
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.acc-group-row > th {
    background: var(--acc-group-bg) !important;
    font-weight: 600;
    position: sticky;
    left: 0;
}

.acc-subtotal-row > * {
    background: var(--acc-total-bg) !important;
    font-weight: 600;
}

/* Leave codes */
.acc-code {
    display: inline-block;
    min-width: 1.7rem;
    padding: 0.05rem 0.35rem;
    border-radius: 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-align: center;
}

.acc-code-0 { --acc-code: var(--acc-code-0); }
.acc-code-1 { --acc-code: var(--acc-code-1); }
.acc-code-2 { --acc-code: var(--acc-code-2); }
.acc-code-3 { --acc-code: var(--acc-code-3); }
.acc-code-4 { --acc-code: var(--acc-code-4); }

.acc-code,
.acc-timesheet td.acc-code-cell {
    color: var(--acc-code);
    background-color: color-mix(in srgb, var(--acc-code) 15%, transparent) !important;
}

.acc-timesheet td.acc-code-cell {
    font-weight: 700;
    font-size: 0.72rem;
}

.acc-leave-col {
    color: var(--apple-secondary-text, #6c757d);
}

/* Records */
.acc-desc {
    max-width: 28rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.acc-records-table td {
    white-space: nowrap;
}

.acc-page-indicator {
    min-width: 5rem;
    opacity: 1 !important;
}

@media (max-width: 575.98px) {
    .acc-mode-buttons {
        width: 100%;
    }

    .acc-mode-buttons .btn {
        min-width: 0;
        flex: 1 1 auto;
    }

    .acc-tool .form-select {
        min-width: 9rem;
    }

    .acc-kpi-value {
        font-size: 1.2rem;
    }
}
