html {
    scroll-behavior: smooth;
}

.input {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    background: #fff;
    padding: 0.65rem 0.8rem;
    font-size: 0.925rem;
    font-weight: 600;
    color: #0f172a;
    outline: none;
}

.input:focus {
    border-color: #059669;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.16);
}

.btn-primary,
.btn-secondary,
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 800;
    transition: 150ms ease;
}

.btn-primary {
    background: #059669;
    color: #fff;
    padding: 0.7rem 1rem;
}

.btn-primary:hover {
    background: #047857;
}

.btn-secondary {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    padding: 0.65rem 0.9rem;
}

.btn-secondary:hover,
.icon-btn:hover {
    background: #f1f5f9;
}

.icon-btn {
    height: 2.25rem;
    width: 2.25rem;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #475569;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.25rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 800;
}

.badge-green {
    background: #dcfce7;
    color: #166534;
}

.badge-red {
    background: #ffe4e6;
    color: #be123c;
}

/* ── AI Scan floating button ─────────────────────────────── */
#ai-scan-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 900;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    color: #fff;
    background: linear-gradient(135deg, #059669, #2563eb);
    box-shadow: 0 4px 20px rgba(5, 150, 105, 0.45);
    transition: transform 200ms ease, box-shadow 200ms ease;
}

#ai-scan-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(5, 150, 105, 0.6);
}

/* Pulsing ring around the button */
.ai-btn-ring {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(5, 150, 105, 0.55);
    animation: ai-ring-pulse 2s ease-out infinite;
    pointer-events: none;
}

@keyframes ai-ring-pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    70% {
        transform: scale(1.45);
        opacity: 0;
    }

    100% {
        transform: scale(1.45);
        opacity: 0;
    }
}

/* ── AI Modal backdrop ───────────────────────────────────── */
.ai-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
}

.ai-modal-backdrop.active {
    opacity: 1;
    pointer-events: all;
}

/* ── AI Modal card ───────────────────────────────────────── */
.ai-modal {
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
    width: 100%;
    max-width: 500px;
    padding: 1.75rem;
    display: grid;
    gap: 1.1rem;
    transform: translateY(18px) scale(0.97);
    transition: transform 240ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai-modal-backdrop.active .ai-modal {
    transform: translateY(0) scale(1);
}

.ai-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.ai-modal-title-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.ai-modal-icon {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 0.55rem;
    background: linear-gradient(135deg, #059669, #2563eb);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.ai-modal h2 {
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0;
}

.ai-modal-close {
    width: 2rem;
    height: 2rem;
    border-radius: 0.4rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 150ms;
}

.ai-modal-close:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.ai-modal-subtitle {
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.55;
    margin: 0;
}

/* ── Drop zone ───────────────────────────────────────────── */
.ai-dropzone {
    position: relative;
    border: 2px dashed #cbd5e1;
    border-radius: 0.75rem;
    background: #f8fafc;
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 160ms, background 160ms;
    cursor: pointer;
}

.ai-dropzone.dragover {
    border-color: #059669;
    background: #f0fdf4;
}

.ai-file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#ai-dropzone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 1.5rem;
    pointer-events: none;
    z-index: 2;
}

.ai-dropzone-icon {
    font-size: 2rem;
    color: #94a3b8;
}

.ai-dropzone-text {
    font-size: 0.9rem;
    font-weight: 700;
    color: #334155;
    margin: 0;
}

.ai-dropzone-hint {
    font-size: 0.8rem;
    color: #94a3b8;
    margin: 0;
}

.ai-browse-btn {
    display: inline-block;
    background: #059669;
    color: #fff;
    padding: 0.45rem 1.1rem;
    border-radius: 0.45rem;
    font-size: 0.8rem;
    font-weight: 800;
    cursor: pointer;
    pointer-events: all;
    z-index: 3;
    position: relative;
    transition: background 150ms;
}

.ai-browse-btn:hover {
    background: #047857;
}

.ai-dropzone-formats {
    font-size: 0.75rem;
    color: #94a3b8;
    margin: 0;
}

/* Image preview */
.ai-preview-wrap {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
}

.ai-preview-img {
    max-height: 180px;
    max-width: 100%;
    border-radius: 0.5rem;
    object-fit: contain;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.ai-remove-img {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    background: none;
    border: none;
    color: #ef4444;
    font-size: 1.3rem;
    cursor: pointer;
    z-index: 5;
    line-height: 1;
    transition: color 150ms;
}

.ai-remove-img:hover {
    color: #b91c1c;
}

/* ── Banners ─────────────────────────────────────────────── */
.ai-banner {
    border-radius: 0.5rem;
    padding: 0.65rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.4;
}

.ai-banner-error {
    background: #fff1f2;
    color: #be123c;
    border: 1px solid #fecdd3;
}

.ai-banner-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* ── Modal footer ────────────────────────────────────────── */
.ai-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 0.25rem;
}

.ai-analyze-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    border: none;
    border-radius: 0.5rem;
    padding: 0.7rem 1.2rem;
    font-size: 0.875rem;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #059669, #2563eb);
    cursor: pointer;
    transition: opacity 200ms, transform 150ms;
    min-width: 130px;
}

.ai-analyze-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.ai-analyze-btn:not(:disabled):hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* ── Highlight AI-filled inputs ──────────────────────────── */
@keyframes ai-fill-flash {
    0% {
        box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.5);
    }

    100% {
        box-shadow: 0 0 0 3px rgba(5, 150, 105, 0);
    }
}

.ai-filled {
    animation: ai-fill-flash 2.5s ease-out forwards;
    border-color: #059669 !important;
}

.hidden {
    display: none !important;
}

/* ── Description autocomplete (ghost text / Copilot style) ── */
.desc-ac-wrap {
    position: relative;
}

/* Mirror sits behind the textarea, inherits same visual box */
.desc-mirror {
    position: absolute;
    inset: 0;
    pointer-events: none;
    user-select: none;
    z-index: 1;
    background: #fff;
    border: 1px solid transparent;
    /* same box-model as .input, border transparent so it's invisible */
    border-radius: 0.5rem;
    padding: 0.65rem 0.8rem;
    font-size: 0.925rem;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    overflow: hidden;
}

/* Typed text rendered in the mirror — transparent (user sees textarea's own text) */
.ghost-typed {
    color: transparent;
}

/* Ghost suggestion rendered in soft slate */
.ghost-suggestion {
    color: #94a3b8;
}

/* Actual textarea floats above the mirror */
.desc-textarea {
    position: relative;
    z-index: 2;
    background: transparent !important;
    resize: vertical;
}

/* Small hint row above the textarea */
.desc-ac-hint {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 0.1rem;
}

.desc-ac-hint kbd {
    display: inline-block;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 0.25rem;
    padding: 0 0.35rem;
    font-size: 0.7rem;
    font-family: inherit;
    color: #475569;
    line-height: 1.5;
}