/*
 * ai-tools.css - AI tools
 * Layout for the AI image matting tool: the drop zone, the before and after
 * panes, the checkerboard that shows transparency, the model picker with its
 * edge fine-tuning panel and the progress readout.
 */

/* ========== drop zone ========== */

.matte-dropzone {
    border: 2px dashed var(--border-color, #d7d7de);
    border-radius: 14px;
    background: #fbfbfd;
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease;
}

.matte-dropzone:hover,
.matte-dropzone:focus-visible {
    border-color: var(--accent-color, #ff4d4d);
    background: #fff7f7;
    outline: none;
}

.matte-dropzone.is-dragging {
    border-color: var(--accent-color, #ff4d4d);
    background: #fff2f2;
}

.matte-dropzone h3 {
    margin: 0.75rem 0 0.35rem;
    font-size: 1.05rem;
}

.matte-dropzone p {
    margin: 0;
    color: var(--muted-color, #6b6b76);
    font-size: 0.92rem;
}

.matte-dropzone .upload-icon {
    font-size: 2rem;
    color: var(--accent-color, #ff4d4d);
}

.matte-note {
    display: block;
    margin-top: 0.85rem;
    font-size: 0.85rem;
    color: var(--muted-color, #6b6b76);
}

/* ========== before and after ========== */

.matte-stage {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
    margin-top: 1.5rem;
}

.matte-pane {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.matte-pane > span {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted-color, #6b6b76);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.matte-frame {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    padding: 0.75rem;
    border: 1px solid var(--border-color, #e3e3ea);
    border-radius: 12px;
    overflow: hidden;
    /* Checkerboard, so removed areas read as transparency. */
    background-color: #ffffff;
    background-image:
        linear-gradient(45deg, #dcdce4 25%, transparent 25%),
        linear-gradient(-45deg, #dcdce4 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #dcdce4 75%),
        linear-gradient(-45deg, transparent 75%, #dcdce4 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.matte-frame.is-solid {
    background-image: none;
}

.matte-frame img,
.matte-canvas {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

.matte-meta {
    font-size: 0.88rem;
    color: var(--muted-color, #6b6b76);
    min-height: 1.2em;
}

/* ========== controls ========== */

.matte-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
    margin-top: 1.25rem;
}

.matte-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.88rem;
    font-weight: 600;
}

.matte-field select,
.matte-field input[type="color"] {
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border-color, #d7d7de);
    border-radius: 8px;
    background: #fff;
    font: inherit;
}

.matte-field input[type="color"] {
    width: 64px;
    height: 38px;
    padding: 2px;
}

.matte-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-left: auto;
}

.matte-model-hint {
    margin-top: 0.75rem;
    font-size: 0.85rem;
}

/* ========== edge fine tuning ========== */

.matte-refine {
    margin-top: 1.25rem;
    padding: 1.1rem 1.25rem 1.3rem;
    border: 1px solid var(--border-color, #e3e3ea);
    border-radius: 12px;
    background: #fbfbfd;
}

.matte-refine-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.matte-refine-head h2 {
    margin: 0;
    font-size: 1rem;
}

.matte-refine-head .btn {
    padding: 0.35rem 0.8rem;
    font-size: 0.82rem;
}

.matte-refine-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem 1.25rem;
    margin-top: 1rem;
}

.matte-field-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}

.matte-refine output {
    color: var(--accent-color, #ff4d4d);
    font-variant-numeric: tabular-nums;
}

.matte-refine input[type="range"] {
    width: 100%;
    accent-color: var(--accent-color, #ff4d4d);
    cursor: pointer;
}

.matte-refine small {
    display: block;
    font-weight: 400;
    font-size: 0.78rem;
    line-height: 1.35;
    color: var(--muted-color, #6b6b76);
}

.matte-check {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
}

.matte-check input[type="checkbox"] {
    margin-top: 0.22rem;
    accent-color: var(--accent-color, #ff4d4d);
    cursor: pointer;
}

.matte-check small {
    display: block;
    font-weight: 400;
    font-size: 0.78rem;
    line-height: 1.35;
    color: var(--muted-color, #6b6b76);
}

body.is-busy .matte-refine {
    pointer-events: none;
    opacity: 0.6;
}

/* ========== status ========== */

.matte-status {
    margin-top: 1rem;
    font-size: 0.92rem;
    min-height: 1.3em;
    color: var(--muted-color, #6b6b76);
}

.matte-status.is-error {
    color: #c62828;
}

.matte-progress {
    height: 6px;
    margin-top: 0.5rem;
    border-radius: 999px;
    background: #ececf2;
    overflow: hidden;
}

.matte-progress-bar {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: var(--accent-color, #ff4d4d);
    transition: width 0.15s linear;
}

body.is-busy .matte-dropzone {
    pointer-events: none;
    opacity: 0.6;
}

/* ========== adults only consent ==========
   Sits in the first screen on purpose: the model runs locally, so the server
   cannot filter output and the warning must be read before anything is made. */

.gen-consent {
    margin: 0 0 1.5rem;
    padding: 1.25rem 1.35rem;
    border: 2px solid var(--accent-color, #ff4d4d);
    border-radius: 12px;
    background: #fff6f6;
}

.gen-consent-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.65rem;
    color: #c62828;
}

.gen-consent-head i {
    font-size: 1.35rem;
}

.gen-consent-head h2 {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.35;
}

.gen-consent-lead {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    line-height: 1.6;
}

.gen-consent-list {
    margin: 0 0 0.9rem;
    padding-left: 1.15rem;
    font-size: 0.92rem;
    line-height: 1.65;
    color: #4a4a52;
}

.gen-consent-check {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    padding: 0.7rem 0.8rem;
    border: 1px solid #f0c9c9;
    border-radius: 8px;
    background: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

.gen-consent-check input {
    width: 1.05rem;
    height: 1.05rem;
    margin: 0.15rem 0 0;
    accent-color: var(--accent-color, #ff4d4d);
    cursor: pointer;
}

.gen-consent-note {
    margin: 0.6rem 0 0;
    font-size: 0.85rem;
    color: #a33;
}

.gen-consent.is-accepted {
    border-color: #2e7d32;
    background: #f4fbf5;
}

.gen-consent.is-accepted .gen-consent-head {
    color: #2e7d32;
}

.gen-consent.is-accepted .gen-consent-note {
    color: #2e7d32;
}

/* ========== image generator ========== */

.gen-grid {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(260px, 1fr);
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 860px) {
    .gen-grid {
        grid-template-columns: 1fr;
    }
}

.gen-controls,
.gen-preview {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.gen-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.88rem;
    font-weight: 600;
}

.gen-field textarea,
.gen-field select,
.gen-field input {
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border-color, #d7d7de);
    border-radius: 8px;
    background: #fff;
    font: inherit;
    font-weight: 400;
}

.gen-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
}

.gen-row .gen-field {
    min-width: 96px;
    flex: 1 1 96px;
}

.gen-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.gen-gpu-panel {
    padding: 0.9rem;
    border: 1px solid var(--border-color, #d7d7de);
    border-radius: 10px;
    background: #fbfbfd;
}

.gen-gpu-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.gen-gpu-help {
    margin-top: 0.65rem;
    font-size: 0.85rem;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.gen-gpu-help summary {
    cursor: pointer;
    font-weight: 600;
}

.gen-gpu-help ol {
    padding-left: 1.3rem;
}

.gen-gpu-help li + li {
    margin-top: 0.5rem;
}

.gen-status {
    margin: 0;
    font-size: 0.9rem;
    color: var(--muted-color, #6b6b76);
    min-height: 1.3em;
}

.gen-status.is-error {
    color: #c62828;
}

.gen-preview {
    align-items: center;
    justify-content: center;
    min-height: 260px;
    padding: 0.75rem;
    border: 1px dashed var(--border-color, #d7d7de);
    border-radius: 12px;
    background: #fbfbfd;
}

.gen-preview canvas {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.gen-placeholder {
    margin: 0;
    color: var(--muted-color, #8a8a95);
    font-size: 0.95rem;
    text-align: center;
}

.gen-model {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color, #e3e3ea);
}

.gen-model h3 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
}

.gen-summary {
    margin: 0 0 0.65rem;
    font-size: 0.9rem;
    color: var(--muted-color, #6b6b76);
}

.gen-file-list {
    list-style: none;
    margin: 0 0 0.9rem;
    padding: 0;
    display: grid;
    gap: 0.35rem;
}

.gen-file {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--muted-color, #6b6b76);
}

.gen-file.is-ready i {
    color: #2e7d32;
}
.gen-file a {
    color: var(--text-color, #333);
    text-decoration: underline;
    word-break: break-all;
}
.gen-file a:hover {
    color: var(--primary-color, #ff4a4a);
}

.gen-note {
    margin: 0.75rem 0 0;
    font-size: 0.85rem;
    color: var(--muted-color, #6b6b76);
}
.gen-note-warn {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-top: 0.9rem;
    padding: 0.6rem 0.75rem;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 8px;
    color: #7a5c00;
}
.gen-note-warn i {
    margin-top: 0.2rem;
}
