/* ═══════════════════════════════════════════════════════════════
   Webhooks Page — BEM namespace: wh-*
   Dockyfy Module 22: Webhook Management

   Design tokens used:
     var(--color-surface-dark)  = #1a2035   card/surface backgrounds
     var(--color-border-dark)   = #1e2a40   borders
     var(--color-text-muted)    = #94a3b8   muted text
   ═══════════════════════════════════════════════════════════════ */

/* ── Page wrapper ────────────────────────────────────────────── */
.wh-page {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ── Page header action ───────────────────────────────────────── */
.wh-add-btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1.1rem;
    font-size: .875rem;
    font-weight: 600;
    border-radius: .5rem;
    background: #6366f1;
    color: #fff;
    border: none;
    cursor: pointer;
    transition: background .15s, transform .1s;
}
.wh-add-btn:hover { background: #4f46e5; transform: translateY(-1px); }
.wh-add-btn .material-symbols-outlined { font-size: 1.1rem; }

/* ── Stats strip ─────────────────────────────────────────────── */
.wh-stats {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.wh-stat-card {
    flex: 1;
    min-width: 140px;
    background: var(--color-surface-dark);
    border: 1px solid var(--color-border-dark);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: .875rem;
}
.wh-stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}
.wh-stat-icon--total   { background: rgba(148,163,184,.1);  color: #94a3b8; }
.wh-stat-icon--active  { background: rgba(34,197,94,.12);   color: #22c55e; }
.wh-stat-icon--deliver { background: rgba(99,102,241,.15);  color: #818cf8; }
.wh-stat-icon--failed  { background: rgba(239,68,68,.12);   color: #ef4444; }
.wh-stat-info { display: flex; flex-direction: column; gap: .1rem; }
.wh-stat-value { font-size: 1.5rem; font-weight: 700; color: #f1f5f9; line-height: 1; }
.wh-stat-label { font-size: .75rem; color: #94a3b8; font-weight: 500; }

/* ── Integration ideas / use-cases ──────────────────────────── */
.wh-usecases {
    background: var(--color-surface-dark);
    border: 1px solid var(--color-border-dark);
    border-radius: .75rem;
    padding: 1.25rem 1.5rem;
}
.wh-usecases-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: 1rem;
}
.wh-usecases-header .material-symbols-outlined { font-size: 1.1rem; color: #818cf8; }
.wh-usecases-title { font-size: .875rem; font-weight: 700; color: #f1f5f9; margin: 0; }
.wh-usecases-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: .75rem;
}
.wh-usecase-card {
    display: flex;
    gap: .75rem;
    align-items: flex-start;
    padding: .875rem 1rem;
    background: rgba(255,255,255,.02);
    border: 1px solid var(--color-border-dark);
    border-radius: .6rem;
    transition: border-color .15s;
}
.wh-usecase-card:hover { border-color: rgba(99,102,241,.35); }
.wh-usecase-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    flex-shrink: 0;
}
.wh-usecase-icon--purple { background: rgba(99,102,241,.15);  color: #818cf8; }
.wh-usecase-icon--blue   { background: rgba(59,130,246,.15);  color: #60a5fa; }
.wh-usecase-icon--amber  { background: rgba(245,158,11,.12);  color: #fbbf24; }
.wh-usecase-icon--green  { background: rgba(34,197,94,.12);   color: #4ade80; }
.wh-usecase-icon--cyan   { background: rgba(34,211,238,.12);  color: #22d3ee; }
.wh-usecase-body { display: flex; flex-direction: column; gap: .25rem; }
.wh-usecase-heading { font-size: .8125rem; font-weight: 700; color: #f1f5f9; line-height: 1.3; }
.wh-usecase-desc { font-size: .775rem; color: #94a3b8; line-height: 1.55; }
.wh-usecase-desc code {
    font-size: .72rem;
    background: rgba(99,102,241,.15);
    color: #a5b4fc;
    padding: .05rem .28rem;
    border-radius: .25rem;
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* ── Webhook card list ───────────────────────────────────────── */
.wh-list {
    display: flex;
    flex-direction: column;
    gap: .875rem;
}

.wh-card {
    background: var(--color-surface-dark);
    border: 1px solid var(--color-border-dark);
    border-radius: .75rem;
    padding: 1.25rem 1.5rem;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .75rem 1rem;
    align-items: start;
    transition: border-color .15s;
}
.wh-card:hover { border-color: rgba(99,102,241,.4); }
.wh-card.wh-card--inactive { opacity: .65; }

.wh-card-main { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }

.wh-card-url {
    font-size: .9rem;
    font-weight: 600;
    color: #f1f5f9;
    word-break: break-all;
}
.wh-card-desc {
    font-size: .8rem;
    color: #94a3b8;
}

.wh-events {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-top: .35rem;
}
.wh-event-pill {
    font-size: .7rem;
    font-weight: 600;
    padding: .15rem .5rem;
    border-radius: 999px;
    background: rgba(99,102,241,.12);
    color: #818cf8;
    border: 1px solid rgba(99,102,241,.2);
}

.wh-meta {
    font-size: .75rem;
    color: #94a3b8;
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
    margin-top: .25rem;
}
.wh-meta-item { display: flex; align-items: center; gap: .25rem; }
.wh-meta-item .material-symbols-outlined { font-size: .9rem; }
.wh-meta-failed { color: #ef4444; }

/* ── Card actions ────────────────────────────────────────────── */
.wh-card-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.wh-toggle {
    position: relative;
    width: 2.5rem;
    height: 1.35rem;
    cursor: pointer;
    flex-shrink: 0;
}
.wh-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.wh-toggle-track {
    position: absolute;
    inset: 0;
    background: var(--color-border-dark);
    border-radius: 999px;
    transition: background .2s;
}
.wh-toggle input:checked + .wh-toggle-track { background: #6366f1; }
.wh-toggle-thumb {
    position: absolute;
    top: .175rem;
    left: .175rem;
    width: 1rem;
    height: 1rem;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
}
.wh-toggle input:checked ~ .wh-toggle-thumb { transform: translateX(1.15rem); }

.wh-icon-btn {
    background: none;
    border: 1px solid var(--color-border-dark);
    border-radius: .4rem;
    padding: .3rem .45rem;
    cursor: pointer;
    color: #94a3b8;
    display: flex;
    align-items: center;
    transition: color .15s, border-color .15s, background .15s;
}
.wh-icon-btn .material-symbols-outlined { font-size: 1rem; }
.wh-icon-btn:hover { color: #f1f5f9; border-color: #6366f1; background: rgba(99,102,241,.08); }
.wh-icon-btn--danger:hover { color: #ef4444; border-color: #ef4444; background: rgba(239,68,68,.06); }
.wh-icon-btn--test { color: #818cf8; }

/* ── Status badge ────────────────────────────────────────────── */
.wh-status-badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    font-size: .7rem;
    font-weight: 600;
    padding: .15rem .5rem;
    border-radius: 999px;
}
.wh-status-badge--active   { background: rgba(34,197,94,.12);  color: #16a34a; }
.wh-status-badge--inactive { background: var(--color-border-dark); color: #94a3b8; }

/* ── Empty state ─────────────────────────────────────────────── */
.wh-empty {
    text-align: center;
    padding: 4rem 2rem;
    color: #94a3b8;
}
.wh-empty .material-symbols-outlined { font-size: 3.5rem; opacity: .3; }
.wh-empty-title { font-size: 1rem; font-weight: 600; color: #f1f5f9; margin: .75rem 0 .25rem; }

/* ── Error banner ────────────────────────────────────────────── */
.wh-error-banner {
    display: flex;
    align-items: center;
    gap: .75rem;
    background: rgba(239,68,68,.08);
    border: 1px solid rgba(239,68,68,.25);
    border-radius: .6rem;
    padding: .75rem 1rem;
    color: #ef4444;
    font-size: .875rem;
    margin-bottom: 1rem;
}
.wh-error-banner .material-symbols-outlined { font-size: 1.1rem; flex-shrink: 0; }
.wh-error-banner button {
    margin-left: auto;
    background: none;
    border: 1px solid rgba(239,68,68,.3);
    border-radius: .35rem;
    color: #ef4444;
    font-size: .8rem;
    padding: .2rem .6rem;
    cursor: pointer;
}

/* ── Skeleton ────────────────────────────────────────────────── */
.wh-skeleton {
    border-radius: .75rem;
    height: 5rem;
    background: linear-gradient(90deg, var(--color-border-dark) 25%, var(--color-surface-dark) 50%, var(--color-border-dark) 75%);
    background-size: 200% 100%;
    animation: wh-shimmer 1.4s infinite;
    margin-bottom: .875rem;
}
@keyframes wh-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Modal (Add / Edit) ──────────────────────────────────────── */
.wh-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    inset: 0;                          /* modern shorthand */
    background: rgba(0,0,0,.82);       /* 82% opacity — hides content behind on dark theme */
    backdrop-filter: blur(3px);        /* glass-blur effect for extra separation */
    -webkit-backdrop-filter: blur(3px);
    z-index: 9999;                     /* above all dashboard chrome */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.wh-modal {
    position: relative;               /* own stacking context inside overlay */
    z-index: 10000;
    background: var(--color-surface-dark);
    border: 1px solid var(--color-border-dark);
    border-radius: 1rem;
    padding: 1.75rem;
    width: 100%;
    max-width: 540px;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0,0,0,.6);
}
.wh-modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #f1f5f9;
    margin: 0 0 1.25rem;
}

.wh-field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.wh-field label { font-size: .8rem; font-weight: 600; color: #94a3b8; }
.wh-field input, .wh-field textarea {
    background: #0f1929;
    border: 1px solid var(--color-border-dark);
    border-radius: .5rem;
    color: #f1f5f9;
    font-size: .875rem;
    padding: .55rem .75rem;
    outline: none;
    width: 100%;
    box-sizing: border-box;
    transition: border-color .15s;
}
.wh-field input:focus, .wh-field textarea:focus { border-color: #6366f1; }
.wh-field textarea { resize: vertical; min-height: 4rem; }

/* Event checkboxes — single column list so all events are always visible */
.wh-events-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .5rem;
}
/* On narrow viewports (< 400px) fall back to single column */
@media (max-width: 400px) {
    .wh-events-grid { grid-template-columns: 1fr; }
}
.wh-event-check {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .82rem;
    color: var(--text);
    cursor: pointer;
    padding: .55rem .75rem;
    border: 1px solid var(--border);
    border-radius: .5rem;
    transition: border-color .15s, background .15s, color .15s;
    user-select: none;
    min-height: 2.25rem;
}
.wh-event-check:hover {
    border-color: var(--accent);
    background: var(--accent-faint, rgba(99,102,241,.04));
}
.wh-event-check:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-faint, rgba(99,102,241,.1));
    color: var(--accent);
    font-weight: 600;
}
.wh-event-check input {
    accent-color: var(--accent);
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    cursor: pointer;
}

.wh-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: .6rem;
    margin-top: 1.25rem;
}
.wh-modal-cancel {
    background: none;
    border: 1px solid var(--color-border-dark);
    border-radius: .5rem;
    color: #94a3b8;
    font-size: .875rem;
    padding: .5rem 1rem;
    cursor: pointer;
    transition: color .15s, border-color .15s;
}
.wh-modal-cancel:hover { color: #f1f5f9; border-color: #94a3b8; }
.wh-modal-save {
    background: #6366f1;
    border: none;
    border-radius: .5rem;
    color: #fff;
    font-size: .875rem;
    font-weight: 600;
    padding: .5rem 1.2rem;
    cursor: pointer;
    transition: background .15s;
}
.wh-modal-save:hover { background: #4f46e5; }
.wh-modal-save:disabled { opacity: .5; cursor: not-allowed; }

/* ── Delivery log drawer ─────────────────────────────────────── */
.wh-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 400;
}
.wh-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 600px;
    background: var(--color-surface-dark);
    border-left: 1px solid var(--color-border-dark);
    display: flex;
    flex-direction: column;
    z-index: 401;
    box-shadow: -8px 0 30px rgba(0,0,0,.3);
}
.wh-drawer-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border-dark);
}
.wh-drawer-title {
    flex: 1;
    font-size: 1rem;
    font-weight: 700;
    color: #f1f5f9;
}
.wh-drawer-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    display: flex;
    align-items: center;
    padding: .25rem;
    border-radius: .35rem;
    transition: color .15s;
}
.wh-drawer-close:hover { color: #f1f5f9; }
.wh-drawer-body { flex: 1; overflow-y: auto; padding: 1rem; }

/* Delivery log item */
.wh-log-item {
    border: 1px solid var(--color-border-dark);
    border-radius: .6rem;
    padding: .875rem 1rem;
    margin-bottom: .6rem;
    font-size: .8rem;
}
.wh-log-header { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; }
.wh-log-attempt { font-weight: 700; color: #94a3b8; font-size: .75rem; }
.wh-log-time { color: #94a3b8; margin-left: auto; }
.wh-log-row { display: flex; gap: .5rem; align-items: flex-start; color: #94a3b8; line-height: 1.5; }
.wh-log-row-label { font-weight: 600; color: #f1f5f9; min-width: 70px; }
.wh-log-code-2xx { color: #22c55e; font-weight: 700; }
.wh-log-code-err { color: #ef4444; font-weight: 700; }

/* Status pill in log */
.wh-log-status {
    display: inline-flex; align-items: center; gap: .25rem;
    font-size: .7rem; font-weight: 700; padding: .1rem .45rem;
    border-radius: 999px;
}
.wh-log-status--success { background: rgba(34,197,94,.12); color: #16a34a; }
.wh-log-status--failed  { background: rgba(239,68,68,.1);  color: #ef4444; }
.wh-log-status--pending { background: var(--color-border-dark); color: #94a3b8; }

.wh-log-empty { text-align: center; padding: 3rem 1rem; color: #94a3b8; font-size: .875rem; }

/* pagination in drawer */
.wh-drawer-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .5rem;
    padding: .875rem 1.5rem;
    border-top: 1px solid var(--color-border-dark);
}
.wh-page-btn {
    background: none;
    border: 1px solid var(--color-border-dark);
    border-radius: .4rem;
    color: #94a3b8;
    padding: .3rem .6rem;
    font-size: .8rem;
    cursor: pointer;
    transition: color .15s, border-color .15s;
}
.wh-page-btn:hover:not(:disabled) { color: #f1f5f9; border-color: #6366f1; }
.wh-page-btn:disabled { opacity: .4; cursor: default; }
.wh-page-info { font-size: .8rem; color: #94a3b8; padding: 0 .25rem; }

/* ── Toast notification ──────────────────────────────────────── */
.wh-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: #22c55e;
    color: #fff;
    border-radius: .6rem;
    padding: .65rem 1.2rem;
    font-size: .875rem;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    z-index: 10001;
    animation: wh-toast-in .2s ease;
}
.wh-toast--err { background: #ef4444; }
@keyframes wh-toast-in {
    from { opacity: 0; transform: translateY(1rem); }
    to   { opacity: 1; transform: none; }
}

/* ── Delete confirm modal ────────────────────────────────────── */
.wh-confirm-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    inset: 0;
    background: rgba(0,0,0,.82);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.wh-confirm {
    position: relative;
    z-index: 10000;
    background: var(--color-surface-dark);
    border: 1px solid var(--color-border-dark);
    border-radius: .75rem;
    padding: 1.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 16px 40px rgba(0,0,0,.5);
}
.wh-confirm-title { font-size: 1rem; font-weight: 700; color: #f1f5f9; margin: 0 0 .5rem; }
.wh-confirm-body  { font-size: .875rem; color: #94a3b8; margin: 0 0 1.25rem; line-height: 1.6; }
.wh-confirm-actions { display: flex; justify-content: flex-end; gap: .6rem; }
.wh-confirm-cancel { background: none; border: 1px solid var(--color-border-dark); border-radius: .4rem; color: #94a3b8; padding: .45rem .9rem; cursor: pointer; font-size: .875rem; transition: color .15s, border-color .15s; }
.wh-confirm-cancel:hover { color: #f1f5f9; border-color: #94a3b8; }
.wh-confirm-delete { background: #ef4444; border: none; border-radius: .4rem; color: #fff; font-weight: 600; padding: .45rem .9rem; cursor: pointer; font-size: .875rem; transition: background .15s; }
.wh-confirm-delete:hover { background: #dc2626; }
.wh-confirm-delete:disabled { opacity: .5; cursor: not-allowed; }

/* ── Secret reveal ───────────────────────────────────────────── */
.wh-secret-box {
    background: #060f1e;
    border: 1px solid var(--color-border-dark);
    border-radius: .5rem;
    padding: .6rem .875rem;
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: .78rem;
    color: #a3e635;
    word-break: break-all;
    margin-top: .35rem;
}
