/* ---------------------------------------------------------------------------
   Open Sans (Figma design font), self-hosted from this RCL's wwwroot so both the
   WASM host and the MAUI WebView get it offline — NO Google Fonts CDN. Served at
   _content/Italy.ViviEnergia.Ui.Shared/fonts/*. Weights: 400 Regular, 600 SemiBold,
   700 Bold (matches the Figma type scale in ViviEnergiaTheme.cs).
   --------------------------------------------------------------------------- */
@font-face {
    font-family: 'Open Sans';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/OpenSans-Regular.ttf') format('truetype');
}

@font-face {
    font-family: 'Open Sans';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('../fonts/OpenSans-SemiBold.ttf') format('truetype');
}

@font-face {
    font-family: 'Open Sans';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/OpenSans-Bold.ttf') format('truetype');
}

/* ---------------------------------------------------------------------------
   Brand variables (VIVI energia corporate colours, see ViviEnergiaBrand.cs). The values come
   from the MudBlazor theme (ViviEnergiaBrand.cs is the ONLY place with colour values);
   the fallbacks only apply before Blazor has started (boot loader).
   --------------------------------------------------------------------------- */
:root {
    --vivienergia-primary: var(--mud-palette-primary, #0063af);
    --vivienergia-on-primary: var(--mud-palette-primary-text, #ffffff);
    --vivienergia-page-background: var(--mud-palette-background, #f3fafe);
    --vivienergia-selected-tint: color-mix(in srgb, var(--vivienergia-primary) 6%, transparent);
    --vivienergia-choice-tint: color-mix(in srgb, var(--vivienergia-primary) 12%, #ffffff);
    /* Figma "mud-palette-lines-inputs": borders of field groups and the footer divider. */
    --vivienergia-divider: #d5d5d5;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif;
}

.main-container {
    min-height: 100vh;
}

.loader {
    border: 6px solid #f3f3f3;
    border-top: 6px solid var(--vivienergia-primary);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    margin: 0 auto;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ---------------------------------------------------------------------------
   Branded ViviEnergia app bar: brand primary, 56px tall, „VIVI ENERGIA“ as text (no
   logo until AGN releases one), two-line centred title, menu right.
   --------------------------------------------------------------------------- */
.vivienergia-wordmark {
    font-family: 'Open Sans', sans-serif;
    font-weight: 700;
    font-style: italic;
    font-size: 18px;
    line-height: 1;
    color: var(--vivienergia-on-primary);
    letter-spacing: 0;
    white-space: nowrap;
}

.vivienergia-appbar-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.1;
}

.vivienergia-appbar-title .title-small {
    font-size: 12px;       /* Body2 */
    font-weight: 400;
    color: var(--vivienergia-on-primary);
}

.vivienergia-appbar-title .title-main {
    font-size: 16px;       /* Body1, bold per Figma */
    font-weight: 700;
    color: var(--vivienergia-on-primary);
}

/* Phones (dev review 2026-11-16): at 390px the wordmark and the centred two-line title touched. Keep the main
   title, drop the small app name (the wordmark already says it) and let the title shrink instead of overlapping. */
@media (max-width: 480px) {
    .vivienergia-wordmark {
        font-size: 15px;
    }

    .vivienergia-appbar-title {
        min-width: 0;
        padding: 0 8px;
    }

    .vivienergia-appbar-title .title-small {
        display: none;
    }

    .vivienergia-appbar-title .title-main {
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
}

/* ---------------------------------------------------------------------------
   Wizard shell: branded bar (in MainLayout) + progress on top, scrollable body,
   fixed footer, on the brand page background.
   --------------------------------------------------------------------------- */
.wizard-shell {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    background-color: var(--vivienergia-page-background);
}

.wizard-progress {
    border-radius: 0;
}

/* C8 step bar under the sub-header: one item per step, the missing-field count as a red badge (hidden at 0).
   Scrolls sideways on narrow screens instead of wrapping. */
.wizard-stepbar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px 20px;
    background-color: var(--mud-palette-surface);
    border-bottom: 1px solid var(--vivienergia-divider);
    scrollbar-width: none;
}

.wizard-stepbar__item {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 13px;
    color: var(--mud-palette-text-secondary);
}

.wizard-stepbar__item--active {
    background-color: var(--mud-palette-primary-hover);
    color: var(--mud-palette-primary);
    font-weight: 700;
}

.wizard-stepbar__number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid currentColor;
    font-size: 11px;
}

.wizard-stepbar__badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background-color: var(--mud-palette-error);
    color: var(--mud-palette-error-text);
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

/* Figma (Bluenergy layouts, node 564:77406): the cards float on the page background with a 20px margin and 20px
   between them. On wide screens the column stays at the footer's 786px so forms don't stretch across a desktop. */
.wizard-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-sizing: border-box;
    width: 100%;
    max-width: calc(786px + 40px);
    margin: 0 auto;
    padding: 20px 20px 0;
    /* Clear the fixed footer so the last content isn't hidden behind it. */
    padding-bottom: 108px;
}

/* Footer pinned to the bottom of the viewport (Figma MudBottomNavigation: page-background bar with a thin
   #d5d5d5 top divider, buttons centred at most 786px wide). `position: fixed` is used instead of `sticky`
   because the MudBlazor layout chain doesn't give the wizard shell a guaranteed full height for sticky. */
.wizard-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    box-sizing: border-box;
    padding: 9px 20px calc(9px + env(safe-area-inset-bottom, 0px));
    background-color: var(--vivienergia-page-background);
    border-top: 1px solid var(--vivienergia-divider);
    z-index: 1200;
}

.wizard-footer__buttons {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 786px;
    margin: 0 auto;
}

/* Back and Next share the row equally (Figma: both flex 1, 48px tall, 12px radius). The radius is set here
   because the runtime Ranger theme gives buttons its own (pill) default. */
.wizard-footer__button {
    flex: 1 1 0;
    min-width: 88px;
    height: 48px;
    border-radius: 12px;
    font-weight: 600;
}

/* ---------------------------------------------------------------------------
   Form-screen template (Figma node 564:77407 / 564:77411)
   Section card: white, 12px radius, flat; 20px card head with the H3 title.
   Field group: 1px light-grey border, 12px radius, 20px padding, bold 16px title.
   --------------------------------------------------------------------------- */
.vivienergia-section-card {
    border-radius: 12px !important;
    overflow: hidden;
}

.vivienergia-section-card__head {
    padding: 20px;
}

.vivienergia-section-card__title.mud-typography {
    font-size: 20px;
    font-weight: 600;
    line-height: 32px;
}

.vivienergia-section-card__content {
    padding: 0 20px 20px;
}

/* A card without a title starts its content at the top padding. */
.vivienergia-section-card > .vivienergia-section-card__content:first-child {
    padding-top: 20px;
}

.vivienergia-field-group {
    border: 1px solid var(--vivienergia-divider);
    border-radius: 12px;
    padding: 20px;
}

.vivienergia-field-group__title.mud-typography {
    font-size: 16px;
    font-weight: 700;
    line-height: 24px;
}

/* Figma inputs (MudTextField / MudSelectField / MudDatePicker): outlined, 12px radius, 40% black border. */
.wizard-shell .mud-input-outlined-border {
    border-radius: 12px;
}

/* All other buttons in the form (upload, „Crea link“, add supply point …) share the 12px Figma radius instead of the
   runtime Ranger theme's pill shape; icon buttons stay round. */
.wizard-shell .mud-button-root.mud-button {
    border-radius: 12px;
}

/* Action panel (Figma „Signature“ / „Contract finished“): centred illustration in a tinted circle, text and button. */
.vivienergia-action-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    padding: 32px 0;
}

.vivienergia-action-panel__illustration {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 112px;
    height: 112px;
    border-radius: 50%;
    background-color: var(--vivienergia-choice-tint);
    color: var(--vivienergia-primary);
}

.vivienergia-action-panel__illustration .mud-icon-root {
    font-size: 56px;
    width: 56px;
    height: 56px;
}

.vivienergia-action-panel__title.mud-typography {
    font-weight: 700;
}

.wizard-shell .vivienergia-action-panel__button {
    min-width: 200px;
    height: 48px;
    font-weight: 600;
}

/* Upload slot (Figma „File upload“): label above an outlined „choose file“ button with a file icon. */
.vivienergia-upload-slot {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wizard-shell .vivienergia-upload-button {
    min-width: 200px;
    border-color: var(--vivienergia-divider);
    font-weight: 600;
}

/* Info / warning boxes inside the form (Figma "Offer description" box): 12px radius like the cards. */
.wizard-shell .mud-alert {
    border-radius: 12px;
}

/* ---------------------------------------------------------------------------
   Reusable selectable option card (Figma): white surface, 12px radius, 1px
   solid #00000066 border, 20px padding, flat. Centred icon (accent blue) over a
   Button-typo (14px/600) black label. Selected = accent-blue 2px border + tint.
   Used by Customer-check (Privat/Company), Type-of-energy, House-type, ...
   --------------------------------------------------------------------------- */
.vivienergia-option-card {
    box-sizing: border-box;
    font: inherit;
    color: inherit;
    width: 231px;
    max-width: 100%;
    background-color: #ffffff;
    border: 1px solid #00000066;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    box-shadow: none;
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.vivienergia-option-card:hover:not(:disabled) {
    border-color: var(--vivienergia-primary);
}

.vivienergia-option-card:focus-visible {
    outline: 2px solid var(--vivienergia-primary);
    outline-offset: 2px;
}

/* Locked category or read-only commodity: visibly inactive, no pointer. */
.vivienergia-option-card:disabled {
    cursor: not-allowed;
    opacity: .5;
}

/* The Figma tiles carry a filled illustration (house, office, flame, bulb …) above the label. */
.vivienergia-option-card .option-illustration {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 0;
}

.vivienergia-option-card .option-icon {
    color: var(--vivienergia-primary);
    font-size: 44px;
    width: 44px;
    height: 44px;
}

/* Second illustration of a pair (Figma „All“ = flame + bulb): lighter brand blue, overlapping like the Figma image. */
.vivienergia-option-card .option-icon--accent {
    color: var(--mud-palette-primary-lighten, #2587e2);
    margin-left: -10px;
}

/* Start-screen tiles (Figma customer type): 231px wide, 126px+ high, label 16px. */
.vivienergia-option-card--large {
    min-height: 140px;
    justify-content: center;
}

.vivienergia-option-card--large .option-icon {
    font-size: 56px;
    width: 56px;
    height: 56px;
}

.vivienergia-option-card--large .option-label {
    font-size: 16px;
}

/* FontAwesome glyph (Pro kit) variant of the option-card icon — accent-blue, sized to match the
   MudBlazor Size.Large icon; duotone secondary uses a lighter accent. */
.vivienergia-option-card .option-icon-fa {
    font-size: 2rem;
    line-height: 1;
    color: var(--vivienergia-primary);
    --fa-primary-color: var(--vivienergia-primary);
    --fa-secondary-color: var(--vivienergia-primary);
    --fa-secondary-opacity: 0.4;
}

.vivienergia-option-card .option-label {
    font-family: 'Open Sans', sans-serif;
    font-size: 14px;       /* Button typo */
    font-weight: 600;
    line-height: 24px;
    color: #000000;
    text-align: center;
}

.vivienergia-option-card--selected {
    border-color: var(--vivienergia-primary);
    border-width: 2px;
    /* keep the box the same size despite the thicker border */
    padding: 19px;
    background-color: var(--vivienergia-selected-tint);
}

/* Row variant: the option tiles sit SIDE BY SIDE and share the row equally (Figma: the Type-of-energy
   tiles are ~165×126 px, three across, filling the card width — not full-width stacked). They wrap on
   very narrow screens via the min-width basis. */
.vivienergia-option-card--fluid {
    flex: 1 1 0;
    min-width: 88px;
}

/* Phones: three tiles get ~95px each inside the card, so tighten the side padding and the label size until the
   longest label („Condominio“) fits on one line without breaking inside the word. */
@media (max-width: 480px) {
    .vivienergia-option-card--fluid {
        padding: 16px 4px;
    }

    .vivienergia-option-card--fluid.vivienergia-option-card--selected {
        padding: 15px 3px;
    }

    .vivienergia-option-card .option-label {
        font-size: 13px;
    }
}

/* Yes/no question box (Figma "Resident Owner"): primary-tinted surface, 12px radius, bold question. */
.vivienergia-choice-box {
    background-color: var(--vivienergia-choice-tint);
    border-radius: 12px;
    padding: 16px 20px;
}

.vivienergia-choice-box__title.mud-typography {
    font-weight: 700;
}

/* Centred content column for option screens (gap 40px below the title block). */
.vivienergia-option-screen {
    flex: 1 1 auto;
    min-height: calc(100vh - 56px);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 40px;
    padding: 20px;
    text-align: center;
}

/* Start screen: the customer-type tiles stack in the middle of the page (Figma „Start contract“). */
.vivienergia-option-card-list--stacked {
    flex-direction: column;
    align-items: center;
}

.vivienergia-option-screen__head {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.vivienergia-option-screen__title.mud-typography {
    font-size: 20px;
    font-weight: 600;
    line-height: 32px;
}

.vivienergia-option-card-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch;
    /* Centre the tiles in the row. No effect on the Type-of-energy tiles (they use --fluid / flex:1 1 0
       and grow to fill the row, leaving nothing to distribute); it centres the non-fluid Type-of-business
       cards, which otherwise sit left-aligned — especially the single card in the B2C-only launch. */
    justify-content: center;
    gap: 12px;
    width: 100%;
}

.gap-4 {
    gap: 16px;
}

/* --- Signature step (Figma node 564:78307) ---------------------------------------------------------
   A read-only checklist of what each signature covers, then the signature pad inside a bordered box
   with a small caption above and a right-aligned "Delete signature" action below. */
.vivienergia-signature-checklist {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.vivienergia-signature-checklist__item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6b7280;
    font-size: 0.9rem;
}

.vivienergia-signature-box {
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    padding: 12px 14px;
}

.vivienergia-signature-box__label {
    font-size: 0.85rem;
    color: #475467;
    margin-bottom: 8px;
}

.vivienergia-signature-box__actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}
