/* ============================================================
 * Intelogix Compliance Hub — global tokens & component styles
 * Anchored to INTELOGIX_DESIGN_SYSTEM.md (v1.0)
 * ============================================================ */

:root {
    /* Backgrounds */
    --bg-canvas:    #0A1018;
    --bg-surface:   #0E1620;
    --bg-divider:   #1F2937;
    --bg-elevated:  #2A3441;

    /* Text */
    --text-primary: #FFFFFF;
    --text-body:    #E8EDF2;
    --text-muted:   #8A98AB;
    --text-subtle:  #6B7B8F;

    /* Semantic state */
    --state-danger: #DC2626;
    --state-warn:   #FBBF24;
    --state-ok:     #22C55E;
    --state-brand:  #1FA8E0;

    --state-danger-light: #FCA5A5;
    --state-warn-light:   #FBBF24;
    --state-ok-light:     #86EFAC;
    --state-brand-light:  #7DD3FC;

    --state-danger-bg: rgba(220, 38, 38, 0.10);
    --state-warn-bg:   rgba(251, 191, 36, 0.10);
    --state-ok-bg:     rgba(34, 197, 94, 0.08);
    --state-brand-bg:  rgba(31, 168, 224, 0.06);

    /* Data ramp (charts only) */
    --data-critical:   #DC2626;
    --data-mid:        #1FA8E0;
    --data-historical: #1E3A5F;

    /* Tool accents — match the original module brand identity */
    --accent-ich:       #4A9EFF;  /* ICH Hub - compliance network blue */
    --accent-csaitx:    #DC2626;  /* CSA ITX - safety vigilance red */
    --accent-hos:       #F59E0B;  /* HoS Verification - amber, auditoria continua */
    --accent-cam:       #8B5CF6;  /* CAM - capacitacion violet (CAM original brand) */
    --accent-botdot:    #1FA8E0;  /* BOTDOT - intelligence brand blue */
    --accent-action:    #EC4899;  /* Action Center - action rose, urgencia */
    --accent-executive: #06B6D4;  /* Executive View - executive clarity cyan */

    /* Aliases — the HoS module CSS internally usa el token con su nombre
       largo original (--accent-hosverification). Mantenemos el alias para
       no editar el intelogix-base.css importado del proyecto standalone. */
    --accent-hosverification: var(--accent-hos);

    /* Typography */
    --font-sans: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', monospace;

    --type-display-xl: 56px;
    --type-display-lg: 36px;
    --type-heading:    24px;
    --type-body-lg:    15px;
    --type-body:       13px;
    --type-eyebrow:    12px;

    --weight-regular: 400;
    --weight-medium:  500;

    /* Spacing */
    --space-xs:  4px;
    --space-sm:  8px;
    --space-md:  12px;
    --space-lg:  16px;
    --space-xl:  24px;
    --space-2xl: 32px;
    --space-3xl: 48px;

    /* Radius */
    --radius-0:  0;
    --radius-sm: 2px;
    --radius-md: 4px;
    --radius-lg: 6px;

    /* Sidebar geometry */
    --sidebar-width: 248px;
    --header-height: 56px;
}

/* ----- Reset / globals ----- */

*, *::before, *::after { box-sizing: border-box; }

html {
    overflow-y: auto;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-canvas);
    color: var(--text-body);
    font-family: var(--font-sans);
    font-size: var(--type-body-lg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a {
    color: var(--accent-ich);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
    color: var(--text-primary);
    font-weight: var(--weight-medium);
    line-height: 1.2;
    margin: 0;
}

h1 { font-size: var(--type-heading); }
h1:focus { outline: none; }

.num, .tabular {
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.025em;
}

.eyebrow {
    font-size: var(--type-eyebrow);
    letter-spacing: 0.15em;
    font-weight: var(--weight-medium);
    text-transform: uppercase;
    color: var(--text-muted);
}

/* ----- App shell ----- */

.page {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
    align-items: start;
}

.sidebar {
    background: var(--bg-surface);
    border-right: 1px solid var(--bg-divider);
}

main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.main-content {
    flex: 1;
    padding: var(--space-2xl) var(--space-2xl);
    max-width: 1400px;
    width: 100%;
}

/* ----- KPI card ----- */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-lg);
}

.kpi-card {
    padding: var(--space-lg) 18px;
    background: var(--bg-surface);
    border: 1px solid var(--bg-divider);
    border-left: 3px solid var(--bg-divider);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}
.kpi-card--danger  { background: var(--state-danger-bg); border-left-color: var(--state-danger); }
.kpi-card--warn    { background: var(--state-warn-bg);   border-left-color: var(--state-warn); }
.kpi-card--ok      { background: var(--state-ok-bg);     border-left-color: var(--state-ok); }
.kpi-card--brand   { background: var(--state-brand-bg);  border-left-color: var(--state-brand); }
.kpi-card--neutral { background: var(--bg-surface);      border-left-color: var(--text-subtle); }

.kpi-card .value {
    font-size: 28px;
    font-weight: var(--weight-medium);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.025em;
    color: var(--text-primary);
    line-height: 1;
}
.kpi-card .value .unit {
    font-size: 16px;
    color: var(--text-muted);
    margin-left: 2px;
}
.kpi-card .delta {
    font-size: var(--type-body);
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}
.kpi-card .delta--good { color: var(--state-ok-light); }
.kpi-card .delta--bad  { color: var(--state-danger-light); }
.kpi-card .meta {
    font-size: var(--type-body);
    color: var(--text-subtle);
}

/* ----- Module placeholder ----- */

.placeholder {
    background: var(--bg-surface);
    border: 1px dashed var(--bg-divider);
    border-radius: var(--radius-lg);
    padding: var(--space-3xl);
    text-align: center;
    color: var(--text-muted);
}
.placeholder h2 {
    font-size: var(--type-heading);
    margin-bottom: var(--space-sm);
}
.placeholder p { margin: 0; }
.placeholder .tag {
    display: inline-block;
    font-size: var(--type-eyebrow);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--accent-ich);
    border: 1px solid var(--accent-ich);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    margin-bottom: var(--space-lg);
}

/* ----- Identity forms (Login / Register / etc.) ----- */

.identity-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-canvas);
    padding: var(--space-2xl);
}
.identity-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-surface);
    border: 1px solid var(--bg-divider);
    border-top: 3px solid var(--accent-ich);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
}
.identity-card .brand {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-xl);
}
.identity-card .brand img { height: 56px; }

/* Override Bootstrap form controls for dark theme */
.form-control,
.form-control:focus {
    background: var(--bg-canvas);
    border: 1px solid var(--bg-divider);
    color: var(--text-body);
    border-radius: var(--radius-md);
    box-shadow: none;
}
.form-control:focus {
    border-color: var(--accent-ich);
    outline: none;
}
.form-floating > label,
label.form-label {
    color: var(--text-muted);
}

.btn {
    border-radius: var(--radius-md);
    font-weight: var(--weight-medium);
}
.btn-primary,
.btn-lg.btn-primary {
    background: var(--accent-ich);
    border-color: var(--accent-ich);
    color: #061122;
}
.btn-primary:hover {
    background: #6BB0FF;
    border-color: #6BB0FF;
    color: #061122;
}

a, .btn-link { color: var(--accent-ich); }

.valid.modified:not([type=checkbox]) { outline: 1px solid var(--state-ok); }
.invalid { outline: 1px solid var(--state-danger); }
.validation-message { color: var(--state-danger-light); }

/* Blazor error UI */
.blazor-error-boundary {
    background: var(--state-danger-bg);
    border-left: 3px solid var(--state-danger);
    color: var(--state-danger-light);
    padding: var(--space-lg) var(--space-xl);
    border-radius: var(--radius-md);
}
.blazor-error-boundary::after { content: "Ocurrio un error."; }

#blazor-error-ui {
    background: var(--state-danger-bg);
    border-top: 1px solid var(--state-danger);
    color: var(--text-body);
    padding: 12px 18px;
    display: none;
    left: 0; bottom: 0; right: 0; position: fixed;
    z-index: 1000;
}
#blazor-error-ui .dismiss {
    cursor: pointer; position: absolute; right: 12px; top: 8px;
}

.darker-border-checkbox.form-check-input { border-color: var(--bg-divider); }
