/* ==========================================================================
   Automagio – components.css
   Wiederverwendbare Bausteine. Alle Farben kommen aus tokens.css.
   ========================================================================== */

/* --- Buttons ------------------------------------------------------------ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 38px; padding: 0 16px;
    border: 1px solid transparent; border-radius: var(--radius);
    font: inherit; font-size: var(--fs-sm); font-weight: 500; line-height: 1;
    color: var(--text); background: transparent;
    cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--c-primary); color: var(--c-on-primary); }
.btn-primary:hover { background: var(--c-primary-hover); color: var(--c-on-primary); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--c-danger); color: #FFFFFF; }
.btn-danger:hover { filter: brightness(0.92); color: #FFFFFF; }
.btn-on-primary { background: var(--c-on-primary); color: var(--c-primary); }
.btn-on-primary:hover { background: var(--c-on-primary); color: var(--c-primary-hover); }
.btn-sm { height: 32px; padding: 0 12px; font-size: var(--fs-xs); }
.btn-lg { height: 46px; padding: 0 22px; font-size: var(--fs-base); }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: 0.55; cursor: not-allowed; }

.icon-btn {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border: 0; border-radius: var(--radius);
    background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.is-active { color: var(--c-primary); }
.icon-btn .dot {
    position: absolute; top: 7px; right: 7px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--c-danger); border: 2px solid var(--surface);
}

/* --- Badges -------------------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    height: 22px; padding: 0 8px; border-radius: 999px;
    font-size: var(--fs-xs); font-weight: 500; line-height: 1; white-space: nowrap;
}
.badge-neutral { background: var(--surface-2); color: var(--text-2); }
.badge-primary { background: var(--c-primary-soft); color: var(--c-primary); }
.badge-active  { background: var(--c-accent-soft);  color: var(--c-accent); }
.badge-success { background: var(--c-success-soft); color: var(--c-success); }
.badge-warning { background: var(--c-warning-soft); color: var(--c-warning); }
.badge-danger  { background: var(--c-danger-soft);  color: var(--c-danger); }
.badge-active::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* --- Karten und Widgets -------------------------------------------------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: var(--space-5);
}
.card-title { font-size: var(--fs-base); margin-bottom: var(--space-2); }

.widget {
    display: flex; flex-direction: column; min-width: 0;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.widget-anchor { border-left: 3px solid var(--c-primary); }
.widget-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 0; }
.widget-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: var(--fs-sm); font-weight: 600; }
.widget-title .icon { color: var(--c-primary); }
.widget-meta { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--text-3); }
.widget-body { flex: 1; padding: 12px 16px 14px; }
.widget-foot { border-top: 1px solid var(--border); padding: 10px 16px; font-size: var(--fs-sm); }
.widget-foot a { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }

/* Listenzeilen in Widgets */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 8px 0; border-top: 1px solid var(--border); font-size: var(--fs-sm);
}
.rows li:first-child { border-top: 0; padding-top: 2px; }
.rows .primary { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.rows .secondary { flex: none; color: var(--text-2); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.rows .is-danger  { color: var(--c-danger); font-weight: 500; }
.rows .is-warning { color: var(--c-warning); font-weight: 500; }
.rows .is-success { color: var(--c-success); font-weight: 500; }

/* Kennzahlen-Kacheln */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.kpi { background: var(--surface-2); border-radius: var(--radius); padding: 10px 12px; }
.kpi-label { font-size: var(--fs-xs); color: var(--text-2); margin-bottom: 2px; }
.kpi-value { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-value.is-warning { color: var(--c-warning); }
.kpi-value.is-danger  { color: var(--c-danger); }

a.kpi-link { color: inherit; text-decoration: none; }
a.kpi-link:hover { background: var(--c-primary-soft); text-decoration: none; }
a.kpi-link:hover .kpi-label { color: var(--c-primary); }

/* Fortschrittsbalken */
.progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--c-primary); border-radius: 999px; }

/* Leere Zustände */
.add-card {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    min-height: 160px; padding: var(--space-4);
    border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg);
    color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; text-decoration: none; text-align: center;
}
.add-card small { font-weight: 400; color: var(--text-3); }
.add-card:hover { border-color: var(--c-primary); background: var(--c-primary-soft); color: var(--c-primary); text-decoration: none; }
.empty { text-align: center; padding: var(--space-8) var(--space-4); color: var(--text-2); }
.empty h3 { font-size: var(--fs-md); }

/* Agent-Karten (Katalog und Startseite) */
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-4); }
.agent-card {
    display: flex; flex-direction: column; gap: 10px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-5);
}
.agent-card:hover { border-color: var(--border-strong); }
.agent-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: var(--radius);
    background: var(--c-primary-soft); color: var(--c-primary);
}
.agent-card h3 { font-size: var(--fs-base); margin: 0; }
.agent-card p { flex: 1; margin: 0; font-size: var(--fs-sm); color: var(--text-2); }
.agent-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.price { font-weight: 600; font-variant-numeric: tabular-nums; }
.price-note { font-size: var(--fs-xs); color: var(--text-2); }

/* Pinnwand-Notizen */
.note-pinned { border-left: 3px solid var(--c-primary); }

/* --- Formulare ----------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-4); }
.label { font-size: var(--fs-sm); font-weight: 500; }
.input, .select, .textarea {
    width: 100%; height: 40px; padding: 0 12px;
    border: 1px solid var(--border-strong); border-radius: var(--radius);
    background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-sm);
}
.textarea { height: auto; min-height: 100px; padding: 10px 12px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--c-primary); box-shadow: var(--focus); outline: 0; }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--c-danger); }
.help { font-size: var(--fs-xs); color: var(--text-2); }
.help.is-error { color: var(--c-danger); }
.check { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--c-primary); }
.form-actions { display: flex; gap: var(--space-2); align-items: center; }

/* Umschalter */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; font-size: var(--fs-sm); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { width: 36px; height: 20px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background 0.15s ease; flex: none; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); transition: transform 0.15s ease; }
.switch input:checked + .switch-track { background: var(--c-accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--focus); }

/* --- Tabellen ------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border-strong); font-size: var(--fs-xs); font-weight: 500; color: var(--text-2); }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- Dropdown ------------------------------------------------------------ */
.dropdown { position: relative; }
.avatar-btn { border: 0; background: transparent; padding: 2px; border-radius: 50%; cursor: pointer; display: inline-flex; }
.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--c-primary-soft); color: var(--c-primary); font-size: var(--fs-xs); font-weight: 600;
}
.dropdown-menu {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 70;
    min-width: 230px; padding: 6px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-pop);
}
.dropdown-menu[hidden] { display: none; }
.dropdown-menu a, .dropdown-menu button.dropdown-item, .dropdown-row {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
    background: transparent; color: var(--text); font: inherit; font-size: var(--fs-sm); text-decoration: none; text-align: left; cursor: pointer;
}
.dropdown-menu a .icon, .dropdown-menu button.dropdown-item .icon { color: var(--text-2); }
.dropdown-menu a:hover, .dropdown-menu button.dropdown-item:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-menu button.dropdown-item.is-danger, .dropdown-menu button.dropdown-item.is-danger .icon { color: var(--c-danger); }
.dropdown-menu button.dropdown-item.is-current { color: var(--c-primary); }
.dropdown-menu button.dropdown-item.is-current .icon { color: var(--c-primary); }
.dropdown-menu.dropdown-left { right: auto; left: 0; }
.dropdown-head { display: flex; flex-direction: column; padding: 8px 10px 10px; }
.dropdown-head strong { font-size: var(--fs-sm); }
.dropdown-head span { font-size: var(--fs-xs); color: var(--text-2); }
.dropdown-sep { border-top: 1px solid var(--border); margin: 6px 0; }
.dropdown-row > span:first-child { flex: 1; color: var(--text-2); }

/* --- Sprachumschalter ---------------------------------------------------- */
.lang-switch { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.lang-option { padding: 5px 9px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); text-decoration: none; }
.lang-option:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.lang-option.is-active, .lang-option.is-active:hover { background: var(--c-primary); color: var(--c-on-primary); }

/* --- Hinweise und Toasts ------------------------------------------------- */
.alert {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 12px 14px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--surface-2); font-size: var(--fs-sm);
}
.alert .icon { flex: none; margin-top: 2px; }
.alert-info    { background: var(--c-primary-soft); border-color: transparent; color: var(--c-primary); }
.alert-success { background: var(--c-success-soft); border-color: transparent; color: var(--c-success); }
.alert-warning { background: var(--c-warning-soft); border-color: transparent; color: var(--c-warning); }
.alert-danger  { background: var(--c-danger-soft);  border-color: transparent; color: var(--c-danger); }

.toast-region {
    position: fixed; top: calc(var(--topbar-h) + 12px); right: 16px; z-index: 90;
    display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.layout-site .toast-region { top: calc(var(--header-h) + 12px); }
.toast {
    pointer-events: auto;
    display: flex; align-items: center; gap: 10px;
    min-width: 260px; max-width: 380px; padding: 10px 12px 10px 14px;
    background: var(--surface); border: 1px solid var(--border-strong); border-left: 3px solid var(--c-primary);
    border-radius: var(--radius); box-shadow: var(--shadow-pop);
    font-size: var(--fs-sm); color: var(--text);
}
.toast-success { border-left-color: var(--c-success); }
.toast-warning { border-left-color: var(--c-warning); }
.toast-danger  { border-left-color: var(--c-danger); }
.toast .icon-btn { margin-left: auto; width: 28px; height: 28px; }

/* --- Platzhalterseiten --------------------------------------------------- */
.stub { max-width: 440px; margin: var(--space-9) auto; text-align: center; }

/* --- Farbmuster (Design-System-Seite) ------------------------------------ */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--space-3); }
.swatch { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.swatch-color { height: 56px; }
.swatch-name { padding: 8px 10px; font-size: var(--fs-xs); }
.swatch-name code { display: block; font-family: var(--font-mono); color: var(--text-2); }
