﻿/* ================================================
   RESET & BASE
   ================================================ */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--color-text);
}

@media (min-width: 768px) {
    html { font-size: 15px; }
}

body {
    background-color: var(--color-page-bg);
}

a {
    color: var(--color-primary);
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary-dark);
}

/* Bootstrap overrides aligned with tokens */
.btn-primary {
    --bs-btn-bg: var(--color-primary);
    --bs-btn-border-color: var(--color-primary-dark);
    --bs-btn-hover-bg: var(--color-primary-dark);
    --bs-btn-hover-border-color: var(--color-uac-navy);
    --bs-btn-active-bg: var(--color-uac-navy);
    --bs-btn-active-border-color: var(--color-uac-navy);
}

.btn-outline-primary {
    --bs-btn-color: var(--color-primary);
    --bs-btn-border-color: var(--color-primary);
    --bs-btn-hover-bg: var(--color-primary);
    --bs-btn-hover-border-color: var(--color-primary);
}

.card {
    border-color: var(--color-border);
    border-radius: 28px;
    box-shadow: var(--shadow-1);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 0.2rem rgba(21, 88, 192, 0.15);
}

/* ================================================
   SIDEBAR SHELL
   ================================================ */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(165deg, var(--sidebar-bg-start) 0%, var(--sidebar-bg-mid) 45%, var(--sidebar-bg-end) 100%);
    color: #fff;
}

aside.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1030;
}

.offcanvas.sidebar {
    width: var(--sidebar-width) !important;
    background: linear-gradient(165deg, var(--sidebar-bg-start) 0%, var(--sidebar-bg-mid) 45%, var(--sidebar-bg-end) 100%) !important;
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-inner::-webkit-scrollbar { width: 4px; }
.sidebar-inner::-webkit-scrollbar-track { background: transparent; }
.sidebar-inner::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* ================================================
   SIDEBAR: BRAND
   ================================================ */
.sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    padding: 22px 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand-icon {
    font-size: 2.4rem;
    color: var(--color-uac-gold);
    line-height: 1;
}

.sidebar-brand-name {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #fff;
}

/* ================================================
   SIDEBAR: PROFILE CARD
   ================================================ */
.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(255,255,255,0.06);
    margin: 16px 12px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255,255,255,0.1);
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

/* The whole profile card links to Settings */
.sidebar-profile-link {
    text-decoration: none;
    display: block;
}

.sidebar-profile-link:hover .sidebar-profile,
.sidebar-profile.active {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.25);
}

.sidebar-profile-gear {
    color: rgba(255,255,255,0.45);
    font-size: 0.95rem;
    flex-shrink: 0;
}

.sidebar-profile-link:hover .sidebar-profile-gear,
.sidebar-profile.active .sidebar-profile-gear {
    color: var(--sidebar-accent);
}

.sidebar-avatar {
    font-size: 2.4rem;
    color: var(--sidebar-accent);
    flex-shrink: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-avatar-img {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.45);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.sidebar-profile-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-profile-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-profile-meta {
    font-size: 0.70rem;
    color: rgba(255,255,255,0.5);
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 4px 20px 8px;
}

/* ================================================
   SIDEBAR: NAV
   ================================================ */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 4px 10px;
    gap: 2px;
}

.sidebar-nav .nav-link,
.sidebar-footer .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 0.855rem;
    font-weight: 500;
    text-decoration: none;
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.sidebar-nav .nav-link i,
.sidebar-footer .nav-link i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
    transform: translateX(3px);
}

.sidebar-nav .nav-link.active {
    background: linear-gradient(90deg, rgba(255,204,0,0.22) 0%, rgba(255,204,0,0.06) 100%);
    color: var(--sidebar-text-active);
    border-left: 3px solid var(--sidebar-accent);
    padding-left: 11px;
}

.nav-group-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 8px 10px;
}

.sidebar-spacer { flex: 1; }

.sidebar-footer {
    padding: 8px 10px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-footer .nav-link:hover {
    background: rgba(248,113,113,0.1);
    color: #f87171;
    transform: translateX(3px);
}

/* ================================================
   MOBILE TOPBAR
   ================================================ */
.mobile-topbar {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(90deg, var(--sidebar-bg-start) 0%, var(--sidebar-bg-end) 100%);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1029;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.topbar-logo {
    font-size: 1.4rem;
    color: var(--color-uac-gold);
    line-height: 1;
}

.topbar-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.03em;
}

.sidebar-toggle {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-sm);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.sidebar-toggle:hover {
    background: rgba(255,255,255,0.2);
}

/* ================================================
   MAIN CONTENT
   ================================================ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: var(--color-page-bg);
}

.content-wrapper {
    padding: 28px 32px;
    max-width: 1400px;
}

@media (max-width: 991.98px) {
    .main-content {
        margin-left: 0;
        padding-top: 62px;
    }

    .content-wrapper {
        padding: 20px 16px;
    }
}

/* ================================================
   PAGE CONTENT STRUCTURE
   Transforms view markup patterns (bg-warning header +
   bg-light body) into Faculty-style card sections.
   ================================================ */

/* Page title header (bg-warning pattern) → navy gradient with gold title */
.content-wrapper .bg-warning {
    background: linear-gradient(90deg, var(--sidebar-bg-start) 0%, var(--sidebar-bg-end) 100%) !important;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    padding: 14px 20px !important;
    /* Gold text so raw-text headers (e.g. card-header bg-warning) are readable on the navy gradient,
       not just <h1>-<h5>. .text-* utilities still override this for badges that opt out. */
    color: var(--color-uac-gold);
}

.content-wrapper .bg-warning h1,
.content-wrapper .bg-warning h2,
.content-wrapper .bg-warning h3,
.content-wrapper .bg-warning h4,
.content-wrapper .bg-warning h5 {
    color: var(--color-uac-gold) !important;
    margin: 0;
    font-weight: 600;
}

/* Content body (bg-light pattern) → white card surface */
.content-wrapper .bg-light {
    background: var(--color-surface) !important;
    border: 1px solid var(--color-border);
    border-radius: 28px;
    box-shadow: var(--shadow-1);
    overflow: hidden;
}

/* Page containers: strip Bootstrap's default side padding so card edges align cleanly */
.content-wrapper .container,
.content-wrapper .container-fluid {
    max-width: 100%;
    width: 100%;
    padding-left: 0;
    padding-right: 0;
    margin-bottom: var(--space-5);
}

/* Cancel Bootstrap row negative margins so rounded corners are not clipped */
.content-wrapper .bg-light > .row {
    margin-left: 0;
    margin-right: 0;
}

/* ================================================
   TABLES
   ================================================ */
.content-wrapper .table {
    color: var(--color-text);
    font-size: var(--font-size-1);
}

.content-wrapper .table thead th {
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-muted);
    background: var(--color-surface-muted);
    border-bottom-color: var(--color-border);
}

.content-wrapper .table-bordered > :not(caption) > * > * {
    border-color: var(--color-border);
}

.content-wrapper .table tbody tr:hover {
    background: var(--color-surface-muted);
}

/* ================================================
   BUTTONS
   ================================================ */
.content-wrapper .btn-warning {
    background: var(--color-uac-gold);
    border-color: var(--color-uac-gold-dark);
    color: var(--color-uac-navy);
    font-weight: var(--font-weight-semibold);
}

.content-wrapper .btn-warning:hover,
.content-wrapper .btn-warning:focus {
    background: var(--color-uac-gold-dark);
    border-color: var(--color-uac-gold-dark);
    color: var(--color-uac-navy);
}

/* ================================================
   CARDS INSIDE CONTENT
   ================================================ */
.content-wrapper .card {
    border-color: var(--color-border);
    box-shadow: var(--shadow-1);
}

.card-header, .card-footer { border-radius: 0 !important; }
.card > .card-header:first-child { border-radius: 28px 28px 0 0 !important; }
.card > .card-footer:last-child  { border-radius: 0 0 28px 28px !important; }

.content-wrapper .card-header {
    background: var(--color-surface-muted);
    border-bottom-color: var(--color-border);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
}

/* card-header + bg-warning gets the navy-gradient restyle (line ~323); keep its text gold —
   the plain .card-header color above would otherwise win on source order and render dark-on-navy */
.content-wrapper .card-header.bg-warning {
    color: var(--color-uac-gold);
}

/* ================================================
   ALERTS
   ================================================ */
.content-wrapper .alert {
    border-radius: var(--radius-md);
    border: none;
    box-shadow: var(--shadow-1);
}

/* ================================================
   FORM CONTROLS
   ================================================ */
.content-wrapper .form-label {
    font-size: var(--font-size-1);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-muted);
}

.content-wrapper .form-control,
.content-wrapper .form-select {
    border-color: var(--color-border);
    color: var(--color-text);
    background: var(--color-surface);
    font-size: var(--font-size-1);
}

.content-wrapper .form-control:focus,
.content-wrapper .form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 0.2rem rgba(21, 88, 192, 0.15);
}

/* ================================================
   Lesson content authored in the Faculty CKEditor
   ================================================
   Lesson HTML is rendered raw, so the markup CKEditor emits has to be styled here — the student
   portal does not load CKEditor's own content stylesheet. Without these rules a resized image
   ("<figure class='image image_resized' style='width:50%'>") is laid out at its natural size,
   because the width lives on the figure and only the inner <img> filling it makes that width real. */

.lesson-content img {
    max-width: 100%;
    height: auto;
}

.lesson-content figure.image {
    display: table;
    clear: both;
    text-align: center;
    margin: var(--space-4) auto;
    max-width: 100%;
}

.lesson-content figure.image img {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
}

/* Faculty picked an explicit size: the figure carries the width, the image fills it. */
.lesson-content figure.image.image_resized {
    display: block;
    box-sizing: border-box;
    max-width: 100%;
}

.lesson-content figure.image.image_resized img {
    width: 100%;
}

/* Inline images take the width on the <img> itself rather than on a wrapping figure. */
.lesson-content img.image_resized {
    width: 100%;
}

.lesson-content figure.image > figcaption {
    display: block;
    caption-side: bottom;
    padding: var(--space-2);
    font-size: var(--font-size-1);
    color: var(--color-text-muted);
    background: var(--color-surface-muted);
}

.lesson-content figure.image-style-side {
    float: right;
    margin-left: var(--space-5);
    max-width: 50%;
}

.lesson-content figure.table {
    max-width: 100%;
    overflow-x: auto;
}
