/* =========================================================
   BUSINESS DRIVERS

   To spalter: listen til venstre, den valgte driver til
   hoejre. Formelbyggeren er den tunge del, og den faar plads
   nok til at en formel kan laeses i et hug.
========================================================= */

.drivers__header-actions {
    display: flex;
    gap: 8px;
}

.drivers__layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 18px;
    align-items: start;
}

/* ---------------------------------------------------------
   LISTEN
--------------------------------------------------------- */

.drivers__list {
    display: grid;
    gap: 8px;
    position: sticky;
    top: 12px;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    padding-right: 4px;
}

.drivers__item {
    display: grid;
    gap: 3px;
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--color-border, #E2E8F0);
    border-radius: 10px;
    background: #FFFFFF;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.12s, box-shadow 0.12s;
}

.drivers__item:hover {
    border-color: #94A3B8;
}

.drivers__item.is-selected {
    border-color: #1F5135;
    box-shadow: 0 0 0 1px #1F5135;
}

.drivers__item-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.drivers__item-head strong {
    font-size: 13px;
    color: #1D2C23;
}

.drivers__item-code {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 10px;
    color: #94A3B8;
}

/*
 * Formlen staar i listen, saa man kan se hvad en driver goer
 * uden at aabne den.
 */
.drivers__item-formula {
    font-size: 11px;
    color: #475569;
    line-height: 1.35;
}

.drivers__item-meta {
    font-size: 10px;
    color: #94A3B8;
}

.drivers__badge {
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
}

.drivers__badge.is-input {
    background: #FFF6D8;
    color: #7A5B00;
}

.drivers__badge.is-calculated {
    background: #E8F1EB;
    color: #1F5135;
}

/* ---------------------------------------------------------
   DETALJEN
--------------------------------------------------------- */

.drivers__detail {
    min-width: 0;
}

.drivers__section {
    padding: 18px;
    margin-bottom: 14px;
    border: 1px solid var(--color-border, #E2E8F0);
    border-radius: 12px;
    background: #FFFFFF;
}

.drivers__section h3 {
    margin: 0 0 14px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #1F5135;
}

.drivers__section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.drivers__section-head h3 {
    margin: 0;
}

.drivers__grid {
    display: grid;
    grid-template-columns:
        repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.drivers__form label,
.drivers__modal-form label {
    display: grid;
    gap: 5px;
    font-size: 10px;
    font-weight: 720;
    color: #64748B;
}

.drivers__full {
    margin-top: 12px;
}

.drivers__note {
    margin: 10px 0 0;
    font-size: 11px;
    line-height: 1.5;
    color: #64748B;
}

.drivers__actions {
    display: flex;
    gap: 10px;
    padding-bottom: 20px;
}

/* ---------------------------------------------------------
   PARAMETERTABELLEN
--------------------------------------------------------- */

.drivers__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.drivers__table th {
    padding: 7px 9px;
    border-bottom: 1px solid #E2E8F0;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    text-align: left;
    color: #64748B;
}

.drivers__table td {
    padding: 9px;
    border-bottom: 1px solid #F1F5F9;
    vertical-align: middle;
}

.drivers__table td small {
    display: block;
    font-size: 10px;
    color: #94A3B8;
}

.drivers__table .is-number {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.drivers__table .is-actions {
    text-align: right;
    white-space: nowrap;
}

.drivers__table code {
    padding: 1px 5px;
    border-radius: 4px;
    background: #F1F5F9;
    font-family: ui-monospace, Menlo, monospace;
    font-size: 11px;
}

.drivers__link {
    padding: 0 6px;
    border: 0;
    background: none;
    color: #1F5135;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

.drivers__link.is-danger {
    color: #B91C1C;
}

/* ---------------------------------------------------------
   FORMELBYGGEREN

   Leddene staar som brikker, man kan klikke vaek igen.
   Farverne skiller de fire slags fra hinanden, saa en lang
   formel kan laeses uden at laese hvert ord.
--------------------------------------------------------- */

.drivers__formula {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    min-height: 54px;
    padding: 12px;
    border: 1px dashed #CBD5E1;
    border-radius: 10px;
    background: #F8FAFC;
}

.drivers__formula-empty {
    font-size: 11px;
    color: #94A3B8;
}

.drivers__token {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 9px;
    border: 1px solid transparent;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 650;
    cursor: pointer;
}

.drivers__token-remove {
    font-size: 13px;
    opacity: 0.45;
}

.drivers__token:hover .drivers__token-remove {
    opacity: 1;
}

.drivers__token.is-parameter {
    background: #FFF6D8;
    border-color: #E8D9A0;
    color: #7A5B00;
}

.drivers__token.is-driver {
    background: #E8F1EB;
    border-color: #B9D4C4;
    color: #1F5135;
}

.drivers__token.is-account {
    background: #E7EEF8;
    border-color: #B6C9E4;
    color: #1D4F77;
}

/*
 * En kategori er summen af mange konti. Den faar sin egen
 * farve, saa en formel kan laeses uden at gaette, om et led
 * er den ene konto eller hele gruppen.
 */
.drivers__token.is-category {
    background: #EDE7F8;
    border-color: #C7B8E4;
    color: #4C2F77;
}

.drivers__token.is-constant {
    background: #F1F5F9;
    border-color: #CBD5E1;
    color: #334155;
}

.drivers__token.is-operator {
    background: #1F5135;
    color: #FFFFFF;
    font-weight: 800;
}

.drivers__token.is-function {
    background: #6B5A2E;
    color: #FFFFFF;
}

.drivers__token.is-group {
    background: #FFFFFF;
    border-color: #CBD5E1;
    color: #475569;
    font-weight: 800;
}

/*
 * Svaret fra serveren. Groen naar formlen kan laeses, roed
 * med selve fejlen naar den ikke kan.
 */
.drivers__status {
    margin: 10px 0 0;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 11px;
    line-height: 1.5;
}

.drivers__status.is-valid {
    background: #E8F1EB;
    color: #1F5135;
    font-weight: 650;
}

.drivers__status.is-invalid {
    background: #FEF2F2;
    color: #B91C1C;
}

.drivers__status p {
    margin: 0;
}

.drivers__status p + p {
    margin-top: 4px;
}

/* ---------------------------------------------------------
   PALETTEN
--------------------------------------------------------- */

.drivers__palette {
    display: grid;
    grid-template-columns:
        repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #F1F5F9;
}

.drivers__palette-group h4 {
    margin: 0 0 8px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #64748B;
}

.drivers__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.drivers__chip {
    padding: 5px 10px;
    border: 1px solid #CBD5E1;
    border-radius: 7px;
    background: #FFFFFF;
    font-size: 11px;
    font-weight: 650;
    color: #334155;
    cursor: pointer;
}

.drivers__chip:hover {
    border-color: #1F5135;
    color: #1F5135;
}

.drivers__chip.is-operator {
    min-width: 34px;
    font-weight: 800;
}

.drivers__chip.is-parameter {
    background: #FFFDF5;
    border-color: #E8D9A0;
}

.drivers__chip.is-driver {
    background: #F5FAF7;
    border-color: #B9D4C4;
}

.drivers__chip.is-function {
    background: #FBF8F1;
    border-color: #DECFA8;
}

.drivers__constant {
    max-width: 120px;
}

.drivers__account {
    flex: 1;
    min-width: 160px;
}

/* ---------------------------------------------------------
   TOMME TILSTANDE
--------------------------------------------------------- */

.drivers__empty,
.drivers__loading {
    display: grid;
    gap: 10px;
    justify-items: center;
    padding: 40px 20px;
    border: 1px dashed #CBD5E1;
    border-radius: 12px;
    color: #94A3B8;
    font-size: 12px;
    text-align: center;
}

.drivers__empty div {
    font-size: 22px;
}

.drivers__error {
    padding: 14px;
    border-radius: 10px;
    background: #FEF2F2;
    color: #B91C1C;
    font-size: 12px;
}

/* ---------------------------------------------------------
   MODAL
--------------------------------------------------------- */

.drivers__overlay {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.45);
}

.drivers__modal {
    width: min(460px, 100%);
    border-radius: 14px;
    background: #FFFFFF;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
    overflow: hidden;
}

.drivers__modal header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid #F1F5F9;
}

.drivers__modal header h3 {
    margin: 0;
    font-size: 14px;
    color: #1D2C23;
}

.drivers__close {
    border: 0;
    background: none;
    font-size: 20px;
    line-height: 1;
    color: #94A3B8;
    cursor: pointer;
}

.drivers__modal-body {
    padding: 18px;
    max-height: 60vh;
    overflow-y: auto;
}

.drivers__modal-form {
    display: grid;
    gap: 12px;
}

.drivers__modal footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 18px;
    border-top: 1px solid #F1F5F9;
    background: #F8FAFC;
}

.drivers__usage {
    margin: 10px 0 0;
    padding-left: 18px;
    font-size: 12px;
    color: #334155;
}

.drivers__usage small {
    display: block;
    font-size: 10px;
    color: #94A3B8;
}

/* ---------------------------------------------------------
   SMALLE SKAERME
--------------------------------------------------------- */

@media (max-width: 1100px) {
    .drivers__layout {
        grid-template-columns: 1fr;
    }

    .drivers__list {
        position: static;
        max-height: none;
    }
}
