/*
 * Tender Miele — public form wizard.
 * @package Raa\TenderMiele
 * @author  Raa Online SRL
 */

.tm-form {
    --tm-accent: #7a1f2b;
    --tm-ink: #1f2328;
    --tm-muted: #6b7280;
    --tm-line: #d8dade;
    --tm-bg-soft: #f7f7f8;
    --tm-error: #b42318;
    --tm-radius: 8px;

    max-width: 860px;
    margin: 0 auto;
    color: var(--tm-ink);
    font-size: 16px;
    line-height: 1.55;
}

/* Progress -------------------------------------------------------------- */

.tm-progress {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0 0 32px;
    padding: 0;
    counter-reset: tm-step;
}

.tm-progress__step {
    flex: 1 1 110px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 8px;
    border-top: 3px solid var(--tm-line);
    color: var(--tm-muted);
    font-size: 13px;
}

.tm-progress__step.is-active {
    border-top-color: var(--tm-accent);
    color: var(--tm-ink);
    font-weight: 600;
}

.tm-progress__step.is-done {
    border-top-color: var(--tm-accent);
    color: var(--tm-ink);
}

.tm-progress__num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--tm-line);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    flex: 0 0 auto;
}

.tm-progress__step.is-active .tm-progress__num,
.tm-progress__step.is-done .tm-progress__num {
    background: var(--tm-accent);
}

/* Steps ----------------------------------------------------------------- */

.tm-step__title {
    margin: 0 0 6px;
    font-size: 22px;
    line-height: 1.3;
}

.tm-step__intro {
    margin: 0 0 24px;
    color: var(--tm-muted);
}

.tm-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 20px;
}

.tm-field {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tm-field--full {
    grid-column: 1 / -1;
}

.tm-form label {
    font-weight: 600;
    font-size: 14px;
}

.tm-req {
    color: var(--tm-accent);
}

/* Optional-field marker: present but visually secondary to the label. */
.tm-opt {
    color: var(--tm-muted);
    font-weight: 400;
    font-size: 0.85em;
    white-space: nowrap;
}

.tm-bid__vat {
    display: block;
    color: var(--tm-muted);
    font-size: 11px;
    line-height: 1.2;
    white-space: nowrap;
}

.tm-form input[type="text"],
.tm-form input[type="email"],
.tm-form input[type="tel"],
.tm-form input[type="url"],
.tm-form input[type="number"],
.tm-form textarea,
.tm-form select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--tm-line);
    border-radius: var(--tm-radius);
    background: #fff;
    color: inherit;
    font: inherit;
    box-sizing: border-box;
}

.tm-form input:focus,
.tm-form textarea:focus,
.tm-form select:focus {
    outline: 2px solid var(--tm-accent);
    outline-offset: 1px;
    border-color: var(--tm-accent);
}

.tm-form .is-invalid {
    border-color: var(--tm-error);
}

.tm-error {
    display: block;
    min-height: 0;
    color: var(--tm-error);
    font-size: 13px;
    font-weight: 500;
}

.tm-error:empty {
    display: none;
}

/* Fieldsets and checkboxes ---------------------------------------------- */

.tm-fieldset {
    margin: 0 0 24px;
    padding: 16px;
    border: 1px solid var(--tm-line);
    border-radius: var(--tm-radius);
}

.tm-fieldset legend {
    padding: 0 6px;
    font-weight: 600;
    font-size: 15px;
}

.tm-checkgrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.tm-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--tm-line);
    border-radius: var(--tm-radius);
    font-weight: 400;
    cursor: pointer;
}

.tm-check:hover {
    border-color: var(--tm-accent);
}

.tm-check input {
    margin-top: 3px;
    flex: 0 0 auto;
}

.tm-check small {
    display: block;
    color: var(--tm-muted);
    font-size: 12px;
}

/* Bids ------------------------------------------------------------------ */

.tm-bid {
    display: grid;
    grid-template-columns: 1fr 200px;
    grid-template-areas:
        "label input"
        "help  input"
        "note  note"
        "error error";
    gap: 6px 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--tm-line);
}

.tm-bid:last-child {
    border-bottom: 0;
}

.tm-bid > label {
    grid-area: label;
    align-self: center;
}

.tm-bid__help {
    grid-area: help;
    color: var(--tm-muted);
    font-size: 13px;
}

.tm-bid__input {
    grid-area: input;
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: center;
}

.tm-bid__unit {
    color: var(--tm-muted);
    font-size: 13px;
    white-space: nowrap;
}

.tm-bid__note {
    grid-area: note;
}

.tm-bid .tm-error {
    grid-area: error;
}

/* Uploads --------------------------------------------------------------- */

.tm-upload {
    margin: 0 0 20px;
    padding: 16px;
    border: 1px dashed var(--tm-line);
    border-radius: var(--tm-radius);
}

.tm-upload label {
    display: block;
    margin-bottom: 8px;
}

.tm-filelist {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
}

.tm-filelist__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: var(--tm-bg-soft);
    border-radius: var(--tm-radius);
    font-size: 14px;
    word-break: break-all;
}

.tm-filelist__remove {
    flex: 0 0 auto;
    border: 0;
    background: none;
    color: var(--tm-error);
    cursor: pointer;
    font-size: 13px;
    text-decoration: underline;
}

/* Summary --------------------------------------------------------------- */

.tm-summary__block {
    margin-bottom: 20px;
    padding: 16px;
    background: var(--tm-bg-soft);
    border-radius: var(--tm-radius);
}

.tm-summary__block h3 {
    margin: 0 0 10px;
    font-size: 16px;
}

.tm-summary dl {
    display: grid;
    grid-template-columns: minmax(140px, 40%) 1fr;
    gap: 4px 16px;
    margin: 0;
    font-size: 14px;
}

.tm-summary dt {
    color: var(--tm-muted);
}

.tm-summary dd {
    margin: 0;
    word-break: break-word;
}

.tm-consent {
    margin: 24px 0;
}

/* Actions --------------------------------------------------------------- */

/*
 * The hidden attribute is only enforced by the UA rule [hidden]{display:none},
 * which ANY class selector outranks. .tm-btn and .tm-progress both set display,
 * so without this guard the wizard cannot hide the "Trimite cererea" / "Înapoi"
 * buttons or the progress bar. Keep this rule above the components that set
 * display, and never drop the !important.
 */
.tm-form [hidden],
.tm-form[hidden] {
    display: none !important;
}

.tm-actions {
    display: flex;
    gap: 12px;
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--tm-line);
}

.tm-btn {
    padding: 12px 24px;
    border: 1px solid transparent;
    border-radius: var(--tm-radius);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.tm-btn--primary {
    background: var(--tm-accent);
    color: #fff;
}

.tm-btn--primary:hover {
    filter: brightness(1.1);
}

.tm-btn--ghost {
    background: transparent;
    border-color: var(--tm-line);
    color: var(--tm-ink);
}

.tm-btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

/* While a request is in flight the label is swapped, so show progress. */
.tm-btn[disabled][data-label] {
    cursor: progress;
}

/* Alerts + honeypot ------------------------------------------------------ */

.tm-alert {
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: var(--tm-radius);
    font-size: 14px;
}

.tm-alert--error {
    background: #fdf1f0;
    border: 1px solid var(--tm-error);
    color: var(--tm-error);
}

.tm-notice {
    padding: 12px 16px;
    background: var(--tm-bg-soft);
    border-radius: var(--tm-radius);
    color: var(--tm-muted);
}

.tm-hp {
    position: absolute !important;
    left: -9999px !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.tm-success {
    padding: 32px;
    background: var(--tm-bg-soft);
    border-radius: var(--tm-radius);
    text-align: center;
}

.tm-success__ref strong {
    font-size: 20px;
    letter-spacing: 0.04em;
}

@media (max-width: 640px) {
    .tm-grid {
        grid-template-columns: 1fr;
    }

    .tm-bid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "label"
            "help"
            "input"
            "note"
            "error";
    }

    .tm-summary dl {
        grid-template-columns: 1fr;
    }

    .tm-progress__label {
        display: none;
    }

    .tm-progress__step {
        flex: 1 1 auto;
        justify-content: center;
    }

    .tm-actions {
        flex-direction: column-reverse;
    }

    .tm-btn {
        width: 100%;
    }
}
