/* ============================================================
   Reusable settings-card component
   Drop <div class="settings-card"> ... </div> into any form.
   Optionally wrap a group of cards in <div class="settings-cards">.
   Header chrome (icon + title + description) lives in the
   components/settings_card_header.html partial.
   ============================================================ */

.settings-cards { width: 100%; }

.settings-card {
    position: relative;
    background: #fff;
    border: 1px solid #eef0f4;
    border-radius: 16px;
    box-shadow: 0 4px 18px rgba(16, 24, 40, .05);
    padding: 26px 28px;
    margin-bottom: 22px;
    transition: box-shadow .2s ease;
}
.settings-card:hover { box-shadow: 0 8px 26px rgba(16, 24, 40, .09); }

/* --- header: icon chip + title + description --- */
.settings-card__header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
}
.settings-card__icon {
    flex: 0 0 auto;
    width: 52px; height: 52px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 14px;
    background: rgba(0, 98, 158, .08);
    color: var(--primary);
    font-size: 1.15rem;
}
.settings-card__logo {
    flex: 0 0 auto;
    width: 52px; height: 52px;
    display: flex; align-items: center; justify-content: center;
}
.settings-card__logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.settings-card__heading { flex: 1 1 auto; min-width: 0; }
.settings-card__title {
    font-weight: 700;
    font-size: 1.12rem;
    color: #1f2937;
    margin: 4px 0 6px;
}
.settings-card__desc {
    color: #6b7280;
    font-size: .9rem;
    line-height: 1.5;
    margin-bottom: 0;
}
.settings-card__desc .hint { color: #9ca3af; font-style: italic; }

/* --- optional top-right control (e.g. a toggle switch) --- */
.settings-card__toggle { position: absolute; top: 26px; right: 28px; }

/* --- inputs ---
   Field/option/button styling applies inside a .settings-card (full shell)
   OR a bare .settings-form (e.g. a modal body that shouldn't get the card
   chrome, to avoid a box-in-a-box). */
.settings-card__label {
    display: block;
    font-weight: 600;
    font-size: .85rem;
    color: #374151;
    margin-bottom: 6px;
}
/* Target real editable inputs only. Exclude the .form-control elements that
   crispy/bootstrap use as layout containers for file widgets (ClearableFileInput
   renders `.form-control.d-flex` and `.form-control.custom-file` inside an
   .input-group) — restyling those breaks the input-group's flush corners. */
.settings-card .form-control:not(.custom-file):not(.d-flex):not([type="file"]),
.settings-form .form-control:not(.custom-file):not(.d-flex):not([type="file"]) {
    width: 100%;
    height: auto;
    border-radius: 10px;
    border: 1px solid #d8dee9;
    padding: .6rem .85rem;
}
.settings-card .form-control:not(.custom-file):not(.d-flex):not([type="file"]):focus,
.settings-form .form-control:not(.custom-file):not(.d-flex):not([type="file"]):focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 98, 158, .12);
}

/* --- radio / checkbox option rows --- */
.settings-card .form-check,
.settings-form .form-check {
    position: relative;
    padding: .7rem .9rem .7rem 2.4rem;
    border: 1px solid #eef0f4;
    border-radius: 12px;
    margin-bottom: 10px;
    transition: border-color .15s ease, background .15s ease;
}
/* make the whole bordered row clickable, not just the radio/label */
.settings-card .form-check .form-check-label,
.settings-form .form-check .form-check-label { cursor: pointer; }
.settings-card .form-check .form-check-label::after,
.settings-form .form-check .form-check-label::after { content: ""; position: absolute; inset: 0; }
.settings-card .form-check:hover,
.settings-form .form-check:hover { border-color: rgba(0, 98, 158, .35); background: #f5fafd; }
.settings-card .form-check:has(.form-check-input:checked),
.settings-form .form-check:has(.form-check-input:checked) { border-color: var(--primary); background: rgba(0, 98, 158, .05); }
.settings-card .form-check-input,
.settings-form .form-check-input { margin-top: .3rem; accent-color: var(--primary); }
.settings-card .badge-secondary,
.settings-form .badge-secondary { background: rgba(0, 98, 158, .08); color: var(--primary); font-weight: 700; }

@media (max-width: 575.98px) {
    .settings-card { padding: 20px; }
    .settings-card__toggle { position: static; display: inline-block; margin-bottom: 12px; }
}

/* ============================================================
   VentoryOne API card — MCP connector (brand: #00629E)
   ============================================================ */
/* --- segmented tabs (API Token / MCP Connector) --- */
.vo-api-tabs {
    display: inline-flex; gap: 4px;
    background: #f2f5f9;
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 20px;
}
.vo-api-tab {
    border: none; background: none;
    padding: 8px 18px;
    border-radius: 9px;
    font-size: .9rem; font-weight: 600; color: #64748b;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.vo-api-tab:hover { color: #1f2937; }
.vo-api-tab.is-active {
    background: #fff;
    color: var(--primary, #00629E);
    box-shadow: 0 1px 3px rgba(16, 24, 40, .08);
}

.vo-api-actions {
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
}
/* Inherit the global .btn radius (.35rem) so these match the Save button. */
.vo-api-actions .btn { font-weight: 600; }

.mcp-reveal { margin-top: 14px; font-weight: 600; }

.vo-token-status {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: .85rem; font-weight: 600; color: #6b7280;
}
.vo-token-status .vo-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #cbd5e1;
}
.vo-token-status.is-active { color: #1f2937; }
.vo-token-status.is-active .vo-dot { background: #1cc88a; }

.vo-token-copy .vo-copy-link {
    border: none; background: none; padding: 0;
    color: var(--primary, #00629E); font-size: .85rem; font-weight: 600; cursor: pointer;
}

.vo-api-divider { border: 0; border-top: 1px solid #eef0f4; margin: 22px 0; }

/* --- MCP sub-section --- */
.mcp-connect__head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.mcp-connect__icon { width: 44px; height: 44px; font-size: 1rem; }
.mcp-connect__heading { flex: 1 1 auto; min-width: 0; }
.mcp-connect__title { font-weight: 700; font-size: 1rem; color: #1f2937; margin: 4px 0 4px; }
.mcp-connect__desc { color: #6b7280; font-size: .88rem; line-height: 1.5; margin: 0; }

.mcp-url {
    display: flex; align-items: center; gap: 12px;
    background: #f7f9fc;
    border: 1px solid #e6eaf2;
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 14px;
}
.mcp-url__icon { color: #9aa4b2; flex: 0 0 auto; }
.mcp-url__value {
    flex: 1 1 auto; min-width: 0;
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: .9rem; color: #334155;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mcp-url__value.is-placeholder {
    font-family: inherit; color: #9aa4b2; font-style: italic;
}
.mcp-url__copy {
    flex: 0 0 auto;
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid #dbe1ec; border-radius: 9px;
    background: #fff; color: var(--primary, #00629E); cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}
.mcp-url__copy:hover:not(:disabled) { background: rgba(0, 98, 158, .06); border-color: rgba(0, 98, 158, .35); }
.mcp-url__copy:disabled { color: #c2cad6; cursor: not-allowed; }

.mcp-note {
    display: flex; gap: 10px;
    background: rgba(0, 98, 158, .06);
    border-radius: 12px;
    padding: 12px 14px;
    color: #3f5165; font-size: .85rem; line-height: 1.5;
}
.mcp-note__icon { color: var(--primary, #00629E); flex: 0 0 auto; margin-top: 2px; }

/* ============================================================
   Automatic SKU Activation — one row per sales source.
   The source's brand colour is passed per row as --accent and each
   criterion's icon colour as --icon (both set inline from the view).
   The tick and tile states follow the app's primary colour.
   ============================================================ */
.sku-activation-row {
    display: flex;
    align-items: stretch;
    gap: 0;
    border: 1px solid #eef0f4;
    border-radius: 11px;
    overflow: hidden;
    margin-bottom: 9px;
    background: #fff;
}

/* --- brand column --- */
.sku-activation-row__brand {
    flex: 0 0 122px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 5px;
    padding: 12px 8px;
    background: color-mix(in srgb, var(--accent) 7%, #fff);
    border-right: 1px solid #eef0f4;
}
.sku-activation-row__brand img { max-width: 68px; max-height: 26px; object-fit: contain; }
.sku-activation-row__brand > i { font-size: 1.35rem; color: var(--accent); }
.sku-activation-row__name { font-weight: 700; font-size: .8rem; color: #1f2937; text-align: center; }
.sku-activation-row__underline { width: 18px; height: 2px; border-radius: 2px; background: var(--accent); }

/* --- criteria column --- */
.sku-activation-row__rules { flex: 1 1 auto; min-width: 0; padding: 10px 14px; }
.sku-activation-row__legend {
    text-transform: uppercase;
    letter-spacing: .04em;
    font-size: .66rem; font-weight: 700; color: #64748b;
    margin-bottom: 7px;
}
.sku-activation-row__match {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 9px;
    border-radius: 999px;
    background: rgba(0, 98, 158, .09);
    color: var(--primary);
    text-transform: none; letter-spacing: 0;
    font-size: .68rem; font-weight: 600;
    vertical-align: middle;
}

.sku-activation-tiles { display: flex; flex-wrap: wrap; gap: 7px; }
.sku-activation-tile {
    position: relative;
    display: flex; align-items: center; gap: 8px;
    /* min-width:0 lets a tile shrink past its label's intrinsic width, so the
       criteria stay on one line instead of wrapping the longest one onto its own */
    flex: 1 1 178px; min-width: 0;
    margin: 0;
    padding: 7px 10px;
    border: 1px solid #e6eaf2;
    border-radius: 9px;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}
.sku-activation-tile:hover:not(.is-disabled) { border-color: rgba(0, 98, 158, .35); background: #f8fafc; }
/* "Activate all new SKUs" supersedes the other criteria — they grey out while it is on */
.sku-activation-tile.is-disabled { opacity: .45; cursor: not-allowed; background: #fbfcfe; }
.sku-activation-tile.is-disabled .sku-activation__check { cursor: not-allowed; }
.sku-activation-tile:has(.sku-activation__check:checked) {
    border-color: var(--primary);
    background: rgba(0, 98, 158, .05);
}
/* radius intentionally left to theme.css so these match every other checkbox in the app */
.sku-activation__check { flex: 0 0 auto; margin: 0; cursor: pointer; }

.sku-activation-tile__icon {
    flex: 0 0 auto;
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    background: color-mix(in srgb, var(--icon) 13%, #fff);
    color: var(--icon);
    font-size: .74rem;
}
.sku-activation-tile__label { font-size: .76rem; font-weight: 600; color: #374151; line-height: 1.25; }

/* --- controls column --- */
.sku-activation-row__controls {
    flex: 0 0 168px;
    display: flex; flex-direction: column; justify-content: center;
    gap: 3px;
    padding: 10px 14px;
    border-left: 1px solid #eef0f4;
}
.sku-activation-row__lookback-label { font-size: .7rem; color: #6b7280; margin-bottom: 0; }
/* override the roomy .settings-card .form-control padding for this compact row */
.settings-card .sku-activation__lookback { padding: .3rem .5rem; font-size: .78rem; border-radius: 8px; }

@media (max-width: 991.98px) {
    .sku-activation-row { flex-wrap: wrap; }
    .sku-activation-row__brand {
        flex: 1 0 100%;
        flex-direction: row; justify-content: flex-start;
        padding: 9px 14px;
        border-right: none; border-bottom: 1px solid #eef0f4;
    }
    .sku-activation-row__underline { display: none; }
    .sku-activation-row__rules { flex: 1 0 100%; }
    .sku-activation-row__controls {
        flex: 1 0 100%;
        flex-direction: row; align-items: center; flex-wrap: wrap; gap: 12px;
        border-left: none; border-top: 1px solid #eef0f4;
    }
    .sku-activation-tile { min-width: 100%; }
}
