/*
 * KMI palette, loaded after the template styles.
 * Primary: navy from the institute logo. Red (logo stripe) only for destructive actions and errors.
 * Green/amber stay standard for "passed" and warnings; everything else is white and grey.
 */
:root {
    --kmi-primary: #002060;
    --kmi-primary-hover: #001640;
    --kmi-primary-soft: #e8edf6;
    --kmi-danger: #a03030;
    --kmi-danger-hover: #852626;

    /* Template (Cuba) and Bootstrap variables */
    --theme-deafult: #002060;
    --theme-secondary: #6c757d;
    --bs-primary: #002060;
    --bs-primary-rgb: 0, 32, 96;
    --bs-danger: #a03030;
    --bs-danger-rgb: 160, 48, 48;
    --bs-link-color: #002060;
    --bs-link-hover-color: #001640;
}

/* Primary */
.btn-primary,
.btn-primary:disabled,
.btn-primary.disabled {
    background-color: var(--kmi-primary) !important;
    border-color: var(--kmi-primary) !important;
    color: #fff !important;
}
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: var(--kmi-primary-hover) !important;
    border-color: var(--kmi-primary-hover) !important;
}
.btn-outline-primary {
    color: var(--kmi-primary) !important;
    border-color: var(--kmi-primary) !important;
}
.btn-outline-primary:hover,
.btn-outline-primary:focus {
    background-color: var(--kmi-primary) !important;
    color: #fff !important;
}
.bg-primary,
.badge.bg-primary,
.badge-primary {
    background-color: var(--kmi-primary) !important;
    color: #fff !important;
}
.text-primary {
    color: var(--kmi-primary) !important;
}
.border-primary {
    border-color: var(--kmi-primary) !important;
}
a {
    color: var(--kmi-primary);
}
.page-item.active .page-link,
.pagination .page-item.active .page-link {
    background-color: var(--kmi-primary) !important;
    border-color: var(--kmi-primary) !important;
    color: #fff !important;
}
.page-link {
    color: var(--kmi-primary);
}
.form-check-input:checked {
    background-color: var(--kmi-primary);
    border-color: var(--kmi-primary);
}
.form-control:focus,
.form-select:focus {
    border-color: #6a7fa8;
    box-shadow: 0 0 0 0.2rem rgba(0, 32, 96, 0.15);
}

/* Danger: logo red */
.btn-danger {
    background-color: var(--kmi-danger) !important;
    border-color: var(--kmi-danger) !important;
}
.btn-danger:hover,
.btn-danger:focus {
    background-color: var(--kmi-danger-hover) !important;
    border-color: var(--kmi-danger-hover) !important;
}
.btn-outline-danger {
    color: var(--kmi-danger) !important;
    border-color: var(--kmi-danger) !important;
}
.btn-outline-danger:hover {
    background-color: var(--kmi-danger) !important;
    color: #fff !important;
}
.bg-danger,
.badge.bg-danger {
    background-color: var(--kmi-danger) !important;
}
.text-danger {
    color: var(--kmi-danger) !important;
}

/* Decorative template colours used as headers or badges become calm */
.bg-secondary-light,
.bg-light-primary {
    background-color: var(--kmi-primary-soft) !important;
}
.card-header.bg-primary,
.card-header.bg-info,
.card-header.bg-secondary {
    background-color: var(--kmi-primary) !important;
    color: #fff !important;
}
.btn-info {
    background-color: #fff !important;
    border-color: var(--kmi-primary) !important;
    color: var(--kmi-primary) !important;
}
.btn-info:hover {
    background-color: var(--kmi-primary) !important;
    color: #fff !important;
}

/* Sidebar: active item in navy */
.page-wrapper.compact-wrapper .page-body-wrapper div.sidebar-wrapper .sidebar-main .sidebar-links .simplebar-wrapper .simplebar-mask .simplebar-content-wrapper .simplebar-content > li .sidebar-link.active,
.sidebar-links li a.active {
    background-color: var(--kmi-primary-soft) !important;
}
.sidebar-links li a.active span,
.sidebar-links li a.active svg {
    color: var(--kmi-primary) !important;
    stroke: var(--kmi-primary) !important;
}

/* Info alerts: calm navy tint instead of the template's violet */
.alert-info {
    background-color: var(--kmi-primary-soft) !important;
    border-color: #c9d3e6 !important;
    color: var(--kmi-primary) !important;
}
.alert-info * {
    color: var(--kmi-primary) !important;
}
.bg-info,
.badge.bg-info {
    background-color: #3a5486 !important;
}
.text-info {
    color: #3a5486 !important;
}

/* "Secondary" is plain grey (the template made it pink) */
.bg-secondary,
.badge.bg-secondary {
    background-color: #6c757d !important;
    color: #fff !important;
}
.btn-secondary {
    background-color: #6c757d !important;
    border-color: #6c757d !important;
    color: #fff !important;
}
.btn-outline-secondary {
    color: #6c757d !important;
    border-color: #6c757d !important;
}
.btn-outline-secondary:hover {
    background-color: #6c757d !important;
    color: #fff !important;
}
.text-secondary {
    color: #6c757d !important;
}

/* Row action buttons (view, edit, extra links): one navy outline style instead of violet/yellow/green */
.btn-outline-info,
.btn-outline-warning,
.btn-outline-success {
    color: var(--kmi-primary) !important;
    border-color: #9fb0cf !important;
    background-color: #fff !important;
}
.btn-outline-info:hover,
.btn-outline-warning:hover,
.btn-outline-success:hover,
.btn-outline-info:focus,
.btn-outline-warning:focus,
.btn-outline-success:focus {
    background-color: var(--kmi-primary) !important;
    border-color: var(--kmi-primary) !important;
    color: #fff !important;
}

/* Error alerts: soft red with readable text (the template used solid red with white text) */
.alert-danger {
    background-color: #f8eaea !important;
    border-color: #e6c3c3 !important;
    color: var(--kmi-danger) !important;
}
.alert-danger * {
    color: var(--kmi-danger);
}
.alert-danger .btn-primary,
.alert-danger .btn-primary * {
    color: #fff !important;
}

/* Statistic cards: navy stripe and icons for every card */
.kmi-stats .card {
    border-left: 4px solid var(--kmi-primary) !important;
}
.kmi-stats .text-success,
.kmi-stats .text-warning,
.kmi-stats .text-secondary,
.kmi-stats .text-info {
    color: var(--kmi-primary) !important;
}

/* Page title row: title on the left, actions on the right; actions wrap under the title on phones */
.kmi-page-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
}
.kmi-page-title h3 {
    margin: 0;
}
.kmi-page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.kmi-page-actions .btn {
    margin: 0 !important;
}
@media (max-width: 575.98px) {
    .kmi-page-title h3 {
        font-size: 20px;
        width: 100%;
    }
    .kmi-page-actions .btn {
        font-size: 13px;
        padding: 6px 12px;
    }
}

/* Wide tables on phones and tablets: short cells stay on one line, the table scrolls sideways,
   and a soft shadow on the edge shows that there is more to the right */
@media (max-width: 991.98px) {
    .table-responsive {
        background:
            linear-gradient(to right, #fff 30%, rgba(255, 255, 255, 0)) left center / 40px 100% no-repeat local,
            linear-gradient(to left, #fff 30%, rgba(255, 255, 255, 0)) right center / 40px 100% no-repeat local,
            radial-gradient(farthest-side at 0 50%, rgba(0, 32, 96, .18), rgba(0, 0, 0, 0)) left center / 12px 100% no-repeat scroll,
            radial-gradient(farthest-side at 100% 50%, rgba(0, 32, 96, .18), rgba(0, 0, 0, 0)) right center / 12px 100% no-repeat scroll;
    }
    .table-responsive > .table {
        background: transparent;
    }
    .table-responsive > .table > :not(caption) > * > * {
        background-color: transparent;
    }
    .table-responsive th,
    .table-responsive td {
        white-space: nowrap;
    }
    .table-responsive td.kmi-wrap {
        white-space: normal;
        min-width: 220px;
    }
}

/* Login: logo above a centred card on a calm background */
.kmi-login {
    background: #f4f6fa !important;
    background-image: none !important;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}
.kmi-login > div {
    width: 100%;
    max-width: 450px;
    text-align: center;
}
.kmi-login .login-main {
    width: 100%;
    margin: 0 auto;
    text-align: left;
}
.kmi-login-logo {
    max-width: 240px;
    width: 70%;
    margin-bottom: 24px;
}

/* Student pages: white bar with the logo and logout, content starts below it */
.kmi-student-nav {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, .95);
    box-shadow: 0 1px 6px rgba(0, 32, 96, .08);
}
.kmi-student-logo {
    max-height: 44px;
    width: auto;
}
@media (max-width: 767.98px) {
    .kmi-student-nav {
        padding: 10px 16px !important;
    }
    .kmi-student-logo {
        max-height: 36px;
    }
}
