/*
 * admin.css — BriefBrew admin UI
 * Single source of truth. No duplicate blocks.
 * Bootstrap 4 overrides use !important only where Bootstrap specificity wins.
 */

/* ══════════════════════════════════════════════════════════════════════════
   1. DESIGN TOKENS
   Scoped to both .admin-page and .admin-modal-backdrop so modal children
   can resolve the same vars even though the modal lives outside .admin-page.
   ══════════════════════════════════════════════════════════════════════════ */
.admin-page,
.admin-modal-backdrop,
.admin-modal {
    --color-text:    #1a1a2e;
    --color-muted:   #6c757d;
    --color-border:  #e2e8f0;
    --color-bg:      #f8fafc;
    --color-surface: #ffffff;
    --color-primary: #3b82f6;
    --color-danger:  #ef4444;
    --font-mono:     'DM Mono', 'Courier New', monospace;
}


/* ══════════════════════════════════════════════════════════════════════════
   3. PAGE LAYOUT
   ══════════════════════════════════════════════════════════════════════════ */
.admin-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.page-title    { font-size: 1.5rem; font-weight: 700; color: var(--color-text); margin: 0; }
.page-subtitle { font-size: 0.875rem; color: var(--color-muted); margin: 0.25rem 0 0; }


/* ══════════════════════════════════════════════════════════════════════════
   4. TAB NAVIGATION
   ══════════════════════════════════════════════════════════════════════════ */
.tab-nav           { display: flex; flex-wrap: wrap; gap: 0.25rem; border-bottom: 1px solid var(--color-border); margin-bottom: 1.5rem; }
.tab-btn           { padding: 0.5rem 1rem; font-size: 0.85rem; font-weight: 500; color: var(--color-muted); background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; margin-bottom: -1px; transition: color 0.15s, border-color 0.15s; }
.tab-btn:hover     { color: var(--color-text); }
.tab-btn--active   { color: var(--color-primary); border-bottom-color: var(--color-primary); }


/* ══════════════════════════════════════════════════════════════════════════
   5. SETTINGS CARD
   ══════════════════════════════════════════════════════════════════════════ */
.settings-card              { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 0.75rem; padding: 1.5rem; }
.settings-card__title       { font-size: 1rem; font-weight: 700; margin: 0 0 0.25rem; }
.settings-card__desc        { font-size: 0.8rem; color: var(--color-muted); margin: 0 0 1.25rem; }
.settings-card__subtitle    { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-muted); margin: 1.5rem 0 0.75rem; border-top: 1px solid var(--color-border); padding-top: 1rem; }
.settings-card__subtitle:first-child { border-top: none; padding-top: 0; margin-top: 0; }


/* ══════════════════════════════════════════════════════════════════════════
   6. FORM ELEMENTS
   !important on focus rules — Bootstrap's _forms.scss and _reboot.scss
   both override outline/box-shadow at high specificity.
   ══════════════════════════════════════════════════════════════════════════ */
.form-grid        { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.form-group       { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group--full { grid-column: 1 / -1; }
.form-group--toggle {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
}

.form-label { font-size: 0.8rem; font-weight: 600; color: var(--color-text); }

.form-input {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border) !important;
    border-radius: 0.5rem !important;
    background: var(--color-bg) !important;
    color: var(--color-text) !important;
    width: 100%;
    box-sizing: border-box;
    box-shadow: none !important;
    transition: border-color 0.15s, box-shadow 0.15s;
    /* Bootstrap sets font-family: inherit which is fine */
}

.form-input:focus {
    outline: none !important;
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18) !important;
    background: #fff !important;
}

/* Select arrow fix — Bootstrap removes native arrow on some resets */
select.form-input {
    appearance: auto !important;
    -webkit-appearance: auto !important;
    cursor: pointer;
}

.form-input--mono {
    font-family: var(--font-mono) !important;
    font-size: 0.8rem !important;
    line-height: 1.65 !important;
    white-space: pre !important;
    word-break: normal !important;
    overflow-x: auto !important;
    tab-size: 2;
}

.form-input--disabled { opacity: 0.6 !important; cursor: not-allowed !important; }
.form-error           { font-size: 0.75rem; color: var(--color-danger); }
.hint                 { font-size: 0.72rem; color: var(--color-muted); font-weight: 400; }
.required             { color: var(--color-danger); }


/* ══════════════════════════════════════════════════════════════════════════
   7. COLOR PICKER
   ══════════════════════════════════════════════════════════════════════════ */
.color-field         { display: flex; align-items: center; gap: 0.5rem; }
.color-field__swatch { width: 2.25rem; height: 2.25rem; border-radius: 0.375rem; border: 1px solid var(--color-border); cursor: pointer; padding: 0; flex-shrink: 0; }
.color-field__text   { flex: 1; }


/* ══════════════════════════════════════════════════════════════════════════
   8. TOGGLE (iOS-style)
   ══════════════════════════════════════════════════════════════════════════ */
.toggle               { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.toggle input         { opacity: 0; width: 0; height: 0; }
.toggle__track        { position: absolute; inset: 0; background: var(--color-border); border-radius: 999px; cursor: pointer; transition: background 0.2s; }
.toggle__track::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform 0.2s; }
.toggle input:checked + .toggle__track              { background: var(--color-primary); }
.toggle input:checked + .toggle__track::before      { transform: translateX(18px); }

.toggle-list              { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--color-border); border-radius: 0.5rem; overflow: hidden; }
.toggle-row               { display: flex; align-items: center; justify-content: space-between; padding: 0.875rem 1rem; background: var(--color-surface); border-bottom: 1px solid var(--color-border); gap: 1rem; }
.toggle-row:last-child    { border-bottom: none; }
.toggle-row__label        { font-size: 0.875rem; font-weight: 600; display: block; }
.toggle-row__desc         { font-size: 0.78rem; color: var(--color-muted); display: block; margin-top: 0.1rem; }


/* ══════════════════════════════════════════════════════════════════════════
   9. CHECKBOX ROWS
   ══════════════════════════════════════════════════════════════════════════ */
.checkbox-row-group { display: flex; flex-direction: column; gap: 0.5rem; }
.checkbox-row       { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; cursor: pointer; }
.checkbox-row input { accent-color: var(--color-primary); width: 15px; height: 15px; flex-shrink: 0; }


/* ══════════════════════════════════════════════════════════════════════════
   10. SAVE BAR
   ══════════════════════════════════════════════════════════════════════════ */
.save-bar { position: sticky; bottom: 0; background: var(--color-bg); border-top: 1px solid var(--color-border); padding: 1rem 0; margin-top: 1.5rem; display: flex; justify-content: flex-end; z-index: 10; }


/* ══════════════════════════════════════════════════════════════════════════
   11. BUTTONS
   !important on modal footer buttons — Bootstrap's .btn specificity wins
   without it and renders the wrong background/border.
   ══════════════════════════════════════════════════════════════════════════ */
.btn          { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.5rem 1.1rem; font-size: 0.875rem; font-weight: 600; border-radius: 0.5rem; border: 1px solid transparent; cursor: pointer; transition: opacity 0.15s, background 0.15s; text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn--primary       { background: var(--color-primary) !important; border-color: var(--color-primary) !important; color: #fff !important; }
.btn--primary:hover { opacity: 0.88; }

.btn--ghost         { background: transparent !important; border-color: var(--color-border) !important; color: var(--color-text) !important; }
.btn--ghost:hover   { background: var(--color-bg) !important; }

.btn--danger        { background: var(--color-danger) !important; border-color: var(--color-danger) !important; color: #fff !important; }
.btn--danger:hover  { opacity: 0.88; }

.btn:hover { box-shadow: none !important; }

.btn-icon           { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 0.375rem; border: 1px solid var(--color-border); background: transparent; cursor: pointer; transition: background 0.15s, color 0.15s; color: var(--color-muted); }
.btn-icon--edit:hover   { background: var(--color-primary) !important; color: #fff !important; border-color: var(--color-primary) !important; }
.btn-icon--delete:hover { background: var(--color-danger) !important;  color: #fff !important; border-color: var(--color-danger) !important; }
.btn-icon--more         { color: var(--color-muted); }
.btn-icon--more:hover   { background: var(--color-bg) !important; border-color: var(--color-border) !important; color: var(--color-text) !important; }


/* ══════════════════════════════════════════════════════════════════════════
   12. DATA TABLE
   ══════════════════════════════════════════════════════════════════════════ */
.data-table-wrap            { overflow-x: auto; border: 1px solid var(--color-border); border-radius: 0.75rem; }
.data-table                 { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th              { text-align: left; padding: 0.75rem 1rem; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-muted); background: var(--color-bg); border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.data-table td              { padding: 0.75rem 1rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td     { background: rgba(59, 130, 246, 0.04); }
.row--deleted td            { opacity: 0.45; }
.row--inactive td           { opacity: 0.5; }
.empty-row                  { text-align: center; color: var(--color-muted); padding: 2.5rem !important; font-size: 0.875rem; }
.text-right                 { text-align: right !important; }


/* ══════════════════════════════════════════════════════════════════════════
   13. BADGES
   ══════════════════════════════════════════════════════════════════════════ */
.badge         { display: inline-block; padding: 0.15rem 0.5rem; font-size: 0.7rem; font-weight: 700; border-radius: 999px; white-space: nowrap; border: none !important; }
.badge--blue   { background: #dbeafe !important; color: #1d4ed8 !important; }
.badge--purple { background: #ede9fe !important; color: #6d28d9 !important; }
.badge--green  { background: #dcfce7 !important; color: #15803d !important; }
.badge--gray   { background: #e2e8f0 !important; color: #475569 !important; }

.badge-code { font-family: var(--font-mono, monospace); font-size: 0.75rem; background: var(--color-bg); border: 1px solid var(--color-border) !important; border-radius: 0.25rem; padding: 0.1rem 0.4rem; }
.cap-badges { display: flex; flex-wrap: wrap; gap: 0.25rem; }


/* ══════════════════════════════════════════════════════════════════════════
   14. STATUS DOTS
   ══════════════════════════════════════════════════════════════════════════ */
.status-dot               { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; font-weight: 600; }
.status-dot::before       { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status-dot--green::before { background: #22c55e; }
.status-dot--gray::before  { background: #94a3b8; }
.status-dot--red::before   { background: #ef4444; }


/* ══════════════════════════════════════════════════════════════════════════
   15. ADMIN MODAL
   Prefixed .admin-modal-* to avoid collision with Bootstrap's .modal-backdrop.
   ══════════════════════════════════════════════════════════════════════════ */
.admin-modal-backdrop {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.55) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 1060 !important;
    padding: 1rem !important;
}

.admin-modal {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.875rem;
    width: 100%;
    max-width: 540px;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    position: relative;
}

.admin-modal--sm { max-width: 400px; }
.admin-modal--lg { max-width: 680px; }

.admin-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    background: #ffffff;
    z-index: 1;
}

.admin-modal__title { font-size: 1rem; font-weight: 700; margin: 0; color: #1a1a2e; }

.admin-modal__close {
    background: none !important;
    border: none !important;
    font-size: 1.5rem;
    line-height: 1;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    box-shadow: none !important;
}
.admin-modal__close:hover { color: #1a1a2e; }

.admin-modal__body   { padding: 1.5rem; }

.admin-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 1.25rem;
    margin-top: 0.75rem;
    border-top: 1px solid #e2e8f0;
}


/* ══════════════════════════════════════════════════════════════════════════
   16. INFO BANNERS & ALERTS
   ══════════════════════════════════════════════════════════════════════════ */
.info-banner          { padding: 0.75rem 1rem; border-radius: 0.5rem; font-size: 0.85rem; margin-top: 1rem; }
.info-banner--warning { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }

.alert         { padding: 0.75rem 1rem; border-radius: 0.5rem; font-size: 0.875rem; margin-bottom: 1rem; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }


/* ══════════════════════════════════════════════════════════════════════════
   17. PROVIDER AVATAR
   ══════════════════════════════════════════════════════════════════════════ */
.provider-avatar {
    width: 28px; height: 28px;
    border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600;
    flex-shrink: 0;
}

.provider-avatar--blue   { background: #dbeafe; color: #1d4ed8; }
.provider-avatar--green  { background: #dcfce7; color: #15803d; }
.provider-avatar--amber  { background: #fef3c7; color: #92400e; }
.provider-avatar--purple { background: #ede9fe; color: #6d28d9; }
.provider-avatar--pink   { background: #fce7f3; color: #9d174d; }


/* ══════════════════════════════════════════════════════════════════════════
   18. PAYMENT PROVIDERS — DEFAULTS BAR
   ══════════════════════════════════════════════════════════════════════════ */
.provider-defaults-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding: 0.875rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.625rem;
}

.provider-defaults-bar__item  { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; }

.provider-defaults-bar__label {
    font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--color-muted);
    padding-right: 0.25rem; margin-right: 0.25rem;
    border-right: 1px solid var(--color-border);
}

.provider-defaults-bar__avatar {
    width: 22px; height: 22px;
    border-radius: 4px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 9px; font-weight: 700;
    flex-shrink: 0;
}

.provider-defaults-bar__name { font-weight: 600; color: var(--color-text); }


/* ══════════════════════════════════════════════════════════════════════════
   19. PAYMENT PROVIDERS — CREDENTIAL STACK
   ══════════════════════════════════════════════════════════════════════════ */
.cred-stack { display: flex; flex-direction: column; gap: 3px; }

.cred-item {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 0.78rem;
    font-family: var(--font-mono, monospace);
}

.cred-item--set   { color: #15803d; }
.cred-item--unset { color: var(--color-muted); }

/* Credential stored indicator inside modal */
.cred-indicator {
    display: flex; align-items: center; gap: 0.35rem;
    font-size: 0.75rem;
    color: #15803d;
    background: #dcfce7;
    border: 1px solid #86efac;
    border-radius: 0.375rem;
    padding: 0.3rem 0.6rem;
    margin-bottom: 0.4rem;
}


/* ══════════════════════════════════════════════════════════════════════════
   20. PAYMENT PROVIDERS — ROLE BADGES
   ══════════════════════════════════════════════════════════════════════════ */
.role-badges { display: flex; flex-wrap: wrap; gap: 3px; }

.role-badge {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    font-size: 0.65rem; font-weight: 700;
    letter-spacing: 0.04em; text-transform: uppercase;
    border-radius: 999px; white-space: nowrap;
}

.role-badge--default { background: #dbeafe; color: #1d4ed8; }
.role-badge--intl    { background: #ede9fe; color: #6d28d9; }


/* ══════════════════════════════════════════════════════════════════════════
   21. PAYMENT PROVIDERS — ACTION MENU (three-dot context menu)
   ══════════════════════════════════════════════════════════════════════════ */
.action-group { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.action-menu  { position: relative; }

.action-menu__dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    min-width: 185px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10);
    z-index: 200;
    overflow: hidden;
}

.action-menu__item {
    display: flex; align-items: center; gap: 0.5rem;
    width: 100%;
    padding: 0.6rem 0.875rem;
    font-size: 0.8rem; font-weight: 500;
    color: var(--color-text);
    background: none; border: none;
    cursor: pointer; text-align: left;
    transition: background 0.12s;
}

.action-menu__item:hover         { background: var(--color-bg); }
.action-menu__item--active       { color: var(--color-primary); font-weight: 600; }
.action-menu__item + .action-menu__item { border-top: 1px solid var(--color-border); }


/* ══════════════════════════════════════════════════════════════════════════
   22. UTILITIES
   ══════════════════════════════════════════════════════════════════════════ */
.hidden      { display: none !important; }
.mt-4        { margin-top: 1rem; }
.font-medium { font-weight: 600; }
.text-sm     { font-size: 0.875rem; }
.text-muted  { color: var(--color-muted); }