/* Application custom styles (loaded globally after the Metronic theme).
   Prefer adding rules here instead of inline style="" attributes in Blade views. */

/* --- Mobile horizontal-scroll fix ---
   Off-canvas panels (cart, user, etc.) are parked at right:-395px.
   On mobile this let the page scroll sideways and exposed them.
   Lock page-level horizontal scrolling; panels still slide in via their toggle. */
html, body {
    overflow-x: hidden;
    max-width: 100%;
}

/* Safety net for wide tables not wrapped in .table-responsive:
   keep them scrollable inside their card instead of being clipped. */
@media (max-width: 991.98px) {
    .card .card-body {
        overflow-x: auto;
    }
}

/* Shared elevation for resource cards (workers, worksites, ...)
   so every card grid renders with a consistent shadow. */
.card-elevated {
    box-shadow: 0 0 30px 0 rgba(82, 63, 105, 0.05), 0 4px 12px 0 rgba(0, 0, 0, 0.08) !important;
}

/* Dashboard header: worksite filter dropdown.
   Mobile: full-width on its own line (avoids horizontal overflow).
   Desktop: grows to fill the row so the select sits inline with the
   action buttons, keeping at least 350px. */
.worksite-filter-wrap {
    width: 100%;
}

@media (min-width: 992px) {
    .worksite-filter-wrap {
        flex: 0 0 350px;
        width: 350px;
    }
}

/* Shared filter bar: let the selects + action buttons wrap onto
   multiple lines on mobile instead of overflowing the viewport. */
.filter-controls {
    row-gap: .5rem;
}

/* Dashboard KPI stat cards. */
.dashboard-stat-card {
    min-height: 80px;
}

.dashboard-stat-icon {
    height: 32px;
    line-height: 32px;
}

/* Presences - worker days
   Monthly data-entry grid (one row per generated day). It is read top to bottom,
   so the rules below prioritise a tight vertical rhythm, aligned numbers and a
   status column that stays at the same x position on every row. */
.presence-days-table td {
    padding: 0.5rem 0.75rem;
    vertical-align: middle;
}

.presence-days-table th {
    padding: 0.6rem 0.75rem;
}

.presence-col-day {
    width: 120px;
    white-space: nowrap;
}

.presence-day-weekday {
    display: inline-block;
    width: 2.8em;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    color: #B5B5C3;
}

.presence-day-date {
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* Status column: a narrow rail of dots, scannable down the whole month. */
.presence-col-status {
    width: 34px;
    text-align: center;
}

.presence-days-table .label.label-dot {
    width: 9px;
    height: 9px;
}

/* Clockings column: bounded width; busy days are condensed to first-in → last-out
   with an expandable detail list, so a burst of events can never widen the table. */
.presence-col-clockings {
    max-width: 460px;
}

.presence-clockings {
    font-variant-numeric: tabular-nums;
}

.presence-clocking-pair {
    white-space: nowrap;
}

.presence-clocking-arrow,
.presence-clocking-sep {
    color: #B5B5C3;
}

.presence-clocking-arrow {
    margin: 0 0.2rem;
}

.presence-clocking-sep {
    margin: 0 0.45rem;
}

.presence-clockings-toggle {
    border: 0;
    padding: 0 0.25rem;
    background: none;
    font-size: 0.8rem;
    color: #3699FF;
    cursor: pointer;
}

.presence-clockings-toggle:hover,
.presence-clockings-toggle:focus {
    text-decoration: underline;
}

.presence-clockings-toggle i {
    font-size: 0.65rem;
}

.presence-clockings-detail {
    margin-top: 0.25rem;
    font-variant-numeric: tabular-nums;
    font-size: 0.85rem;
}

/* One line per worksite: times keep their vertical alignment, the site name
   closes the line in muted text so days split across worksites read instantly. */
.presence-clocking-line + .presence-clocking-line {
    margin-top: 0.1rem;
}

.presence-clocking-line-worksite {
    margin-left: 0.6rem;
    font-size: 0.8rem;
}

.presence-clocking-worksites {
    font-size: 0.8rem;
    line-height: 1.3;
    margin-top: 0.1rem;
    max-width: 440px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.presence-col-worksite {
    width: 230px;
}

.presence-col-type {
    width: 190px;
}

.presence-col-hours {
    width: 180px;
}

.presence-worksite-select,
.presence-type-select,
.presence-hours-input {
    font-size: 0.9rem;
}

/* Computed hours hint: an input-group addon glued to its input, clickable to copy. */
.presence-hours-hint {
    font-size: 0.8rem;
    color: #7E8299;
    font-variant-numeric: tabular-nums;
    border: 1px solid #E4E6EF;
    background-color: #F3F6F9;
}

button.presence-hours-hint {
    cursor: pointer;
}

button.presence-hours-hint:hover,
button.presence-hours-hint:focus {
    color: #3699FF;
    background-color: #EBF3FC;
}

.presence-hours-hint-static {
    cursor: default;
}

/* Saturdays are usually non-worked: tint them so the working week stands out. */
.presence-days-table tbody tr.presence-day-saturday {
    background-color: #F6F8FB;
}

.presence-days-table tbody tr.presence-day-saturday:hover {
    background-color: #EDF1F6;
}

/* DURC di Congruità - counter gauges (EdilConnect-style donuts).
   The filled arc is driven by --congruity-value (0-100), set inline per gauge. */
.congruity-gauge {
    --congruity-color: #007bff;
    width: 140px;
    height: 140px;
    margin: 0 auto;
    border-radius: 50%;
    background: conic-gradient(var(--congruity-color) calc(var(--congruity-value, 0) * 1%), #e9ecef 0);
    display: flex;
    align-items: center;
    justify-content: center;
}

.congruity-gauge-inner {
    width: 106px;
    height: 106px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.congruity-gauge-secondary { --congruity-color: #6c757d; }
.congruity-gauge-primary   { --congruity-color: #007bff; }
.congruity-gauge-success   { --congruity-color: #28a745; }
.congruity-gauge-warning   { --congruity-color: #ffc107; }
.congruity-gauge-danger    { --congruity-color: #dc3545; }

/* DURC di Congruità - grouped bar chart of the two cumulative counters.
   Axis is fixed 0-100%; bar height is --congruity-h (percent, capped at 100)
   mapped to a 180px-tall plot. The dashed track top edge is the 100% line.
   Grey = theoretical benchmark (deliberately neutral), blue = effective. */
.congruity-chart-scroll {
    overflow-x: auto;
    padding-top: 18px;
}

.congruity-chart-track {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    min-width: 100%;
    width: max-content;
    padding: 0 8px;
    border-bottom: 1px solid #E4E6EF;
}

.congruity-chart-track::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    border-top: 1px dashed #E4E6EF;
}

.congruity-chart-max-label {
    position: absolute;
    top: -16px;
    right: 8px;
    font-size: 0.7rem;
    color: #B5B5C3;
}

.congruity-chart-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1 0 auto;
    min-width: 48px;
}

.congruity-chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 180px;
}

.congruity-chart-bar {
    width: 14px;
    height: calc(var(--congruity-h, 0) * 1.8px);
    border-radius: 4px 4px 0 0;
}

.congruity-chart-bar-theoretical { background-color: #6c757d; }
.congruity-chart-bar-effective   { background-color: #007bff; }

.congruity-chart-label {
    margin: 6px 0 4px;
    font-size: 0.75rem;
    color: #7E8299;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.congruity-legend-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    vertical-align: -1px;
    margin-right: 4px;
}
