/* =========================================================
   AmbientePay Hub — Admin Styles
   ========================================================= */

:root {
    --ap-accent:   #5b7dff;
    --ap-purple:   #a855f7;
    --ap-ok-bg:    #f0fdf4;
    --ap-ok-bd:    #bbf7d0;
    --ap-ok-tx:    #166534;
    --ap-warn-bg:  #fefce8;
    --ap-warn-bd:  #fef08a;
    --ap-warn-tx:  #854d0e;
    --ap-danger:   #ef4444;
    --ap-radius:   8px;
    --ap-shadow:   0 1px 4px rgba(0,0,0,.08);
}

/* ── Layout ─────────────────────────────────────────────── */

.ap-hub { max-width: 1400px; }

.ap-hub__header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0 8px;
}

.ap-hub__logo-dot {
    display: inline-block;
    width: 32px; height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--ap-accent), var(--ap-purple));
    flex-shrink: 0;
}

.ap-hub__title {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1d2327;
    margin: 0;
    line-height: 1;
}

.ap-hub__title small {
    font-size: .85rem;
    font-weight: 400;
    color: #888;
    margin-left: 4px;
}

.ap-accent { color: var(--ap-accent); }

/* ── Tabs ────────────────────────────────────────────────── */

.ap-hub__nav {
    margin-bottom: 0 !important;
    border-bottom: 1px solid #c3c4c7;
}

.ap-hub__nav .nav-tab { font-size: .9rem; }

.ap-tab--active,
.ap-hub__nav .nav-tab-active {
    border-bottom-color: #fff !important;
    background: #fff;
    color: var(--ap-accent) !important;
    font-weight: 600;
}

/* ── Body ────────────────────────────────────────────────── */

.ap-hub__body {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-top: none;
    padding: 24px;
    border-radius: 0 0 var(--ap-radius) var(--ap-radius);
}

/* ── Card ────────────────────────────────────────────────── */

.ap-card { max-width: 1200px; }

.ap-card h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0 0 6px;
    color: #1d2327;
}

.ap-card__desc {
    color: #646970;
    font-size: .88rem;
    margin: 0 0 20px;
    line-height: 1.5;
}

.ap-divider {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 24px 0;
}

/* ── Badges ──────────────────────────────────────────────── */

.ap-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--ap-radius);
    font-size: .85rem;
    font-weight: 500;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.ap-badge--ok      { background: var(--ap-ok-bg);   border-color: var(--ap-ok-bd);   color: var(--ap-ok-tx); }
.ap-badge--warn    { background: var(--ap-warn-bg);  border-color: var(--ap-warn-bd); color: var(--ap-warn-tx); }
.ap-badge--neutral { background: #f3f4f6; border-color: #d1d5db; color: #374151; }

/* ── Webhook endpoints table ─────────────────────────────── */

.ap-endpoints { border-collapse: collapse; margin-top: 8px; width: 100%; max-width: 700px; }
.ap-endpoints td { padding: 10px 14px; border: 1px solid #e5e7eb; font-size: .87rem; }
.ap-endpoints__label { font-weight: 600; color: #444; white-space: nowrap; }
.ap-endpoints code { background: #f3f4f6; padding: 4px 8px; border-radius: 4px; font-size: .82rem; }

/* ── Checkout Fields — compact sortable rows ─────────────── */

.ap-checkout-card { max-width: 720px; }

.ap-fields-section { margin-bottom: 24px; }

.ap-fields-section__head {
    font-size: .82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #6b7280;
    padding: 6px 10px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
}

.ap-field-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid #e5e7eb;
    border-radius: 0 0 6px 6px;
    overflow: hidden;
}

.ap-field-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    background: #fff;
    border-bottom: 1px solid #f3f4f6;
    cursor: default;
    transition: background .1s;
    min-height: 36px;
}

.ap-field-row:last-child { border-bottom: none; }
.ap-field-row:hover      { background: #f9fafb; }
.ap-field-row.ui-sortable-helper {
    background: #eff6ff;
    border: 1px solid var(--ap-accent);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(91,125,255,.15);
}
.ap-field-row.ui-sortable-placeholder {
    background: #f0f7ff;
    border: 1px dashed var(--ap-accent);
    visibility: visible !important;
}

.ap-drag-handle {
    cursor: grab;
    color: #c4c4c4;
    font-size: 1rem;
    user-select: none;
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}
.ap-drag-handle:active { cursor: grabbing; }

.ap-field-row__label {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    cursor: pointer;
    min-width: 0;
}

.ap-field-row__label input[type=checkbox] { margin: 0; flex-shrink: 0; }

.ap-field-row__name {
    font-size: .875rem;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
}

.ap-field-row__key {
    margin-left: auto;
    font-size: .75rem;
    color: #9ca3af;
    font-family: monospace;
    background: #f3f4f6;
    padding: 1px 6px;
    border-radius: 3px;
    white-space: nowrap;
    flex-shrink: 0;
}

.ap-required  { color: #ef4444; margin-left: 2px; font-style: normal; }
.ap-lock-icon { margin-left: 4px; font-size: .8rem; }

/* ── Toggle switch ───────────────────────────────────────── */

.ap-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.ap-toggle input[type=checkbox] { display: none; }

.ap-toggle__track {
    width: 40px; height: 22px;
    background: #d1d5db;
    border-radius: 11px;
    position: relative;
    transition: background .2s;
    flex-shrink: 0;
}

.ap-toggle__track::after {
    content: '';
    position: absolute;
    left: 3px; top: 3px;
    width: 16px; height: 16px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    transition: left .2s;
}

.ap-toggle input:checked ~ .ap-toggle__track { background: var(--ap-accent); }
.ap-toggle input:checked ~ .ap-toggle__track::after { left: 21px; }

.ap-toggle--small .ap-toggle__track { width: 32px; height: 18px; border-radius: 9px; }
.ap-toggle--small .ap-toggle__track::after { width: 12px; height: 12px; }
.ap-toggle--small input:checked ~ .ap-toggle__track::after { left: 17px; }

.ap-toggle__label { font-size: .9rem; font-weight: 500; color: #374151; }

.ap-toggle-row {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 16px;
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: var(--ap-radius);
    margin-bottom: 20px;
}

/* ── Notice box ──────────────────────────────────────────── */

.ap-notice-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--ap-radius);
    padding: 14px 18px;
    margin-bottom: 20px;
    font-size: .87rem;
    color: #1e40af;
}

.ap-notice-box ul {
    margin: 6px 0 0 18px;
    list-style: disc;
}

.ap-notice-box li { margin-bottom: 3px; }

/* ── Tables ──────────────────────────────────────────────── */

.ap-table { margin-bottom: 20px; }
.ap-table th { font-weight: 600; font-size: .85rem; color: #374151; }
.ap-table td, .ap-table th { padding: 12px 16px; vertical-align: middle; }

/* ── Product link row ────────────────────────────────────── */

.ap-link-row { display: flex; gap: 6px; align-items: center; }

.ap-link-input {
    flex: 1;
    font-size: .8rem;
    font-family: monospace;
    padding: 5px 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    color: #374151;
    background: #f9fafb;
    cursor: text;
}

.ap-copy-btn { flex-shrink: 0; }
.ap-copy-btn.copied { background: var(--ap-ok-bg); border-color: var(--ap-ok-bd); color: var(--ap-ok-tx); }

.ap-btn-regen {
    flex-shrink: 0;
    color: #6b7280 !important;
    border-color: #d1d5db !important;
    padding: 0 8px !important;
    font-size: 1rem;
    line-height: 1;
}
.ap-btn-regen:hover { color: var(--ap-danger) !important; border-color: #fca5a5 !important; }

.ap-select-small { height: 30px; padding: 2px 6px; font-size: .85rem; }

.ap-muted { color: #9ca3af; font-size: .82rem; }

/* ── Subscriptions inline ─────────────────────────────────── */

.ap-sub-label { margin-left: 6px; }

/* ── My Account Subscriptions (frontend) ─────────────────── */

.ap-my-subs h2 { margin-bottom: 16px; }

.ap-subs-table { width: 100%; border-collapse: collapse; }
.ap-subs-table th, .ap-subs-table td {
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    font-size: .9rem;
}
.ap-subs-table th { background: #f9fafb; font-weight: 600; }

.ap-sub-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: .78rem;
    font-weight: 600;
}
.ap-sub-status--active  { background: var(--ap-ok-bg);   color: var(--ap-ok-tx); }
.ap-sub-status--expired { background: #fef2f2; color: #991b1b; }

/* ── Checkout flat field list ────────────────────────────── */

.ap-fields-flat-header {
    display: grid;
    grid-template-columns: 28px 1fr 56px 72px;
    gap: 8px;
    align-items: center;
    padding: 6px 10px;
    font-size: .75rem;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 4px;
}
.ap-col-drag  {}
.ap-col-show,
.ap-col-req   { text-align: center; }

.ap-sortable-flat { list-style: none; margin: 0; padding: 0; }

.ap-sortable-flat .ap-field-row {
    display: grid;
    grid-template-columns: 28px 1fr 56px 72px;
    gap: 8px;
    align-items: center;
    padding: 7px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 5px;
    margin-bottom: 4px;
    background: #fff;
    transition: background .15s;
}
.ap-sortable-flat .ap-field-row:hover { background: #f9fafb; }
.ap-sortable-flat .ap-field-row.ui-sortable-helper {
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
    background: #fff;
    border-color: var(--ap-accent);
}
.ap-sortable-flat .ui-sortable-placeholder {
    background: #eff6ff;
    border: 1px dashed var(--ap-accent);
    border-radius: 5px;
    visibility: visible !important;
}

.ap-field-row .ap-drag-handle {
    cursor: grab;
    color: #9ca3af;
    font-size: 1.1rem;
    line-height: 1;
    user-select: none;
}
.ap-field-row .ap-drag-handle:active { cursor: grabbing; }

.ap-col-name {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    flex-wrap: wrap;
}

.ap-group-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 9999px;
    font-size: .68rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: .03em;
    white-space: nowrap;
    flex-shrink: 0;
}

.ap-col-show input,
.ap-col-req  input {
    display: block;
    margin: 0 auto;
    width: 16px;
    height: 16px;
    cursor: pointer;
}
.ap-col-show input:disabled,
.ap-col-req  input:disabled { opacity: .4; cursor: not-allowed; }

