:root {
    --primary-color: #0d6efd;
    --primary-hover: #0b5ed7;
    --surface-page: #f5f7fb;
    --surface-card: #ffffff;
    --surface-muted: #f8f9fa;
    --border-soft: #dee2e6;
    --text-muted: #6c757d;
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --shadow-card: 0 6px 18px rgba(15, 23, 42, 0.08);
    /* Accent panels should match the site's primary blue theme. */
    --app-accent-gradient: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
}

html, body {
    /* Defensive reset: if Bootstrap reboot CSS fails to load for any reason,
       prevent the browser default margins/padding creating a top gap above navbar. */
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--surface-page);
}

/* Extra guard: navbar should never be offset from the top by margins. */
.navbar {
    margin: 0;
    position: relative;
    z-index: 1100;
}

.navbar .dropdown-menu {
    z-index: 1110;
}

.navbar-brand img {
    height: 40px;
    margin-right: 10px;
}

.navbar-brand {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    max-width: calc(100% - 70px);
}

.navbar-brand-text {
    min-width: 0;
    white-space: nowrap;
}

.lang-choice {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.lang-flag {
    width: 18px;
    height: 12px;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
    flex: 0 0 auto;
}

.app-avatar-xs {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.35);
    vertical-align: -6px;
    margin-right: 6px;
    display: inline-block;
    flex: 0 0 auto;
}

.app-avatar-sm {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    object-fit: cover;
    background: #f3f4f6;
    border: 1px solid rgba(0,0,0,0.08);
}

.main-content {
    flex: 1;
    padding: 20px 0;
}

.app-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.app-footer-link {
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
}

.app-footer-link:hover,
.app-footer-link:focus {
    color: #fff;
    text-decoration: underline;
}

.app-footer-link:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.75);
    outline-offset: 2px;
    border-radius: 4px;
}

.sidebar {
    background-color: var(--surface-muted);
    min-height: calc(100vh - 56px);
    padding: 20px;
}

.sidebar .nav-link {
    color: #333;
    padding: 10px 15px;
    margin-bottom: 5px;
    border-radius: 5px;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background-color: var(--primary-color);
    color: white;
}

.bg-primary {
    background-color: var(--primary-color) !important;
}

.text-primary {
    color: var(--primary-color) !important;
}

.border-primary {
    border-color: var(--primary-color) !important;
}

.btn-primary,
.btn-outline-primary:hover {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #fff !important;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
    color: #fff !important;
}

.btn-outline-primary {
    color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

.badge.bg-primary {
    background-color: var(--primary-color) !important;
}

.card {
    background: var(--surface-card);
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-card);
    margin-bottom: 20px;
}

.app-card-interactive {
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.app-card-interactive:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.app-accent-gradient {
    background: var(--app-accent-gradient);
    color: #fff;
}

.app-accent-panel {
    background: var(--app-accent-gradient);
    color: #fff;
    border-radius: var(--radius-md);
}

.app-card-header-accent {
    background: var(--app-accent-gradient);
    color: #fff;
}

.app-card-header-accent a {
    color: inherit;
}

.app-hero {
    background: var(--app-accent-gradient);
    color: #fff;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.app-muted-panel {
    background: var(--surface-muted);
    border: 1px solid var(--border-soft);
}

.app-empty-state-icon {
    color: #c2c8d0;
    font-size: 4rem;
}

.app-icon-lg {
    font-size: 2rem;
}

.app-icon-xl {
    font-size: 3rem;
}

.app-icon-xxl {
    font-size: 4rem;
}

.app-muted-icon {
    color: #c2c8d0;
}

.app-img-maxh-200 {
    max-height: 200px;
}

.app-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.app-page-title {
    margin: 0;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.app-page-subtitle {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
}

.card-header h4,
.card-header h5 {
    letter-spacing: 0.2px;
}

.app-sticky-top-20 {
    top: 20px;
}

.soft-divider-on-dark {
    border-color: rgba(255, 255, 255, 0.2);
    opacity: 1;
}

/* Shared SDH student entry UI (used in lesson form + reuse). */
.student-row {
    background: var(--surface-muted);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    position: relative;
}

.student-row .remove-student {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    cursor: pointer;
    color: #dc3545;
}

.add-student-btn {
    border: 2px dashed var(--border-soft);
    background: transparent;
    color: var(--text-muted);
    width: 100%;
    padding: 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.add-student-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #f0f7ff;
}

.badge-status {
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
}

.badge-draft { background-color: #6c757d; color: white; }
.badge-submitted { background-color: #ffc107; color: black; }
.badge-verified { background-color: #28a745; color: white; }
.badge-rejected { background-color: #dc3545; color: white; }

.badge-on-time { background-color: #28a745; color: white; }
.badge-late { background-color: #ffc107; color: black; }
.badge-not-submitted { background-color: #dc3545; color: white; }

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

@media (max-width: 991.98px) {
    .main-content {
        padding: 12px 0;
    }

    .sidebar {
        min-height: auto;
        padding: 12px 10px;
    }

    .sidebar .nav-link {
        padding: 8px 10px;
        margin-bottom: 4px;
    }

    .sidebar hr {
        margin: 0.5rem 0;
    }
}

@media (max-width: 767.98px) {
    .app-page-header {
        flex-direction: column;
        align-items: stretch;
    }
}
