/* ===== TOP NAVBAR (blue gradient) ===== */
.navbar-default, .navbar.navbar-default, nav.navbar.navbar-default {
    background: linear-gradient(90deg, #0F2A5F 0%, #1E5FD8 100%) !important;
    border: none !important;
}
.navbar-default > .container-fluid > .navbar-header > .navbar-brand,
.navbar-default > .container-fluid > .collapse > .nav > li:not(.fd-new-doc-wrapper):not(.fd-lang-pill-wrapper):not(.fd-icon-item) > a:not(.fd-new-doc-btn):not(.fd-lang-pill):not(.fd-icon-link) {
    color: #ffffff !important;
}

/* ===== LEFT SIDEBAR (navy, white text) ===== */

/* ===== DROPDOWN MENUS (white bg, dark text) — explicit, no leak ===== */
.navbar .dropdown-menu {
    background-color: #ffffff !important;
}
.navbar .dropdown-menu > li > a {
    color: #1A1A1A !important;
    background-color: #ffffff !important;
}
.navbar .dropdown-menu > li > a:hover,
.navbar .dropdown-menu > li > a:focus {
    color: #1E5FD8 !important;
    background-color: #F2F4F8 !important;
}
.navbar .dropdown-menu .menu-user-name { color: #4A5568 !important; font-weight: 600; }
.navbar .dropdown-menu .divider { background-color: #E2E8F0 !important; }
.navbar .dropdown-menu button {
    color: #1A1A1A !important;
    background: transparent !important;
    border: none !important;
}
.navbar .dropdown-menu button:hover { color: #1E5FD8 !important; }

/* ===== BUTTONS ===== */
.btn-primary {
    background-color: #1E5FD8 !important;
    border-color: #1E5FD8 !important;
    color: #ffffff !important;
}
.btn-primary:hover, .btn-primary:focus {
    background-color: #1647B0 !important;
    border-color: #1647B0 !important;
    color: #ffffff !important;
}

/* ===== PAGE BG ===== */
body { background-color: #F7F9FC; }

/* ===== HIDE MAYAN LINKS ===== */
.navbar a[href*="mayan-edms.com"],
.navbar a[href*="/dependencies/licenses"],
.navbar .dropdown-menu li:has(> a[href*="mayan-edms.com"]),
.navbar .dropdown-menu li:has(> a[href*="/dependencies/licenses"]) {
    display: none !important;
}

/* Fix: re-hide all external Mayan links */
.navbar a[href*="forum.mayan-edms"],
.navbar a[href*="docs.mayan-edms"],
.navbar a[href*="list.mayan-edms"],
.navbar a[href*="www.mayan-edms"],
.navbar a[href*="gitlab.com/mayan-edms"],
.navbar a[href*="/dependencies/license"] {
    display: none !important;
}
.navbar .dropdown-menu li:has(> a[href*="mayan-edms"]),
.navbar .dropdown-menu li:has(> a[href*="/dependencies/license"]) {
    display: none !important;
}

/* Fix: sidebar footer area (the FanDocs / © 2026 / FAN Advertising line) */
#main-menu-footer,
.navbar-fixed-bottom,
#main-menu-footer p,
#main-menu-footer span,
.navbar-fixed-bottom p {
    color: #ffffff !important;
}
#main-menu-footer p:nth-child(n+2),
.navbar-fixed-bottom p:nth-child(n+2) {
    color: #94A3B8 !important;
}

/* ============================================================ */
/* === FANDOCS SIDEBAR REBUILD (Session 4 Step 1)            === */
/* ============================================================ */

.fd-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin-bottom: 4px;
    color: #CBD5E1 !important;
    text-decoration: none !important;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
    position: relative;
}
.fd-nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: #ffffff !important;
    text-decoration: none !important;
}
.fd-nav-item.active {
    background: rgba(30,95,216,0.20);
    color: #ffffff !important;
    font-weight: 600;
}
.fd-nav-item.active::before {
    content: "";
    position: absolute;
    left: -10px;
    top: 6px;
    bottom: 6px;
    width: 3px;
    background: #1E5FD8;
    border-radius: 0 3px 3px 0;
}

.fd-nav-icon {
    width: 18px;
    text-align: center;
    font-size: 16px;
    color: inherit;
    flex-shrink: 0;
}

.fd-nav-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fd-nav-badge {
    background: rgba(255,255,255,0.10);
    color: #CBD5E1;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}
.fd-nav-item.active .fd-nav-badge {
    background: rgba(30,95,216,0.40);
    color: #ffffff;
}

/* Hide the old accordion sidebar fragments if any survive */
#accordion-sidebar { display: none; }

/* === Storage donut widget (Session 4 Step 3) === */

.fd-storage-label {
    font-size: 11px;
    color: #94A3B8;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.fd-storage-donut {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    margin: 0 auto 10px auto;
    background: conic-gradient(
        #1E5FD8 0% calc(var(--fd-pct, 0) * 1%),
        rgba(255,255,255,0.10) calc(var(--fd-pct, 0) * 1%) 100%
    );
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.fd-storage-donut-inner {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: #0F2A5F;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fd-storage-percent {
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
}

.fd-storage-text {
    font-size: 12px;
    color: #CBD5E1;
    margin-bottom: 10px;
    font-weight: 500;
}

.fd-storage-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255,255,255,0.06);
    color: #CBD5E1 !important;
    text-decoration: none !important;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    transition: background 0.15s;
}
.fd-storage-link:hover {
    background: rgba(255,255,255,0.10);
    color: #ffffff !important;
}
.fd-storage-link i {
    font-size: 10px;
}

/* === FINAL OVERRIDE: force sidebar contents to be truly centered === */

/* === User profile dropdown (Session 4 Step 4) === */

.fd-profile-button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 14px 16px;
    background: transparent;
    border: none;
    border-top: 1px solid rgba(255,255,255,0.08);
    color: inherit;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease;
    box-sizing: border-box;
}
.fd-profile-button:hover {
    background: rgba(255,255,255,0.04);
}
.fd-profile-button:focus {
    outline: none;
    background: rgba(255,255,255,0.06);
}

.fd-profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1E5FD8, #0F2A5F);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.fd-profile-info {
    flex: 1;
    min-width: 0;
}

.fd-profile-name {
    color: white;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fd-profile-role {
    color: #94A3B8;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fd-profile-caret {
    color: #94A3B8;
    font-size: 12px;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}
.fd-profile-button[aria-expanded="true"] .fd-profile-caret {
    transform: rotate(180deg);
}

.fd-profile-menu {
    position: absolute;
    bottom: 100%;
    left: 8px;
    right: 8px;
    background: #1A3D7A;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 8px;
    padding: 6px;
    margin-bottom: 6px;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.30);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.15s, transform 0.15s, visibility 0s linear 0.15s;
    pointer-events: none;
}
/* Open on hover, keyboard focus, OR when JS adds .fd-open */
.fd-sidebar-profile:hover .fd-profile-menu,
.fd-sidebar-profile:focus-within .fd-profile-menu,
.fd-profile-menu.fd-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
    transition: opacity 0.15s, transform 0.15s, visibility 0s;
}
/* Rotate caret when menu open */
.fd-sidebar-profile:hover .fd-profile-caret,
.fd-sidebar-profile:focus-within .fd-profile-caret {
    transform: rotate(180deg);
}

.fd-profile-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: #CBD5E1 !important;
    text-decoration: none !important;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s ease;
}
.fd-profile-menu-item:hover {
    background: rgba(255,255,255,0.08);
    color: white !important;
    text-decoration: none !important;
}
.fd-profile-menu-item i {
    width: 14px;
    text-align: center;
    color: inherit;
    font-size: 13px;
}

.fd-profile-menu-divider {
    height: 1px;
    background: rgba(255,255,255,0.10);
    margin: 4px 6px;
}

.fd-profile-logout {
    color: #F87171 !important;
}
.fd-profile-logout:hover {
    background: rgba(248,113,113,0.10);
    color: #FCA5A5 !important;
}


/* ============================================================ */
/* FANDOCS SIDEBAR - SINGLE SOURCE OF TRUTH                    */
/* ============================================================ */

/* Mayan's wrapper - just give it the right width and ensure
   it doesn't add unwanted padding. The actual sidebar styling
   lives on .fd-sidebar inside it. */
#menu-main {
    width: 210px !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* The sidebar itself - position fixed so it ALWAYS fills the
   viewport from below the topbar to the bottom, regardless of
   screen height or content height. */
.fd-sidebar {
    position: fixed;
    top: 51px;
    left: 0;
    width: 210px;
    height: calc(100vh - 51px);
    background: #0F2A5F;
    color: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
    z-index: 1045;
}

.fd-sidebar-logo {
    flex-shrink: 0;
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    text-align: center;
}
.fd-sidebar-logo img {
    height: 32px;
    width: auto;
}

/* Nav fills available space and scrolls internally if needed */
.fd-sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px 10px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Storage widget - fixed height, never shrinks */
.fd-sidebar-storage {
    flex-shrink: 0;
    padding: 14px 0;
    border-top: 1px solid rgba(255,255,255,0.08);
    text-align: center;
    color: #CBD5E1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

/* Profile widget - fixed height, never shrinks, sticks to bottom */
.fd-sidebar-profile {
    flex-shrink: 0;
    position: relative;
    width: 100%;
    box-sizing: border-box;
}


/* ============================================================ */
/* RESPONSIVE: Hamburger + mobile sidebar (Session 4 Step 5)   */
/* ============================================================ */

/* Hamburger button - hidden on desktop, shown on mobile only */
.fd-hamburger {
    display: none;
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 1050;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 6px;
    background: #1E5FD8;
    color: white;
    cursor: pointer;
    font-size: 16px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.20);
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.fd-hamburger:hover {
    background: #2870E8;
}

/* Backdrop behind open mobile sidebar */
.fd-sidebar-backdrop { display: none !important; }
.fd-sidebar-backdrop.fd-open { display: none !important; }

@media (max-width: 768px) {
    /* Show hamburger */
    .fd-hamburger {
        display: flex;
    }

    /* Slide sidebar off-screen by default */
    .fd-sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        top: 0 !important;
        height: 100vh !important;
        box-shadow: 4px 0 24px rgba(0,0,0,0.40);
    }
    .fd-sidebar.fd-open {
        transform: translateX(0);
    }

    /* Hide #menu-main width reservation on mobile */
    #menu-main {
        width: 0 !important;
    }
}


/* Hide Mayan's native Bootstrap navbar hamburger (we use our own) */
@media (max-width: 768px) {
    .navbar-toggle {
        display: none !important;
    }
    /* Also keep the navbar collapse from interfering */
    .navbar-collapse {
        display: block !important;
    }
}


/* ============================================================ */
/* RESPONSIVE: stat cards + mobile sidebar logo                 */
/* ============================================================ */

/* Default desktop = 5 columns (inline style on element) */

@media (max-width: 1200px) {
    .fd-stat-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 900px) {
    .fd-stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 600px) {
    .fd-stat-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Mobile sidebar - ensure logo visible when sidebar opens */
@media (max-width: 768px) {
    .fd-sidebar-logo {
        display: flex !important;
        justify-content: center;
        align-items: center;
        /* Extra left padding so logo doesn't sit under hamburger button */
        padding: 18px 16px 18px 60px !important;
        background: #0F2A5F;
        min-height: 60px;
    }
    .fd-sidebar-logo img {
        height: 36px !important;
        max-width: 70%;
        display: block;
    }
    .fd-sidebar-logo span {
        color: white;
        font-weight: 600;
        font-size: 18px;
    }
}


/* Mobile: when sidebar is open, push Bootstrap navbar behind it */
@media (max-width: 768px) {
    .fd-sidebar.fd-open {
        z-index: 1100 !important;
    }
    /* Also bump hamburger above the opened sidebar so X stays clickable */
    .fd-hamburger {
        z-index: 1110 !important;
    }
    /* Keep our custom topbar visible on mobile, hide only non-fd-topbar navbars */
    nav.navbar-fixed-top:not(.fd-topbar) {
        display: none !important;
    }
}


/* ==========================================================================
   SESSION 5 - TOPBAR REBUILD
   ========================================================================== */

/* Topbar shell: convert Bootstrap float layout to flexbox single-row */
nav.fd-topbar {
    background: #1E5FD8 !important;
    border: none !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    min-height: 60px;
    height: 60px;
}

nav.fd-topbar .container-fluid {
    display: flex;
    align-items: center;
    height: 60px;
    padding: 0 16px;
    gap: 16px;
}

/* Override Bootstrap floats so children align horizontally */
nav.fd-topbar .navbar-header {
    float: none !important;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 !important;
    height: 60px;
    flex-shrink: 0;
}

nav.fd-topbar .navbar-collapse {
    float: none !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    flex-shrink: 0;
    margin-left: auto;
}

nav.fd-topbar .fd-topbar-actions {
    float: none !important;
    display: flex !important;
    align-items: center;
    gap: 6px;
    margin: 0 !important;
    height: 60px;
}

nav.fd-topbar .fd-topbar-actions > li {
    float: none !important;
    display: flex;
    align-items: center;
    height: 60px;
}

/* Page title */
.fd-page-title {
    color: #FFFFFF;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    display: inline-block;
    cursor: default;
}

/* Search bar */
.fd-topbar-search {
    flex: 1 1 auto;
    max-width: 560px;
    height: 38px;
    background: #F1F3F5;
    border-radius: 8px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    position: relative;
    margin: 0;
}

.fd-search-icon {
    color: #6C757D;
    font-size: 14px;
    margin-right: 8px;
    flex-shrink: 0;
}

.fd-search-type-chip {
    display: flex;
    align-items: center;
    height: 26px;
    background: #FFFFFF;
    border-radius: 6px;
    padding: 0 10px;
    margin-right: 10px;
    flex-shrink: 0;
}

.fd-search-type-chip .dropdown-toggle {
    color: #0F2A5F;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    padding: 0;
    line-height: 26px;
    background: none;
    border: none;
}

.fd-search-type-chip .dropdown-toggle:hover,
.fd-search-type-chip .dropdown-toggle:focus {
    color: #1E5FD8;
    text-decoration: none;
    background: none;
}

.fd-search-type-chip .caret {
    margin-left: 6px;
    color: #6C757D;
}

.fd-search-input {
    flex: 1 1 auto;
    border: none !important;
    background: transparent !important;
    outline: none !important;
    box-shadow: none !important;
    height: 100%;
    font-size: 13px;
    color: #0F2A5F;
    padding: 0;
    min-width: 0;
}

.fd-search-input::placeholder {
    color: #6C757D;
}

.fd-search-shortcut {
    background: #FFFFFF;
    color: #6C757D;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid #DEE2E6;
    flex-shrink: 0;
    margin-left: 8px;
}

/* + Nouveau document button */
.fd-new-doc-wrapper {
    margin-right: 8px;
}

.fd-new-doc-btn {
    background: #FFFFFF !important;
    color: #1E5FD8 !important;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px !important;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center;
    gap: 6px;
    text-decoration: none !important;
    line-height: 1 !important;
    height: 38px;
}

.fd-new-doc-btn:hover,
.fd-new-doc-btn:focus {
    background: #F1F3F5 !important;
    color: #1E5FD8 !important;
}

.fd-new-doc-btn::before {
    content: "+";
    font-size: 16px;
    font-weight: 700;
    margin-right: 2px;
}

.fd-new-doc-btn .caret {
    margin-left: 4px;
}

/* Icon buttons (bell, mail, help) */
.fd-icon-item {
    position: relative;
}

.fd-icon-link {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    color: #FFFFFF !important;
    font-size: 16px;
    text-decoration: none !important;
    transition: background 0.15s ease;
}

.fd-icon-link:hover,
.fd-icon-link:focus {
    background: rgba(255, 255, 255, 0.15) !important;
    color: #FFFFFF !important;
}

.fd-icon-link i {
    line-height: 1;
}

/* Notification badge */
.fd-badge {
    position: absolute;
    top: 6px;
    right: 4px;
    background: #FF4757;
    color: #FFFFFF;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
    border: 2px solid #1E5FD8;
}

/* FR language pill */
.fd-lang-pill-wrapper {
    margin-left: 4px;
}

.fd-lang-pill {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.15) !important;
    border-radius: 50% !important;
    color: #FFFFFF !important;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none !important;
    padding: 0 !important;
}

.fd-lang-pill:hover,
.fd-lang-pill:focus {
    background: rgba(255, 255, 255, 0.25) !important;
    color: #FFFFFF !important;
}

.fd-lang-pill .caret {
    display: none;
}

.fd-lang-code {
    line-height: 1;
}

.fd-lang-option {
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    padding: 6px 16px;
    color: #1A1A1A;
    font-size: 13px;
    cursor: pointer;
}

.fd-lang-option:hover {
    background: #F1F3F5;
}

/* Hide stock Mayan topbar icons that we replaced (earth/refresh/server/profile/old bell/chat) */
nav.fd-topbar .fd-topbar-actions > li.dropdown:not(.fd-new-doc-wrapper):not(.fd-lang-pill-wrapper),
nav.fd-topbar .fd-topbar-actions > li:not(.fd-icon-item):not(.fd-new-doc-wrapper):not(.fd-lang-pill-wrapper) {
    display: none !important;
}

/* Adjust home page top spacing - topbar is 60px tall now */
body {
    padding-top: 60px;
}

/* Sidebar offset: was top: 51px, adjust if needed */
.fd-sidebar {
    top: 60px !important;
}

/* Hide page title on narrow screens */
@media (max-width: 992px) {
    .fd-page-title {
        display: none;
    }
    .fd-search-shortcut {
        display: none;
    }
}

@media (max-width: 768px) {
    .fd-topbar-search {
        display: flex !important;
        flex: 1;
        max-width: none;
        margin: 0 6px;
    }
    .fd-search-type-chip {
        display: none;
    }
    .fd-search-input {
        font-size: 13px;
    }
}

/* END SESSION 5 - TOPBAR REBUILD */


/* ==========================================================================
   SESSION 5 - TOPBAR FIX 1
   Hide Mayan's stock search form that gets injected by appearance_app_templates
   ========================================================================== */

#search-navbar-form {
    display: none !important;
}

/* Force #navbar to be flex row, not stacked block */
nav.fd-topbar .navbar-collapse {
    display: flex !important;
    align-items: center;
    flex-direction: row;
}

/* Make sure the actions UL doesn't fight the flex */
nav.fd-topbar .fd-topbar-actions {
    flex: 0 0 auto;
}

/* END TOPBAR FIX 1 */


/* ==========================================================================
   SESSION 5 - TOPBAR FIX 2
   - Force Nouveau document button text color visible
   - Add body padding so content sits below fixed topbar
   - FR pill light-blue per mockup
   ========================================================================== */

/* Higher-specificity override for the button text */
nav.fd-topbar .fd-topbar-actions .fd-new-doc-btn,
nav.fd-topbar .fd-topbar-actions .fd-new-doc-btn:hover,
nav.fd-topbar .fd-topbar-actions .fd-new-doc-btn:focus,
nav.fd-topbar .fd-topbar-actions .fd-new-doc-btn:active {
    color: #1E5FD8 !important;
    background: #FFFFFF !important;
}

nav.fd-topbar .fd-topbar-actions .fd-new-doc-btn:hover {
    background: #F1F3F5 !important;
}

nav.fd-topbar .fd-topbar-actions .fd-new-doc-btn .caret {
    border-top-color: #1E5FD8;
}

/* Push body content below the 60px fixed topbar - higher specificity */
html body {
    padding-top: 60px !important;
}

/* FR pill - light blue per mockup */
nav.fd-topbar .fd-lang-pill,
nav.fd-topbar .fd-lang-pill:focus {
    background: #DCE7FA !important;
    color: #1E5FD8 !important;
}

nav.fd-topbar .fd-lang-pill:hover {
    background: #C5D6F5 !important;
    color: #1E5FD8 !important;
}

/* END TOPBAR FIX 2 */


/* ==========================================================================
   SESSION 5 - TOPBAR FIX 3
   - Kill Mayan stock spacer; body padding-top is doing the job
   ========================================================================== */

#appearance-main-viewport {
    margin-top: 0 !important;
}

/* END TOPBAR FIX 3 */


/* ==========================================================================
   SESSION 7 - ARBORESCENCE WIDGET
   ========================================================================== */

.fd-arborescence-tree,
.fd-arborescence-tree ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.fd-tree-node {
    position: relative;
}

.fd-tree-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 6px;
    border-radius: 6px;
    transition: background 0.12s ease;
    cursor: default;
}

.fd-tree-row:hover {
    background: #F7F9FC;
}

/* Indentation by level via padding-left */
.fd-tree-row[data-level="0"] { padding-left: 6px; }
.fd-tree-row[data-level="1"] { padding-left: 28px; }
.fd-tree-row[data-level="2"] { padding-left: 50px; }
.fd-tree-row[data-level="3"] { padding-left: 72px; }
.fd-tree-row[data-level="4"] { padding-left: 94px; }
.fd-tree-row[data-level="5"] { padding-left: 116px; }

.fd-tree-toggle {
    background: none;
    border: none;
    width: 18px;
    height: 18px;
    padding: 0;
    cursor: pointer;
    color: #64748B;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.18s ease;
    flex-shrink: 0;
}

.fd-tree-toggle:hover {
    color: #1E5FD8;
}

.fd-tree-toggle.fd-expanded {
    transform: rotate(90deg);
}

.fd-tree-toggle-spacer {
    display: inline-block;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.fd-tree-folder-icon {
    color: #1E5FD8;
    font-size: 14px;
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

.fd-tree-doc-icon {
    color: #94A3B8;
    font-size: 13px;
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

.fd-tree-label {
    color: #0F2A5F;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fd-tree-label:hover {
    color: #1E5FD8;
    text-decoration: none;
}

.fd-tree-doc-label {
    color: #475569;
    font-size: 12.5px;
    font-weight: 400;
    text-decoration: none;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fd-tree-doc-label:hover {
    color: #1E5FD8;
    text-decoration: none;
}

.fd-tree-count {
    background: #EEF2F8;
    color: #64748B;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.fd-tree-row:hover .fd-tree-count {
    background: #DCE7FA;
    color: #1E5FD8;
}

/* END SESSION 7 - ARBORESCENCE WIDGET */


/* ==========================================================================
   SESSION 7c - DOC TYPES DONUT WIDGET
   ========================================================================== */

.fd-doctype-row {
    display: flex;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
}

.fd-doctype-donut-wrap {
    flex: 0 0 auto;
    width: 180px;
    height: 180px;
}

.fd-doctype-donut {
    width: 100%;
    height: 100%;
}

.fd-doctype-donut path {
    transition: opacity 0.18s ease, transform 0.18s ease;
    transform-origin: 60px 60px;
    cursor: pointer;
}

.fd-doctype-donut path:hover {
    opacity: 0.82;
    transform: scale(1.04);
}

.fd-doctype-legend {
    flex: 1 1 280px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 24px;
    min-width: 280px;
}

.fd-doctype-row-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #0F2A5F;
}

.fd-doctype-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.fd-doctype-label {
    flex: 1 1 auto;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fd-doctype-pct {
    color: #0F2A5F;
    font-weight: 700;
    font-size: 13px;
}

.fd-doctype-count {
    color: #64748B;
    font-size: 12px;
}

@media (max-width: 720px) {
    .fd-doctype-row {
        flex-direction: column;
        align-items: stretch;
    }
    .fd-doctype-donut-wrap {
        margin: 0 auto;
    }
    .fd-doctype-legend {
        grid-template-columns: 1fr;
    }
}

/* END SESSION 7c - DOC TYPES DONUT WIDGET */


/* ==========================================================================
   SESSION 8 - MES TACHES WIDGET
   ========================================================================== */

.fd-tasks-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.fd-task-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 10px;
    border-radius: 8px;
    transition: background 0.15s ease;
    cursor: pointer;
    border-bottom: 1px solid #F1F5F9;
}

.fd-task-item:last-child {
    border-bottom: none;
}

.fd-task-item:hover {
    background: #F8FAFC;
}

.fd-task-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.fd-task-body {
    flex: 1 1 auto;
    min-width: 0;
}

.fd-task-doc-label {
    display: block;
    color: #0F2A5F;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 4px;
}

.fd-task-doc-label:hover {
    color: #1E5FD8;
    text-decoration: none;
}

.fd-task-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #64748B;
    flex-wrap: wrap;
}

.fd-task-state {
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 11px;
    white-space: nowrap;
}

.fd-task-priority {
    font-weight: 600;
    display: inline-flex;
    align-items: center;
}

.fd-task-sep {
    color: #CBD5E0;
    font-weight: 700;
}

.fd-task-age {
    color: #94A3B8;
}

.fd-task-chevron {
    color: #CBD5E0;
    font-size: 12px;
    flex-shrink: 0;
    transition: color 0.15s ease, transform 0.15s ease;
}

.fd-task-item:hover .fd-task-chevron {
    color: #1E5FD8;
    transform: translateX(2px);
}

/* END SESSION 8 - MES TACHES WIDGET */


/* ==========================================================================
   SESSION 10 - CLASSEURS PAGE (Option C: tree + breadcrumb + doc cards)
   ========================================================================== */

.fd-classeurs-container {
    background: #F8FAFC;
    padding: 0;
    margin: -20px;
    min-height: calc(100vh - 100px);
}

/* Breadcrumb bar */
.fd-classeurs-breadcrumb {
    background: white;
    border-bottom: 1px solid #E2E8F0;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #64748B;
}
.fd-classeurs-breadcrumb i.fa-home {
    color: #1E5FD8;
    font-size: 14px;
}
.fd-crumb-link {
    color: #64748B;
    text-decoration: none;
    transition: color 0.15s;
}
.fd-crumb-link:hover {
    color: #1E5FD8;
    text-decoration: none;
}
.fd-crumb-sep {
    color: #CBD5E0;
    font-size: 10px;
}
.fd-crumb-current {
    color: #0F2A5F;
    font-weight: 600;
}

/* Two-column layout */
.fd-classeurs-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 0;
    min-height: calc(100vh - 160px);
}

/* LEFT: tree panel */
.fd-classeurs-tree {
    background: white;
    border-right: 1px solid #E2E8F0;
    padding: 20px 14px;
    overflow-y: auto;
}
.fd-tree-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94A3B8;
    font-weight: 700;
    margin-bottom: 10px;
    padding: 0 8px;
}
.fd-clas-list,
.fd-clas-children {
    list-style: none;
    padding: 0;
    margin: 0;
}
.fd-clas-children {
    padding-left: 16px;
    margin-top: 2px;
}
.fd-clas-node {
    margin-bottom: 2px;
}
.fd-clas-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    color: #334155;
    text-decoration: none;
    font-size: 13px;
    transition: background 0.12s, color 0.12s;
}
.fd-clas-row:hover {
    background: #F1F5F9;
    color: #1E5FD8;
    text-decoration: none;
}
.fd-clas-row-current {
    background: #E6F1FB;
    color: #0F2A5F;
    font-weight: 600;
}
.fd-clas-icon {
    color: #1E5FD8;
    font-size: 13px;
    flex-shrink: 0;
}
.fd-clas-row-current .fd-clas-icon {
    color: #1E5FD8;
}
.fd-clas-label {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fd-clas-count {
    background: #E2E8F0;
    color: #64748B;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 8px;
}
.fd-clas-row-current .fd-clas-count {
    background: #1E5FD8;
    color: white;
}

/* RIGHT: main panel */
.fd-classeurs-main {
    padding: 24px 28px;
    overflow-y: auto;
}
.fd-classeurs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
}
.fd-classeurs-title {
    color: #0F2A5F;
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 4px;
}
.fd-classeurs-count {
    color: #64748B;
    font-size: 13px;
}

/* Doc card grid */
.fd-doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}
.fd-doc-card {
    background: white;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
}
.fd-doc-card:hover {
    border-color: #1E5FD8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 95, 216, 0.08);
    text-decoration: none;
    color: inherit;
}
.fd-doc-thumb {
    background: #F1F5F9;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.fd-doc-thumb i {
    font-size: 34px;
    color: #94A3B8;
}
.fd-doc-card-body {
    padding: 10px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.fd-doc-card-label {
    font-size: 12px;
    font-weight: 600;
    color: #0F2A5F;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 6px;
}
.fd-doc-card-meta {
    font-size: 10px;
    color: #64748B;
    margin-bottom: 6px;
}
.fd-doc-card-type {
    background: #F1F5F9;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
}
.fd-doc-card-state {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    font-weight: 700;
    margin-top: auto;
}
.fd-doc-card-state-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

/* Empty state */
.fd-classeurs-empty {
    background: white;
    border-radius: 10px;
    padding: 60px 30px;
    text-align: center;
    border: 1px solid #E2E8F0;
}
.fd-classeurs-empty-icon {
    font-size: 56px;
    color: #CBD5E0;
    display: block;
    margin-bottom: 14px;
}
.fd-classeurs-empty-title {
    color: #0F2A5F;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
}
.fd-classeurs-empty-text {
    color: #64748B;
    font-size: 13px;
}

/* Responsive */
@media (max-width: 900px) {
    .fd-classeurs-layout {
        grid-template-columns: 1fr;
    }
    .fd-classeurs-tree {
        border-right: none;
        border-bottom: 1px solid #E2E8F0;
    }
}

/* END SESSION 10 */


/* ==========================================================================
   SESSION 11 - GLOBAL THEMING (Mayan stock pages -> FanDocs brand)
   Applies to every stock list/detail/form page across the app.
   ========================================================================== */

/* === BACKGROUND: soften the page area, NOT the topbar === */
/* Apply only to container-fluid that is direct child of #main-content or body,
   never to one inside the navbar topbar (which has its own brand-blue bg). */
body > .container-fluid,
#main-content > .container-fluid,
#main-container.container-fluid,
.main-content .container-fluid {
    background: #F8FAFC !important;
}
/* Belt-and-suspenders: explicitly clear bg on topbar container-fluid */
nav.navbar .container-fluid,
.fd-topbar .container-fluid {
    background: transparent !important;
}

/* === TOOLBAR (pagination + filter + sort bar): white card not "well" === */
.well.toolbar {
    background: white !important;
    border: 1px solid #E2E8F0 !important;
    border-radius: 8px !important;
    box-shadow: 0 1px 3px rgba(15, 42, 95, 0.04) !important;
    padding: 14px 18px !important;
    margin-bottom: 20px !important;
}

/* === GENERIC BUTTONS: Bootstrap defaults -> FanDocs === */
.btn {
    border-radius: 6px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    transition: all 0.15s ease !important;
    border-width: 1px !important;
}

.btn-default,
.btn-outline,
.btn.btn-default.btn-outline {
    background: white !important;
    border: 1px solid #CBD5E0 !important;
    color: #0F2A5F !important;
}
.btn-default:hover,
.btn-outline:hover,
.btn.btn-default.btn-outline:hover {
    background: #F1F5F9 !important;
    border-color: #1E5FD8 !important;
    color: #1E5FD8 !important;
}

.btn-primary {
    background: #1E5FD8 !important;
    border-color: #1E5FD8 !important;
    color: white !important;
}
.btn-primary:hover {
    background: #1849B0 !important;
    border-color: #1849B0 !important;
}

.btn-danger {
    background: #EF4444 !important;
    border-color: #EF4444 !important;
    color: white !important;
}
.btn-danger:hover {
    background: #DC2626 !important;
    border-color: #DC2626 !important;
}

.btn-success {
    background: #10B981 !important;
    border-color: #10B981 !important;
}

.btn-warning {
    background: #F59E0B !important;
    border-color: #F59E0B !important;
    color: white !important;
}

.btn-xs {
    padding: 4px 10px !important;
    font-size: 12px !important;
}

/* === TABLES: clean FanDocs grid === */
.appearance-table-condensed,
.table-condensed.table-striped {
    background: white !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    border: 1px solid #E2E8F0 !important;
    box-shadow: 0 1px 3px rgba(15, 42, 95, 0.04) !important;
}

.appearance-table-condensed thead,
.table-condensed thead {
    background: #F1F5F9 !important;
}

.appearance-table-condensed thead th,
.table-condensed thead th {
    color: #0F2A5F !important;
    font-weight: 700 !important;
    font-size: 12px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    padding: 12px 16px !important;
    border-bottom: 1px solid #E2E8F0 !important;
}

.appearance-table-condensed tbody td,
.table-condensed tbody td {
    padding: 14px 16px !important;
    color: #334155 !important;
    border-top: 1px solid #F1F5F9 !important;
    vertical-align: middle !important;
}

.appearance-table-condensed tbody tr:hover,
.table-condensed tbody tr:hover {
    background: #F8FAFC !important;
}

.table-striped > tbody > tr:nth-of-type(odd) {
    background: white !important;
}

/* === FORM INPUTS: branded focus === */
.form-control {
    border: 1px solid #CBD5E0 !important;
    border-radius: 6px !important;
    color: #0F2A5F !important;
    font-size: 13px !important;
    box-shadow: none !important;
    transition: border-color 0.15s, box-shadow 0.15s !important;
}
.form-control:focus {
    border-color: #1E5FD8 !important;
    box-shadow: 0 0 0 3px rgba(30, 95, 216, 0.1) !important;
    outline: none !important;
}

/* === PAGINATION: branded === */
.pagination > li > a,
.pagination > li > span {
    color: #1E5FD8 !important;
    border: 1px solid #E2E8F0 !important;
    background: white !important;
}
.pagination > li.active > a,
.pagination > li.active > span {
    background: #1E5FD8 !important;
    color: white !important;
    border-color: #1E5FD8 !important;
}
.pagination > li > a:hover {
    background: #F1F5F9 !important;
    color: #1849B0 !important;
}

/* === PANELS (well, panel) === */
.well:not(.toolbar):not(.fd-classeurs *) {
    background: white !important;
    border: 1px solid #E2E8F0 !important;
    border-radius: 8px !important;
    box-shadow: 0 1px 3px rgba(15, 42, 95, 0.04) !important;
}

.panel {
    border-radius: 8px !important;
    border: 1px solid #E2E8F0 !important;
    box-shadow: 0 1px 3px rgba(15, 42, 95, 0.04) !important;
}
.panel-heading {
    background: #F1F5F9 !important;
    border-bottom: 1px solid #E2E8F0 !important;
    border-radius: 8px 8px 0 0 !important;
    color: #0F2A5F !important;
    font-weight: 600 !important;
}

/* === LINKS: keep readable but branded on hover === */
a:not(.btn):not(.fd-classeurs *):not(.fd-doc-card):not(.fd-clas-row) {
    color: #1E5FD8;
    transition: color 0.15s;
}
a:not(.btn):not(.fd-classeurs *):not(.fd-doc-card):not(.fd-clas-row):hover {
    color: #1849B0;
    text-decoration: underline;
}

/* === "Total: N" headings: distinctive but not overwhelming === */
.container-fluid > h4,
.container-fluid h4:first-of-type {
    color: #0F2A5F !important;
    font-weight: 700 !important;
    font-size: 18px !important;
    margin: 20px 0 16px !important;
    padding-bottom: 12px !important;
    border-bottom: 2px solid #E2E8F0 !important;
}

/* === BREADCRUMB on detail pages === */
.breadcrumb {
    background: white !important;
    border: 1px solid #E2E8F0 !important;
    border-radius: 6px !important;
    padding: 10px 14px !important;
    font-size: 13px !important;
}
.breadcrumb > li > a {
    color: #64748B !important;
}
.breadcrumb > .active {
    color: #0F2A5F !important;
    font-weight: 600 !important;
}

/* === LABELS (Bootstrap 3 colored pills): rebrand === */
.label-info {
    background-color: #1E5FD8 !important;
}
.label-success {
    background-color: #10B981 !important;
}
.label-warning {
    background-color: #F59E0B !important;
}
.label-danger {
    background-color: #EF4444 !important;
}
.label {
    border-radius: 4px !important;
    font-weight: 600 !important;
    padding: 3px 8px !important;
}

/* === DROPDOWN MENUS (Bootstrap 3 stock) === */
.dropdown-menu {
    border-radius: 8px !important;
    border: 1px solid #E2E8F0 !important;
    box-shadow: 0 4px 12px rgba(15, 42, 95, 0.08) !important;
    padding: 6px !important;
}
.dropdown-menu > li > a {
    color: #334155 !important;
    border-radius: 4px !important;
    padding: 8px 12px !important;
    transition: background 0.12s !important;
}
.dropdown-menu > li > a:hover {
    background: #F1F5F9 !important;
    color: #1E5FD8 !important;
}

/* === ALERTS === */
.alert {
    border-radius: 8px !important;
    border: 1px solid transparent !important;
    padding: 14px 18px !important;
}
.alert-info {
    background: #EFF6FF !important;
    border-color: #BFDBFE !important;
    color: #1E40AF !important;
}
.alert-success {
    background: #ECFDF5 !important;
    border-color: #A7F3D0 !important;
    color: #047857 !important;
}
.alert-warning {
    background: #FFFBEB !important;
    border-color: #FDE68A !important;
    color: #92400E !important;
}
.alert-danger {
    background: #FEF2F2 !important;
    border-color: #FECACA !important;
    color: #B91C1C !important;
}

/* === MODAL DIALOGS === */
.modal-content {
    border-radius: 12px !important;
    border: none !important;
    box-shadow: 0 20px 60px rgba(15, 42, 95, 0.15) !important;
}
.modal-header {
    background: #F8FAFC !important;
    border-bottom: 1px solid #E2E8F0 !important;
    border-radius: 12px 12px 0 0 !important;
    padding: 18px 24px !important;
}
.modal-title {
    color: #0F2A5F !important;
    font-weight: 700 !important;
}
.modal-body {
    padding: 24px !important;
}
.modal-footer {
    background: #F8FAFC !important;
    border-top: 1px solid #E2E8F0 !important;
    border-radius: 0 0 12px 12px !important;
}

/* === BREADCRUMB FOR CABINETS specifically (Mayans uses ::: separator) === */
/* Already handled via .breadcrumb above */

/* END SESSION 11 - GLOBAL THEMING */


/* ==========================================================================
   SESSION 11 PATCH - hide Mayan table decoration rows
   These are structural spacers/rulers Mayan adds between thead and tbody.
   They render as ugly empty gray bands in our cleaner FanDocs table style.
   ========================================================================== */
.appearance-table-thead-tr-spacer,
.appearance-table-thead-tr-ruler,
.appearance-table-tbody-tr-ruler {
    display: none !important;
}
/* END PATCH */


/* ==========================================================================
   SESSION 11 PATCH 2 - Right rail (.list-group) FanDocs branding
   The "Related" / "Return" sidebar on detail pages uses Bootstrap 3 list-group.
   Mayans default .list-group-item.active has dark navy bg + blue text = invisible.
   ========================================================================== */

.list-group-item {
    border: 1px solid #E2E8F0 !important;
    color: #334155 !important;
    padding: 10px 14px !important;
    font-size: 13px !important;
    transition: background 0.12s, color 0.12s, border-color 0.12s !important;
}

.list-group-item:hover {
    background: #F1F5F9 !important;
    color: #1E5FD8 !important;
}

.list-group-item.active,
.list-group-item.active:hover,
.list-group-item.active:focus,
a.list-group-item.active {
    background: #1E5FD8 !important;
    border-color: #1E5FD8 !important;
    color: white !important;
}

.list-group-item.active i,
a.list-group-item.active i {
    color: white !important;
}

/* Section divider headings in right rail ("Related", "Return") */
.list-group-item.disabled,
.list-group .list-group-item:not(a):not(button),
.list-group-item[class*="heading"] {
    background: transparent !important;
    border: none !important;
    color: #94A3B8 !important;
    font-size: 11px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    font-weight: 700 !important;
    padding: 12px 14px 4px !important;
}

/* END PATCH 2 */


/* === SIDEBAR ACTIVE STATE (Session 11 final v2) === */
/* Uses body[data-fd-active-pattern] + child .fd-nav-item[data-fd-match].
   Mayan's partial nav can repaint sidebar items without losing this state,
   because the data attribute lives on <body>, which Mayan does not touch. */
body[data-fd-active-pattern="^/?$|^/home/?$"] .fd-nav-item[data-fd-match="^/?$|^/home/?$"],
body[data-fd-active-pattern="^/documents/documents"] .fd-nav-item[data-fd-match="^/documents/documents"],
body[data-fd-active-pattern="^/arborescence"] .fd-nav-item[data-fd-match="^/arborescence"],
body[data-fd-active-pattern="^/cabinets"] .fd-nav-item[data-fd-match="^/cabinets"],
body[data-fd-active-pattern="^/workflows"] .fd-nav-item[data-fd-match="^/workflows"],
body[data-fd-active-pattern="^/metadata"] .fd-nav-item[data-fd-match="^/metadata"],
body[data-fd-active-pattern="^/tags"] .fd-nav-item[data-fd-match="^/tags"],
body[data-fd-active-pattern="^/accounts/users"] .fd-nav-item[data-fd-match="^/accounts/users"],
body[data-fd-active-pattern="^/statistics"] .fd-nav-item[data-fd-match="^/statistics"] {
    background: rgba(255, 255, 255, 0.10) !important;
    color: #FFFFFF !important;
    font-weight: 600 !important;
    border-left: 3px solid #FFFFFF !important;
    padding-left: 13px !important;
}
/* === END active state === */

/* ============================================================================
   Mes taches - inline transition buttons (Session 8b)
   ============================================================================ */
.fd-task-item {
    position: relative;
}

.fd-task-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.fd-task-btn {
    border: none;
    color: white;
    padding: 5px 12px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
    font-family: inherit;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.fd-task-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.fd-task-btn:active {
    transform: translateY(0);
}

.fd-task-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.fd-task-btn .fa {
    margin-right: 4px;
    font-size: 10px;
}

/* Fade out animation when task is resolved */
.fd-task-item.fd-task-resolving {
    opacity: 0.4;
    pointer-events: none;
}

.fd-task-item.fd-task-resolved {
    opacity: 0;
    max-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    transition: opacity 0.3s ease, max-height 0.4s ease, padding 0.3s ease, margin 0.3s ease;
}

/* Toast notification (bottom-right) */
.fd-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-size: 13px;
    font-weight: 500;
    z-index: 99999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    max-width: 360px;
}

.fd-toast.fd-toast-show {
    transform: translateX(0);
}

.fd-toast-success { background: #10B981; }
.fd-toast-error { background: #EF4444; }
.fd-toast-info { background: #1E5FD8; }

/* Fix for task item buttons clipping into next row (Session 8b polish) */
.fd-tasks-list .fd-task-item {
    border-bottom: 1px solid #F1F5F9;
    padding-bottom: 14px;
    margin-bottom: 14px;
}
.fd-tasks-list .fd-task-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

/* Force dropdowns to open DOWNWARD even when JS adds .dropup auto-flip */
.dropdown.dropup .dropdown-menu,
.dropup .dropdown-menu {
    top: 100% !important;
    bottom: auto !important;
    margin-top: 2px !important;
    margin-bottom: 0 !important;
}

/* Fix: Mayan's right "En rapport / Retour" sidebar (#sidebar) is fixed-positioned
   and overlaps the table's rightmost columns, eating clicks on row action buttons.
   Make the container ignore clicks, but keep its child links clickable. */
#sidebar {
    pointer-events: none;
}
#sidebar > * {
    pointer-events: auto;
}

/* ============================================================================
   Workflow templates list - dropdown button visibility fix
   ============================================================================
   The "⋮" (three-dot) Actions dropdown in the rightmost ACTIONS column was
   getting clipped by the table edge. Fix: give the column generous right
   padding and force the Bootstrap dropdown menu to open leftward with enough
   margin so it never gets clipped by the viewport or sidebar overlay.
*/

/* Give the rightmost cell room to breathe so the ⋮ button isn't flush to edge */
table.table > tbody > tr > td:last-child,
table.table > thead > tr > th:last-child {
    padding-right: 16px !important;
}

/* Make the three-dot button more visible: subtle bg + border so it doesn't look "barely there" */
table.table button.btn-invisible[data-toggle="dropdown"] {
    background: rgba(15, 42, 95, 0.06);
    border: 1px solid rgba(15, 42, 95, 0.10);
    border-radius: 6px;
    padding: 4px 8px;
    transition: background 0.15s, border-color 0.15s;
}

table.table button.btn-invisible[data-toggle="dropdown"]:hover {
    background: rgba(30, 95, 216, 0.12);
    border-color: rgba(30, 95, 216, 0.40);
}

/* The dropdown menu opens dropup AND right-aligned. Two issues fixed:
   1. Menu was clipping at table edge - ensure parent containers don't crop.
   2. Last-row menu was getting cut - shift menu left so it never extends
      beyond the table right edge. */
table.table .dropdown-menu {
    right: 100% !important;
    left: auto !important;
    margin-right: 8px;
    margin-top: 0 !important;
    /* Sufficient z-index to sit above any sidebar overlay and the table card */
    z-index: 1100;
}

/* Ensure table containers don't clip the dropdown when it escapes the cell */
.table-responsive {
    overflow: visible !important;
}
table.table tbody td {
    overflow: visible !important;
    position: relative;
}

/* The td that holds the dropdown needs to be the positioning context */
table.table td .dropdown {
    position: static;
}


/* The dropdown menu opens dropup AND right-aligned. Two issues fixed:
   1. Menu was clipping at table edge - ensure parent containers don't crop.
   2. Last-row menu was getting cut - shift menu left so it never extends
      beyond the table right edge. */
table.table .dropdown-menu {
    right: 100% !important;
    left: auto !important;
    margin-right: 8px;
    margin-top: 0 !important;
    /* Sufficient z-index to sit above any sidebar overlay and the table card */
    z-index: 1100;
}

/* Ensure table containers don't clip the dropdown when it escapes the cell */
.table-responsive {
    overflow: visible !important;
}
table.table tbody td {
    overflow: visible !important;
    position: relative;
}

/* The td that holds the dropdown needs to be the positioning context */
table.table td .dropdown {
    position: static;
}

/* ============================================================================
   Fix: notification toast readability
   ============================================================================
   Mayan's success alert renders with white text — our styling made background
   too light so text became invisible. Force proper contrast on system alerts. */
.alert-success,
div.alert.alert-success,
.notification-success,
.toast-success {
    background-color: #10B981 !important;
    color: #FFFFFF !important;
    border-color: #059669 !important;
}

.alert-success *,
.notification-success *,
.toast-success * {
    color: #FFFFFF !important;
}

/* Also fix the close (x) button visibility on colored alerts */
.alert-success .close,
.alert-danger .close,
.alert-warning .close {
    color: #FFFFFF !important;
    opacity: 0.9;
}

/* Info alerts (blue) - similar treatment */
.alert-info {
    background-color: #1E5FD8 !important;
    color: #FFFFFF !important;
    border-color: #185FA5 !important;
}
.alert-info * { color: #FFFFFF !important; }

/* Warning alerts - keep dark text on amber for readability */
.alert-warning {
    background-color: #FBBF24 !important;
    color: #78350F !important;
    border-color: #F59E0B !important;
}
.alert-warning * { color: #78350F !important; }

/* Danger alerts */
.alert-danger {
    background-color: #EF4444 !important;
    color: #FFFFFF !important;
    border-color: #DC2626 !important;
}
.alert-danger * { color: #FFFFFF !important; }

/* ============================================================================
   RTL SUPPORT
   ============================================================================
   Fires when <html dir="rtl"> (set by root.html based on LANGUAGE_BIDI).
   Django's LANGUAGE_BIDI is True for Arabic, Hebrew, Persian, Urdu.
   Only overrides directional properties; keeps LTR as default. */

/* Sidebar: flip from left to right edge of viewport */
[dir="rtl"] .fd-sidebar {
    left: auto;
    right: 0;
}

/* Tree indentation: children should push right, not left */
[dir="rtl"] .fd-tree-row[data-level="0"] { padding-left: 0; padding-right: 6px; }
[dir="rtl"] .fd-tree-row[data-level="1"] { padding-left: 0; padding-right: 28px; }
[dir="rtl"] .fd-tree-row[data-level="2"] { padding-left: 0; padding-right: 50px; }
[dir="rtl"] .fd-tree-row[data-level="3"] { padding-left: 0; padding-right: 72px; }
[dir="rtl"] .fd-tree-row[data-level="4"] { padding-left: 0; padding-right: 94px; }
[dir="rtl"] .fd-tree-row[data-level="5"] { padding-left: 0; padding-right: 116px; }

/* Toggle chevron: point in the correct direction. In LTR, the > chevron
   rotates to v when open. In RTL, the closed chevron should visually be 
   pointing "into" the parent from the right. Mirror the entire chevron. */
[dir="rtl"] .fd-tree-toggle i.fa-chevron-right {
    transform: scaleX(-1);
}

/* Arborescence widget classic tree - same indentation flip */
[dir="rtl"] .fd-clas-list ul,
[dir="rtl"] .fd-clas-children {
    padding-right: 20px;
    padding-left: 0;
}

/* Sidebar profile menu: opens upward but its dropdown arrow needs mirroring */
[dir="rtl"] .fd-profile-caret {
    /* No structural change - the caret icon already works in both directions */
}

/* Task list, cabinets tree bullet dots stay right-aligned to nav labels */
[dir="rtl"] .fd-task-dot,
[dir="rtl"] .fd-clas-icon {
    margin-right: 0;
    margin-left: 8px;
}

/* Nav item icons: swap left margin for right margin so labels align */
[dir="rtl"] .fd-nav-icon {
    margin-right: 0;
    margin-left: 12px;
}

/* Stat card border accent: in LTR the colored bar is border-left.
   In RTL flip to border-right for visual balance. */
[dir="rtl"] div[style*="border-left: 4px solid"] {
    border-left: none !important;
    border-right: 4px solid;
    /* browser will inherit the same color from the inline style */
}

/* Topbar dropdown menu: opens right-aligned in LTR. In RTL should open
   left-aligned so it doesn't overflow the left edge. */
[dir="rtl"] .dropdown-menu-right {
    right: auto !important;
    left: 0 !important;
}

/* Mobile hamburger menu: sidebar slides in from RIGHT in RTL, not LEFT */
@media (max-width: 992px) {
    [dir="rtl"] .fd-sidebar {
        transform: translateX(100%);  /* off-screen to the RIGHT */
    }
    [dir="rtl"] .fd-sidebar.fd-open {
        transform: translateX(0);
    }
}

/* END RTL SUPPORT */

/* #menu-main is position: fixed; top: 51px; left: 0 in LTR (independent
   of .fd-sidebar which is ALSO position: fixed inside it). Float on a
   fixed-positioned element is a no-op - we must swap left/right instead. */
[dir="rtl"] #menu-main {
    left: auto !important;
    right: 0 !important;
}

/* Viewport spacing: #menu-main is position:fixed and overlays the right
   edge (210px wide). Content needs padding-right to avoid being hidden
   under it. This mirrors LTR's implicit padding-left behavior. */
[dir="rtl"] #appearance-main-viewport {
    margin-left: 0 !important;
    padding-left: 0;
    padding-right: 210px;
}

/* RTL topbar: flip auto margin so action cluster hugs left edge */
[dir="rtl"] nav.navbar-fixed-top .navbar-collapse {
    margin-left: 0 !important;
    margin-right: auto !important;
}

/* Dropdown menus in tables need to escape overflow: hidden.
   Root cause: table.table has overflow:hidden + limited height.
   Menu opens below the row button and gets clipped by table bottom. */
.table,
table.table,
table.table-condensed,
.table-responsive {
    overflow: visible !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
}

/* Ensure dropdown menu itself renders above sidebar/topbar */
.dropdown-menu {
    z-index: 2000 !important;
}

/* Mobile: both #menu-main and .fd-sidebar hidden/slide-in from the right */
@media (max-width: 992px) {
    [dir="rtl"] #menu-main {
        right: auto !important;
        left: auto !important;
    }
}

/* Topbar logo */
.fd-topbar-logo img {
    height: 36px;
    width: auto;
    display: block;
}

/* Hide list display mode toggle (grid/list switcher - not needed) */
.btn-toolbar .btn-group:first-child .btn[href*="list_mode"],
form#navigation-form-sort-field,
.btn-toolbar-search-filter {
    /* keep filter */
}
.appearance-list-content > .row > .col-xs-12 > .btn-toolbar > .btn-group:first-child {
    display: none !important;
}

/* Hide list display mode toggle (grid/list switcher) on mobile - wastes space */
@media (max-width: 768px) {
    .btn-toolbar .btn-group:first-child > a.btn[href*="list_mode"],
    .pull-left .btn-toolbar .btn-group:first-child {
        display: none !important;
    }
}

/* Hide Mayan's native sidebar toggle - max specificity */
html body #main-menu-button-open,
html body .main-menu-button-open,
button#main-menu-button-open {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    pointer-events: none !important;
}

/* Advanced search button inside search bar */
.fd-search-advanced-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(255,255,255,0.15);
    color: white;
    text-decoration: none;
    flex-shrink: 0;
    margin-left: 4px;
    transition: background 0.2s;
}
.fd-search-advanced-btn:hover {
    background: rgba(255,255,255,0.3);
    color: white;
    text-decoration: none;
}
.fd-search-advanced-btn .fa {
    font-size: 13px;
}
