/* default dark theme */
:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #111111;
    --border: #2a2a2a;
    --border-hover: #444444;
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --text-muted: #666666;
    --text-faint: #444444;
    --accent: #ffffff;
    --accent-text: #0f0f0f;
    --badge-allowed-bg: #14532d;
    --badge-allowed-text: #4ade80;
    --badge-flagged-bg: #451a03;
    --badge-flagged-text: #fb923c;
    --badge-blocked-bg: #450a0a;
    --badge-blocked-text: #f87171;
}

/* light theme — overrides dark values */
:root.light {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f0f0;
    --border: #e0e0e0;
    --border-hover: #bbbbbb;
    --text-primary: #0f0f0f;
    --text-secondary: #1a1a1a;
    --text-muted: #666666;
    --text-faint: #999999;
    --accent: #0f0f0f;
    --accent-text: #ffffff;
    --badge-allowed-bg: #dcfce7;
    --badge-allowed-text: #166534;
    --badge-flagged-bg: #fff7ed;
    --badge-flagged-text: #9a3412;
    --badge-blocked-bg: #fef2f2;
    --badge-blocked-text: #991b1b;
}

/* reset default browser margin and padding */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* base page styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg-primary);
    color: var(--text-secondary);
    min-height: 100vh;
}

/* top navigation bar */
header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

header h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

/* last updated timestamp text */
header span {
    font-size: 13px;
    color: var(--text-muted);
}

/* centers and limits width of page content */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px;
}

/* three column grid for summary cards */
.cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

/* individual summary card */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
}

/* card label text */
.card .label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

/* card number value */
.card .value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
}

/* flagged card number is orange */
.card.flagged .value { color: #f59e0b; }

/* blocked card number is red */
.card.blocked .value { color: #ef4444; }

/* row of filter buttons */
.filters {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

/* individual filter button */
.filter-btn {
    padding: 6px 16px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
}

/* active filter button is highlighted */
.filter-btn.active {
    background: var(--border);
    color: var(--text-primary);
    border-color: var(--text-faint);
}

/* wrapper around the table */
.table-wrap {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

/* full width table with no gaps between cells */
table {
    width: 100%;
    border-collapse: collapse;
}

/* table header cells */
th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

/* table data cells */
td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

/* no border on last row */
tr:last-child td { border-bottom: none; }

/* highlight row on hover and show pointer cursor */
tr:hover td {
    background: var(--bg-tertiary);
    cursor: pointer;
}

/* status badge pill */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 500;
}

/* green badge for allowed */
.badge.allowed { background: #14532d; color: #4ade80; }

/* orange badge for flagged */
.badge.flagged { background: #451a03; color: #fb923c; }

/* red badge for blocked */
.badge.blocked { background: #450a0a; color: #f87171; }

/* dark overlay behind the modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

/* show the overlay when open class is added */
.modal-overlay.open { display: flex; }

/* modal box */
.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    width: 640px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px;
}

.modal h2 {
    font-size: 16px;
    margin-bottom: 20px;
    color: #fff;
}

/* spacing between each detail field */
.modal .field {
    margin-bottom: 16px;
}

/* field label */
.modal .field label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

/* field value box */
.modal .field p {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

/* close button in top right of modal */
.close-btn {
    float: right;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    margin-top: -4px;
}

.close-btn:hover { color: #fff; }

/* empty state message in table */
.empty {
    text-align: center;
    padding: 48px;
    color: var(--text-faint);
    font-size: 14px;
}

/* header right side — timestamp and logout */
.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* logout link */
.logout-btn {
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
}

.logout-btn:hover {
    color: var(--text-primary);
}

/* floating chat widget bubble */
#chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
}

/* bubble icon */
#widget-bubble {
    width: 52px;
    height: 52px;
    background: var(--text-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    position: relative;
}

#widget-bubble:hover {
    background: var(--text-secondary);
}

/* notification badge */
.widget-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: var(--text-primary);
    font-size: 10px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* widget panel */
.widget-panel {
    position: absolute;
    bottom: 64px;
    right: 0;
    width: 340px;
    height: 520px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}

/* widget header */
.widget-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.widget-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* expand to full page link */
.widget-expand {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 16px;
}

.widget-expand:hover {
    color: var(--text-primary);
}

.widget-header button {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
}

.widget-header button:hover {
    color: var(--text-primary);
}

/* iframe fills widget body */
.widget-frame {
    width: 100%;
    height: 100%;
    border: none;
}

.widget-body {
    flex: 1;
    overflow: hidden;
}

/* hide elements */
.hidden {
    display: none !important;
}

/* specifically hide widget panel */
#widget-panel.hidden {
    display: none !important;
}

/* right click context menu */
.context-menu {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px;
    z-index: 1000;
    min-width: 120px;
}

.context-menu button {
    display: block;
    width: 100%;
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 8px 12px;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    border-radius: 4px;
}

.context-menu button:hover {
    background: var(--border);
}

/* theme toggle button */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-muted);
}

.theme-toggle:hover {
    border-color: var(--border-hover);
}
/* light mode sidebar border */
:root.light .sidebar {
    border-right: 1px solid var(--border);
}

/* light mode chat area background */
:root.light .chat-area {
    background: var(--bg-primary);
}

/* light mode message input */
:root.light #message-input {
    background: var(--bg-secondary);
    border-color: var(--border);
}