/* ==========================================================================
   Compliance (cmp-* component family)
   Activity log, users summary, active sessions and retention for admins,
   plus the "Compliance log" tab on staff and client contact profiles.
   Tokens from design_language.md. Dark mode rules are at the end of this
   file: color/000001.css is cached by app_version only, so rules added
   there don't reach browsers until the version is bumped, while this file
   is cache-busted by its modification time (load_css).
   ========================================================================== */

/* Page header
   ========================================================================== */
.cmp-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin: 0 0 20px 0;
}

.cmp-page-header__title {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.4px;
    color: #1f2937;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.cmp-page-header__title i {
    color: #8b1a4a;
    font-size: 22px;
}

.cmp-page-header__subtitle {
    color: #6b7280;
    font-size: 13px;
    font-weight: 500;
    margin-top: 4px;
    max-width: 760px;
}

.cmp-page-header__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Buttons
   ========================================================================== */
.cmp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    line-height: 18px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    text-decoration: none !important;
    transition: all .15s ease;
    white-space: nowrap;
}

.cmp-btn:hover { transform: translateY(-1px); }
.cmp-btn:active { transform: translateY(0); }

.cmp-btn--primary { background: #8b1a4a; color: #ffffff; }
.cmp-btn--primary:hover,
.cmp-btn--primary:focus { background: #a8325f; color: #ffffff; }

.cmp-btn--outline { background: #ffffff; color: #374151; border-color: #d1d5db; }
.cmp-btn--outline:hover,
.cmp-btn--outline:focus { background: #f9fafb; color: #1f2937; }

.cmp-btn--danger { background: #fee2e2; color: #991b1b; }
.cmp-btn--danger:hover,
.cmp-btn--danger:focus { background: #fecaca; color: #991b1b; }

.cmp-btn--sm { padding: 6px 12px; font-size: 12px; }

/* Icon-only row actions (info, sign out) */
.cmp-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    color: #6b7280 !important;
    background: transparent;
    transition: all .15s ease;
    text-decoration: none !important;
}

.cmp-icon-btn:hover { background: #f3f4f6; color: #8b1a4a !important; }
.cmp-icon-btn--danger:hover { background: #fee2e2; color: #991b1b !important; }

/* KPI cards
   ========================================================================== */
.cmp-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.cmp-kpi {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 16px;
    min-height: 82px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: all .2s ease;
    cursor: pointer;
    text-decoration: none !important;
}

.cmp-kpi:hover {
    border-color: #d1d5db;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.cmp-kpi__icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.cmp-kpi__icon--primary { background: rgba(139, 26, 74, 0.1); color: #8b1a4a; }
.cmp-kpi__icon--blue    { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.cmp-kpi__icon--green   { background: rgba(34, 197, 94, 0.1); color: #22c55e; }
.cmp-kpi__icon--accent  { background: rgba(212, 160, 74, 0.12); color: #d4a04a; }
.cmp-kpi__icon--red     { background: rgba(220, 38, 38, 0.1); color: #dc2626; }

.cmp-kpi__info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.cmp-kpi__number {
    font-size: 26px;
    font-weight: 800;
    line-height: 1.1;
    color: #1f2937;
}

.cmp-kpi__label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #6b7280;
    margin-top: 2px;
}

.cmp-kpi__hint {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 2px;
}

/* Card with tab bar
   ========================================================================== */
.cmp-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    margin-bottom: 16px;
    overflow: hidden;
}

.cmp-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid #f0f0f5;
}

.cmp-card-header__title {
    font-size: 14px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cmp-card-header__title i { color: #8b1a4a; }

.cmp-card-body { padding: 20px; }

.cmp-card-note {
    font-size: 12px;
    color: #6b7280;
    padding: 12px 20px 0;
}

.cmp-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
    border: none !important;
}

.cmp-tabs > li { float: none !important; margin: 0 !important; }

.cmp-tabs > li > a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px !important;
    border-radius: 10px !important;
    border: none !important;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280 !important;
    background: transparent !important;
    transition: all .15s ease;
}

.cmp-tabs > li > a:hover { background: #f9fafb !important; color: #1f2937 !important; }

.cmp-tabs > li.active > a,
.cmp-tabs > li.active > a:hover,
.cmp-tabs > li.active > a:focus {
    background: rgba(139, 26, 74, 0.08) !important;
    color: #8b1a4a !important;
}

.cmp-tabs__count {
    font-size: 11px;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 20px;
    background: #f3f4f6;
    color: #4b5563;
}

.cmp-tabs > li.active .cmp-tabs__count { background: rgba(139, 26, 74, 0.12); color: #8b1a4a; }

/* Data tables inside a compliance card (appTable / DataTables)
   ========================================================================== */
.cmp-card table.dataTable {
    border-collapse: collapse !important;
    margin: 0 !important;
}

.cmp-card table.dataTable thead th {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #6b7280;
    background: transparent;
    border-bottom: 2px solid #e5e7eb !important;
    border-top: none !important;
    padding: 12px 14px !important;
    white-space: nowrap;
}

.cmp-card table.dataTable tbody td {
    font-size: 13px;
    color: #374151;
    border-top: none !important;
    border-bottom: 1px solid #f5f5fa !important;
    padding: 12px 14px !important;
    vertical-align: top;
}

.cmp-card table.dataTable tbody tr:hover td { background: #fafbfc; }

.cmp-card table.dataTable tbody td a { color: #8b1a4a; }
.cmp-card table.dataTable tbody td a:hover { color: #a8325f; }

/* Pills
   ========================================================================== */
.cmp-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    line-height: 16px;
    white-space: nowrap;
}

.cmp-pill--primary { background: rgba(139, 26, 74, 0.1); color: #8b1a4a; }
.cmp-pill--neutral { background: #f3f4f6; color: #374151; }
.cmp-pill--success { background: #dcfce7; color: #166534; }
.cmp-pill--warning { background: #fef3c7; color: #92400e; }
.cmp-pill--info    { background: #dbeafe; color: #1e40af; }
.cmp-pill--error   { background: #fee2e2; color: #991b1b; }
.cmp-pill--orange  { background: #fed7aa; color: #9a3412; }

/* status dot inside a pill (online / idle) */
.cmp-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    display: inline-block;
}

.cmp-pill--success .cmp-dot { animation: cmp-pulse 2s infinite; }

@keyframes cmp-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .35; }
}

/* Cells
   ========================================================================== */
.cmp-user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.cmp-user__avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid #e5e7eb;
}

.cmp-user__name {
    font-weight: 600;
    color: #1f2937 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.cmp-user__name:hover { color: #8b1a4a !important; }

.cmp-user__sub {
    font-size: 12px;
    color: #9ca3af;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cmp-time {
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
}

.cmp-time__sub {
    display: block;
    font-size: 12px;
    color: #9ca3af;
}

.cmp-page__name {
    font-weight: 600;
    color: #1f2937;
}

.cmp-mono,
.cmp-page__uri {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 11px;
    color: #9ca3af;
    word-break: break-all;
}

.cmp-page__uri .cmp-method {
    font-weight: 700;
    color: #6b7280;
    margin-right: 4px;
}

.cmp-nowrap { white-space: nowrap; }

.cmp-details { color: #4b5563; font-size: 12px; line-height: 18px; }

.cmp-details__data {
    display: block;
    margin-top: 2px;
    color: #9ca3af;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 11px;
    word-break: break-all;
}

.cmp-status-ok    { color: #166534; font-weight: 600; }
.cmp-status-redirect { color: #6b7280; font-weight: 600; }
.cmp-status-error { color: #991b1b; font-weight: 600; }

.cmp-number { font-weight: 700; color: #1f2937; }
.cmp-number--zero { color: #d1d5db; font-weight: 500; }
.cmp-number--alert { color: #991b1b; }

/* Detail modal
   ========================================================================== */
.cmp-detail-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding-bottom: 16px;
    margin-bottom: 4px;
    border-bottom: 1px solid #f0f0f5;
}

.cmp-detail-head__title {
    font-size: 15px;
    font-weight: 700;
    color: #1f2937;
}

.cmp-detail-grid {
    display: grid;
    grid-template-columns: 170px 1fr;
}

.cmp-detail-grid > dt,
.cmp-detail-grid > dd {
    padding: 10px 0;
    border-bottom: 1px solid #f5f5fa;
    margin: 0;
}

.cmp-detail-grid > dt {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #6b7280;
    padding-right: 12px;
}

.cmp-detail-grid > dd {
    font-size: 13px;
    color: #374151;
    word-break: break-word;
}

.cmp-detail-grid > dd .cmp-mono { font-size: 12px; color: #374151; }
.cmp-detail-grid > dd .cmp-mono--faint { color: #9ca3af; }

.cmp-code {
    background: #f9fafb;
    border: 1px solid #f0f0f5;
    border-radius: 8px;
    padding: 10px 12px;
    margin: 0;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 12px;
    color: #374151;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 320px;
    overflow: auto;
}

/* Retention form
   ========================================================================== */
.cmp-form-row {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 16px;
    align-items: start;
}

.cmp-form-label {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    padding-top: 7px;
}

.cmp-form-help {
    font-size: 12px;
    color: #6b7280;
    margin-top: 8px;
    max-width: 560px;
}

.cmp-card-footer {
    padding: 14px 20px;
    border-top: 1px solid #f0f0f5;
    background: #f9fafb;
    display: flex;
    justify-content: flex-end;
}

/* Responsive
   ========================================================================== */
@media (max-width: 1100px) {
    .cmp-kpis { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .cmp-kpis { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .cmp-kpi { padding: 12px; min-height: 0; }
    .cmp-kpi__icon { width: 40px; height: 40px; font-size: 17px; }
    .cmp-kpi__number { font-size: 22px; }
    .cmp-card-header { padding: 10px 12px; }
    .cmp-card-note { padding: 10px 12px 0; }
    .cmp-card-body { padding: 14px; }
    .cmp-detail-grid { grid-template-columns: 1fr; }
    .cmp-detail-grid > dt { border-bottom: none; padding-bottom: 0; }
    .cmp-form-row { grid-template-columns: 1fr; gap: 6px; }
    .cmp-form-label { padding-top: 0; }
}

/* Dark mode (html.theme-dark is set by setThemeColor)
   ========================================================================== */
html.theme-dark .cmp-page-header__title { color: #e0e0e0 !important; }
html.theme-dark .cmp-page-header__title i,
html.theme-dark .cmp-card-header__title i { color: #e88aae !important; }
html.theme-dark .cmp-page-header__subtitle,
html.theme-dark .cmp-card-note,
html.theme-dark .cmp-form-help { color: #888888 !important; }

html.theme-dark .cmp-btn--outline { background: #252729 !important; color: #e0e0e0 !important; border-color: #3a3a3a !important; }
html.theme-dark .cmp-btn--outline:hover { background: #282a2b !important; }
html.theme-dark .cmp-btn--danger { background: #991b1b33 !important; color: #f87171 !important; }
html.theme-dark .cmp-icon-btn { color: #888888 !important; }
html.theme-dark .cmp-icon-btn:hover { background: #282a2b !important; color: #e88aae !important; }
html.theme-dark .cmp-icon-btn--danger:hover { background: #991b1b33 !important; color: #f87171 !important; }

html.theme-dark .cmp-kpi,
html.theme-dark .cmp-card {
    background: #1e2022 !important;
    border-color: #2b2b2b !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .3) !important;
}
html.theme-dark .cmp-kpi:hover { border-color: #3a3a3a !important; }
html.theme-dark .cmp-kpi__number,
html.theme-dark .cmp-card-header__title,
html.theme-dark .cmp-detail-head__title,
html.theme-dark .cmp-form-label { color: #e0e0e0 !important; }
html.theme-dark .cmp-kpi__label { color: #888888 !important; }
html.theme-dark .cmp-kpi__hint { color: #777777 !important; }
html.theme-dark .cmp-kpi__icon--primary { background: rgba(139, 26, 74, .3) !important; color: #e88aae !important; }

html.theme-dark .cmp-card-header,
html.theme-dark .cmp-detail-head { border-bottom-color: #2b2b2b !important; }
html.theme-dark .cmp-card-footer { background: #1a1c1e !important; border-top-color: #2b2b2b !important; }

html.theme-dark .cmp-tabs > li > a { color: #888888 !important; }
html.theme-dark .cmp-tabs > li > a:hover { background: #282a2b !important; color: #e0e0e0 !important; }
html.theme-dark .cmp-tabs > li.active > a { background: rgba(139, 26, 74, .3) !important; color: #e88aae !important; }
html.theme-dark .cmp-tabs__count { background: #333333 !important; color: #dbdbdb !important; }

html.theme-dark .cmp-card table.dataTable thead th { color: #888888 !important; border-bottom-color: #2b2b2b !important; }
html.theme-dark .cmp-card table.dataTable tbody td { color: #dbdbdb !important; border-bottom-color: #2b2b2b !important; background: transparent !important; }
html.theme-dark .cmp-card table.dataTable tbody tr:hover td { background: #1a1c1e !important; }
html.theme-dark .cmp-card table.dataTable tbody td a { color: #e88aae !important; }

html.theme-dark .cmp-pill--primary { background: rgba(139, 26, 74, .3) !important; color: #e88aae !important; }
html.theme-dark .cmp-pill--neutral { background: #333333 !important; color: #dbdbdb !important; }
html.theme-dark .cmp-pill--success { background: #16653433 !important; color: #4ade80 !important; }
html.theme-dark .cmp-pill--warning { background: #92400e33 !important; color: #fbbf24 !important; }
html.theme-dark .cmp-pill--info    { background: #1e40af33 !important; color: #60a5fa !important; }
html.theme-dark .cmp-pill--error   { background: #991b1b33 !important; color: #f87171 !important; }
html.theme-dark .cmp-pill--orange  { background: #9a341233 !important; color: #fb923c !important; }

html.theme-dark .cmp-user__avatar { border-color: #2b2b2b !important; }
html.theme-dark .cmp-user__name,
html.theme-dark .cmp-page__name,
html.theme-dark .cmp-number { color: #e0e0e0 !important; }
html.theme-dark .cmp-user__name:hover { color: #e88aae !important; }
html.theme-dark .cmp-time { color: #dbdbdb !important; }
html.theme-dark .cmp-user__sub,
html.theme-dark .cmp-time__sub,
html.theme-dark .cmp-mono,
html.theme-dark .cmp-page__uri,
html.theme-dark .cmp-details__data { color: #777777 !important; }
html.theme-dark .cmp-page__uri .cmp-method,
html.theme-dark .cmp-details { color: #888888 !important; }
html.theme-dark .cmp-number--zero { color: #555555 !important; }
html.theme-dark .cmp-number--alert,
html.theme-dark .cmp-status-error { color: #f87171 !important; }
html.theme-dark .cmp-status-ok { color: #4ade80 !important; }

html.theme-dark .cmp-detail-grid > dt { color: #888888 !important; border-bottom-color: #2b2b2b !important; }
html.theme-dark .cmp-detail-grid > dd { color: #dbdbdb !important; border-bottom-color: #2b2b2b !important; }
html.theme-dark .cmp-detail-grid > dd .cmp-mono { color: #dbdbdb !important; }
html.theme-dark .cmp-detail-grid > dd .cmp-mono--faint { color: #777777 !important; }
html.theme-dark .cmp-code { background: #1a1c1e !important; border-color: #2b2b2b !important; color: #dbdbdb !important; }
