/* Invisible Unicode Threat Scanner — Styles */
.utd-scanner-wrap {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    max-width: 860px;
    margin: 0 auto;
    padding: 24px 28px 28px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 2px 16px rgba(0,0,0,.08);
    color: #111;
}

/* ── Top bar: tabs + lang toggle ─────────────────────────────────────────── */
.utd-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.utd-tab-bar { display: flex; align-items: center; gap: 4px; }

.utd-tab {
    padding: 7px 16px;
    border-radius: 8px;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.utd-tab.active      { background: #111; color: #fff; }
.utd-tab:not(.active):hover { background: #f3f4f6; color: #374151; }

.utd-tab-divider { border: none; border-top: 1px solid #e5e7eb; margin: 16px 0 20px; }

/* Language toggle */
.utd-lang-toggle { display: flex; gap: 4px; flex-shrink: 0; }
.utd-lang-btn {
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid #e5e7eb;
    background: transparent;
    color: #6b7280;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s;
    letter-spacing: .5px;
}
.utd-lang-btn:hover  { background: #f3f4f6; color: #374151; }
.utd-lang-btn.active { background: #6366f1; color: #fff; border-color: #6366f1; }

/* ── Field groups (Encode tab) ───────────────────────────────────────────── */
.utd-field-group { margin-bottom: 20px; }

.utd-field-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.utd-field-group textarea,
.utd-field-group input[type="text"] {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    font-family: "Cascadia Code", "Fira Mono", monospace;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color .2s;
    line-height: 1.6;
    background: #fff;
    color: #374151;
}
.utd-field-group input[type="text"] { resize: none; padding: 10px 14px; }
.utd-field-group textarea:focus,
.utd-field-group input[type="text"]:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}

/* ── Live Preview box ────────────────────────────────────────────────────── */
.utd-live-preview-box {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 20px;
}

.utd-live-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 10px;
}
.utd-live-preview-title { font-size: 14px; font-weight: 700; color: #111; }

/* Result box inside Live Preview */
.utd-live-result-box {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}
.utd-live-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px;
    background: #fafafa;
    border-bottom: 1px solid #f3f4f6;
}
.utd-live-result-label { font-size: 13px; font-weight: 700; color: #374151; }

.utd-inline-copy-btn {
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    background: #fff;
    font-size: 12px;
    color: #374151;
    cursor: pointer;
    transition: background .15s;
    white-space: nowrap;
}
.utd-inline-copy-btn:hover { background: #f3f4f6; }

.utd-enc-result {
    padding: 14px;
    font-family: "Cascadia Code", "Fira Mono", monospace;
    font-size: 13px;
    line-height: 1.8;
    min-height: 60px;
    color: #374151;
    white-space: pre-wrap;
    word-break: break-all;
}
.utd-enc-result.utd-annotated { line-height: 2; }
.utd-enc-result:empty::before {
    content: attr(data-placeholder);
    color: #9ca3af;
    font-style: italic;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ── Consent notice ──────────────────────────────────────────────────────── */
.utd-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 10px 16px;
    margin-bottom: 18px;
    font-size: 13px;
    color: #1e40af;
}
.utd-dismiss {
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    font-size: 16px;
    padding: 0 2px;
    line-height: 1;
    flex-shrink: 0;
}
.utd-dismiss:hover { color: #374151; }

/* ── Detect tab — input area ─────────────────────────────────────────────── */
.utd-input-area { position: relative; }
#utd-input {
    width: 100%;
    padding: 14px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    font-family: "Cascadia Code", "Fira Mono", monospace;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color .2s;
    line-height: 1.6;
    min-height: 160px;
}
#utd-input:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.12); }

.utd-live-badge {
    position: absolute;
    bottom: 10px;
    right: 12px;
    font-size: 12px;
    color: #9ca3af;
    pointer-events: none;
    background: rgba(255,255,255,.85);
    padding: 2px 6px;
    border-radius: 4px;
}
.utd-live-badge.has-threats { color: #dc2626; font-weight: 600; }

/* ── Action buttons ──────────────────────────────────────────────────────── */
.utd-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.utd-btn {
    padding: 10px 22px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background .15s, opacity .15s;
    white-space: nowrap;
}
.utd-btn-primary   { background: #6366f1; color: #fff; }
.utd-btn-primary:hover { background: #4f46e5; }
.utd-btn-secondary { background: #f3f4f6; color: #374151; border: 1px solid #e5e7eb; }
.utd-btn-secondary:hover { background: #e9eaeb; }
.utd-btn-ghost { background: transparent; color: #6b7280; border: 1px solid #e5e7eb; }
.utd-btn-ghost:hover:not(:disabled) { background: #f9fafb; }
.utd-btn:disabled { opacity: .4; cursor: default; }

/* ── Results section ─────────────────────────────────────────────────────── */
.utd-results { margin-top: 30px; border-top: 2px solid #f3f4f6; padding-top: 26px; }

.utd-risk-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    border-radius: 10px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    margin-bottom: 26px;
    flex-wrap: wrap;
}
.utd-risk-label { font-weight: 600; color: #374151; font-size: 14px; }
.utd-risk-badge {
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
}
.utd-risk-none   { background: #d1fae5; color: #065f46; }
.utd-risk-low    { background: #fef9c3; color: #713f12; }
.utd-risk-medium { background: #ffedd5; color: #9a3412; }
.utd-risk-high   { background: #fee2e2; color: #991b1b; }

.utd-stats-inline { display: flex; gap: 18px; font-size: 13px; color: #6b7280; margin-left: auto; }
.utd-stats-inline strong { color: #111; }

.utd-section { margin-bottom: 28px; }
.utd-section h3, .utd-edu-section h3 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }

.utd-section-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.utd-section-header h3 { margin: 0; }
.utd-collapse-btn {
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid #e5e7eb;
    background: transparent;
    font-size: 12px;
    color: #6b7280;
    cursor: pointer;
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.utd-collapse-btn:hover { background: #f3f4f6; color: #374151; }

/* Annotated preview */
.utd-annotated {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    font-family: "Cascadia Code", "Fira Mono", monospace;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-all;
    min-height: 60px;
    line-height: 2;
}

/* Invisible char markers */
mark.utd-char {
    background: transparent;
    border-bottom: 2px solid;
    cursor: help;
    font-size: 10px;
    vertical-align: middle;
    border-radius: 2px;
    padding: 0 1px;
}
.utd-zws  { border-color: #6366f1; color: #6366f1; }
.utd-zwnj { border-color: #10b981; color: #10b981; }
.utd-is   { border-color: #f59e0b; color: #f59e0b; }
.utd-zwj  { border-color: #ef4444; color: #ef4444; }
.utd-bom  { border-color: #8b5cf6; color: #8b5cf6; }
.utd-wj   { border-color: #ec4899; color: #ec4899; }
.utd-lrm  { border-color: #0ea5e9; color: #0ea5e9; }
.utd-rlm  { border-color: #f97316; color: #f97316; }

.utd-legend { font-size: 12px; color: #9ca3af; margin-top: 8px; }

/* Character table */
.utd-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.utd-table th {
    background: #f3f4f6;
    text-align: left;
    padding: 10px 14px;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
}
.utd-table td { padding: 9px 14px; border-bottom: 1px solid #f3f4f6; }
.utd-table tr:last-child td { border-bottom: none; }
.utd-table tr:hover td { background: #f9fafb; }

.utd-cp {
    font-family: monospace;
    background: #ede9fe;
    color: #5b21b6;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 12px;
}

/* Hidden messages */
.utd-messages-section .utd-message {
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
    padding: 14px 18px;
    font-family: monospace;
    font-size: 13px;
    margin-bottom: 10px;
    color: #78350f;
    word-break: break-word;
}

/* Educational panel */
.utd-edu-section { margin-top: 28px; border-top: 1px solid #f3f4f6; padding-top: 22px; }
.utd-edu-section details {
    margin-bottom: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}
.utd-edu-section summary {
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    color: #374151;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.utd-edu-section summary::before { content: '▶'; font-size: 10px; color: #9ca3af; transition: transform .2s; }
.utd-edu-section details[open] summary::before { transform: rotate(90deg); }
.utd-edu-section details[open] summary { border-bottom: 1px solid #e5e7eb; }
.utd-edu-section details p { padding: 14px 16px; margin: 0; font-size: 13px; color: #6b7280; line-height: 1.75; }

/* Print footer — always visible below Learn More (inside #utd-results) */
.utd-print-footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #f3f4f6;
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
}
.utd-print-footer a { color: #6366f1; text-decoration: underline; }

/* ── Print / PDF styles ──────────────────────────────────────────────────── */
@media print {
    .utd-top-bar, .utd-tab-bar, .utd-tab-divider, .utd-lang-toggle,
    #utd-panel-encode, .utd-notice, .utd-input-area, .utd-actions,
    .utd-edu-section, .utd-live-badge, #utd-btn-print { display: none !important; }

    .utd-scanner-wrap { box-shadow: none; padding: 0; max-width: 100%; }
    #utd-panel-detect { display: block !important; }
    #utd-results { display: block !important; }

    .utd-print-footer a { color: #1d4ed8; }
}

@media (max-width: 600px) {
    .utd-scanner-wrap { padding: 16px; }
    .utd-stats-inline { display: none; }
    .utd-actions { flex-direction: column; }
    .utd-btn { width: 100%; text-align: center; }
    .utd-tab { padding: 6px 12px; font-size: 13px; }
}
