/* Float image right and wrap text when paragraph is right-aligned */
.fi-fo-rich-editor-content p[style*="text-align: right"] img,
.fi-fo-rich-editor-content p[style*="text-align: end"] img,
.fi-in-text p[style*="text-align: right"] img,
.fi-in-text p[style*="text-align: end"] img {
    float: right;
    margin-left: 1.5rem;
    margin-bottom: 0.75rem;
}

/* Float image left and wrap text when paragraph is left-aligned */
.fi-fo-rich-editor-content p[style*="text-align: left"] img,
.fi-fo-rich-editor-content p[style*="text-align: start"] img,
.fi-in-text p[style*="text-align: left"] img,
.fi-in-text p[style*="text-align: start"] img {
    float: left;
    margin-right: 1.5rem;
    margin-bottom: 0.75rem;
}

/* Center image when paragraph is center-aligned */
.fi-fo-rich-editor-content p[style*="text-align: center"] img,
.fi-in-text p[style*="text-align: center"] img {
    display: block;
    margin: 1.5rem auto;
}

/* Ensure paragraph has block formatting context to contain floats */
.fi-fo-rich-editor-content p,
.fi-in-text p {
    display: flow-root;
}

/* --- PREMIUM UI STYLING --- */

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.25);
    border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(156, 163, 175, 0.4);
}

/* Sidebar Custom Styling */
.fi-sidebar {
    border-right: 1px solid rgba(229, 231, 235, 0.6) !important;
    background-color: #fcfdfe !important;
}
.dark .fi-sidebar {
    border-right: 1px solid rgba(75, 85, 99, 0.2) !important;
    background-color: #080b12 !important;
}

.fi-sidebar-item-button {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    border-radius: 10px !important;
    margin: 2px 8px !important;
}
.fi-sidebar-item-button:hover {
    background-color: rgba(99, 102, 241, 0.08) !important;
    transform: translateX(3px);
}
.dark .fi-sidebar-item-button:hover {
    background-color: rgba(99, 102, 241, 0.15) !important;
}

/* Card & Section Enhancements */
.fi-section, .fi-ta-content, .fi-card {
    border-radius: 16px !important;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.03), 0 1px 2px -1px rgba(0, 0, 0, 0.03) !important;
    border: 1px solid rgba(229, 231, 235, 0.6) !important;
    transition: box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}
.dark .fi-section, .dark .fi-ta-content, .dark .fi-card {
    border: 1px solid rgba(75, 85, 99, 0.2) !important;
    background-color: #111827 !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.15), 0 2px 4px -1px rgba(0, 0, 0, 0.08) !important;
}

.fi-section:hover, .fi-ta-content:hover, .fi-card:hover {
    box-shadow: 0 12px 20px -8px rgba(99, 102, 241, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.02) !important;
    border-color: rgba(99, 102, 241, 0.25) !important;
}
.dark .fi-section:hover, .dark .fi-ta-content:hover, .dark .fi-card:hover {
    border-color: rgba(99, 102, 241, 0.35) !important;
}

/* Topbar glassmorphism */
.fi-topbar {
    background-color: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border-bottom: 1px solid rgba(229, 231, 235, 0.5) !important;
}
.dark .fi-topbar {
    background-color: rgba(17, 24, 39, 0.8) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border-bottom: 1px solid rgba(75, 85, 99, 0.2) !important;
}

/* Form input focus highlights */
.fi-fo-text-input input:focus, 
.fi-fo-select select:focus, 
.fi-fo-textarea textarea:focus {
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12) !important;
}

/* Main content spacing and dynamic transitions */
main {
    animation: fadeIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Premium Login Layout Gradient Background */
.fi-simple-layout {
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.08), transparent 40%),
                radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.06), transparent 40%),
                #fafbfc !important;
}
.dark .fi-simple-layout {
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.15), transparent 40%),
                radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.08), transparent 40%),
                #030712 !important;
}
.fi-simple-page-card {
    border-radius: 20px !important;
    border: 1px solid rgba(229, 231, 235, 0.5) !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.08) !important;
}
.dark .fi-simple-page-card {
    border: 1px solid rgba(75, 85, 99, 0.3) !important;
    background-color: #0b0f19 !important;
}

/* Note Editor Preview Table & List Styles */
.fi-fo-rich-editor-content table,
.fi-in-text table {
    border-collapse: collapse;
    width: 100%;
    margin: 1.5rem 0;
}
.fi-fo-rich-editor-content table,
.fi-fo-rich-editor-content th,
.fi-fo-rich-editor-content td,
.fi-in-text table,
.fi-in-text th,
.fi-in-text td {
    border: 1.5px solid #94a3b8 !important;
    padding: 8px 12px !important;
}
.fi-fo-rich-editor-content th,
.fi-in-text th {
    background-color: rgba(148, 163, 184, 0.1) !important;
    font-weight: bold;
}

/* Image Figures & Captions */
.fi-fo-rich-editor-content figcaption,
.fi-in-text figcaption {
    font-style: italic !important;
    color: #64748b !important;
    font-size: 0.875rem !important;
    text-align: center !important;
    margin-top: 0.5rem !important;
}
.fi-fo-rich-editor-content figure,
.fi-in-text figure {
    margin: 1.5rem 0;
    text-align: center;
}

/* Lists Line Spacing (in trix-editor typing area, previews, and read views) */
trix-editor ul,
trix-editor ol,
.fi-fo-rich-editor-content ul,
.fi-fo-rich-editor-content ol,
.fi-in-text ul,
.fi-in-text ol {
    margin-top: 0.25rem !important;
    margin-bottom: 0.25rem !important;
    line-height: 1.0 !important;
}
trix-editor li,
.fi-fo-rich-editor-content li,
.fi-in-text li {
    line-height: 1.0 !important;
    margin-bottom: 0.15rem !important;
}

/* RichEditor (Trix) toolbar wrap styling to prevent overflow */
trix-toolbar .trix-button-row {
    display: flex !important;
    flex-wrap: wrap !important;
}
trix-toolbar .trix-button-group {
    margin-bottom: 4px !important;
    border-right: 1px solid #e2e8f0 !important;
    padding-right: 4px !important;
}
.dark trix-toolbar .trix-button-group {
    border-right: 1px solid #334155 !important;
}

/* --- COMPACT PREMIUM TYPE SYSTEM (ALL ADMIN PAGES) --- */
.fi-body,
.fi-layout,
.fi-main {
    font-size: 12px;
    letter-spacing: -0.005em;
}

.fi-main {
    background:
        radial-gradient(circle at 100% 0, rgba(99, 102, 241, 0.035), transparent 28%),
        #f8fafc;
}

.dark .fi-main {
    background:
        radial-gradient(circle at 100% 0, rgba(99, 102, 241, 0.08), transparent 28%),
        #080c14;
}

/* Page and section headings */
.fi-header-heading {
    font-size: 1.25rem !important;
    font-weight: 750 !important;
    letter-spacing: -0.035em !important;
    line-height: 1.3 !important;
}

.fi-header-subheading {
    font-size: 0.72rem !important;
    line-height: 1.55 !important;
}

.fi-section-header-heading {
    font-size: 0.78rem !important;
    font-weight: 750 !important;
    letter-spacing: -0.01em !important;
}

.fi-section-header-description {
    font-size: 0.68rem !important;
    line-height: 1.5 !important;
}

/* Navigation */
.fi-sidebar-item-label {
    font-size: 0.72rem !important;
    font-weight: 650 !important;
}

.fi-sidebar-group-label {
    font-size: 0.61rem !important;
    font-weight: 800 !important;
    letter-spacing: 0.09em !important;
    text-transform: uppercase;
}

.fi-sidebar-item-icon {
    width: 1.05rem !important;
    height: 1.05rem !important;
}

/* Forms */
.fi-fo-field-label-content,
.fi-fo-field-label,
.fi-input-wrp input,
.fi-input-wrp select,
.fi-input-wrp textarea,
.fi-select-input,
.fi-fo-placeholder {
    font-size: 0.72rem !important;
}

.fi-fo-field-label-content {
    font-weight: 650 !important;
}

.fi-fo-field-wrp-helper-text,
.fi-fo-field-wrp-error-message {
    font-size: 0.64rem !important;
    line-height: 1.45 !important;
}

.fi-input-wrp {
    border-radius: 10px !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.025) !important;
    transition: border-color 160ms ease, box-shadow 160ms ease !important;
}

.fi-input-wrp:focus-within {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1) !important;
}

/* Tables, badges, pagination and actions */
.fi-ta-header-cell-label,
.fi-ta-text-item-label,
.fi-ta-cell,
.fi-pagination,
.fi-dropdown-list-item-label {
    font-size: 0.69rem !important;
}

.fi-ta-header-cell-label {
    font-size: 0.62rem !important;
    font-weight: 800 !important;
    letter-spacing: 0.045em !important;
    text-transform: uppercase;
}

.fi-badge {
    border-radius: 999px !important;
    font-size: 0.61rem !important;
    font-weight: 750 !important;
    letter-spacing: 0.02em !important;
}

.fi-btn {
    border-radius: 9px !important;
    font-size: 0.68rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.005em !important;
}

.fi-icon-btn {
    border-radius: 9px !important;
}

/* Modals, tabs and notifications */
.fi-modal-heading {
    font-size: 0.95rem !important;
    font-weight: 750 !important;
    letter-spacing: -0.02em !important;
}

.fi-modal-description,
.fi-tabs-item-label,
.fi-no-notification-title,
.fi-no-notification-body {
    font-size: 0.7rem !important;
}

/* Keep authored learning content readable, but slightly more compact. */
.fi-fo-rich-editor-content,
.fi-in-text,
trix-editor {
    font-size: 0.78rem !important;
    line-height: 1.55 !important;
}

@media (max-width: 640px) {
    .fi-header-heading {
        font-size: 1.1rem !important;
    }

    .fi-main {
        font-size: 11px;
    }
}

/* Compact data density for MCQ and SQ/LQ question tables only. */
.compact-question-table .fi-ta-header-cell-label {
    font-size: 0.58rem !important;
}

.compact-question-table .fi-ta-cell,
.compact-question-table .fi-ta-text-item-label,
.compact-question-table .fi-ta-text {
    font-size: 0.64rem !important;
    line-height: 1.35 !important;
}

.compact-question-table .fi-badge {
    font-size: 0.56rem !important;
    padding-block: 0.18rem !important;
}

.compact-question-table .fi-ta-row > td {
    padding-block: 0.48rem !important;
}

/* --- BRAND LOGO (123.png) & TEXT STYLING FOR NAVBAR, SIDEBAR & LOGIN --- */
.fi-logo a,
.fi-logo div,
.fi-sidebar-header a,
.fi-sidebar-header div {
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.6rem !important;
}

.fi-logo img,
.fi-sidebar-header img {
    max-height: 2.4rem !important;
    width: auto !important;
    object-fit: contain !important;
    border-radius: 6px !important;
}

.fi-simple-header img {
    max-height: 3.8rem !important;
    width: auto !important;
    margin: 0 auto 0.75rem auto !important;
    object-fit: contain !important;
    border-radius: 10px !important;
}

.fi-logo span,
.fi-sidebar-header span,
.fi-simple-header span {
    display: inline-block !important;
    font-size: 1.2rem !important;
    font-weight: 850 !important;
    letter-spacing: -0.025em !important;
    color: #1e1b4b !important;
    white-space: nowrap !important;
}

.dark .fi-logo span,
.dark .fi-sidebar-header span,
.dark .fi-simple-header span {
    color: #f8fafc !important;
}
