/**
 * BCSS Base Styles
 *
 * Global base styles that apply across all BCSS applications.
 * This file should be loaded AFTER Bootstrap and BEFORE other BCSS CSS files.
 */

/* PERF-21f-011: CLS-prevention fallback font for Inter (universal - all layouts)
 * Matches the metrics in critical-css.html so public/www layouts also benefit. */
@font-face {
    ascent-override: 90%;
    descent-override: 22.43%;
    font-family: 'Inter Fallback';
    line-gap-override: 0%;
    size-adjust: 107.64%;
    src: local('Arial');
}

/* ===== Global Base Styles ===== */
body {
    background-color: var(--gray-100);
    color: var(--gray-900);
    font-family: var(--font-family-sans-serif);
    font-size: var(--font-size-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-base);

    /* PERF-001 P0: Prevent CLS from fixed header - reserve space for top bar */
    /* RES-H-002 P0: Use --top-bar-height at all breakpoints (56px standardized) */
    /* RES-I-018: sidebar.css body:has(.top-bar) is the canonical conditional rule;
     * this provides the fallback for browsers without :has() support */
    padding-top: var(--top-bar-height);
}

/* RES-I-018: Public layouts without a top bar should not have padding-top */
.public-layout {
    padding-top: 0;
}

/* ===== Global Link Styles ===== */
a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-hover);
    text-decoration: none;
}

a:focus {
    outline: var(--focus-outline-width) solid var(--focus-outline-color);
    outline-offset: var(--focus-outline-offset);
}

a:active {
    color: var(--primary-active);
}

/* Override Bootstrap's default blue link color */
.btn-link {
    color: var(--primary-color);
}

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

/* ===== Headings ===== */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    color: var(--gray-900);
    font-family: var(--font-family-heading, var(--font-family-sans-serif));
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-tight);
    margin-bottom: var(--spacing-md);
}

h1, .h1 { font-size: 2.5rem; font-weight: var(--font-weight-light); }
h2, .h2 { font-size: 2rem; font-weight: var(--font-weight-light); }
h3, .h3 { font-size: 1.75rem; }
h4, .h4 { font-size: 1.5rem; }
h5, .h5 { font-size: 1.25rem; }
h6, .h6 { font-size: 1rem; }

/* RES-H-012 P2: Responsive heading font sizes with clamp() for mobile */
/* RES-I-015: Converted to modern range syntax */
@media (width <= 767.98px) {
    h1, .h1 { font-size: clamp(1.5rem, 5vw, 2rem); }
    h2, .h2 { font-size: clamp(1.25rem, 4vw, 1.75rem); }
    h3, .h3 { font-size: clamp(1.125rem, 3.5vw, 1.75rem); }  /* RES-009: Mobile responsive h3 */
    h4, .h4 { font-size: clamp(1rem, 3vw, 1.5rem); }          /* RES-009: Mobile responsive h4 */
}

/* RES-016: Global responsive images - prevent overflow on all screen sizes */
img {
    height: auto;
    max-width: 100%;
}

/* ===== Paragraphs ===== */
p {
    margin-bottom: var(--spacing-md);
}

p:last-child {
    margin-bottom: 0;
}

/* ===== Code & Pre ===== */
code, kbd, samp, pre {
    font-family: var(--font-family-monospace);
}

/* ===== Selection ===== */
::selection {
    background-color: var(--primary-color);
    color: var(--white);
}

/* ===== Smooth Scrolling (respects prefers-reduced-motion) ===== */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* ===== Scrollbar Styling (Webkit browsers) ===== */
::-webkit-scrollbar {
    height: 0.75rem;
    width: 0.75rem;
}

::-webkit-scrollbar-track {
    background: var(--gray-200);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: var(--border-radius);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

/* ===== Print Styles ===== */
@media print {
    body {
        background-color: var(--white);
        color: var(--black);
    }

    a {
        text-decoration: underline;
    }

    a[href^="http"]::after {
        content: " (" attr(href) ")";
    }
}

/* ===== Mobiscroll Icon Fix ===== */
/*
 * The Mobiscroll CSS uses .mbsc-font-icon:before but templates use .mbsc-icon
 * This bridges the gap to ensure icons render correctly
 */
.mbsc-icon::before {
    font-family: Mobiscroll !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-style: normal;
    font-variant: normal;
    font-weight: 400;
    speak: none;
    text-transform: none;
}


/* ===== Admin Navbar Icon Button ===== */
.admin-navbar-icon-btn {
    align-items: center;
    background: transparent;
    border: none;
    border-radius: var(--border-radius);
    color: var(--top-bar-text, var(--white));
    cursor: pointer;
    display: inline-flex;
    font-size: 1.25rem;
    height: 2.5rem;
    justify-content: center;
    padding: 0;
    transition: background-color var(--transition-fast);
    width: 2.5rem;
}

.admin-navbar-icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.admin-navbar-icon-btn:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* ===== Responsive Grid Layout ===== */
.responsive-grid {
    display: grid;
    gap: var(--spacing-lg);
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* ===== Metric Cards ===== */
.bcss-metric-card {
    background-color: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    display: flex;
    padding: var(--spacing-lg);
    position: relative;
    transition: box-shadow var(--transition-fast);
}

.bcss-metric-card:hover {
    box-shadow: var(--shadow);
}

.bcss-metric-card .card-link-overlay {
    inset: 0;
    position: absolute;
    z-index: 1;
}

.metric-card-primary {
    border-left: 4px solid var(--primary-color);
}

.metric-card-success {
    border-left: 4px solid var(--success-color);
}

.metric-card-warning {
    border-left: 4px solid var(--warning-color);
}

.metric-card-danger {
    border-left: 4px solid var(--danger-color);
}

.metric-card-info {
    border-left: 4px solid var(--info-color);
}

.metric-icon {
    align-items: center;
    border-radius: 50%;
    display: flex;
    height: 56px;
    justify-content: center;
    margin-right: var(--spacing-md);
    width: 56px;
}

.metric-icon.text-primary {
    background-color: var(--primary-lightest);
}

.metric-icon.text-success {
    background-color: var(--success-light);
}

.metric-icon.text-warning {
    background-color: var(--warning-light);
}

.metric-icon.text-danger {
    background-color: var(--danger-light);
}

.metric-icon.text-info {
    background-color: var(--info-light);
}

.metric-content {
    flex: 1;
}

.bcss-metric-value {
    color: var(--gray-900);
    font-size: 1.75rem;
    font-weight: var(--font-weight-semibold);
    line-height: 1.2;
}

.bcss-metric-label {
    color: var(--gray-600);
    font-size: var(--font-size-sm);
    margin-top: var(--spacing-xs);
}

/* ===== BCSS Card Components ===== */
.bcss-card {
    background-color: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
}

.bcss-card-header {
    border-bottom: 1px solid var(--border-color);
    padding: var(--spacing-md) var(--spacing-lg);
}

.bcss-card-body {
    padding: var(--spacing-lg);
}

.bcss-card-footer {
    border-top: 1px solid var(--border-color);
    padding: var(--spacing-md) var(--spacing-lg);
}

/* ===== Compliance Score Circle ===== */
.compliance-score-circle {
    align-items: center;
    border: 4px solid var(--success-color);
    border-radius: 50%;
    display: flex;
    font-size: 1.5rem;
    font-weight: var(--font-weight-bold);
    height: 80px;
    justify-content: center;
    width: 80px;
}

.compliance-score-circle.score-high {
    border-color: var(--success-color);
    color: var(--success-color);
}

.compliance-score-circle.score-medium {
    border-color: var(--warning-color);
    color: var(--warning-color);
}

.compliance-score-circle.score-low {
    border-color: var(--danger-color);
    color: var(--danger-color);
}

/* ===== Icon Box Utility ===== */
.bcss-icon-box {
    align-items: center;
    border-radius: var(--border-radius);
    display: inline-flex;
    font-size: 1.25rem;
    height: 2.5rem;
    justify-content: center;
    width: 2.5rem;
}

/* ===== Content Wrapper ===== */
.content-wrapper {
    background-color: var(--white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--spacing-xl);
}
