/* ===== UDS-specific Styles ===== */

/* Hero SVG */
.tester-box, .ecu-box { fill: var(--bg-card); stroke: var(--accent); stroke-width: 2; }
.box-label { fill: var(--accent); font-size: 16px; font-weight: 700; text-anchor: middle; dominant-baseline: middle; }
svg .byte-label { fill: var(--yellow); font-family: 'Consolas', monospace; font-size: 13px; text-anchor: middle; opacity: 0; animation: fadeIn 0.5s ease forwards; }
.bl-1 { animation-delay: 0.6s; }
.bl-2 { animation-delay: 1.4s; }
.bl-3 { animation-delay: 1.0s; }
.arrow-head { fill: var(--accent); opacity: 0; animation: fadeIn 0.3s ease forwards; }
.ah-1 { animation-delay: 0.5s; }
.ah-2 { animation-delay: 1.3s; }
.sid-badge { fill: var(--green); opacity: 0.2; stroke: var(--green); stroke-width: 1; }
.sid-text { fill: var(--green); font-size: 14px; font-weight: 700; text-anchor: middle; dominant-baseline: middle; }
.nrc-badge-svg { fill: var(--red); opacity: 0.2; stroke: var(--red); stroke-width: 1; }
.nrc-text { fill: var(--red); font-size: 14px; font-weight: 700; text-anchor: middle; dominant-baseline: middle; }

/* ===== Byte Format Display ===== */
.byte-format { display: flex; gap: 4px; margin-bottom: 24px; flex-wrap: wrap; }
.byte-field {
    background: var(--bg-card); border: 2px solid var(--field-color, var(--accent));
    border-radius: var(--radius); padding: 12px; text-align: center; min-width: 80px; flex: 1;
}
.field-name { font-weight: 700; color: var(--field-color, var(--accent)); font-size: 14px; margin-bottom: 4px; font-family: 'Consolas', monospace; }
.field-size { font-size: 11px; color: var(--text-dim); margin-bottom: 4px; }
.field-desc { font-size: 12px; color: var(--text); }

/* ===== Byte Examples ===== */
.examples-list { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.byte-example { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.example-name { font-weight: 600; color: var(--text-bright); margin-bottom: 10px; font-size: 14px; }
.byte-row { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.byte-row.compact { gap: 4px; }
.byte-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.byte-cell.sm .byte-val { padding: 4px 6px; font-size: 13px; }
.byte-val {
    font-family: 'Consolas', monospace; font-size: 15px; font-weight: 700; color: var(--green);
    background: rgba(0, 230, 118, 0.1); padding: 6px 10px; border-radius: 4px; display: inline-block;
}
.byte-cell .byte-label {
    font-size: 10px; color: var(--text-dim); text-align: center; max-width: 80px;
    fill: unset; opacity: 1; animation: none;
}
.example-desc { font-size: 13px; color: var(--text-dim); font-style: italic; }

/* ===== Session Cards ===== */
.session-cards { display: grid; grid-template-columns: 1fr; gap: 16px; }
.session-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-top: 3px solid var(--session-color, var(--accent)); border-radius: var(--radius); padding: 20px;
}
.session-header { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.session-id {
    font-family: 'Consolas', monospace; font-weight: 700; color: var(--session-color, var(--accent));
    font-size: 14px; background: rgba(255,255,255,0.05); padding: 2px 8px; border-radius: 4px;
}
.session-name { font-size: 13px; font-weight: 600; color: var(--text-bright); font-family: 'Consolas', monospace; }
.session-name-ja { font-size: 16px; font-weight: 700; color: var(--text-bright); margin-bottom: 8px; }
.session-desc { font-size: 13px; margin-bottom: 12px; }
.session-scenario { font-size: 12px; color: var(--text-dim); background: rgba(255,255,255,0.03); padding: 8px 12px; border-radius: 4px; margin-bottom: 10px; }
.session-sids { font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }

/* ===== Tags ===== */
.sid-tag {
    font-family: 'Consolas', monospace; font-size: 11px; padding: 2px 6px;
    background: var(--accent-glow); border: 1px solid var(--accent-dim); border-radius: 10px; color: var(--accent);
}

/* ===== Sequence Flow ===== */
.sequence-flow { max-width: 520px; }
.seq-step {
    display: flex; gap: 12px; padding: 12px 16px;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
}
.seq-num {
    width: 28px; height: 28px; background: var(--accent); color: var(--bg-dark);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.seq-body { flex: 1; }
.seq-action { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.seq-send { color: var(--green); }
.seq-recv { color: var(--cyan); }

/* ===== Level Table ===== */
.level-table { max-width: 480px; }
.level-row { display: flex; gap: 12px; padding: 10px; border-bottom: 1px solid var(--border); align-items: center; }
.level-id { font-family: 'Consolas', monospace; font-size: 13px; color: var(--accent); width: 80px; flex-shrink: 0; }
.level-name { font-weight: 600; font-size: 13px; color: var(--text-bright); width: 80px; flex-shrink: 0; }
.level-use { font-size: 13px; color: var(--text-dim); }

/* ===== Timing ===== */
.timing-params { max-width: 560px; }
.timing-row { display: flex; gap: 12px; padding: 10px; border-bottom: 1px solid var(--border); align-items: center; }
.timing-name { font-family: 'Consolas', monospace; font-weight: 600; color: var(--accent); width: 100px; flex-shrink: 0; }
.timing-value { font-weight: 700; color: var(--text-bright); width: 80px; flex-shrink: 0; }
.timing-desc { font-size: 13px; color: var(--text-dim); }

/* ===== SID Section ===== */
.sid-section h2 { display: flex; align-items: center; gap: 10px; }
.sid-hex {
    font-family: 'Consolas', monospace; font-size: 16px; color: var(--green);
    background: rgba(0, 230, 118, 0.1); padding: 4px 10px; border-radius: 4px;
}
.sid-name-ja { font-size: 15px; color: var(--text-dim); margin-bottom: 8px; }
.sid-desc { font-size: 14px; margin-bottom: 16px; max-width: 640px; }

/* SubFunction Table */
.subfunc-table { margin-bottom: 16px; max-width: 640px; overflow-x: auto; }
.subfunc-header {
    display: grid; grid-template-columns: 70px 200px 1fr; gap: 8px; padding: 8px 12px;
    background: var(--border); border-radius: var(--radius) var(--radius) 0 0;
    font-size: 12px; font-weight: 600; color: var(--text-dim);
}
.subfunc-row {
    display: grid; grid-template-columns: 70px 200px 1fr; gap: 8px; padding: 8px 12px;
    border-bottom: 1px solid var(--border); font-size: 13px;
}
.subfunc-id { font-family: 'Consolas', monospace; color: var(--accent); font-weight: 600; }
.subfunc-name { font-family: 'Consolas', monospace; color: var(--text-bright); font-size: 12px; }
.subfunc-desc { color: var(--text-dim); }

/* Request/Response Pair */
.req-resp-pair { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.req-box, .resp-box {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px 16px; min-width: 160px; flex: 1;
}
.req-box { border-top: 2px solid var(--green); }
.resp-box { border-top: 2px solid var(--cyan); }
.rr-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.req-box .rr-label { color: var(--green); }
.resp-box .rr-label { color: var(--cyan); }
.rr-meaning { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.rr-arrow { font-size: 24px; color: var(--accent-dim); }

/* SID Scenario & Notes */
.sid-scenario {
    font-size: 13px; background: rgba(255,255,255,0.03); padding: 12px 16px;
    border-radius: var(--radius); margin-bottom: 12px; border-left: 3px solid var(--orange);
}
.safety-note {
    font-size: 13px; background: rgba(255,82,82,0.08); border: 1px solid rgba(255,82,82,0.3);
    padding: 10px 16px; border-radius: var(--radius); margin-bottom: 12px; color: var(--red);
}
.sid-note { font-size: 12px; color: var(--text-dim); font-style: italic; margin-bottom: 12px; }
.sid-meta { display: flex; gap: 20px; font-size: 12px; color: var(--text-dim); flex-wrap: wrap; }
.nrc-link {
    font-family: 'Consolas', monospace; color: var(--red); text-decoration: none;
    padding: 1px 4px; background: rgba(255,82,82,0.08); border-radius: 3px; cursor: pointer;
}
.nrc-link:hover { background: rgba(255,82,82,0.2); }

/* DID Table */
.did-table { margin: 16px 0; max-width: 640px; overflow-x: auto; }
.did-row { display: grid; grid-template-columns: 90px 220px 1fr; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.did-id { font-family: 'Consolas', monospace; color: var(--accent); font-weight: 600; }
.did-name { font-family: 'Consolas', monospace; color: var(--text-bright); font-size: 12px; }
.did-desc { color: var(--text-dim); }

/* ===== DTC Status Bits ===== */
.status-bits { margin: 16px 0; max-width: 560px; }
.bit-row { display: grid; grid-template-columns: 50px 200px 1fr; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.uds-bit-num { font-family: 'Consolas', monospace; color: var(--accent); font-weight: 600; }
.bit-name { font-family: 'Consolas', monospace; color: var(--text-bright); font-size: 12px; }
.bit-desc { color: var(--text-dim); }

/* ===== UDS Sequence ===== */
.uds-sequence { max-width: 520px; }
.uds-step {
    display: flex; align-items: center; gap: 12px; padding: 10px 16px;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
}
.uds-sid {
    font-family: 'Consolas', monospace; font-size: 13px; font-weight: 700; color: var(--green);
    background: rgba(0,230,118,0.1); padding: 4px 8px; border-radius: 4px; flex-shrink: 0; white-space: nowrap;
}
.uds-step-body { display: flex; flex-direction: column; gap: 2px; }
.uds-service { font-size: 13px; font-weight: 600; color: var(--text-bright); }
.uds-desc { font-size: 12px; color: var(--text-dim); }

/* ===== NRC Styles ===== */
.nrc-summary { max-width: 640px; max-height: 400px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.nrc-summary-row {
    display: grid; grid-template-columns: 60px 240px 1fr; gap: 8px; padding: 6px 12px;
    border-bottom: 1px solid var(--border); font-size: 13px; transition: background 0.15s;
}
.nrc-summary-row:hover { background: var(--accent-glow); }
.nrc-code { font-family: 'Consolas', monospace; color: var(--red); font-weight: 700; }
.nrc-name-en { font-family: 'Consolas', monospace; color: var(--text-bright); font-size: 11px; }
.nrc-short { color: var(--text-dim); }

.nrc-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; margin-bottom: 12px;
}
.nrc-header { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.nrc-code-big {
    font-family: 'Consolas', monospace; font-size: 20px; font-weight: 700; color: var(--red);
    background: rgba(255,82,82,0.1); padding: 6px 14px; border-radius: var(--radius);
}
.nrc-names { display: flex; flex-direction: column; }
.nrc-name-main { font-family: 'Consolas', monospace; font-size: 14px; color: var(--text-bright); font-weight: 600; }
.nrc-name-ja { font-size: 15px; color: var(--text); }
.nrc-description { font-size: 14px; margin-bottom: 12px; }
.nrc-when, .nrc-fix { font-size: 13px; padding: 8px 12px; border-radius: 4px; margin-bottom: 8px; }
.nrc-when { background: rgba(255,145,0,0.06); border-left: 3px solid var(--orange); }
.nrc-fix { background: rgba(0,230,118,0.06); border-left: 3px solid var(--green); }
.nrc-sids { font-size: 12px; color: var(--text-dim); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }

/* ===== Diagnostic Flow ===== */
.difficulty-badge { font-size: 11px; padding: 2px 10px; border-radius: 12px; font-weight: 600; vertical-align: middle; }
.difficulty-badge.basic { background: rgba(0,230,118,0.15); color: var(--green); }
.difficulty-badge.intermediate { background: rgba(255,145,0,0.15); color: var(--orange); }
.difficulty-badge.advanced { background: rgba(255,82,82,0.15); color: var(--red); }

.diag-flow { max-width: 640px; }
.diag-step { display: flex; gap: 12px; padding: 10px 16px; border-radius: var(--radius); margin-bottom: 4px; }
.diag-step.send { background: rgba(0,230,118,0.05); border-left: 3px solid var(--green); }
.diag-step.recv { background: rgba(0,229,255,0.05); border-left: 3px solid var(--cyan); }
.diag-step.note { background: rgba(255,215,64,0.05); border-left: 3px solid var(--yellow); }
.step-direction { font-size: 12px; font-weight: 700; width: 60px; flex-shrink: 0; }
.send-dir { color: var(--green); }
.recv-dir { color: var(--cyan); }
.note-dir { color: var(--yellow); }
.step-body { flex: 1; }
.step-bytes {
    font-family: 'Consolas', monospace; font-size: 13px; font-weight: 700; color: var(--yellow);
    background: rgba(255,215,64,0.08); padding: 2px 8px; border-radius: 4px; display: inline-block; margin-bottom: 4px;
}
.step-service { font-size: 12px; font-weight: 600; color: var(--text-bright); }
.step-desc { font-size: 12px; color: var(--text-dim); }
.step-note { font-size: 11px; color: var(--orange); font-style: italic; margin-top: 2px; }

/* ===== History Timeline ===== */
.history-timeline { max-width: 560px; }
.history-item { display: flex; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.history-year { min-width: 70px; font-weight: 700; color: var(--accent); font-size: 14px; }
.history-event { font-size: 14px; }

/* ===== Desktop ===== */
@media (min-width: 768px) {
    .session-cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
    .byte-format { flex-direction: row; }
    .req-resp-pair { flex-direction: row; }
    .subfunc-header, .subfunc-row { grid-template-columns: 70px 200px 1fr; }
    .nrc-summary-row { grid-template-columns: 60px 240px 1fr; }
}

@media (max-width: 768px) {
    .byte-format { flex-direction: column; }
    .byte-field { min-width: unset; }
    .req-resp-pair { flex-direction: column; }
    .rr-arrow { transform: rotate(90deg); }
    .subfunc-header, .subfunc-row { grid-template-columns: 60px 140px 1fr; font-size: 12px; }
    .did-row { grid-template-columns: 70px 1fr; }
    .did-desc { grid-column: 1 / -1; }
    .nrc-summary-row { grid-template-columns: 50px 1fr; }
    .nrc-name-en { grid-column: 1 / -1; }
    .bit-row { grid-template-columns: 45px 1fr; }
    .bit-desc { grid-column: 1 / -1; }
}
