/* =========================================
   Proper LD Layout Inside CSUK
========================================= */

.csuk-main {
    position: relative;
    height: 100%;
}

.csuk-main:has(.ld-focus) {
    transform: translateZ(0);
}

.csuk-main .ld-focus {
    position: absolute;
    inset: 0;
}

.ld-focus-main{
    display:block !important;
}

.nt-note-tab {
	margin-bottom: 20px;
    margin-right: 125px;
}

body.ld-in-focus-mode.admin-bar {
    padding-top: 0 !important;
}

@media only screen and (min-width: 783px) {
    body.admin-bar .learndash-wrapper .ld-focus-header {
        top: 0px !important;
    }
}

body.admin-bar .learndash-wrapper .ld-focus-sidebar {
    top: 0px !important;
}

.learndash-wrapper .ld-focus .ld-focus-main .ld-focus-content {
	padding-top: 100px !important;
}

/* =========================================
   Disable CSUK scroll when LD is present
========================================= */

.csuk-main:has(.ld-focus) {
    overflow: hidden !important;
}

.learndash-wrapper .ld-focus .ld-focus-sidebar {
	z-index: 1 !important;
}

/* Rebuild Focus layout INSIDE csuk container */
.csuk-main .ld-focus {
    display: flex;
    flex-direction: column;
}

/* Header natural height */
.csuk-main .ld-focus-header {
    flex-shrink: 0;
}

/* Main row fills remaining space */
.csuk-main .ld-focus-main {
    flex: 1;
    display: flex;
    min-height: 0; /* critical */
}

/* Sidebar fixed width */
.csuk-main .ld-focus-sidebar {
    flex-shrink: 0;
}

/* Make ld-focus fill container */
.csuk-main .ld-focus {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Header natural height */
.csuk-main .ld-focus-header {
    flex-shrink: 0;
}

/* Main area scrolls (like native) */
.csuk-main .ld-focus-main {
    flex: 1;
    display: flex;
    overflow-y: auto;
    min-height: 0; /* critical */
}

/* Sidebar fixed width */
.csuk-main .ld-focus-sidebar {
    flex-shrink: 0;
}

/* Content just fills space */
.csuk-main .ld-focus-content {
    flex: 1;
    min-height: 0;
}

/* Prevent tiny overflow */
.csuk-main .ld-focus-main {
    overflow-y: auto;
    overflow-x: hidden;
}

/* Ensure sidebar never exceeds height */
.csuk-main .ld-focus-sidebar {
    max-height: 100%;
}

/* =========================================
   CORE LAYOUT
========================================= */

.csuk-app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* TOP BAR */
.csuk-topbar {
    height: 64px;
    background: var(--card-background);
    border-top: 1px solid color-mix(in srgb, var(--text-color) 10%, transparent);
    border-bottom: 3px solid var(--csuk-accent);
    color: var(--text-color);
	border-bottom: 3px solid var(--csuk-accent);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
}

/* BODY AREA */
.csuk-body {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

.csuk-left-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

.csuk-interface-logo {
    height: 36px !important;
    width: auto !important;
    object-fit: contain !important;
}

.csuk-logo-text {
    font-weight: 600;
    font-size: 16px;
    color: #1e293b;
}

/* =============================
   USER INFO (Top Right)
============================= */

.csuk-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.csuk-user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    border: 2px solid var(--csuk-accent);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.csuk-user-avatar:hover,
.csuk-user-avatar:focus {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--csuk-accent) 22%, transparent);
    outline: none;
    transform: translateY(-1px);
}

.csuk-user-name {
    font-weight: 600;
    font-size: 14px;
}

.csuk-user-edit {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid color-mix(in srgb, var(--text-color) 12%, transparent);
    border-radius: 50%;
    background: color-mix(in srgb, var(--main-background) 82%, transparent);
    color: var(--text-color);
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    padding: 0;
    transition: background 0.2s ease, transform 0.2s ease;
}

.csuk-user-edit:hover {
    background: var(--csuk-accent);
    color: #ffffff;
    transform: translateY(-1px);
}

.csuk-profile-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000000;
    background: rgba(15, 23, 42, 0.62);
    backdrop-filter: blur(4px);
}

.csuk-profile-modal-content {
    position: relative;
    width: min(460px, calc(100vw - 32px));
    margin: 8vh auto;
    padding: 24px;
    border-radius: 10px;
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
}

.csuk-profile-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    border: 0;
    background: transparent;
    color: #475569;
    cursor: pointer;
    font-size: 26px;
    line-height: 1;
}

.csuk-profile-modal-content h2 {
    margin: 0 0 18px;
    font-size: 22px;
    line-height: 1.2;
}

.csuk-profile-modal-content label {
    display: block;
    margin: 12px 0 6px;
    font-size: 13px;
    font-weight: 700;
}

.csuk-profile-modal-content input {
    width: 100%;
    min-height: 40px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
}

.csuk-profile-modal-content button[type="submit"] {
    width: 100%;
    min-height: 42px;
    margin-top: 18px;
    border: 0;
    border-radius: 8px;
    background: var(--csuk-accent);
    color: #ffffff;
    cursor: pointer;
    font-weight: 800;
}

.csuk-profile-modal-content button[type="submit"]:disabled {
    cursor: wait;
    opacity: 0.65;
}

.csuk-avatar-modal-content {
    width: min(680px, calc(100vw - 32px));
    max-height: 84vh;
    overflow: auto;
}

.csuk-avatar-selection {
    display: grid;
    gap: 18px;
}

.csuk-avatar-group-title {
    margin: 0 0 10px;
    color: #334155;
    font-size: 14px;
    line-height: 1.2;
}

.csuk-avatar-group {
    border-top: 1px solid #e2e8f0;
    padding-top: 14px;
}

.csuk-avatar-group:first-child {
    border-top: 0;
    padding-top: 0;
}

.csuk-avatar-option {
    width: 68px;
    height: 68px;
    margin: 0 8px 8px 0;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 50%;
    background: #f8fafc;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.csuk-avatar-option:hover,
.csuk-avatar-option:focus {
    border-color: var(--csuk-accent);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
    outline: none;
    transform: translateY(-2px);
}

.csuk-avatar-option:disabled {
    cursor: wait;
    opacity: 0.72;
}

.csuk-avatar-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.csuk-avatar-empty {
    margin: 0;
    color: #64748b;
}


/* =============================
   USAGE WIDGET (Top Center)
============================= */

.csuk-usage-widget {
    min-width: 340px;
    max-width: 520px;
    flex: 0 1 520px;
    display: grid;
    grid-template-columns: minmax(170px, 1fr) minmax(110px, 180px) auto;
    align-items: center;
    gap: 12px;
    padding: 8px 10px 8px 14px;
}

.csuk-usage-widget-guest {
    grid-template-columns: minmax(170px, 1fr);
}

.csuk-usage-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.csuk-usage-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--text-color) 58%, transparent);
    line-height: 1.1;
}

.csuk-usage-value {
    font-size: 13px;
    font-weight: 800;
    color: var(--text-color);
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.csuk-usage-reset {
    font-size: 10px;
    font-weight: 600;
    color: color-mix(in srgb, var(--text-color) 62%, transparent);
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.csuk-usage-meter {
    height: 8px;
    width: 100%;
    overflow: hidden;
    border-radius: 999px;
    background: color-mix(in srgb, var(--text-color) 10%, transparent);
}

.csuk-usage-meter span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #16a34a 0%, #22c55e 55%, var(--csuk-accent) 100%);
    transition: width 0.55s ease;
}

.csuk-usage-widget.is-warning .csuk-usage-meter span {
    background: linear-gradient(90deg, #f59e0b 0%, #ef4444 100%);
}

.csuk-usage-widget.is-unlimited .csuk-usage-meter span {
    background: linear-gradient(90deg, #7c3aed 0%, #06b6d4 100%);
}

.csuk-usage-widget.is-refreshing {
    animation: csukUsagePulse 0.65s ease;
}

.csuk-usage-upgrade,
.csuk-usage-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
}

.csuk-usage-upgrade {
    color: #ffffff;
    background: var(--csuk-accent);
    box-shadow: 0 6px 14px color-mix(in srgb, var(--csuk-accent) 28%, transparent);
}

.csuk-usage-upgrade:hover {
    color: #ffffff;
    transform: translateY(-1px);
}

.csuk-usage-badge {
    color: #ffffff;
    background: linear-gradient(135deg, #7c3aed 0%, #0ea5e9 100%);
}

@keyframes csukUsagePulse {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--csuk-accent) 28%, transparent); }
    100% { box-shadow: 0 0 0 12px transparent; }
}

/* =========================================
   SIDEBAR BASE
========================================= */

.csuk-sidebar::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 2px;
    height: 100%;
    background: var(--csuk-accent);
    opacity: 0.1;
}

.csuk-sidebar {
    width: 72px;
    background: var(--main-background);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    padding-top: 20px;
    transition: width 0.25s ease;
    overflow: hidden;
	align-items: stretch;
    position: relative;
    z-index: 30;
}

/* EXPANDED (hover) OR DOCKED */
.csuk-app.expanded .csuk-sidebar,
.csuk-app.docked .csuk-sidebar {
    width: 240px;
}

.csuk-nav-area {
    position: relative;
    display: flex;
    z-index: 20;
}

.csuk-menu-separator{
    height:1px;
    margin:14px 8px;
    background:linear-gradient(
        to right,
        transparent,
        var(--csuk-accent),
        transparent
    );
    opacity:0.5;
}

.csuk-menu-separator-text{
    display:none;
    font-size:10px;
    font-weight:700;
    text-transform:uppercase;
    letter-spacing:0.08em;
    color: color-mix(in srgb, var(--text-color) 55%, transparent);
    margin:10px 8px 4px;
    text-align:center;
    line-height:1.2;
}

.csuk-app.expanded .csuk-menu-separator-text,
.csuk-app.docked .csuk-menu-separator-text{
    display:block;
}

/* =========================================
   LOCKED MENU ITEMS
========================================= */

.csuk-menu-locked {
    opacity: 0.4;
    cursor: not-allowed !important;
    position: relative;
}

.csuk-menu-locked .csuk-menu-icon,
.csuk-menu-locked .csuk-icon-text {
    filter: grayscale(0.6);
}

.csuk-menu-lock-tooltip {
    display: none;
    position: fixed;
    background: #1f2937;
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    z-index: 2147483647;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    gap: 8px;
    align-items: center;
    pointer-events: auto;
    transform: translateY(-50%);
    transition: opacity 0.15s ease;
    opacity: 0;
}

.csuk-menu-lock-tooltip.is-visible {
    display: flex;
    opacity: 1;
}

.csuk-menu-lock-tooltip::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 6px 6px 6px 0;
    border-style: solid;
    border-color: transparent #1f2937 transparent transparent;
}

.csuk-menu-lock-icon {
    font-size: 18px;
    line-height: 1;
}

.csuk-menu-lock-msg {
    opacity: 0.85;
}

.csuk-menu-lock-link {
    color: var(--csuk-accent);
    text-decoration: underline;
    font-weight: 600;
    pointer-events: auto;
    margin-left: 4px;
}

.csuk-menu-lock-link:hover {
    opacity: 0.8;
}

/* =========================================
   MENU ITEM LABELS / BANNERS
========================================= */

.csuk-menu-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #ffffff;
    background-color: #ff6b6b;
    margin-left: 8px;
    flex-shrink: 0;
    white-space: nowrap;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    text-shadow: none;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Hidden in collapsed state */
.csuk-app:not(.expanded):not(.docked) .csuk-menu-label {
    display: none;
}

/* Slightly adjust position in docked/expanded state */
.csuk-app.expanded .csuk-menu-label,
.csuk-app.docked .csuk-menu-label {
    margin-left: auto;
    margin-right: 4px;
}

/* Labels in overlay panels (child menu items) */
.csuk-overlay-panel .csuk-menu-label {
    margin-left: auto;
    margin-right: 0;
}

/* =========================================
   ICON ROW
========================================= */

.csuk-top-icon {
    height: 60px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.25s ease;
}

.csuk-top-icon:hover {
	background: color-mix(in srgb, var(--text-color) 8%, transparent);
    transform: translateX(2px);
    border-bottom: 3px solid var(--csuk-accent);
}

.csuk-top-icon.active {
    background: color-mix(in srgb, var(--csuk-accent) 15%, white);
    border-right: 3px solid var(--csuk-accent);
}

.csuk-top-icon.active .csuk-icon-text {
    color: #1e3a8a;
    font-weight: 600;
}

/* COLLAPSED STATE (DEFAULT) */
.csuk-app:not(.expanded):not(.docked) .csuk-top-icon {
    justify-content: flex-start;
    padding: 20px;
}

/* EXPANDED OR DOCKED STATE */
.csuk-app.expanded .csuk-top-icon,
.csuk-app.docked .csuk-top-icon {
    justify-content: flex-start;
    padding: 0 20px;
    gap: 15px;
}

/* =========================================
   ICON
========================================= */

.csuk-menu-icon {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
}

.csuk-sidebar ul,
.csuk-sidebar ol {
    margin: 0 !important;
    padding: 0 !important;
    list-style: none;
}

.csuk-menu-icon {
    filter: none !important;
}

/* =========================================
   TEXT
========================================= */

.csuk-icon-text {
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.15s ease;
    color: var(--text-color);
    font-size: 14px;
    font-weight: 500;
}

/* SHOW TEXT WHEN EXPANDED OR DOCKED */
.csuk-app.expanded .csuk-icon-text,
.csuk-app.docked .csuk-icon-text {
    opacity: 1;
}

/* =========================================
   LEVEL 1 PUSH PANEL
========================================= */

.csuk-panel-level-1 {
    width: 0;
    background: #1f2937;
    overflow: hidden;
    transition: width 0.25s ease;
    flex-shrink: 0;
}

.csuk-panel-level-1.active {
    width: 240px;
}

.csuk-panel-level-1 .csuk-slide-link {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* =========================================
   MAIN CONTENT
========================================= */

.csuk-main {
    flex: 1;
    overflow-y: auto;
    background: var(--main-background);
}


/* =========================================
   OVERLAY PANELS (LEVEL 2+)
========================================= */

.csuk-overlay-panel {
    position: absolute;
    top: 0;
    left: 240px;
    width: 260px;
    height: 100%;
    background: #ffffff;
    background-image: none;
    color: var(--text-color);
    border-left: 1px solid #e2e8f0;
    box-shadow: -4px 0 12px rgba(0,0,0,0.05);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 5;
    border-left: 1px solid #e2e8f0;
    box-shadow: -8px 0 20px rgba(0,0,0,0.04);
}

.csuk-overlay-panel.active {
    transform: translateX(0);
}

.csuk-overlay-panel .csuk-slide-link {
    padding: 12px 16px;
    background: #ffffff;
}

/* =========================================
   LINKS
========================================= */

.csuk-slide-link {
    padding: 10px 12px;
    margin-bottom: 6px;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
}

.csuk-slide-link-text {
    white-space: nowrap;
    font-size: 14px;
    font-weight: 500;
}

.csuk-slide-link:hover {
    background: color-mix(in srgb, var(--text-color) 8%, transparent);
    border-bottom: 3px solid var(--csuk-accent);
}

/* SEPARATORS IN OVERLAY PANELS */
.csuk-overlay-panel .csuk-menu-separator-text {
    display: block;
    margin: 10px 16px 4px;
    color: #64748b;
}

.csuk-overlay-panel .csuk-menu-separator {
    margin: 10px 16px;
}


.csuk-parent-header {
    font-weight: 600;
    padding: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    color: #ffffff;
}

.csuk-parent-header.clickable {
    cursor: pointer;
}

.csuk-parent-header.clickable:hover {
    background: rgba(255,255,255,0.08);
    border-radius: 6px;
}

/* =========================================
   DOCK MODE
========================================= */

.csuk-dock-toggle {
    color: var(--text-color);
    cursor: pointer;
}

.csuk-app.docked .csuk-sidebar {
    width: 240px;
    align-items: flex-start;
    padding-left: 15px;
}

.csuk-app.docked .csuk-top-icon {
    justify-content: flex-start;
    gap: 15px;
}

/* =========================================
   GAMIFICATION ICONS
========================================= */

.csuk-user-gamification{
    display:flex;
    align-items:center;
    gap:16px;
    margin-right:20px;
}

.csuk-gamify-item{
    display:flex;
    align-items:center;
    gap:6px;
    font-weight:600;
    font-size:14px;
}

.csuk-gamify-item img{
    height:26px;
    width:auto;
}

.csuk-rank img{
    height:30px;
}

.csuk-gamify-item span{
    color:#000;
}

@media (max-width: 900px) {

    .csuk-topbar {
        padding: 0 14px;
    }

    .csuk-user-name {
        font-size: 13px;
    }

    .csuk-usage-widget {
        min-width: 240px;
        max-width: 380px;
        grid-template-columns: minmax(130px, 1fr) minmax(80px, 120px) auto;
        gap: 8px;
        padding: 7px 8px 7px 10px;
    }

    .csuk-usage-label,
    .csuk-usage-reset {
        font-size: 9px;
    }

    .csuk-usage-value {
        font-size: 12px;
    }

    .csuk-usage-upgrade,
    .csuk-usage-badge {
        min-height: 28px;
        padding: 0 10px;
        font-size: 11px;
    }

    .csuk-app.is-mobile-view .csuk-body {
        overflow: hidden;
    }

    .csuk-app.is-mobile-view .csuk-nav-area {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(320px, 86vw);
        pointer-events: none;
        z-index: 40;
    }

    .csuk-app.is-mobile-view .csuk-sidebar {
        width: 72px;
        height: 100%;
        background: #ffffff !important;
        background-image: none !important;
        transform: translateX(-100%);
        opacity: 0;
        visibility: hidden;
        transition: transform 0.25s ease, opacity 0.2s ease, visibility 0.2s ease;
        box-shadow: 14px 0 28px rgba(0,0,0,0.12);
    }

    .csuk-app.is-mobile-view.mobile-nav-open .csuk-nav-area {
        pointer-events: auto;
    }

    .csuk-app.is-mobile-view.mobile-nav-open .csuk-sidebar {
        transform: translateX(0);
        opacity: 1;
        visibility: visible;
    }

    .csuk-app.is-mobile-view .csuk-sidebar::before {
        opacity: 0.2;
    }

    .csuk-app.is-mobile-view .csuk-top-icon {
        justify-content: flex-start;
        padding: 20px;
        color: #0f172a;
    }

    .csuk-app.is-mobile-view .csuk-top-icon:hover {
        transform: none;
    }

    .csuk-app.is-mobile-view .csuk-menu-icon {
        filter: none !important;
    }

    .csuk-app.is-mobile-view .csuk-icon-text,
    .csuk-app.is-mobile-view .csuk-slide-link {
        color: #0f172a;
    }

    .csuk-app.is-mobile-view .csuk-main {
        width: 100%;
    }

    .csuk-app.is-mobile-view .csuk-overlay-panel {
        top: 0;
        left: 72px !important;
        width: calc(100% - 72px);
        min-width: 0;
        height: 100%;
        background: #ffffff !important;
        background-image: none !important;
        border-left: 1px solid #e2e8f0;
        box-shadow: -8px 0 20px rgba(0,0,0,0.08);
    }

    .csuk-app.is-mobile-view .csuk-overlay-panel .csuk-slide-link {
        background: #ffffff;
    }

    .csuk-app.is-mobile-view .csuk-overlay-panel.active {
        transform: translateX(0);
    }
}

@media (max-width: 640px) {

    .csuk-topbar {
        height: 58px;
    }

    .csuk-left-group {
        gap: 10px;
    }

    .csuk-interface-logo {
        height: 30px !important;
    }

    .csuk-usage-widget {
        min-width: 0;
        flex: 1 1 auto;
        grid-template-columns: minmax(110px, 1fr) auto;
        max-width: none;
    }

    .csuk-usage-meter {
        display: none;
    }

    .csuk-usage-reset {
        display: none;
    }

    .csuk-usage-upgrade,
    .csuk-usage-badge {
        min-height: 26px;
        padding: 0 8px;
    }

    .csuk-user-name {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .csuk-user-info {
        gap: 8px;
    }

    .csuk-user-avatar {
        width: 30px;
        height: 30px;
    }

    .csuk-app.is-mobile-view .csuk-nav-area {
        width: 100%;
    }

    .csuk-app.is-mobile-view .csuk-sidebar {
        width: 68px;
    }

    .csuk-app.is-mobile-view .csuk-overlay-panel {
        left: 68px !important;
        width: calc(100% - 68px);
    }
}
