/* ========================================
   ConnectAI — Pages: Chat, Agents, Specs, Jira, Security, Webhooks
   ======================================== */

/* ── Contact/List Items (shared across pages) ── */
.contact-item {
    padding: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid transparent;
    transition: all 0.15s;
}
.contact-item:hover { background: var(--bg-hover); }
.contact-item.active {
    background: var(--primary-dim);
    border-color: var(--border-brand);
}
.contact-item.blocked {
    border-color: rgba(239,68,68,0.1);
    background: var(--red-dim);
}

.avatar {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: var(--ai-gradient);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: #fff; font-size: 13px;
    flex-shrink: 0;
}

.contact-info { flex: 1; min-width: 0; }
.contact-name {
    font-size: 13px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.contact-meta {
    font-size: 11px; color: var(--text-4);
    margin-top: 3px;
    display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
}

/* ── Chat Messages ── */
.msg-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 75%;
}
.msg-wrap.user { align-self: flex-start; }
.msg-wrap.assistant { align-self: flex-end; flex-direction: row-reverse; }
.msg-wrap.tool_log { align-self: flex-end; flex-direction: row-reverse; max-width: 80%; }

.msg-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    flex-shrink: 0;
    background: var(--bg-hover);
    color: var(--text-4);
    border: 1px solid var(--border);
}
.msg-wrap.assistant .msg-avatar {
    background: var(--primary-dim);
    color: var(--primary);
    border-color: var(--border-brand);
}

.msg-bubble {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.msg {
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 12.5px;
    line-height: 1.5;
    word-wrap: break-word;
    transition: transform 0.1s ease, box-shadow 0.15s ease;
}
.msg-wrap.user .msg {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    color: var(--text-1);
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    backdrop-filter: blur(8px);
}
.msg-wrap.user .msg:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}
.msg-wrap.assistant .msg {
    background: linear-gradient(135deg, var(--primary) 0%, color-mix(in srgb, var(--primary) 85%, #000) 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 10px rgba(108,71,255,0.25);
}
.msg-wrap.assistant .msg:hover {
    box-shadow: 0 4px 16px rgba(108,71,255,0.3);
    transform: translateY(-1px);
}
.msg-wrap.assistant .msg a { color: rgba(255,255,255,0.9); text-decoration: underline; }
.msg-wrap.assistant .msg code { background: rgba(255,255,255,0.15); color: #fff; }
.msg-wrap.assistant .msg pre { background: rgba(0,0,0,0.2); border-radius: 8px; }

.msg-wrap.tool_log .msg {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    font-size: 11px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--text-3);
    border-radius: var(--radius-xs);
    padding: 8px 12px;
}

.msg-sender {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-4);
    padding: 0 4px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.msg-wrap.assistant .msg-sender { justify-content: flex-end; }

.msg-time {
    font-size: 9px;
    color: var(--text-4);
    font-weight: 400;
    opacity: 0.7;
}

.msg-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-4);
}

.tool-call-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-3);
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 4px;
    margin-bottom: 4px;
}

/* Markdown inside messages */
.markdown-body { line-height: 1.6; }
.markdown-body p { margin: 0 0 8px; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin: 12px 0 4px; font-size: 14px; font-weight: 600; }
.markdown-body ul, .markdown-body ol { margin: 4px 0; padding-left: 20px; }
.markdown-body li { margin: 2px 0; }
.markdown-body code {
    background: var(--bg);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'SF Mono', 'Fira Code', monospace;
}
.markdown-body pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    overflow-x: auto;
    font-size: 12px;
    margin: 8px 0;
}

/* ── Specs ── */
.spec-row {
    display: flex;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-light);
}
.spec-name { font-size: 13px; flex: 1; }
.spec-chars {
    font-size: 11px;
    font-family: 'SF Mono', monospace;
    color: var(--text-3);
    width: 72px;
    text-align: right;
}

.pill {
    padding: 3px 10px;
    border-radius: var(--radius-xs);
    font-size: 11px;
    font-weight: 600;
}
.pill.zero { background: var(--bg); color: var(--text-4); border: 1px solid var(--border); }
.pill.low { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(234,179,8,0.15); }
.pill.high { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,0.15); }

/* ── Jira ── */
.jira-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.jira-form input,
.jira-form textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-1);
    outline: none;
    transition: border-color 0.15s;
}
.jira-form select {
    width: 100%;
}
.jira-form input:focus,
.jira-form textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-dim);
}
.jira-form textarea { resize: vertical; min-height: 80px; }

.issue-item {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    transition: all 0.15s;
    background: var(--bg-white);
}
.issue-item:hover { border-color: var(--border-brand); transform: translateY(-1px); box-shadow: var(--shadow); }
.issue-key { font-size: 12px; font-family: monospace; color: var(--primary); font-weight: 600; }
.issue-title { font-size: 14px; font-weight: 600; color: var(--text-1); }
.issue-title a { color: var(--primary); }
.issue-title a:hover { text-decoration: underline; }
.issue-status {
    display: inline-flex;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
}
.issue-meta { font-size: 12px; color: var(--text-3); margin-top: 6px; }

/* ── Security ── */
.sec-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--border);
    border-bottom: 1px solid var(--border);
}
.sec-stat {
    background: var(--bg-white);
    padding: 10px 8px;
    text-align: center;
    display: flex; flex-direction: column; gap: 2px;
}
.sec-stat__num {
    font-size: 20px; font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
    color: var(--primary);
    line-height: 1;
}
.sec-stat__num--warn { color: var(--yellow); }
.sec-stat__num--danger { color: var(--red); }
.sec-stat__num--ok { color: var(--green); }
.sec-stat__label {
    font-size: 9px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-4);
}

/* Filter chips */
.sec-filter {
    display: flex; gap: 4px; flex-wrap: wrap;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    align-items: center;
}
.sec-filter:empty { display: none; }
.sec-filter__label {
    font-size: 10px; color: var(--text-4);
    font-weight: 600; margin-right: 2px;
}
.sec-filter__chip {
    font-size: 10px; font-weight: 600;
    padding: 3px 8px; border-radius: var(--radius-xs);
    cursor: pointer;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-3);
    transition: all 0.15s;
    font-family: inherit;
}
.sec-filter__chip:hover { border-color: var(--border-brand); color: var(--text-2); }
.sec-filter__chip--active { background: var(--primary-dim); color: var(--primary); border-color: var(--border-brand); }
.sec-filter__chip--warn.sec-filter__chip--active { background: var(--yellow-dim); color: var(--yellow); border-color: rgba(234,179,8,0.2); }
.sec-filter__chip--danger.sec-filter__chip--active { background: var(--red-dim); color: var(--red); border-color: rgba(239,68,68,0.2); }
.sec-filter__chip--ok.sec-filter__chip--active { background: var(--green-dim); color: var(--green); border-color: rgba(34,197,94,0.2); }

/* Security log entry */
.sec-log-entry {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-white);
    transition: border-color 0.15s;
}
.sec-log-entry:hover { border-color: rgba(239,68,68,0.2); }
.sec-log-entry__header {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 6px; flex-wrap: wrap;
}
.sec-log-entry__time { font-size: 11px; color: var(--text-4); }
.sec-log-entry__cats { display: flex; gap: 4px; flex-wrap: wrap; }
.sec-log-entry__text {
    font-size: 12px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    background: var(--bg);
    padding: 8px 10px;
    border-radius: var(--radius-xs);
    color: var(--text-2);
    line-height: 1.5;
    word-break: break-all;
    white-space: pre-wrap;
}

/* Category cards */
.sec-cat-card {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-white);
    transition: all 0.15s;
}
.sec-cat-card:hover { border-color: var(--border-brand); }
.sec-cat-card__count {
    font-size: 24px; font-weight: 800;
    color: var(--red);
    font-variant-numeric: tabular-nums;
    min-width: 40px; text-align: center;
}
.sec-cat-card__info { flex: 1; }
.sec-cat-card__name { font-size: 13px; font-weight: 600; }
.sec-cat-card__desc { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ── Webhooks ── */
.wh-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}
.wh-detail-field__label {
    font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-4);
    margin-bottom: 4px;
}
.wh-detail-field__value { font-size: 13px; color: var(--text-1); }

/* Log code block */
.log-entry { padding: 10px 0; border-bottom: 1px solid var(--border-light); }
.log-entry:last-child { border-bottom: none; }
.log-code {
    font-size: 12px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    background: var(--bg);
    padding: 8px 10px;
    border-radius: var(--radius-xs);
    color: var(--text-2);
    line-height: 1.5;
    word-break: break-all;
    white-space: pre-wrap;
}

details > summary { list-style: none; cursor: pointer; user-select: none; }
details > summary::-webkit-details-marker { display: none; }

/* ══════════════════════════════════════════
   POC COMPONENTS (Dashboard, Detail panels, Tables)
══════════════════════════════════════════ */

/* ── Stats Row (Dashboard) ── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 20px;
}
.stat-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.stat-card__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.stat-card__icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
}
.stat-card__icon--purple { background: var(--primary-dim); color: var(--primary); }
.stat-card__icon--red { background: var(--red-dim); color: var(--red); }
.stat-card__icon--green { background: var(--green-dim); color: var(--green); }
.stat-card__icon--yellow { background: var(--yellow-dim); color: var(--yellow); }
.stat-card__change { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 2px; }
.stat-card__change--up { color: var(--green); }
.stat-card__change--down { color: var(--red); }
.stat-card__label {
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-3);
}
.stat-card__value { font-size: 28px; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.stat-card__desc { font-size: 12px; color: var(--text-4); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    text-align: left;
    padding: 10px 16px;
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-3);
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
tbody td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
tbody tr:hover { background: var(--bg); }
tbody tr:last-child td { border-bottom: none; }

/* ── Progress bar ── */
.progress {
    height: 8px;
    background: var(--border-light, #e5e7eb);
    border-radius: 4px;
    overflow: hidden;
    display: block;
    width: 80px;
    position: relative;
}
.progress--lg { height: 10px; width: 100%; border-radius: 5px; }
.progress__bar {
    display: block;
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
    min-width: 2px;
}
.progress__bar--green { background: linear-gradient(90deg, #22c55e, #4ade80); }
.progress__bar--yellow { background: linear-gradient(90deg, #eab308, #facc15); }
.progress__bar--red { background: linear-gradient(90deg, #ef4444, #f87171); }
.progress__bar--primary { background: linear-gradient(90deg, #6C47FF, #9b7aff); }

/* ── Tabs ── */
.tabs {
    display: flex; gap: 0;
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    background: var(--bg-white);
}
.tab {
    padding: 12px 16px;
    font-size: 13px; font-weight: 500;
    color: var(--text-3);
    border: none; background: none; cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.15s;
    display: flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--text-1); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.integTab.active { background: var(--primary-dim) !important; color: var(--primary) !important; font-weight: 600 !important; }

/* ── Detail header ── */
.detail-header {
    padding: 20px 24px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: flex-start; gap: 16px;
}
.detail-header__icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    background: var(--primary-dim);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
}
.detail-header__info { flex: 1; }
.detail-header__title {
    font-size: 20px; font-weight: 800;
    letter-spacing: -0.3px;
    display: flex; align-items: center; gap: 8px;
}
.detail-header__desc { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.detail-header__actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* ── Detail stats grid ── */
.detail-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    padding: 20px 24px;
}
.detail-stat {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.detail-stat__label {
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-3); margin-bottom: 8px;
}
.detail-stat__value { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
.detail-stat__desc { font-size: 12px; color: var(--text-4); margin-top: 4px; }

/* ── Credential fields ── */
.cred-section { padding: 20px 24px; }
.cred-section__title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.cred-section__desc { font-size: 13px; color: var(--text-3); margin-bottom: 16px; }
.cred-field { margin-bottom: 16px; }
.cred-field__label { font-size: 12px; font-weight: 600; color: var(--text-3); margin-bottom: 6px; }
.cred-field__row { display: flex; gap: 8px; }
.cred-field__input {
    flex: 1; padding: 10px 14px;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px; font-family: 'SF Mono','Fira Code',monospace;
    color: var(--text-2);
}
.cred-field__copy {
    width: 40px; height: 40px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-white);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-3); cursor: pointer; transition: all 0.15s;
}
.cred-field__copy:hover { background: var(--bg-hover); color: var(--text-1); }

/* ── Activity feed ── */
.feed { display: flex; flex-direction: column; gap: 4px; }
.feed-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); transition: background .15s ease; }
.feed-item:hover { background: var(--bg-hover); }
.feed-item__avatar {
    width: 36px; height: 36px;
    border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: #fff;
    position: relative;
}
.feed-item__avatar--purple { background: linear-gradient(135deg, #A78BFA, #6C47FF); }
.feed-item__avatar--blue { background: linear-gradient(135deg, #93C5FD, #3B82F6); }
.feed-item__avatar--green { background: linear-gradient(135deg, #86EFAC, #22C55E); }
.feed-item__avatar--red { background: linear-gradient(135deg, #FCA5A5, #EF4444); }
.feed-item__status {
    position: absolute; bottom: -2px; right: -2px;
    width: 12px; height: 12px; border-radius: 50%;
    border: 2px solid var(--bg-white);
}
.feed-item__status--green { background: var(--green); }
.feed-item__status--red { background: var(--red); }
.feed-item__body { flex: 1; }
.feed-item__text { font-size: 13px; color: var(--text-2); }
.feed-item__text b { color: var(--text-1); font-weight: 600; }
.feed-item__time { font-size: 11px; color: var(--text-4); margin-top: 2px; }

/* ── Health bars ── */
.health-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.health-bar__label { font-size: 13px; color: var(--text-2); }
.health-bar__value { font-size: 13px; font-weight: 700; }
.health-bar__track { width: 100%; height: 6px; background: var(--border-light); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.health-bar__fill { height: 100%; border-radius: 3px; }
.health-bar__fill--green { background: var(--green); }
.health-bar__fill--blue { background: var(--blue); }

/* ── Live badge ── */
.live-badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11px; font-weight: 600;
    color: var(--green); background: var(--green-dim);
    padding: 3px 10px; border-radius: 100px;
    border: 1px solid rgba(34,197,94,0.15);
}
.live-badge__dot {
    width: 6px; height: 6px; background: var(--green);
    border-radius: 50%; animation: livePulse 2s infinite;
}
@keyframes livePulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ── Action Tags (clickable badges) ── */
.action-tag {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11px; font-weight: 600;
    padding: 4px 12px; border-radius: 100px;
    cursor: pointer; transition: all .15s;
    user-select: none;
}
.action-tag--primary {
    color: var(--primary); background: var(--primary-dim);
    border: 1px solid rgba(108,71,255,0.15);
}
.action-tag--primary:hover { background: var(--primary); color: #fff; }
.action-tag--red {
    color: var(--red); background: var(--red-dim);
    border: 1px solid rgba(239,68,68,0.15);
}
.action-tag--red:hover { background: var(--red); color: #fff; }
.action-tag--green {
    color: var(--green); background: var(--green-dim);
    border: 1px solid rgba(34,197,94,0.15);
}
.action-tag--green:hover { background: var(--green); color: #fff; }

/* ── 3-dot menu ── */
.dots-menu {
    width: 32px; height: 32px;
    border: 1px solid var(--border); border-radius: var(--radius-xs);
    background: none; display: flex; align-items: center; justify-content: center;
    color: var(--text-3); font-size: 16px; cursor: pointer;
}
.dots-menu:hover { background: var(--bg-hover); }

/* ── Page scroll container ── */
.page-scroll { flex: 1; overflow-y: auto; padding: 20px 32px 32px; }

/* ── Chat tool items ── */
.chat-tool-item:hover {
    background: var(--bg-hover) !important;
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .detail-stats { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .wh-detail-grid { grid-template-columns: 1fr; }
    .sec-stats { grid-template-columns: repeat(3, 1fr); }
    .stats-row { grid-template-columns: 1fr 1fr; }
}
