/**
 * This file is part of LawFirm plugin for FacturaScripts.
 * FacturaScripts Copyright (C) 2015-2026 Carlos Garcia Gomez <carlos@facturascripts.com>
 * LawFirm        Copyright (C) 2021-2026 Jose Antonio Cuello Principal <yopli2000@gmail.com>
 *
 * This program and its files are under the terms of the license specified in the LICENSE file.
 *
 * Styles for the law firm dashboard. Every color comes from a Bootstrap 5.3
 * token, so the whole panel follows the theme of the installation and reads
 * correctly in light and in dark without a single hard coded value. The
 * accent of each card is declared once in its data-accent attribute.
 */

/* --------------------------------------------------------------- Accents */
[data-accent="danger"] {
    --dash-accent: var(--bs-danger);
    --dash-accent-rgb: var(--bs-danger-rgb);
    --dash-subtle: var(--bs-danger-bg-subtle);
    --dash-text: var(--bs-danger-text-emphasis);
}

[data-accent="info"] {
    --dash-accent: var(--bs-info);
    --dash-accent-rgb: var(--bs-info-rgb);
    --dash-subtle: var(--bs-info-bg-subtle);
    --dash-text: var(--bs-info-text-emphasis);
}

[data-accent="primary"] {
    --dash-accent: var(--bs-primary);
    --dash-accent-rgb: var(--bs-primary-rgb);
    --dash-subtle: var(--bs-primary-bg-subtle);
    --dash-text: var(--bs-primary-text-emphasis);
}

[data-accent="secondary"] {
    --dash-accent: var(--bs-secondary);
    --dash-accent-rgb: var(--bs-secondary-rgb);
    --dash-subtle: var(--bs-secondary-bg-subtle);
    --dash-text: var(--bs-secondary-color);
}

[data-accent="success"] {
    --dash-accent: var(--bs-success);
    --dash-accent-rgb: var(--bs-success-rgb);
    --dash-subtle: var(--bs-success-bg-subtle);
    --dash-text: var(--bs-success-text-emphasis);
}

[data-accent="warning"] {
    --dash-accent: var(--bs-warning);
    --dash-accent-rgb: var(--bs-warning-rgb);
    --dash-subtle: var(--bs-warning-bg-subtle);
    --dash-text: var(--bs-warning-text-emphasis);
}

/* ------------------------------------------------------------------ Zones */
.dashboard-zone {
    margin-bottom: 1.75rem;
}

.dashboard-zone-title {
    align-items: center;
    color: var(--bs-secondary-color);
    display: flex;
    font-size: 0.8rem;
    font-weight: 700;
    gap: 0.6rem;
    letter-spacing: 0.09em;
    margin-bottom: 0.9rem;
    text-transform: uppercase;
}

/* The rule that follows the title, so every zone reads as a band */
.dashboard-zone-title::after {
    background-image: linear-gradient(to right, var(--bs-border-color), transparent);
    content: "";
    flex: 1 1 auto;
    height: 1px;
}

/* Period selector of the header */
.dashboard-period {
    align-items: center;
    display: flex;
    gap: 0.5rem;
}

.dashboard-period > i {
    color: var(--bs-secondary-color);
}

/* The label says which figure the period governs: only the billed one */
.dashboard-period-label {
    color: var(--bs-secondary-color);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    margin-bottom: 0;
    text-transform: uppercase;
}

/* Shared card surface: no heavy shadow at rest, a discreet lift on hover */
.dashboard-card,
.dashboard-list {
    background-color: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.85rem;
    box-shadow: 0 1px 2px rgba(var(--bs-emphasis-color-rgb), 0.05);
    overflow: hidden;
    position: relative;
    transition: box-shadow 0.15s ease-in-out, transform 0.15s ease-in-out, border-color 0.15s ease-in-out;
}

/* The accent strip that identifies the block, drawn over the top border */
.dashboard-card::before,
.dashboard-list::before {
    background-color: var(--dash-accent);
    content: "";
    height: 3px;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
}

/* ------------------------------------------------------------------ Money */
.dashboard-card {
    color: inherit;
    text-decoration: none;
}

a.dashboard-card:hover,
.dashboard-list:hover {
    border-color: rgba(var(--dash-accent-rgb), 0.45);
    box-shadow: 0 0.5rem 1rem rgba(var(--bs-emphasis-color-rgb), 0.1);
    transform: translateY(-2px);
}

.dashboard-card .card-body {
    padding: 1.1rem 1.15rem 1rem;
}

.dashboard-card-head {
    align-items: flex-start;
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    margin-bottom: 0.4rem;
    min-height: 2.5rem;
}

.dashboard-card-title {
    color: var(--bs-secondary-color);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.3;
    text-decoration: none;
    text-transform: uppercase;
}

a.dashboard-card-title {
    color: var(--bs-secondary-color);
}

a.dashboard-card-title:hover {
    color: var(--dash-text);
}

/* Soft square badge behind the icon, tinted with the accent of the card */
.dashboard-card-icon {
    align-items: center;
    background-color: var(--dash-subtle);
    border-radius: 0.6rem;
    color: var(--dash-text);
    display: inline-flex;
    flex-shrink: 0;
    height: 2.25rem;
    justify-content: center;
    width: 2.25rem;
}

/* Lining figures, so the amounts of the four cards align vertically */
.dashboard-card-amount {
    color: var(--dash-text);
    font-size: 1.7rem;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.dashboard-card-detail {
    color: var(--bs-secondary-color);
    font-size: 0.78rem;
    line-height: 1.5;
}

/* Small pill for the figure inside the figure: overdue, variation... */
.dashboard-chip {
    border-radius: 2rem;
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    margin-left: 0.15rem;
    padding: 0.05rem 0.5rem;
    white-space: nowrap;
}

.dashboard-chip-danger {
    background-color: var(--bs-danger-bg-subtle);
    color: var(--bs-danger-text-emphasis);
}

.dashboard-chip-success {
    background-color: var(--bs-success-bg-subtle);
    color: var(--bs-success-text-emphasis);
}

/* Segmented control of the billed card */
.dashboard-scopes {
    display: flex;
    gap: 0.15rem;
}

.dashboard-scope {
    background-color: transparent;
    border: 0;
    border-radius: 2rem;
    color: var(--bs-secondary-color);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.15rem 0.6rem;
    transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out;
}

.dashboard-scope:hover {
    background-color: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
}

.dashboard-scope.active {
    background-color: var(--dash-subtle);
    color: var(--dash-text);
}

/* ----------------------------------------------------------------- Alerts */
.dashboard-alerts {
    display: flex;
    gap: 1rem;
}

.dashboard-indicators {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
}

.dashboard-indicator {
    align-items: center;
    background-color: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-left: 3px solid var(--dash-accent);
    border-radius: 0.7rem;
    box-shadow: 0 1px 2px rgba(var(--bs-emphasis-color-rgb), 0.05);
    cursor: pointer;
    display: flex;
    gap: 0.75rem;
    min-height: 4.25rem;
    padding: 0.75rem 0.9rem;
    text-align: left;
    transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

/* Nothing pending: the indicator steps back instead of shouting in grey */
.dashboard-indicator.is-empty {
    border-left-color: var(--bs-border-color);
    opacity: 0.65;
}

.dashboard-indicator:hover {
    background-color: var(--bs-tertiary-bg);
}

.dashboard-indicator.active {
    background-color: var(--dash-subtle);
    border-color: rgba(var(--dash-accent-rgb), 0.5);
    border-left-color: var(--dash-accent);
    box-shadow: 0 0.25rem 0.6rem rgba(var(--bs-emphasis-color-rgb), 0.08);
}

.dashboard-indicator-icon {
    color: var(--dash-text);
    flex-shrink: 0;
    font-size: 1.1rem;
    width: 1.4rem;
}

.dashboard-indicator-label {
    flex: 1 1 auto;
    font-size: 0.85rem;
    line-height: 1.25;
    min-width: 0;
}

.dashboard-indicator-count {
    background-color: var(--dash-subtle);
    border-radius: 2rem;
    color: var(--dash-text);
    flex-shrink: 0;
    font-size: 1.05rem;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    min-width: 2.4rem;
    padding: 0.1rem 0.55rem;
    text-align: center;
}

/* Fixed height, sized to fit around four records before scrolling */
.dashboard-alerts-detail {
    background-color: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.85rem;
    box-shadow: 0 1px 2px rgba(var(--bs-emphasis-color-rgb), 0.05);
    height: 16rem;
    overflow: hidden;
}

.dashboard-alerts-detail .card-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.dashboard-detail-pane {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
}

.dashboard-detail-title {
    align-items: center;
    display: flex;
    flex-shrink: 0;
    font-size: 1rem;
    font-weight: 600;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.dashboard-detail-rows {
    flex: 1 1 auto;
    margin-right: -0.35rem;
    min-height: 0;
    overflow-y: auto;
    padding-right: 0.35rem;
    scrollbar-width: thin;
}

.dashboard-detail-row {
    border-bottom: 1px solid var(--bs-border-color-translucent);
    color: inherit;
    display: block;
    padding: 0.4rem 1.1rem 0.4rem 0.4rem;
    position: relative;
    text-decoration: none;
    transition: background-color 0.12s ease-in-out;
}

.dashboard-detail-row:last-child {
    border-bottom: 0;
}

a.dashboard-detail-row:hover {
    background-color: var(--bs-tertiary-bg);
    border-radius: 0.4rem;
}

/* The chevron only shows up on the row the pointer is over */
a.dashboard-detail-row::after {
    color: var(--bs-secondary-color);
    content: "\203A";
    font-size: 1.1rem;
    line-height: 1;
    opacity: 0;
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    transition: opacity 0.12s ease-in-out;
}

a.dashboard-detail-row:hover::after {
    opacity: 1;
}

/* ------------------------------------------------------------------ Lists */
.dashboard-list-head {
    align-items: center;
    background-color: var(--dash-subtle);
    border-bottom: 1px solid var(--bs-border-color);
    display: flex;
    gap: 0.7rem;
    padding: 0.7rem 0.9rem;
}

.dashboard-list-title {
    flex: 1 1 auto;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.2;
    min-width: 0;
}

.dashboard-list-amount {
    color: var(--dash-text);
    flex-shrink: 0;
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.dashboard-list-summary {
    color: var(--bs-secondary-color);
    font-size: 0.78rem;
    margin-bottom: 0.5rem;
}

.dashboard-list-rows {
    display: flex;
    flex-direction: column;
}

.dashboard-list-row {
    align-items: center;
    border-bottom: 1px solid var(--bs-border-color-translucent);
    color: inherit;
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    padding: 0.45rem 0.4rem;
    text-decoration: none;
    transition: background-color 0.12s ease-in-out;
}

.dashboard-list-row:last-child {
    border-bottom: 0;
}

.dashboard-list-row:hover {
    background-color: var(--bs-tertiary-bg);
    border-radius: 0.4rem;
}

.dashboard-list-row-main {
    min-width: 0;
}

.dashboard-list-row-main strong {
    color: var(--dash-text);
}

.dashboard-list-row-side {
    flex-shrink: 0;
    text-align: right;
    white-space: nowrap;
}

.dashboard-list-row-amount {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.dashboard-list-row-sub {
    color: var(--bs-secondary-color);
    display: block;
    font-size: 0.74rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ------------------------------------------------------------------ Empty */
.dashboard-empty {
    align-items: center;
    color: var(--bs-secondary-color);
    display: flex;
    font-size: 0.85rem;
    gap: 0.5rem;
    margin-bottom: 0;
}

.dashboard-empty i {
    color: var(--bs-success);
}

/* ---------------------------------------------------------- Adaptations */
@media (min-width: 992px) {
    .dashboard-indicators {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.75rem;
        width: 50%;
    }

    .dashboard-alerts-detail {
        width: 50%;
    }
}

@media (max-width: 991.98px) {
    .dashboard-indicators {
        gap: 0.75rem;
    }

    /* Below desktop there is no detail panel, so the indicators only inform */
    .dashboard-indicator {
        cursor: default;
        pointer-events: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dashboard-card,
    .dashboard-detail-row,
    .dashboard-indicator,
    .dashboard-list,
    .dashboard-list-row,
    .dashboard-scope {
        transition: none;
    }

    a.dashboard-card:hover,
    .dashboard-list:hover {
        transform: none;
    }
}
