/* Hochfrequenz-inspired light theme — matches docs/book/custom.css
 *
 * Palette aligned with hochfrequenz.de:
 *   Primärgrün        hsl(141.5, 24%, 44%)
 *   Sekundärgrün      hsl(140,   23%, 57%)
 *   Text              hsl(328,   30%, 11%)
 *   Off-White BG      hsl(0,     0%,  97%)
 *   Muted teal border hsl(169,   18%, 86%)
 *
 * Typografie: Quicksand (Headings), Noto Sans (Body), Noto Sans Mono (Code).
 */

@import url("https://fonts.googleapis.com/css2?family=Quicksand:wght@500;600;700&family=Noto+Sans:wght@400;500;600&family=Noto+Sans+Mono:wght@400;500&display=swap");

/* === Reset === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html { color-scheme: light; }

/* === Variables === */
:root {
    --hf-primary:        hsl(141.5, 24%, 44%);
    --hf-primary-hover:  hsl(141.5, 28%, 36%);
    --hf-primary-light:  hsl(140,   23%, 57%);
    --hf-primary-soft:   hsl(141,   30%, 94%);
    --hf-primary-softer: hsl(141,   30%, 97%);
    --hf-text:           hsl(328,   30%, 11%);
    --hf-text-muted:     hsl(328,   8%,  38%);
    --hf-border:         hsl(169,   18%, 86%);
    --hf-border-strong:  hsl(169,   20%, 73%);
    --hf-bg:             hsl(0,     0%,  97%);
    --hf-card-bg:        #ffffff;

    /* Semantic colors (accessible on light bg) */
    --color-success:     hsl(141.5, 50%, 35%);
    --color-success-bg:  hsl(141,   45%, 94%);
    --color-warning:     hsl(36,    85%, 40%);
    --color-warning-bg:  hsl(42,    95%, 94%);
    --color-error:       hsl(0,     68%, 45%);
    --color-error-bg:    hsl(0,     70%, 96%);
    --color-info:        hsl(210,   65%, 45%);
    --color-info-bg:     hsl(210,   65%, 95%);

    /* Legacy aliases kept for backward-compat inside components */
    --color-bg:             var(--hf-bg);
    --color-surface:        var(--hf-card-bg);
    --color-surface-hover:  var(--hf-primary-soft);
    --color-border:         var(--hf-border);
    --color-text:           var(--hf-text);
    --color-text-muted:     var(--hf-text-muted);
    --color-primary:        var(--hf-primary);
    --color-secondary:      var(--hf-primary-light);

    --font-mono: "Noto Sans Mono", ui-monospace, "SFMono-Regular", "Cascadia Code", monospace;
    --font-sans: "Noto Sans", system-ui, -apple-system, sans-serif;
    --font-heading: "Quicksand", system-ui, sans-serif;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-pill: 999px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.08);
}

body {
    background-color: var(--hf-bg);
    color: var(--hf-text);
    font-family: var(--font-sans);
    line-height: 1.65;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--hf-text);
    letter-spacing: -0.01em;
}

code, pre, kbd {
    font-family: var(--font-mono);
}

/* === Layout === */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* === Navbar === */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.5rem;
    background: var(--hf-card-bg);
    border-bottom: 1px solid var(--hf-border);
    margin-bottom: 1.5rem;
}

.navbar h1 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--hf-primary);
    letter-spacing: -0.01em;
}

.navbar nav a {
    color: var(--hf-text-muted);
    text-decoration: none;
    margin-left: 1.5rem;
    font-size: 0.92rem;
    font-weight: 500;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-sm);
    transition: color 0.15s ease, background 0.15s ease;
}

.navbar nav a:hover,
.navbar nav a.active {
    color: var(--hf-primary);
    background: var(--hf-primary-soft);
}

/* === Auth Status === */
.auth-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
    padding-left: 1.5rem;
}

.auth-loading {
    color: var(--hf-text-muted);
    font-size: 0.85rem;
}

.auth-user {
    color: var(--hf-text-muted);
    font-size: 0.85rem;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-error {
    color: var(--color-error);
    font-size: 0.8rem;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-login {
    background: var(--hf-primary);
    color: #ffffff !important;
    border-color: var(--hf-primary);
    font-weight: 600;
}

.btn-login:hover:not(:disabled) {
    background: var(--hf-primary-hover);
    border-color: var(--hf-primary-hover);
}

.btn-logout {
    background: transparent;
    color: var(--hf-text-muted);
    border-color: var(--hf-border);
}

.btn-logout:hover:not(:disabled) {
    color: var(--color-error);
    border-color: var(--color-error);
    background: var(--color-error-bg);
}

/* === Auth Gate === */
.auth-gate {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 420px;
    padding: 2rem;
}

.auth-gate-card {
    text-align: center;
    background: var(--hf-card-bg);
    border: 1px solid var(--hf-border);
    border-radius: 16px;
    padding: 3rem 4rem;
    max-width: 480px;
    box-shadow: var(--shadow);
}

.auth-gate-card h2 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--hf-text);
    margin-bottom: 0.75rem;
}

.auth-gate-card p {
    color: var(--hf-text-muted);
    margin-bottom: 1.5rem;
    font-size: 0.98rem;
}

.auth-gate-card .btn {
    font-size: 1rem;
    padding: 0.78rem 1.6rem;
}

.auth-gate-card .spinner {
    width: 2rem;
    height: 2rem;
    border: 2px solid var(--hf-border);
    border-top-color: var(--hf-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

.auth-gate-error {
    color: var(--color-error);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    padding: 0.5rem 1rem;
    background: var(--color-error-bg);
    border: 1px solid hsl(0, 70%, 88%);
    border-radius: var(--radius-sm);
}

/* === Fixture Selector === */
.fixture-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    margin-bottom: 1rem;
    background: var(--hf-card-bg);
    border: 1px solid var(--hf-border);
    border-radius: var(--radius);
}

.fixture-selector .fixture-label {
    font-size: 0.85rem;
    color: var(--hf-text-muted);
    font-weight: 500;
    white-space: nowrap;
}

/* Select dropdowns — usable anywhere, not just inside .fixture-selector */
.fixture-select {
    padding: 0.45rem 0.7rem;
    background: var(--hf-card-bg);
    color: var(--hf-text);
    border: 1px solid var(--hf-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;

    /* Custom chevron — remove native appearance so light theme is consistent */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234a7862' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 10px;
    padding-right: 1.9rem;
}

.fixture-selector .fixture-select {
    flex: 1;
    min-width: 200px;
}

.fixture-select-narrow {
    flex: 0 0 auto;
    min-width: 120px;
    max-width: 180px;
}

.fixture-select:focus {
    outline: none;
    border-color: var(--hf-primary);
    box-shadow: 0 0 0 3px var(--hf-primary-soft);
}

.fixture-selector .btn-load {
    white-space: nowrap;
}

.fixture-selector .fixture-loading {
    font-size: 0.8rem;
    color: var(--hf-primary);
    font-weight: 500;
}

.fixture-selector .fixture-error {
    font-size: 0.8rem;
    color: var(--color-error);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === Converter Layout === */
.converter-layout {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: start;
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .converter-layout {
        grid-template-columns: 1fr;
    }
}

/* === Editor Panel === */
.editor-panel {
    background: var(--hf-card-bg);
    border: 1px solid var(--hf-border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.editor-panel:focus-within {
    border-color: var(--hf-primary-light);
    box-shadow: 0 0 0 3px var(--hf-primary-soft);
}

.editor-panel .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    background: var(--hf-primary-softer);
    border-bottom: 1px solid var(--hf-border);
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--hf-text-muted);
    letter-spacing: 0.02em;
}

.editor-panel textarea {
    width: 100%;
    min-height: 350px;
    padding: 1rem;
    background: transparent;
    color: var(--hf-text);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    border: none;
    outline: none;
    resize: vertical;
    line-height: 1.55;
}

.editor-panel textarea::placeholder {
    color: var(--hf-text-muted);
}

.editor-panel textarea:read-only {
    color: var(--hf-text-muted);
    cursor: default;
}

/* === Controls === */
.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding-top: 2rem;
}

/* === Response Controls === */
.response-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    border-top: 1px solid var(--hf-border);
    padding-top: 0.75rem;
}

.validation-filters {
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--hf-border);
}

.response-checkbox {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    color: var(--hf-text-muted);
    cursor: pointer;
    font-weight: 500;
}

.response-checkbox input[type="checkbox"] {
    accent-color: var(--hf-primary);
}

.response-controls .fixture-select {
    width: 100%;
    padding: 0.3rem 0.45rem;
    font-size: 0.78rem;
}

/* === Response Panel Content === */
.response-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.response-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.response-format-label {
    font-size: 0.8rem;
    color: var(--hf-text-muted);
    font-weight: 500;
}

.response-textarea {
    width: 100%;
    min-height: 200px;
    padding: 0.8rem;
    background: var(--hf-primary-softer);
    color: var(--hf-text);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    border: 1px solid var(--hf-border);
    border-radius: var(--radius-sm);
    resize: vertical;
    line-height: 1.55;
}

.response-textarea:focus {
    outline: none;
    border-color: var(--hf-primary);
    box-shadow: 0 0 0 3px var(--hf-primary-soft);
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.3rem;
    border: 1px solid var(--hf-border);
    border-radius: var(--radius-pill);
    background: var(--hf-card-bg);
    color: var(--hf-text);
    font-family: var(--font-heading);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.15s ease,
                background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    text-decoration: none;
}

.btn:hover:not(:disabled) {
    border-color: var(--hf-primary);
    color: var(--hf-primary);
    background: var(--hf-primary-soft);
}

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

.btn-primary {
    background: var(--hf-primary);
    color: #ffffff !important;
    border-color: var(--hf-primary);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
    background: var(--hf-primary-hover);
    border-color: var(--hf-primary-hover);
    color: #ffffff !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(85, 139, 110, 0.28);
}

.btn-secondary {
    background: transparent;
    color: var(--hf-primary) !important;
    border-color: var(--hf-primary);
    box-shadow: inset 0 0 0 0.5px var(--hf-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--hf-primary-soft);
    color: var(--hf-primary-hover) !important;
    border-color: var(--hf-primary-hover);
}

.btn-small {
    padding: 0.35rem 0.8rem;
    font-size: 0.8rem;
}

/* === Direction Toggle === */
/* The DirectionToggle component is a <button> whose text is the
 * "EDIFACT → BO4E" label itself — style it as a pill chip. */
.direction-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    background: var(--hf-primary-soft);
    color: var(--hf-primary-hover);
    border: 1px solid var(--hf-primary-light);
    border-radius: var(--radius-pill);
    font-family: var(--font-heading);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease,
                border-color 0.15s ease, transform 0.1s ease,
                box-shadow 0.15s ease;
}

.direction-toggle:hover {
    background: var(--hf-primary);
    color: #ffffff;
    border-color: var(--hf-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(85, 139, 110, 0.25);
}

.direction-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--hf-primary-soft),
                0 0 0 4px var(--hf-primary);
}

/* Supports the legacy two-line markup (<div class="direction-toggle"><span class="label">) */
.direction-toggle .label {
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: inherit;
}

/* === Collapsible Panel === */
.collapsible-panel {
    background: var(--hf-card-bg);
    border: 1px solid var(--hf-border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.collapsible-panel:hover {
    border-color: var(--hf-primary-light);
}

.collapsible-panel .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 1rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}

.collapsible-panel .panel-header:hover {
    background: var(--hf-primary-soft);
}

.collapsible-panel .panel-header .title {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--hf-text);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.6rem;
    border-radius: var(--radius-pill);
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--hf-primary-soft);
    color: var(--hf-primary-hover);
    letter-spacing: 0.02em;
}

.collapsible-panel .panel-header .badge {
    padding: 0.12rem 0.55rem;
    font-weight: 500;
}

.collapsible-panel .panel-header .chevron {
    transition: transform 0.2s ease;
    color: var(--hf-text-muted);
    font-weight: 600;
}

.collapsible-panel.open .panel-header .chevron {
    transform: rotate(90deg);
    color: var(--hf-primary);
}

.collapsible-panel .panel-body {
    display: none;
    padding: 1rem;
    border-top: 1px solid var(--hf-border);
    background: var(--hf-primary-softer);
}

.collapsible-panel.open .panel-body {
    display: block;
}

/* === Segment Tree === */
.segment-tree {
    font-family: var(--font-mono);
    font-size: 0.82rem;
}

.segment-tree .tree-node {
    padding: 0.25rem 0;
}

.segment-tree .tree-node .node-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: default;
}

.segment-tree .tree-node .node-row:hover {
    background: var(--hf-primary-soft);
}

.segment-tree .tag-badge {
    display: inline-flex;
    padding: 0.12rem 0.5rem;
    background: var(--hf-primary);
    color: #ffffff;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
}

.segment-tree .line-number {
    color: var(--hf-text-muted);
    font-size: 0.72rem;
    min-width: 3rem;
}

.segment-tree .raw-content {
    color: var(--hf-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 500px;
}

.segment-tree .children {
    padding-left: 1.5rem;
    border-left: 1px solid var(--hf-border);
    margin-left: 0.75rem;
}

/* === Trace Table === */
.trace-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--hf-border);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 0.82rem;
}

.trace-table th {
    text-align: left;
    padding: 0.6rem 0.85rem;
    background: var(--hf-primary-soft);
    border-bottom: 1px solid var(--hf-border);
    color: var(--hf-text);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.trace-table td {
    padding: 0.5rem 0.85rem;
    border-bottom: 1px solid var(--hf-border);
    font-family: var(--font-mono);
}

.trace-table tr:last-child td {
    border-bottom: none;
}

.trace-table tr:hover td {
    background: var(--hf-primary-softer);
}

.trace-table .value-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.trace-table .note-cell {
    color: var(--hf-text-muted);
    font-family: var(--font-sans);
    font-style: italic;
}

/* === Error List === */
.error-list {
    list-style: none;
}

.error-list .error-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--hf-border);
}

.error-list .error-item:last-child {
    border-bottom: none;
}

.error-list .severity-icon {
    flex-shrink: 0;
    width: 1.4rem;
    height: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.72rem;
    font-weight: 700;
}

.error-list .severity-icon.warning {
    background: var(--color-warning);
    color: #ffffff;
}

.error-list .severity-icon.error,
.error-list .severity-icon.critical {
    background: var(--color-error);
    color: #ffffff;
}

.error-list .severity-icon.info {
    background: var(--color-info);
    color: #ffffff;
}

.error-list .error-code {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--hf-primary-hover);
}

.error-list .error-message {
    font-size: 0.9rem;
    color: var(--hf-text);
}

.error-list .error-bo4e-path,
.error-list .error-location {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--hf-text-muted);
    margin-top: 0.2rem;
}

.no-errors {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    background: var(--color-success-bg);
    border: 1px solid hsl(141, 40%, 82%);
    border-radius: var(--radius-sm);
    color: var(--color-success);
    font-size: 0.9rem;
    font-weight: 500;
}

/* === Coordinator Cards === */
.coordinator-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
    margin: 1.5rem 0;
}

.coordinator-card {
    position: relative;
    background: var(--hf-card-bg);
    border: 1px solid var(--hf-border);
    border-radius: 16px;
    padding: 1.75rem 1.5rem 1.5rem;
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease,
                border-color 0.15s ease;
}

.coordinator-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--hf-primary);
    opacity: 0.55;
    transition: opacity 0.15s ease;
}

.coordinator-card:hover {
    transform: translateY(-2px);
    border-color: var(--hf-primary-light);
    box-shadow: var(--shadow-lg);
}

.coordinator-card:hover::before { opacity: 1; }

.coordinator-card h3 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--hf-text);
    margin: 0 0 0.35rem;
}

.coordinator-card .description {
    font-size: 0.92rem;
    color: var(--hf-text-muted);
    margin-bottom: 0.85rem;
    line-height: 1.55;
}

.coordinator-card .versions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.coordinator-card .version-badge {
    display: inline-flex;
    padding: 0.2rem 0.6rem;
    background: var(--hf-primary-soft);
    color: var(--hf-primary-hover);
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-heading);
    letter-spacing: 0.02em;
}

/* === Loading / Status === */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--hf-text-muted);
    font-weight: 500;
}

.loading .spinner {
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid var(--hf-border);
    border-top-color: var(--hf-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 0.75rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === Responsive === */
@media (max-width: 720px) {
    .navbar { padding: 0.7rem 1rem; flex-wrap: wrap; gap: 0.5rem; }
    .navbar h1 { font-size: 1.1rem; }
    .navbar nav a { margin-left: 0.75rem; font-size: 0.85rem; }
    .auth-gate-card { padding: 2rem 1.5rem; }
    .editor-panel textarea { min-height: 260px; }
}
