:root {
    --theme-bg: #f4f5f7;
    --theme-surface: #ffffff;
    --theme-surface-soft: #f8fafc;
    --theme-border: #e6e8ef;
    --theme-text: #172133;
    --theme-muted: #68758d;
    --theme-primary: #0f6e6a;
    --theme-primary-2: #0b5560;
    --theme-accent: #f4b860;
    --theme-success: #0e9f6e;
    --theme-danger: #dc5b5b;
    --theme-shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
    --theme-shadow-lg: 0 24px 60px rgba(16, 24, 40, 0.14);
    --theme-radius: 18px;
}

html,
body {
    font-family: 'Somar', 'Somar Sans', 'Cairo', 'Tajawal', sans-serif;
    font-size: 18px;
    line-height: 1.75;
    background: radial-gradient(circle at 5% 10%, #fff7ea 0%, transparent 40%),
        radial-gradient(circle at 95% 90%, #e6fbf8 0%, transparent 35%),
        var(--theme-bg);
    color: var(--theme-text);
}

input,
textarea,
select,
button,
.form-control,
.form-select {
    font-family: 'Somar', 'Somar Sans', 'Cairo', 'Tajawal', sans-serif !important;
}

.page-content {
    padding: 2.25rem 1rem;
    font-size: 1rem;
}

.page-content.teacher-theme {
    position: relative;
    isolation: isolate;
    --teacher-scroll: 0px;
    --teacher-scroll-soft: 0px;
}

.page-content.teacher-theme::before,
.page-content.teacher-theme::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image: var(--teacher-brand-logo-url, none);
    background-repeat: no-repeat;
    filter: grayscale(0.2);
}

.page-content.teacher-theme::before {
    background-size: min(96vw, 1280px);
    background-position: right -260px top 2vh;
    opacity: 0.14;
    filter: grayscale(0.15) blur(0.2px);
    transform: translate3d(0, calc(var(--teacher-scroll) * -0.085), 0) scale(1.14) rotate(-6deg);
    animation: teacher-brand-fade-strong 10s ease-in-out infinite alternate,
        teacher-brand-drift-1 30s linear infinite;
}

.page-content.teacher-theme::after {
    background-size: min(84vw, 980px);
    background-position: left -250px bottom -10vh;
    opacity: 0.1;
    filter: grayscale(0.25) blur(0.4px);
    transform: translate3d(0, calc(var(--teacher-scroll) * -0.055), 0) scale(1.06) rotate(8deg);
    animation: teacher-brand-fade-strong 13s ease-in-out infinite alternate-reverse,
        teacher-brand-drift-2 35s linear infinite;
}

.page-content.teacher-theme .content-wrapper::before {
    content: "";
    position: fixed;
    inset: auto 0 6vh 0;
    margin: 0 auto;
    width: min(72vw, 900px);
    height: min(72vw, 900px);
    pointer-events: none;
    z-index: 0;
    background-image: var(--teacher-brand-logo-url, none);
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    opacity: 0.06;
    filter: grayscale(0.2) blur(1px);
    transform: translate3d(0, calc(var(--teacher-scroll-soft) * -0.04), 0) scale(1.3) rotate(-2deg);
    animation: teacher-brand-fade 14s ease-in-out infinite alternate;
}

.page-content.teacher-theme .content-wrapper {
    position: relative;
    z-index: 1;
}

/* Performance: disable heavy moving background logo layers. */
.page-content.teacher-theme::before,
.page-content.teacher-theme::after,
.page-content.teacher-theme .content-wrapper::before,
.teacher-theme .dashboard-home::before {
    content: none !important;
    background-image: none !important;
    animation: none !important;
    transform: none !important;
}

.content-wrapper {
    max-width: 1400px;
    margin-inline: auto;
}

.teacher-theme {
    --theme-primary: var(--teacher-brand-primary, #0f6e6a);
    --theme-primary-2: var(--teacher-brand-secondary, #0b5560);
    --theme-accent: var(--teacher-brand-accent, #f4b860);
    --bs-primary: var(--theme-primary);
    --bs-secondary: var(--theme-primary-2);
    --bs-info: var(--theme-accent);
    --bs-link-color: var(--theme-primary);
    --bs-link-hover-color: var(--theme-primary-2);
}

.teacher-theme .btn-primary {
    --bs-btn-bg: var(--theme-primary);
    --bs-btn-border-color: var(--theme-primary-2);
    --bs-btn-hover-bg: var(--theme-primary-2);
    --bs-btn-hover-border-color: var(--theme-primary-2);
    --bs-btn-active-bg: var(--theme-primary-2);
    --bs-btn-active-border-color: var(--theme-primary-2);
}

.teacher-theme .btn-outline-primary {
    --bs-btn-color: var(--theme-primary);
    --bs-btn-border-color: var(--theme-primary);
    --bs-btn-hover-bg: var(--theme-primary);
    --bs-btn-hover-border-color: var(--theme-primary);
}

.teacher-theme .btn-secondary {
    --bs-btn-bg: var(--theme-primary-2);
    --bs-btn-border-color: var(--theme-primary-2);
    --bs-btn-hover-bg: var(--theme-primary);
    --bs-btn-hover-border-color: var(--theme-primary);
}

.teacher-theme .btn-warning {
    --bs-btn-bg: var(--theme-accent);
    --bs-btn-border-color: var(--theme-accent);
    --bs-btn-hover-bg: color-mix(in srgb, var(--theme-accent) 80%, black);
    --bs-btn-hover-border-color: color-mix(in srgb, var(--theme-accent) 80%, black);
}

.teacher-theme .btn-purple {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--theme-primary);
    --bs-btn-border-color: var(--theme-primary);
    --bs-btn-hover-bg: var(--theme-primary-2);
    --bs-btn-hover-border-color: var(--theme-primary-2);
    --bs-btn-active-bg: var(--theme-primary-2);
    --bs-btn-active-border-color: var(--theme-primary-2);
}

.teacher-theme .btn-outline-purple {
    --bs-btn-color: var(--theme-primary);
    --bs-btn-border-color: var(--theme-primary);
    --bs-btn-hover-bg: var(--theme-primary);
    --bs-btn-hover-border-color: var(--theme-primary);
    --bs-btn-hover-color: #fff;
}

.teacher-theme .btn-outline-purple:hover,
.teacher-theme .btn-outline-purple:focus,
.teacher-theme .btn-purple:hover,
.teacher-theme .btn-purple:focus {
    box-shadow: none;
}

.teacher-theme .teacher-brand-stat {
    min-height: 130px;
    border-radius: 20px;
    box-shadow: 0 12px 18px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 20px;
    color: #fff;
    border: 0;
}

.teacher-theme .teacher-brand-stat:hover {
    transform: translateY(-10px);
}

.teacher-theme .teacher-brand-stat .card-icon {
    background: #fff;
    color: var(--theme-primary-2);
}

.teacher-theme .teacher-brand-stat-primary {
    background: linear-gradient(140deg, var(--theme-primary) 0%, var(--theme-primary-2) 100%);
}

.teacher-theme .teacher-brand-stat-secondary {
    background: linear-gradient(140deg, var(--theme-primary-2) 0%, var(--theme-accent) 100%);
}

.teacher-theme .teacher-brand-stat-accent {
    background: linear-gradient(140deg, var(--theme-accent) 0%, var(--theme-primary) 100%);
}

.teacher-theme .teacher-brand-stat-contrast {
    background: linear-gradient(140deg, var(--theme-primary) 0%, var(--theme-accent) 100%);
}

.teacher-theme .bg-purple,
.teacher-theme .badge.bg-purple,
.teacher-theme .card-header.bg-purple {
    background-color: var(--theme-primary) !important;
}

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

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

.teacher-theme .bg-pink,
.teacher-theme .badge.bg-pink,
.teacher-theme .card-header.bg-pink {
    background-color: var(--theme-secondary) !important;
}

.teacher-theme .border-pink {
    border-color: var(--theme-secondary) !important;
}

.teacher-theme .text-pink {
    color: var(--theme-secondary) !important;
}

.teacher-theme .bg-white.bg-opacity-25 {
    background-color: #fff !important;
}

.teacher-theme .dashboard-card .card-icon {
    color: var(--theme-primary-2);
}

.teacher-theme .btn-outline-dark {
    --bs-btn-color: var(--theme-primary-2);
    --bs-btn-border-color: var(--theme-primary-2);
    --bs-btn-hover-bg: var(--theme-primary-2);
    --bs-btn-hover-border-color: var(--theme-primary-2);
}

.teacher-theme .text-primary,
.teacher-theme .link-primary {
    color: var(--theme-primary) !important;
}

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

.teacher-theme .bg-secondary {
    background-color: var(--theme-primary-2) !important;
}

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

.teacher-theme .alert-primary {
    background-color: color-mix(in srgb, var(--theme-primary) 12%, white);
    border-color: color-mix(in srgb, var(--theme-primary) 25%, white);
    color: var(--theme-primary-2);
}

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

.teacher-theme .teacher-brand-logo {
    width: auto;
    max-width: 360px;
    max-height: 260px;
    object-fit: contain;
    display: block;
}

.teacher-theme .teacher-brand-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
}

.teacher-theme .teacher-brand-card .badge {
    background: rgba(255, 255, 255, 0.24);
}

.teacher-theme .teacher-brand-card .teacher-brand-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.teacher-theme .table-responsive,
.teacher-theme .alert,
.teacher-theme .modal-content,
.teacher-theme .accordion-item {
    position: relative;
    overflow: hidden;
}

.teacher-theme .table-responsive::before,
.teacher-theme .alert::before,
.teacher-theme .modal-content::before,
.teacher-theme .accordion-item::before {
    content: "";
    position: absolute;
    inset-inline-start: -50px;
    top: -34px;
    width: 190px;
    height: 190px;
    pointer-events: none;
    background-image: var(--teacher-brand-logo-url, none);
    background-repeat: no-repeat;
    background-size: contain;
    opacity: 0.04;
    filter: grayscale(0.3);
    transform: rotate(-16deg);
}

.teacher-theme .dashboard-home::before {
    background-image: var(--teacher-brand-logo-url, none);
    background-size: 70%;
    background-repeat: no-repeat;
    background-position: center;
    mix-blend-mode: soft-light;
    opacity: 0.15;
    transform: translate3d(0, calc(var(--teacher-scroll-soft) * -0.03), 0) rotate(-8deg) scale(1.1);
}

.teacher-theme .dashboard-home::after {
    opacity: 0.18;
}

.teacher-theme .card-header {
    background: color-mix(in srgb, var(--theme-primary) 8%, white);
    border-bottom-color: var(--theme-border);
    color: var(--theme-primary-2);
    font-weight: 700;
}

.navbar.floating-navbar {
    background: linear-gradient(125deg, #0f6e6a 0%, #0d4f73 100%) !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    margin: 14px 16px 0;
    width: calc(100% - 32px);
    box-shadow: 0 14px 34px rgba(13, 79, 115, 0.32);
}

.floating-navbar .navbar-nav-link {
    color: #eff8ff !important;
    border-radius: 10px;
    transition: 0.25s ease;
}

.floating-navbar .navbar-nav-link:hover,
.floating-navbar .navbar-nav-link:focus {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.floating-navbar .dropdown-menu {
    border-radius: 14px;
    border: 1px solid var(--theme-border);
    box-shadow: var(--theme-shadow);
}

.card,
.modal-content,
.dropdown-menu,
.accordion-item,
.alert {
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius);
    box-shadow: var(--theme-shadow);
}

.card {
    color: var(--theme-text);
    font-size: 1rem;
}

.card:not([class*="bg-"]) {
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.card[class*="bg-"] {
    background-image: none !important;
}

.card-footer {
    border-top: 1px solid var(--theme-border);
    background: transparent;
    font-size: 1rem;
}

.btn {
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.98rem;
    transition: 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--theme-primary) 0%, var(--theme-primary-2) 100%);
    border-color: var(--theme-primary-2);
}

.btn-outline-primary {
    color: var(--theme-primary);
    border-color: rgba(15, 110, 106, 0.45);
}

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

.btn-warning {
    background: #f8c071;
    border-color: #f8c071;
    color: #3a2b14;
}

.btn-danger {
    background: #d75555;
    border-color: #d75555;
}

.table {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: rgba(15, 110, 106, 0.04);
    --bs-table-hover-bg: rgba(15, 110, 106, 0.08);
    border-color: var(--theme-border);
}

.table> :not(caption)>*>* {
    padding: 1rem 0.85rem;
    font-size: 1rem;
}

.table thead th {
    font-weight: 700;
    color: var(--theme-text);
    background: #f8fafc;
    font-size: 1rem;
}

.form-control,
.form-select {
    background-color: #ffffff;
    color: var(--theme-text);
    border-radius: 12px;
    border-color: #d9deea;
    padding: 0.72rem 0.85rem;
    font-size: 1rem;
}

/* RTL: keep the dropdown caret on the left and prevent text overlap. */
[dir="rtl"] .form-select {
    --bs-form-select-bg-position: left 0.75rem center;
    background-position: left 0.75rem center;
    padding-left: 2.3rem;
    padding-right: 0.85rem;
}

.form-control::placeholder,
.form-select::placeholder {
    color: var(--theme-muted);
}

.form-control:focus,
.form-select:focus {
    background-color: #ffffff;
    color: var(--theme-text);
    border-color: var(--theme-primary);
    outline: 0;
    box-shadow: 0 0 0 0.18rem rgba(15, 110, 106, 0.22);
}

.dashboard-home {
    min-height: auto;
    margin-bottom: 2rem;
    border-radius: 28px;
    padding: 42px 28px;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--theme-primary, #0e4b68) 0%, var(--theme-primary-2, #0f6e6a) 55%, var(--theme-accent, #1f8f80) 100%);
    color: #fff;
    box-shadow: var(--theme-shadow-lg);
}

.dashboard-home::before,
.dashboard-home::after {
    content: "";
    position: absolute;
    width: 380px;
    height: 380px;
    border-radius: 999px;
    opacity: 0.25;
    pointer-events: none;
}

.dashboard-home::before {
    top: -190px;
    right: -120px;
    background: #ffd89f;
}

.dashboard-home::after {
    bottom: -240px;
    left: -160px;
    background: #84e6cf;
}

.dashboard-home .hero,
.dashboard-home .dashboard-grid {
    position: relative;
    z-index: 1;
}

.dashboard-home .hero {
    margin-bottom: 2rem;
}

.dashboard-home .hero h1 {
    font-size: clamp(2.2rem, 4vw, 3.4rem);
    font-weight: 800;
    margin-bottom: 0.55rem;
}

.dashboard-home .hero p {
    font-size: 1.05rem;
    color: rgba(255, 255, 255, 0.92);
}

.dashboard-home .badge {
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(5px);
    border-radius: 999px;
    padding: 0.45rem 0.85rem;
    font-size: 0.95rem;
}

.dashboard-home .dashboard-grid {
    display: grid;
    grid-template-columns: 1.35fr 1fr 1fr;
    gap: 1rem;
}

.dashboard-home .dashboard-item {
    border-radius: 22px;
    padding: 1.35rem;
    color: #fff;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: 0.25s ease;
}

.dashboard-home .dashboard-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 35px rgba(9, 29, 45, 0.3);
}

.dashboard-home .dashboard-item h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.dashboard-home .dashboard-item p {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 0.8rem;
}

.dashboard-home .dashboard-item span {
    font-size: 0.98rem;
    font-weight: 700;
}

.dashboard-home .dashboard-item .icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    margin-bottom: 0.95rem;
    background: rgba(255, 255, 255, 0.2);
}

.dashboard-home .dashboard-item.payments {
    background: linear-gradient(140deg, var(--theme-primary, #0f172a) 0%, var(--theme-primary-2, #203756) 100%);
    grid-column: span 1;
}

.dashboard-home .dashboard-item.attendance {
    background: linear-gradient(140deg, var(--theme-primary-2, #12566e) 0%, var(--theme-accent, #17808f) 100%);
}

.dashboard-home .dashboard-item.exams {
    background: linear-gradient(140deg, var(--theme-accent, #9c5d17) 0%, #d48a2f 100%);
}

.dashboard-home,
.card,
.table-responsive,
.alert,
.btn,
.form-control,
.form-select {
    animation: theme-fade-up 0.36s ease;
}

@keyframes theme-fade-up {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 992px) {
    .page-content {
        padding: 1.25rem 0.55rem;
    }

    html,
    body {
        font-size: 17px;
    }

    .navbar.floating-navbar {
        margin: 8px;
        width: calc(100% - 16px);
    }

    .dashboard-home {
        padding: 28px 18px;
    }

    .dashboard-home .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .page-content.teacher-theme::before {
        background-size: min(130vw, 920px);
        background-position: right -280px top 10vh;
        opacity: 0.11;
    }

    .page-content.teacher-theme::after {
        background-size: min(120vw, 820px);
        background-position: left -280px bottom -8vh;
        opacity: 0.085;
    }

    .page-content.teacher-theme .content-wrapper::before {
        width: min(92vw, 560px);
        height: min(92vw, 560px);
        opacity: 0.05;
    }
}

@keyframes teacher-brand-fade {
    0% {
        opacity: 0.03;
    }

    50% {
        opacity: 0.09;
    }

    100% {
        opacity: 0.045;
    }
}

@keyframes teacher-brand-fade-strong {
    0% {
        opacity: 0.07;
    }

    50% {
        opacity: 0.16;
    }

    100% {
        opacity: 0.095;
    }
}

@keyframes teacher-brand-drift-1 {
    0% {
        transform: translate3d(0, 0, 0) rotate(0deg);
    }

    50% {
        transform: translate3d(-18px, 12px, 0) rotate(-3deg);
    }

    100% {
        transform: translate3d(0, 0, 0) rotate(0deg);
    }
}

@keyframes teacher-brand-drift-2 {
    0% {
        transform: translate3d(0, 0, 0) rotate(0deg);
    }

    50% {
        transform: translate3d(20px, -10px, 0) rotate(4deg);
    }

    100% {
        transform: translate3d(0, 0, 0) rotate(0deg);
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}