/*
 * Vigil On-Prem Controller — UI Stylesheet
 *
 * Design Direction: Precision Instrument
 * A dark, high-contrast interface befitting an enterprise compliance and
 * data discovery platform. Deliberate use of amber accents against deep
 * navy surfaces evokes security monitoring tools and audit consoles.
 *
 * Author: Venkat Mangudi
 */

/* ---------------------------------------------------------------------------
 * CSS Custom Properties
 * --------------------------------------------------------------------------- */
:root {
    --bg-base:       #0d1117;
    --bg-panel:      #161b27;
    --bg-surface:    #1c2333;
    --bg-elevated:   #212d40;

    --text-primary:  #e6edf3;
    --text-secondary:#8b949e;
    --text-muted:    #484f58;
    --text-inverse:  #0d1117;

    --accent:        #e8a020;
    --accent-hover:  #f0b030;
    --accent-dim:    rgba(232, 160, 32, 0.12);
    --accent-border: rgba(232, 160, 32, 0.35);

    --color-success: #3fb950;
    --color-warning: #d29922;
    --color-error:   #f85149;
    --color-info:    #58a6ff;

    --border:        #30363d;
    --border-subtle: #21262d;

    --font-ui:   -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
    --font-mono: 'Consolas', 'Monaco', 'Courier New', monospace;

    --radius:    6px;
    --radius-lg: 10px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);

    --nav-width: 260px;
}

/* ---------------------------------------------------------------------------
 * Reset and base — 16px base for readability on high-res monitors
 * --------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-ui);
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover { color: var(--accent-hover); }

/* ---------------------------------------------------------------------------
 * Typography
 * --------------------------------------------------------------------------- */
h1 { font-size: 1.875rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.5rem;   font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 1.25rem;  font-weight: 600; }
h4 { font-size: 1.0625rem; font-weight: 600; }

h1, h2, h3, h4 {
    color: var(--text-primary);
    line-height: 1.3;
}

.mono {
    font-family: var(--font-mono);
    font-size: 0.9em;
}

/* ---------------------------------------------------------------------------
 * Application shell — fixed sidebar, scrollable main
 * --------------------------------------------------------------------------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-nav {
    /* Scoped light-theme variable overrides — inherited by all child elements,
     * including those with inline var() style references in base.html.
     * The global dark palette is preserved for the main content area. */
    --text-primary:   #1a1a2e;
    --text-secondary: #495057;
    --text-muted:     #8a929b;
    --bg-elevated:    #eef0f2;
    --border-subtle:  #e2e6ea;
    --accent-dim:     rgba(232, 160, 32, 0.10);

    width: var(--nav-width);
    background: #ffffff;
    border-right: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
}

.app-main {
    flex: 1;
    margin-left: var(--nav-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    /* Scoped light-theme overrides so var() inline styles render with dark
     * text on the white header background. */
    --text-primary:   #1a1a2e;
    --text-secondary: #495057;

    height: 60px;
    background: #ffffff;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 50;
    flex-shrink: 0;
}

.app-content {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* ---------------------------------------------------------------------------
 * Navigation
 * --------------------------------------------------------------------------- */
.nav-brand {
    background-color: #1a1a2e;
    padding: 1.5rem 1.25rem 1.125rem;
    border-bottom: 1px solid var(--border-subtle);
}

.nav-brand-logo {
    display: block;
    height: 56px;
    width: auto;
    object-fit: contain;
    object-position: left center;
    margin-bottom: 0.75rem;
}

.nav-brand-mark {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.nav-brand-name {
    font-family: var(--font-mono);
    font-size: 1.1875rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.nav-brand-suffix {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 500;
}

.nav-section {
    padding: 1.25rem 0 0.5rem;
}

.nav-section-label {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 1.25rem 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.25rem;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
    border-left: 2px solid transparent;
    transition: all 0.12s ease;
    cursor: pointer;
    white-space: nowrap;
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
    text-decoration: none;
}

.nav-item.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: transparent;
}

.nav-item-icon {
    width: 18px;
    height: 18px;
    opacity: 0.65;
    flex-shrink: 0;
}

.nav-item.active .nav-item-icon { opacity: 1; }

.nav-footer {
    margin-top: auto;
    padding: 1.25rem;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ---------------------------------------------------------------------------
 * Cards
 * --------------------------------------------------------------------------- */
.card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

/* ---------------------------------------------------------------------------
 * Stat tiles
 * --------------------------------------------------------------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-tile {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.375rem 1.5rem;
    position: relative;
    overflow: hidden;
}

.stat-tile::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--accent);
    opacity: 0.4;
}

.stat-tile.critical::before { background: var(--color-error);   opacity: 0.9; }
.stat-tile.warning::before  { background: var(--color-warning);  opacity: 0.9; }
.stat-tile.ok::before       { background: var(--color-success);  opacity: 0.7; }

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.625rem;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 0.375rem;
}

.stat-detail {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* ---------------------------------------------------------------------------
 * Tables
 * --------------------------------------------------------------------------- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

thead { background: var(--bg-surface); }

thead th {
    padding: 0.75rem 1.25rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.1s ease;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-surface); }

tbody td {
    padding: 0.875rem 1.25rem;
    color: var(--text-secondary);
    vertical-align: middle;
}

tbody td.primary { color: var(--text-primary); font-weight: 500; }
tbody td.mono    { font-family: var(--font-mono); font-size: 0.9rem; }

/* ---------------------------------------------------------------------------
 * Badges
 * --------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.625rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.badge-new      { background: rgba(88,166,255,0.15);  color: #58a6ff; }
.badge-acked    { background: rgba(63,185,80,0.15);   color: #3fb950; }
.badge-fp       { background: rgba(139,148,158,0.15); color: #8b949e; }
.badge-risk     { background: rgba(210,153,34,0.15);  color: #d29922; }
.badge-active   { background: rgba(63,185,80,0.12);   color: #3fb950; }
.badge-inactive { background: rgba(248,81,73,0.12);   color: #f85149; }
.badge-enrolled { background: rgba(88,166,255,0.12);  color: #58a6ff; }

.status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.active   { background: var(--color-success); box-shadow: 0 0 5px var(--color-success); }
.status-dot.inactive { background: var(--color-error); }
.status-dot.enrolled { background: var(--color-info); }

/* ---------------------------------------------------------------------------
 * Forms
 * --------------------------------------------------------------------------- */
.form-group { margin-bottom: 1.25rem; }

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.form-input {
    width: 100%;
    padding: 0.6875rem 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 1rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
}

.form-input::placeholder { color: var(--text-muted); }

.form-input:focus {
    border-color: var(--accent-border);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-error {
    font-size: 0.8125rem;
    color: var(--color-error);
    margin-top: 0.375rem;
}

/* ---------------------------------------------------------------------------
 * Buttons
 * --------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6875rem 1.375rem;
    border-radius: var(--radius);
    font-family: var(--font-ui);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    color: var(--text-inverse);
    border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--text-inverse);
    text-decoration: none;
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-surface);
    border-color: var(--text-muted);
    text-decoration: none;
}

.btn-danger {
    background: rgba(248,81,73,0.1);
    color: var(--color-error);
    border-color: rgba(248,81,73,0.3);
}

.btn-danger:hover:not(:disabled) {
    background: rgba(248,81,73,0.2);
    text-decoration: none;
}

.btn-full { width: 100%; }
.btn-sm   { padding: 0.4375rem 0.875rem; font-size: 0.875rem; }

/* ---------------------------------------------------------------------------
 * Alerts
 * --------------------------------------------------------------------------- */
.alert {
    padding: 0.875rem 1.125rem;
    border-radius: var(--radius);
    font-size: 0.9375rem;
    border-left: 3px solid transparent;
    margin-bottom: 1.25rem;
}

.alert-error   { background: rgba(248,81,73,0.08);  border-left-color: var(--color-error);   color: #fca5a5; }
.alert-warning { background: rgba(210,153,34,0.08); border-left-color: var(--color-warning);  color: #fcd34d; }
.alert-success { background: rgba(63,185,80,0.08);  border-left-color: var(--color-success);  color: #6ee7b7; }
.alert-info    { background: rgba(88,166,255,0.08); border-left-color: var(--color-info);      color: #93c5fd; }

/* ---------------------------------------------------------------------------
 * License warning banner
 * --------------------------------------------------------------------------- */
.license-banner {
    background: rgba(232,160,32,0.08);
    border-bottom: 1px solid var(--accent-border);
    padding: 0.625rem 2rem;
    font-size: 0.9375rem;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-wrap: wrap;
}

.license-banner-warn {
    background: rgba(210,153,34,0.10);
    color: #fcd34d;
    border-bottom: 1px solid rgba(210,153,34,0.35);
}

.license-banner-grace,
.license-banner-blocked {
    background: rgba(248,81,73,0.12);
    color: #fca5a5;
    border-bottom: 1px solid rgba(248,81,73,0.40);
}

/* License page status badges */
.badge-license-active  { background: rgba(63,185,80,0.12);   color: #3fb950; }
.badge-license-warn    { background: rgba(210,153,34,0.12);  color: #fcd34d; }
.badge-license-grace   { background: rgba(248,81,73,0.12);   color: #fca5a5; }
.badge-license-blocked { background: rgba(248,81,73,0.18);   color: #ff7b72; }
.badge-license-none    { background: rgba(139,148,158,0.12); color: #8b949e; }

/* ---------------------------------------------------------------------------
 * Utility
 * --------------------------------------------------------------------------- */
.text-muted     { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent    { color: var(--accent); }
.text-error     { color: var(--color-error); }
.text-success   { color: var(--color-success); }
.text-right     { text-align: right; }
.text-center    { text-align: center; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }

.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2        { gap: 0.5rem; }
.gap-3        { gap: 0.75rem; }
.gap-4        { gap: 1rem; }
.w-full       { width: 100%; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------------------
 * Scrollbar
 * --------------------------------------------------------------------------- */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---------------------------------------------------------------------------
 * Exclusion Management — Tab Navigation
 * Added for the /exclusions page. Tabs are link-based (URL ?tab=) with
 * optional JS-driven switching to avoid full page reloads.
 * --------------------------------------------------------------------------- */
.ex-tab-nav {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
    gap: 0;
}

.ex-tab-link {
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    text-decoration: none;
    transition: color 0.12s ease, border-color 0.12s ease;
    cursor: pointer;
    white-space: nowrap;
}

.ex-tab-link:hover {
    color: var(--text-primary);
    text-decoration: none;
}

.ex-tab-link.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.ex-tab-count {
    margin-left: 0.375rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: var(--bg-elevated);
    padding: 0.125rem 0.4rem;
    border-radius: 3px;
    color: var(--text-muted);
}
