/* Cifra shell styling layered on top of the MudBlazor theme (see Theme/CifraTheme.cs).
   Keep visual rules here; colour semantics live in the theme. */

:root {
    /* Aliases onto the MudBlazor palette (CifraTheme.cs is the single source of color truth).
       Never re-declare hex here — a rebrand must be a one-file change. MudThemeProvider emits
       the --mud-palette-* variables at runtime in MainLayout AND AuthLayout, so the static-SSR
       login/account pages resolve them too. */
    --cifra-border: var(--mud-palette-lines-default);
    --cifra-danger: var(--mud-palette-error);
    --cifra-amber: var(--mud-palette-warning);
    --cifra-blue: var(--mud-palette-info);
}

html, body {
    margin: 0;
    font-family: 'Roboto', Helvetica, Arial, sans-serif;
}

/* --- Sidebar brand block --- */
.cifra-brand {
    padding: 1.25rem 1rem 1rem;
    text-align: center;
    border-bottom: 1px solid var(--cifra-border);
}

.cifra-brand__logo {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    /* The brand text comes from config as mixed case (e.g. "Sky Kitchens") — the all-caps
       look is a style rule, not the literal's spelling. */
    text-transform: uppercase;
    color: var(--mud-palette-text-primary);
}

.cifra-brand__user {
    margin-top: 0.35rem;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #94A3B8;
}

/* --- Dynamic sidebar nav: active item = blue->indigo gradient pill, white text, rounded --- */
.cifra-nav {
    padding: 0.5rem;
}

.cifra-nav .mud-nav-link {
    border-radius: 8px;
    margin: 0.15rem 0;
    color: var(--mud-palette-drawer-text);
}

.cifra-nav .mud-nav-link.active,
.cifra-nav .mud-nav-link.active:hover {
    background: linear-gradient(90deg, var(--cifra-blue) 0%, var(--mud-palette-primary) 100%);
    /* !important needed: MudBlazor's .mud-navmenu-default .mud-nav-link.active rule
       (5 classes) outranks this selector and would otherwise force the primary color. */
    color: #FFFFFF !important;
}

.cifra-nav .mud-nav-link.active .mud-nav-link-icon {
    color: #FFFFFF;
}

/* --- Logout button pinned to the bottom of the sidebar --- */
.cifra-sidebar-footer {
    margin-top: auto;
    padding: 0.75rem;
    border-top: 1px solid var(--cifra-border);
}

.cifra-sidebar-footer form {
    margin: 0;
}

/* Make the drawer a column so the footer can sit at the bottom. */
.cifra-drawer .mud-drawer-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* --- Login screen: centred card on the light-gray background --- */
.cifra-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--mud-palette-background);
    padding: 1rem;
}

/* --- Shared module surfaces --- */
.cifra-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cifra-page__header,
.cifra-filterbar,
.cifra-section__header,
.cifra-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.cifra-page__header,
.cifra-filterbar {
    flex-wrap: wrap;
}

.cifra-filterbar {
    padding: 1rem;
    border: 1px solid var(--cifra-border);
    border-radius: 8px;
    background-color: var(--mud-palette-surface);
}

.cifra-filterbar .mud-input-control {
    min-width: 190px;
}

.cifra-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1rem;
}

.cifra-card {
    border: 1px solid var(--cifra-border);
    border-radius: 8px;
}

.cifra-card--success {
    border-left: 5px solid var(--mud-palette-success);
}

.cifra-card--danger {
    border-left: 5px solid var(--cifra-danger);
}

.cifra-card--amber {
    border-left: 5px solid var(--cifra-amber);
}

.cifra-card--blue {
    border-left: 5px solid var(--cifra-blue);
}

.cifra-card--slate {
    border-left: 5px solid var(--mud-palette-text-secondary);
}

.cifra-section {
    padding: 1rem;
    border: 1px solid var(--cifra-border);
    border-radius: 8px;
    background-color: var(--mud-palette-surface);
}

.cifra-table {
    margin-top: 1rem;
}

.cifra-table__amount {
    text-align: right;
    white-space: nowrap;
}

.cifra-table__actions {
    width: 96px;
    text-align: right;
    white-space: nowrap;
}

.cifra-pager {
    margin-top: 0.75rem;
    border-top: 1px solid var(--cifra-border);
    padding-top: 0.75rem;
}

@media (max-width: 720px) {
    .cifra-page__header,
    .cifra-filterbar,
    .cifra-section__header,
    .cifra-pager {
        align-items: stretch;
        flex-direction: column;
    }

    .cifra-filterbar .mud-input-control {
        min-width: 100%;
    }
}

/* --- Income module --- */
.income-location-card__title,
.income-shift-band,
.income-channel-list__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.income-location-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.income-matrix-wrap {
    overflow-x: auto;
}

.income-matrix {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.875rem;
}

.income-matrix th,
.income-matrix td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--cifra-border);
    text-align: right;
    white-space: nowrap;
}

.income-matrix thead th,
.income-matrix tbody th,
.income-matrix tfoot th {
    background-color: var(--mud-palette-dark);
    color: #FFFFFF;
    font-weight: 600;
}

.income-matrix tbody th,
.income-matrix tfoot th {
    text-align: left;
}

.income-matrix tfoot td,
.income-matrix__total {
    color: var(--mud-palette-success);
    font-weight: 700;
}

.income-location-card .mud-card-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.income-shift-band {
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    color: #FFFFFF;
}

.income-shift-band--day {
    background-color: var(--cifra-amber);
}

.income-shift-band--night {
    background-color: var(--mud-palette-primary);
}

.income-channel-list,
.income-tender-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.income-channel-list__row {
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--cifra-border);
}

.income-tender-list {
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    background-color: var(--mud-palette-background);
    color: var(--mud-palette-text-secondary);
    font-size: 0.8rem;
}

.income-empty-line {
    padding: 0 0.25rem;
}

.confirm-dialog,
.confirm-dialog__title {
    display: flex;
    gap: 0.75rem;
}

.confirm-dialog {
    flex-direction: column;
}

.confirm-dialog__title {
    align-items: center;
}

/* --- Expenses module --- */

.expense-dialog {
    min-width: 0;
}

.expense-errors {
    padding-left: 1.25rem;
    margin: 0;
}

/* --- Invoices module --- */

.invoice-dialog,
.payment-dialog {
    min-width: 0;
}

.invoice-errors {
    padding-left: 1.25rem;
    margin: 0;
}

/* --- Reconnect overlay (see App.razor) --- */
#components-reconnect-modal {
    display: none;
}

#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 2000;
    align-items: center;
    justify-content: center;
    background: rgba(30, 41, 59, 0.6);
}

/* Hex fallbacks matter here: the overlay must render correctly even if the MudBlazor theme
   variables are unavailable when the circuit is gone. */
.cifra-reconnect__card {
    background: var(--mud-palette-surface, #FFFFFF);
    border-radius: 8px;
    padding: 2rem 2.5rem;
    text-align: center;
    max-width: 320px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.cifra-reconnect__title {
    font-weight: 600;
    font-size: 1.1rem;
    margin: 0.75rem 0 0.25rem;
}

.cifra-reconnect__text {
    margin: 0 0 1rem;
    color: var(--mud-palette-text-secondary, #64748B);
}

/* State copy: attempting-text while retrying, failed-text once the framework gives up. */
.cifra-reconnect__text--failed { display: none; }
#components-reconnect-modal.components-reconnect-failed .cifra-reconnect__text--attempting,
#components-reconnect-modal.components-reconnect-rejected .cifra-reconnect__text--attempting { display: none; }
#components-reconnect-modal.components-reconnect-failed .cifra-reconnect__text--failed,
#components-reconnect-modal.components-reconnect-rejected .cifra-reconnect__text--failed { display: block; }
#components-reconnect-modal.components-reconnect-failed .cifra-reconnect__spinner,
#components-reconnect-modal.components-reconnect-rejected .cifra-reconnect__spinner { animation: none; opacity: 0.3; }

.cifra-reconnect__spinner {
    width: 32px;
    height: 32px;
    margin: 0 auto;
    border: 3px solid var(--cifra-border, #E2E8F0);
    border-top-color: var(--mud-palette-primary, #4F46E5);
    border-radius: 50%;
    animation: cifra-reconnect-spin 0.9s linear infinite;
}

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

.cifra-reconnect__reload {
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1.5rem;
    background: var(--mud-palette-primary, #4F46E5);
    color: #FFFFFF;
    font-size: 0.95rem;
    cursor: pointer;
}

/* --- Topbar selectors (LocationSelector / MonthSelector) --- */
.cifra-topbar-ubicacion { min-width: 210px; }
.cifra-topbar-mes { min-width: 170px; }

/* Below MudBlazor's sm breakpoint the fixed widths overflow a phone viewport (≈590px of topbar
   content vs 375px of screen), so the two selects share the remaining row width instead; their
   collapsed text truncates, but the dropdown popovers still open at full size. */
@media (max-width: 599.98px) {
    .cifra-topbar-ubicacion,
    .cifra-topbar-mes {
        min-width: 0;
        flex: 1 1 0;
    }
}
