/* Walter Web Flasher, shared by flash.html and es/flasher.html */

.flasher-page {
    min-height: 100vh;
    padding: 4.75rem 1.5rem 1.5rem 1.5rem;
    background-color: #f1f9fc;
}

/* Let the footer gradient start from the page background instead of white. */
.flasher-page ~ .footer {
    padding-top: 2rem;
    background: linear-gradient(#f1f9fc, rgba(0, 135, 134, 1));
}

.flasher-layout {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: minmax(0, 1fr);
    max-width: 120rem;
    margin: 0 auto;
}

.flasher-layout > .flasher-notice {
    grid-column: 1 / -1;
    margin: 0;
}

.flasher-column {
    min-width: 0;
}

.flasher-terminal-column {
    scroll-margin-top: 4.5rem;
}

@media only screen and (min-width: 1024px) {
    .flasher-layout {
        grid-template-columns: minmax(24rem, 32rem) minmax(0, 1fr);
    }

    /* Both panes fill the screen height; only the firmware list and terminal scroll. */
    .flasher-flash-card,
    .terminal-card {
        display: flex;
        flex-direction: column;
        /* navbar offset + credits line below the panes */
        height: calc(100vh - 8rem);
        min-height: 34rem;
    }

    .flasher-flash-card .fw-list {
        flex: 1 1 auto;
        min-height: 8rem;
        overflow-y: auto;
        align-content: start;
        margin: -4px;
        padding: 4px;
        scrollbar-width: thin;
        scrollbar-color: #9fd3d2 transparent;
    }

    .terminal-output {
        flex: 1 1 auto;
        height: auto;
        min-height: 0;
    }
}

.flasher-card {
    background-color: #ffffff;
    border: 1px solid #e3eef2;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 6px 24px rgba(37, 44, 56, 0.05);
}

.flasher-step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.flasher-step-number {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background-color: #005E5D;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.9375rem;
}

.flasher-step h3 {
    margin: 0;
    font-size: 1.375rem;
    line-height: 1.75rem;
}

.flasher-notice {
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    background-color: #fff4e5;
    border: 1px solid #ffd8a8;
    color: #7a4b00;
}

.flasher-notice a {
    color: #005E5D;
    font-weight: 600;
}

/* Firmware options */

.fw-list {
    display: grid;
    gap: 0.875rem;
    grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
    align-items: start;
}

.fw-option {
    position: relative;
    display: flex;
    gap: 0.875rem;
    padding: 1.125rem 1.25rem;
    border: 2px solid #e3eef2;
    border-radius: 14px;
    background-color: #f8fcfd;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.fw-option:hover,
.fw-option.dragging {
    border-color: #9fd3d2;
}

.fw-option.selected {
    border-color: #008786;
    background-color: #ffffff;
    box-shadow: 0 4px 16px rgba(0, 135, 134, 0.12);
}

.fw-option input[type=radio] {
    flex: 0 0 auto;
    margin-top: 0.3rem;
    width: 1.05rem;
    height: 1.05rem;
    accent-color: #005E5D;
}

.fw-body {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    flex: 1 1 auto;
}

.fw-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.fw-name {
    color: #252c38;
    font-weight: 700;
    font-size: 1.0625rem;
}

.fw-version {
    padding: 0 0.5rem;
    border-radius: 32px;
    background-color: #e0f3f2;
    color: #005E5D;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.375rem;
}

.fw-desc {
    font-size: 0.9375rem;
    line-height: 1.375rem;
}

.fw-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    color: #8a949b;
}

.fw-meta a {
    color: #008786;
    font-weight: 600;
    text-decoration: none;
}

.fw-meta a .fas {
    margin-right: 0.25rem;
    font-size: 0.75rem;
}

.fw-meta a:hover {
    text-decoration: underline;
}

.fw-error {
    color: #b42318;
}

.fw-custom-fields {
    margin-top: 0.75rem;
    display: grid;
    gap: 0.75rem;
}

.fw-drop {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border: 2px dashed #9fd3d2;
    border-radius: 12px;
    background-color: #ffffff;
    color: #252c38;
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.fw-drop:hover,
.fw-option.dragging .fw-drop {
    border-color: #008786;
    background-color: #f1f9fc;
}

.fw-drop .fas {
    color: #008786;
    font-size: 1.25rem;
}

.fw-drop input[type=file] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.fw-drop-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #6b747b;
}

.fw-field label {
    display: block;
    margin-bottom: 0.25rem;
    color: #252c38;
    font-size: 0.8125rem;
    font-weight: 600;
}

.flasher-input,
.flasher-select {
    height: 2.5rem;
    padding: 0 0.875rem;
    border: 1px solid #cfdde2;
    border-radius: 10px;
    background-color: #ffffff;
    color: #252c38;
    font-size: 0.875rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.flasher-select {
    padding-right: 2.25rem;
}

.flasher-input:focus,
.flasher-select:focus {
    outline: none;
    border-color: #008786;
    box-shadow: 0 0 0 3px rgba(0, 135, 134, 0.15);
}

.flasher-input.invalid {
    border-color: #b42318;
}

.flasher-input.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.fw-hint {
    font-size: 0.8125rem;
    line-height: 1.25rem;
}

.fw-hint.error {
    color: #b42318;
}

.fw-warning {
    padding: 0.625rem 0.875rem;
    border-radius: 10px;
    background-color: #fff4e5;
    color: #7a4b00;
    font-size: 0.8125rem;
    line-height: 1.25rem;
}

/* Flash options and action */

.flasher-options {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid #e3eef2;
}

.flasher-check {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #252c38;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
}

.flasher-check input {
    width: 1rem;
    height: 1rem;
    accent-color: #005E5D;
}

.flasher-action {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 1.5rem;
    margin-top: 1.5rem;
}

.flasher-status-wrap {
    flex: 1 1 16rem;
    min-width: 0;
}

.flasher-status {
    margin: 0;
    color: #252c38;
    font-size: 0.9375rem;
    font-weight: 600;
}

.flasher-status[data-kind=success] {
    color: #008786;
}

.flasher-status[data-kind=error] {
    color: #b42318;
}

.flasher-progress {
    margin-top: 0.5rem;
    height: 0.5rem;
    border-radius: 32px;
    background-color: #e3eef2;
    overflow: hidden;
}

.flasher-progress-bar {
    width: 0;
    height: 100%;
    border-radius: 32px;
    background: linear-gradient(90deg, #005E5D, #00b2ad);
    transition: width 0.2s ease;
}

/* Terminal */

.terminal-card {
    padding: 0;
    overflow: hidden;
}

.terminal-head {
    padding: 1.5rem 1.5rem 1rem 1.5rem;
}

.terminal-head .flasher-step {
    margin-bottom: 0;
    flex-wrap: wrap;
}

.term-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: auto;
    padding: 0.125rem 0.75rem;
    border-radius: 32px;
    background-color: #eef2f4;
    color: #6b747b;
    font-size: 0.75rem;
    font-weight: 600;
}

.term-pill::before {
    content: "";
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background-color: #9aa5ab;
}

.term-pill[data-state=connected] {
    background-color: #e0f3f2;
    color: #005E5D;
}

.term-pill[data-state=connected]::before {
    background-color: #00b2ad;
}

.term-pill[data-state=waiting] {
    background-color: #fff4e5;
    color: #7a4b00;
}

.term-pill[data-state=waiting]::before {
    background-color: #f59f00;
    animation: term-blink 1s ease-in-out infinite;
}

.term-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.625rem 0.75rem;
    padding: 0 1.5rem 1rem 1.5rem;
}

.term-toolbar .spacer {
    flex: 1 1 auto;
}

.btn-term {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    height: 2.5rem;
    padding: 0 1rem;
    border: 1px solid #cfdde2;
    border-radius: 32px;
    background-color: #ffffff;
    color: #252c38;
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-term:hover:not(:disabled) {
    border-color: #005E5D;
    color: #005E5D;
}

.btn-term:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-term.primary {
    border-color: #005E5D;
    background-color: #005E5D;
    color: #ffffff;
}

.btn-term.primary:hover:not(:disabled) {
    background-color: transparent;
    color: #005E5D;
}

.terminal-output {
    height: 28rem;
    margin: 0;
    padding: 1rem 1.5rem;
    overflow: auto;
    background-color: #1b2129;
    color: #d7e3e8;
    font: 0.8125rem/1.25rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    white-space: pre-wrap;
    word-break: break-all;
}

.terminal-output::selection,
.terminal-output *::selection {
    background-color: #00b2ad;
    color: #ffffff;
}

.term-input-row {
    display: flex;
    gap: 0.625rem;
    padding: 1rem 1.5rem 1.25rem 1.5rem;
    background-color: #f8fcfd;
    border-top: 1px solid #e3eef2;
}

.term-input-row .flasher-input {
    flex: 1 1 auto;
    min-width: 0;
}

.term-input-row .flasher-input:disabled {
    background-color: #f4f7f8;
}

.flasher-credits {
    max-width: 120rem;
    margin: 0 auto;
    padding: 0.75rem 0.5rem 0 0.5rem;
    text-align: center;
    font-size: 0.8125rem;
    line-height: 1.375rem;
    color: #8a949b;
}

.flasher-credits a {
    color: #008786;
    font-weight: 600;
    text-decoration: none;
}

.flasher-credits a:hover {
    text-decoration: underline;
}

/* Confirmation dialog */

.flasher-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background-color: rgba(27, 33, 41, 0.55);
}

.flasher-modal[hidden] {
    display: none;
}

.flasher-modal-box {
    width: 100%;
    max-width: 30rem;
    padding: 1.75rem;
    border-radius: 16px;
    background-color: #ffffff;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.flasher-modal-box h4 {
    margin-bottom: 0.75rem;
}

.flasher-modal-box p {
    margin-bottom: 0.75rem;
    font-size: 0.9375rem;
    line-height: 1.5rem;
}

.flasher-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.625rem;
    margin-top: 1.25rem;
}

[hidden] {
    display: none !important;
}

@keyframes term-blink {
    50% { opacity: 0.35; }
}

@media only screen and (max-width: 640px) {
    .flasher-card {
        padding: 1.25rem;
    }

    .terminal-card {
        padding: 0;
    }

    .terminal-head,
    .term-toolbar,
    .term-input-row {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .flasher-page {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .terminal-output {
        height: 65vh;
        padding: 0.75rem 1rem;
    }

    .term-input-row {
        flex-wrap: wrap;
    }

    .term-pill {
        margin-left: 0;
    }
}
