/* ============================================================
   AD Module Styles — dashboard widgets, cards, modals.
   Layout/sidebar use the global ThreatScope shell (style.css).
   ============================================================ */

/* ---------- Header actions (inside global .header > .header-right) ----------- */
.ad-actions {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    justify-content: flex-end;
}

.ad-conn-chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 14px; border-radius: 20px;
    font-size: 13px; font-weight: 600;
    border: 1px solid transparent;
}
.ad-conn-chip .ad-conn-dot { width: 8px; height: 8px; border-radius: 50%; }
.ad-conn-chip--connected { background: #eafaf1; color: #1a9f5a; border-color: #bfefd3; }
.ad-conn-chip--connected .ad-conn-dot { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
.ad-conn-chip--none { background: #f5f6fa; color: #8b8e99; border-color: #eef0f4; }
.ad-conn-chip--none .ad-conn-dot { background: #c0c4cc; }
.ad-conn-chip--stale { background: #fffbeb; color: #b06c00; border-color: #fde68a; }
.ad-conn-chip--stale .ad-conn-dot { background: #f59e0b; }

.ad-tb-btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 12px; border-radius: 9px;
    font-size: 12.5px; font-weight: 600;
    border: 1px solid transparent; cursor: pointer;
    transition: all .15s; white-space: nowrap;
}
.ad-tb-btn:disabled { opacity: .5; cursor: not-allowed; }
.ad-tb-btn--outline { background: #fff; color: #2e5aff; border-color: #c9d4ff; }
.ad-tb-btn--outline:hover:not(:disabled) { background: #f0f4ff; }
.ad-tb-btn--danger { background: #fff; color: #e34545; border-color: #ffc9c9; }
.ad-tb-btn--danger:hover:not(:disabled) { background: #fff5f5; }
.ad-tb-btn--primary {
    background: linear-gradient(135deg, #4f7cff, #2e5aff);
    color: #fff; box-shadow: 0 4px 14px rgba(79,124,255,.3);
    border: none;
}
.ad-tb-btn--primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(79,124,255,.35); }

.ad-last-scan { color: #8b8e99; font-size: 12.5px; font-weight: 500; padding: 0 6px; white-space: nowrap; }
.ad-tb-icon-btn {
    width: 38px; height: 38px; border-radius: 10px;
    background: #f5f6fa; border: 1px solid #eef0f4;
    color: #4a5568; cursor: pointer; position: relative;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; transition: all .15s;
}
.ad-tb-icon-btn:hover { background: #eef3ff; color: #2e5aff; }
.ad-tb-badge {
    position: absolute; top: -4px; right: -4px;
    background: #ef4444; color: #fff; font-size: 10px; font-weight: 700;
    width: 17px; height: 17px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff;
}

/* ---------- Page wrapper ----------- */
.ad-page { padding: 24px 28px 36px; }
.ad-page-head { margin-bottom: 20px; }
.ad-page-head h1 { font-size: 26px; font-weight: 800; color: #1a1d29; letter-spacing: -.4px; }
.ad-page-head p { font-size: 13px; color: #8b8e99; margin-top: 4px; }

/* ---------- KPI cards ----------- */
.ad-kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 20px; }
.ad-kpi {
    background: #fff; border-radius: 16px;
    padding: 20px 22px; border: 1px solid #eef0f4;
    box-shadow: 0 2px 10px rgba(0,0,0,.03);
    display: flex; gap: 16px; align-items: flex-start;
    transition: all .2s;
}
.ad-kpi-icon {
    width: 54px; height: 54px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
}
.ad-kpi--users .ad-kpi-icon { background: #eef3ff; color: #4f7cff; }
.ad-kpi--weak .ad-kpi-icon { background: #feeceb; color: #ef4444; }
.ad-kpi--inactive .ad-kpi-icon { background: #fff8e6; color: #f59e0b; }
.ad-kpi--priv .ad-kpi-icon { background: #f1ecff; color: #8b5cf6; }
.ad-kpi-body { flex: 1; min-width: 0; }
.ad-kpi-value { font-size: 30px; font-weight: 800; color: #1a1d29; line-height: 1.1; letter-spacing: -.4px; }
.ad-kpi-label { font-size: 13px; color: #8b8e99; margin-top: 2px; font-weight: 500; }
.ad-kpi-delta {
    display: inline-flex; align-items: center; gap: 4px;
    margin-top: 10px; font-size: 11.5px; font-weight: 600;
}
.ad-kpi-delta--up { color: #e34545; }
.ad-kpi-delta--down { color: #1a9f5a; }
.ad-kpi-delta--flat { color: #8b8e99; }
.ad-kpi-delta small { color: #a0a4ad; font-weight: 500; margin-left: 2px; }

/* ---------- Dashboard middle grid ----------- */
.ad-mid-grid {
    display: grid;
    grid-template-columns: 1.1fr 1.2fr 1fr 0.9fr;
    gap: 18px;
    margin-bottom: 20px;
}
.ad-card {
    background: #fff; border-radius: 16px;
    padding: 20px; border: 1px solid #eef0f4;
    box-shadow: 0 2px 10px rgba(0,0,0,.03);
    display: flex; flex-direction: column;
    min-height: 330px;
}
.ad-card h3 {
    font-size: 15px; font-weight: 700; color: #1a1d29;
    margin: 0 0 16px; letter-spacing: -.2px;
}
.ad-card-footer-link {
    margin-top: auto; padding-top: 14px;
    font-size: 13px; font-weight: 600;
    color: #2e5aff; text-decoration: none;
    display: inline-flex; align-items: center; gap: 6px;
}
.ad-card-footer-link:hover { text-decoration: underline; }

/* Donut chart card */
.ad-donut-wrap { display: flex; align-items: center; gap: 16px; flex: 1; }
.ad-donut-canvas-wrap { position: relative; width: 160px; height: 160px; flex-shrink: 0; }
.ad-donut-center {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    pointer-events: none;
}
.ad-donut-center-value { font-size: 22px; font-weight: 800; color: #1a1d29; line-height: 1; }
.ad-donut-center-label { font-size: 11px; color: #8b8e99; margin-top: 3px; font-weight: 500; }
.ad-donut-legend { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.ad-donut-legend-item {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; color: #4a5568;
}
.ad-donut-legend-item .ad-dot { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.ad-donut-legend-item .lg-label { flex: 1; }
.ad-donut-legend-item .lg-val { color: #8b8e99; font-weight: 600; font-size: 11.5px; }

/* Attack graph card (mini) */
.ad-mini-graph { flex: 1; min-height: 200px; border-radius: 10px; background: #fafbfd; }

/* Scan summary card */
.ad-kv-list { display: flex; flex-direction: column; gap: 0; flex: 1; }
.ad-kv-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 11px 0; border-bottom: 1px solid #f0f1f5;
    font-size: 13px;
}
.ad-kv-row:last-child { border-bottom: none; }
.ad-kv-row .k { color: #8b8e99; font-weight: 500; }
.ad-kv-row .v { color: #1a1d29; font-weight: 600; text-align: right; }
.ad-kv-row .v.badge-pill {
    background: #feeceb; color: #e34545; padding: 3px 10px; border-radius: 10px;
    font-size: 12px;
}

/* Quick actions card */
.ad-quick-list { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.ad-quick-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 10px;
    border: 1px solid #eef0f4; text-decoration: none;
    color: #4a5568; font-size: 13px; font-weight: 600;
    background: #fff; cursor: pointer; transition: all .15s;
}
.ad-quick-item:hover { border-color: #c9d4ff; color: #2e5aff; background: #f0f4ff; }
.ad-quick-item i { width: 16px; text-align: center; font-size: 13px; }

/* Connection info card */
.ad-conn-info { display: flex; flex-direction: column; gap: 0; flex: 1; }

/* ---------- Weak passwords table ----------- */
.ad-table-card {
    background: #fff; border-radius: 16px;
    border: 1px solid #eef0f4; overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,.03);
    margin-bottom: 20px;
}
.ad-table-head {
    padding: 18px 22px 14px;
    display: flex; justify-content: space-between; align-items: center; gap: 14px;
}
.ad-table-head h3 { font-size: 15px; font-weight: 700; color: #1a1d29; display: flex; align-items: center; gap: 10px; }
.ad-table-head h3 .ad-chip {
    background: #feeceb; color: #e34545; font-size: 11.5px; font-weight: 700;
    padding: 3px 10px; border-radius: 10px;
}
.ad-table-head .ad-see-all {
    color: #2e5aff; text-decoration: none; font-size: 13px; font-weight: 600;
    display: inline-flex; align-items: center; gap: 6px;
}
.ad-tbl { width: 100%; border-collapse: collapse; }
.ad-tbl thead th {
    padding: 12px 22px; text-align: left;
    font-size: 11.5px; font-weight: 600; color: #8b8e99;
    background: #fafbfd; border-top: 1px solid #eef0f4;
    border-bottom: 1px solid #eef0f4; text-transform: none; letter-spacing: 0;
    white-space: nowrap;
}
.ad-tbl tbody td {
    padding: 14px 22px; font-size: 13px; color: #1a1d29;
    border-bottom: 1px solid #f0f1f5; vertical-align: middle;
}
.ad-tbl tbody tr:last-child td { border-bottom: none; }
.ad-tbl .td-user { font-weight: 600; }
.ad-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; display: inline-block; margin-right: 6px; vertical-align: middle; }
.ad-risk-pill {
    padding: 3px 10px; border-radius: 8px;
    font-size: 11.5px; font-weight: 700;
}
.ad-risk-pill--high { background: #feeceb; color: #e34545; }
.ad-risk-pill--med { background: #fff8e6; color: #b06c00; }
.ad-risk-pill--low { background: #eafaf1; color: #1a9f5a; }

/* Pagination */
.ad-pag-bar {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 14px 22px; border-top: 1px solid #eef0f4;
}
.ad-pag-info { color: #8b8e99; font-size: 12px; }
.ad-pag-ctl { display: flex; align-items: center; gap: 4px; }
.ad-pag-btn {
    min-width: 32px; height: 32px; border-radius: 8px;
    background: #fff; border: 1px solid #eef0f4; cursor: pointer;
    font-size: 12.5px; font-weight: 600; color: #4a5568;
    display: inline-flex; align-items: center; justify-content: center; padding: 0 8px;
}
.ad-pag-btn:hover:not(:disabled) { border-color: #c9d4ff; color: #2e5aff; }
.ad-pag-btn.active { background: #2e5aff; color: #fff; border-color: #2e5aff; }
.ad-pag-btn:disabled { opacity: .4; cursor: not-allowed; }
.ad-pag-ellipsis { color: #8b8e99; padding: 0 4px; font-size: 13px; }
.ad-pag-size {
    padding: 6px 10px; border: 1px solid #eef0f4; border-radius: 8px;
    background: #fff; font-size: 12px; color: #4a5568;
}

/* ---------- Modal ----------- */
.ad-modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 1000;
    background: rgba(15,23,42,.45); align-items: center; justify-content: center;
}
.ad-modal-overlay.open { display: flex; }
.ad-modal {
    background: #fff; border-radius: 18px;
    width: 540px; max-width: 92vw; max-height: 90vh; overflow-y: auto;
    padding: 26px 28px; box-shadow: 0 30px 80px rgba(0,0,0,.25);
}
.ad-modal h3 {
    font-size: 17px; font-weight: 800; color: #1a1d29;
    margin-bottom: 18px; display: flex; align-items: center; gap: 10px;
}
.ad-modal h3 i { color: #2e5aff; }
.ad-modal .ad-form-group { margin-bottom: 13px; }
.ad-modal label { display: block; font-size: 12px; font-weight: 600; color: #4a5568; margin-bottom: 5px; }
.ad-modal input, .ad-modal select {
    width: 100%; padding: 10px 14px;
    border: 1.5px solid #eef0f4; border-radius: 10px;
    font-size: 13px; background: #fafbfd; color: #1a1d29;
}
.ad-modal input:focus, .ad-modal select:focus { outline: none; border-color: #2e5aff; background: #fff; box-shadow: 0 0 0 3px rgba(46,90,255,.1); }
.ad-modal-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ad-modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.ad-modal-actions .ad-tb-btn { flex: 1; justify-content: center; padding: 11px; font-size: 13.5px; }

.ad-progress { display: none; margin-top: 16px; background: #fafbfd; border-radius: 12px; padding: 14px; border: 1px solid #eef0f4; }
.ad-progress.visible { display: block; }
.ad-progress-step { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 12.5px; color: #b0bec5; font-weight: 500; }
.ad-progress-step i { width: 14px; font-size: 11px; }
.ad-progress-step.active { color: #2e5aff; font-weight: 600; }
.ad-progress-step.done { color: #22c55e; }

/* OU tree inside scan modal */
.ad-ou-panel { margin: 12px 0; padding: 12px; background: #fafbfd; border: 1px solid #eef0f4; border-radius: 10px; max-height: 220px; overflow-y: auto; }
.ad-ou-node { padding: 6px 10px; border-radius: 8px; cursor: pointer; font-size: 12.5px; color: #4a5568; display: flex; align-items: center; gap: 6px; }
.ad-ou-node:hover { background: #eef3ff; }
.ad-ou-node.selected { background: #eef3ff; color: #2e5aff; font-weight: 700; }
.ad-ou-node i { width: 12px; color: #a0a4ad; }
.ad-ou-node.selected i { color: #2e5aff; }
.ad-ou-count { margin-left: auto; font-size: 10.5px; color: #a0a4ad; }

/* Empty state */
.ad-empty {
    text-align: center; padding: 80px 20px;
    background: #fff; border-radius: 16px; border: 1px solid #eef0f4;
    box-shadow: 0 2px 10px rgba(0,0,0,.03);
}
.ad-empty i { font-size: 56px; color: #c0c4cc; margin-bottom: 16px; }
.ad-empty h3 { font-size: 17px; color: #1a1d29; font-weight: 700; margin-bottom: 6px; }
.ad-empty p { font-size: 13px; color: #8b8e99; max-width: 400px; margin: 0 auto 18px; line-height: 1.55; }
.ad-empty .ad-tb-btn { display: inline-flex; }

/* Generic content card for sub-pages (users/risks/etc) */
.ad-content-card { background: #fff; border-radius: 16px; border: 1px solid #eef0f4; box-shadow: 0 2px 10px rgba(0,0,0,.03); padding: 20px 22px; margin-bottom: 18px; }

/* ---------- Dashboard bridging: global stats-row / modern-card adopts AD content ---------- */
/* Stat icon tints (used on /ad dashboard) */
.stat-card-icon.stat-icon--users    { background: #eef3ff; color: #4f7cff; }
.stat-card-icon.stat-icon--weak     { background: #feeceb; color: #ef4444; }
.stat-card-icon.stat-icon--inactive { background: #fff8e6; color: #f59e0b; }
.stat-card-icon.stat-icon--priv     { background: #f1ecff; color: #8b5cf6; }

/* Delta badge inside .stat-card-footer (JS swaps class to --up/--down/--flat) */
.stat-card-footer .ad-kpi-delta {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; font-weight: 600; margin: 0;
}
.stat-card-footer .ad-kpi-delta small { color: #a0a4ad; font-weight: 500; margin-left: 2px; }

/* Quick-action icon tints for /ad */
.action-icon.ad-ic-scan    { background: #dbeafe; color: #2563eb; }
.action-icon.ad-ic-users   { background: #eef3ff; color: #4f7cff; }
.action-icon.ad-ic-risk    { background: #fee2e2; color: #dc2626; }
.action-icon.ad-ic-graph   { background: #ede9fe; color: #7c3aed; }
.action-icon.ad-ic-report  { background: #d1fae5; color: #059669; }
.action-icon.ad-ic-history { background: #fef3c7; color: #d97706; }

/* Inline chip next to modern-card title (e.g. "12" count) */
.modern-card-title .ad-chip {
    background: #feeceb; color: #e34545;
    font-size: 11px; font-weight: 700;
    padding: 2px 9px; border-radius: 10px;
    margin-left: 4px;
}

/* When donut / mini-graph / kv-list live inside a modern-card */
.modern-card .ad-donut-wrap { align-items: center; gap: 16px; }
.modern-card .ad-donut-canvas-wrap { width: 150px; height: 150px; flex-shrink: 0; }
.modern-card .ad-mini-graph { width: 100%; min-height: 220px; border-radius: 10px; background: #fafbfd; }
.modern-card .ad-kv-list { display: flex; flex-direction: column; }

/* Weak-password table flush-edge inside modern-card (negative margin to edge-align) */
.modern-card .ad-tbl-wrap { margin: 0 -22px; overflow-x: auto; }
.modern-card .ad-tbl--flush { width: 100%; border-collapse: collapse; }
.modern-card .ad-tbl--flush thead th { padding: 11px 22px; background: #fafbfd; border-top: 1px solid #eef0f4; border-bottom: 1px solid #eef0f4; }
.modern-card .ad-tbl--flush tbody td { padding: 13px 22px; }
.modern-card .ad-pag-bar--flush { margin: 0 -22px -22px; border-top: 1px solid #eef0f4; }

/* Connection info button inside modern-card */
.modern-card > #ci-disconnect { margin-top: 14px; }

/* Responsive */
@media (max-width: 1400px) {
    .ad-actions .ad-btn-text { display: none; }
    .ad-actions .ad-tb-btn { padding: 8px 10px; }
}
@media (max-width: 1300px) {
    .ad-mid-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
    .ad-kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .ad-mid-grid { grid-template-columns: 1fr; }
    .modern-card .ad-donut-wrap { flex-direction: column; }
}
