/* ============================================
   SIDEBAR NAVIGATION LAYOUT
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}


html {
  font-size: 14px;
    height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f8f9fa;
    overflow-x: hidden;
}

body.sidebar-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 270px;
    background-color: #ffffff;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform 0.3s ease, width 0.3s ease;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
}

.sidebar.collapsed {
    width: 70px;
}

.sidebar.collapsed .brand-text,
.sidebar.collapsed .menu-text,
.sidebar.collapsed .search-input,
.sidebar.collapsed .menu-badge,
.sidebar.collapsed .submenu-arrow,
.sidebar.collapsed .user-name,
.sidebar.collapsed .submenu {
    display: none;
}

.sidebar.collapsed .user-menu-icon {
    display: none;
}

.sidebar.collapsed .search-wrapper {
    padding: 8px;
    justify-content: center;
}

.sidebar.collapsed .search-icon {
    margin: 0;
}

.sidebar.collapsed .user-avatar {
    margin: 0;
}

.sidebar.collapsed .menu-link,
.sidebar.collapsed .app-switch-link,
.sidebar.collapsed .user-profile-link {
    justify-content: center;
    padding: 12px;
}

.sidebar.collapsed .menu-icon {
    margin-right: 0;
}

/* Sidebar Header */
.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-header .sidebar-toggle {
    width: 36px;
    height: 36px;
    border: none;
    background-color: transparent;
    color: #3b3b3b;
    font-size: 18px;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-header .sidebar-toggle:hover {
    background-color: #f1f3f5;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
}

.sidebar.collapsed .sidebar-brand {
    display: none;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.sidebar-brand a {
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-logo {
    height: 80px;
    width: auto;
    object-fit: contain;
}

.brand-text {
    white-space: nowrap;
}

/* Search Bar */
.sidebar-search {
    padding: 16px;
    border-bottom: 1px solid #e9ecef;
}

.search-wrapper {
    display: flex;
    align-items: center;
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 8px 12px;
    transition: background-color 0.2s ease;
}

.search-wrapper:focus-within {
    background-color: #e9ecef;
}

.search-icon {
    color: #868e96;
    margin-right: 8px;
    font-size: 14px;
}

.search-input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-size: 14px;
    color: #3b3b3b;
}

.search-input::placeholder {
    color: #868e96;
}

/* Sidebar Menu */
.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
}

.sidebar-menu::-webkit-scrollbar {
    width: 4px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background-color: #dee2e6;
    border-radius: 4px;
}

.menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-item {
    position: relative;
    margin: 2px 8px;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: #3b3b3b;
    text-decoration: none;
    border-radius: 8px;
    transition: background-color 0.2s ease, color 0.2s ease;
    cursor: pointer;
    position: relative;
}

.menu-link:hover {
    background-color: #f1f3f5;
    color: #3b3b3b;
    text-decoration: none;
}

.menu-item.active > .menu-link {
    background-color: #fff5f5;
    color: #de2121;
    font-weight: 500;
}

.menu-item.active > .menu-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: #de2121;
    border-radius: 0 3px 3px 0;
}

.menu-icon {
    width: 20px;
    font-size: 18px;
    margin-right: 12px;
    text-align: center;
}

.menu-text {
    flex: 1;
    font-size: 14px;
    white-space: nowrap;
}

.menu-badge {
    background-color: #de2121;
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.menu-badge:empty {
    display: none;
}

/* Submenu */
.menu-item.has-submenu > .menu-link {
    position: relative;
}

.submenu-arrow {
    margin-left: auto;
    font-size: 12px;
    transition: transform 0.2s ease;
}

.menu-item.has-submenu.expanded .submenu-arrow {
    transform: rotate(90deg);
}

.submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.menu-item.has-submenu.expanded .submenu {
    max-height: 500px;
}

.submenu-item {
    margin: 0;
}

.submenu-link {
    display: flex;
    align-items: center;
    padding: 10px 16px 10px 52px;
    color: #3b3b3b;
    text-decoration: none;
    font-size: 13px;
    border-radius: 8px;
    margin: 2px 8px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.submenu-link:hover {
    background-color: #f1f3f5;
    color: #3b3b3b;
    text-decoration: none;
}

.submenu-item.active .submenu-link {
    background-color: #fff5f5;
    color: #de2121;
    font-weight: 500;
}

.submenu-text {
    white-space: nowrap;
}

/* Menu Divider */
.menu-divider {
    height: 1px;
    background-color: #e9ecef;
    margin: 12px 16px;
}

/* ============================================
   SIDEBAR FOOTER
   ============================================ */

.sidebar-footer {
    border-top: 1px solid #e9ecef;
    padding: 8px;
}

/* App Switcher */
.app-switcher {
    position: relative;
    margin-bottom: 4px;
}

.app-switch-link {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: #3b3b3b;
    text-decoration: none;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.app-switch-link:hover {
    background-color: #f1f3f5;
    text-decoration: none;
}

.app-switcher-dropdown {
    position: absolute;
    bottom: 100%;
    left: 8px;
    right: 8px;
    background-color: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
}

.app-switcher-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.app-switcher-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    color: #3b3b3b;
}

.app-switcher-item:first-child {
    border-radius: 8px 8px 0 0;
}

.app-switcher-item:last-child {
    border-radius: 0 0 8px 8px;
}

.app-switcher-item:hover {
    background-color: #f1f3f5;
}

.app-switcher-item.active {
    background-color: #fff5f5;
    color: #de2121;
    font-weight: 500;
}

.app-switcher-item i:first-child {
    width: 20px;
    text-align: center;
}

.app-switcher-item span {
    flex: 1;
    font-size: 14px;
}

.app-switcher-item i:last-child {
    color: #de2121;
}

/* User Profile */
.user-profile {
    position: relative;
}

.user-profile-link {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: #3b3b3b;
    text-decoration: none;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.user-profile-link:hover {
    background-color: #f1f3f5;
    text-decoration: none;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #de2121 0%, #a70c0c 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    margin-right: 12px;
    flex-shrink: 0;
}

.user-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu-icon {
    margin-left: auto;
    font-size: 14px;
    color: #868e96;
}

.user-dropdown {
    position: absolute;
    bottom: 100%;
    left: 8px;
    right: 8px;
    background-color: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
}

.user-avatar-large {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #de2121 0%, #a70c0c 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name-large {
    font-size: 14px;
    font-weight: 600;
    color: #3b3b3b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 12px;
    color: #868e96;
    margin-top: 2px;
}

.user-dropdown-divider {
    height: 1px;
    background-color: #e9ecef;
    margin: 0;
}

.logout-form {
    margin: 0;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: none;
    color: #3b3b3b;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    text-align: left;
    border-radius: 0 0 8px 8px;
}

.user-dropdown-item:hover {
    background-color: #f1f3f5;
}

.user-dropdown-item i {
    width: 20px;
    text-align: center;
}

/* ============================================
   TOPBAR
   ============================================ */

.topbar {
    position: fixed;
    top: 0;
    left: 270px;
    right: 0;
    height: 64px;
    background-color: #ffffff;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1030;
    transition: left 0.3s ease;
}

.sidebar.collapsed ~ .topbar {
    left: 70px;
}

.sidebar.collapsed ~ .main-content {
    margin-left: 70px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.breadcrumb-wrapper {
    display: flex;
    align-items: center;
}

.breadcrumb-text {
    font-size: 18px;
    font-weight: 600;
    color: #3b3b3b;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-action {
  position: relative;
    width: 40px;
    height: 40px;
    border: none;
    background-color: transparent;
    color: #3b3b3b;
    font-size: 18px;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-action:hover {
    background-color: #f1f3f5;
}

.notification-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: #de2121;
    color: #ffffff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
}

.notification-badge:empty {
    display: none;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.main-content {
    margin-left: 270px;
    margin-top: 64px;
    flex: 1 0 auto;
    min-height: 0;
    transition: margin-left 0.3s ease;
    display: flex;
    flex-direction: column;
}

.main-content.no-sidebar {
    margin-left: 0;
    margin-top: 0;
}

.content-wrapper {
    flex: 1;
    padding: 24px;
    max-width: 100%;
    display: flex;
    flex-direction: column;
}

/* Remove container width constraints for full-width layout */
.content-wrapper .container {
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 0;
    padding-right: 0;
}

/* Page titles - hide them since they're in the breadcrumb */
.content-wrapper h1:first-child,
.content-wrapper .container h1:first-child {
    display: none;
}

/* Ensure content takes available space and footer stays at bottom */
body.sidebar-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============================================
   FOOTER
   ============================================ */

.app-footer {
    background-color: #ffffff;
    border-top: 1px solid #e9ecef;
    padding: 16px 24px;
    margin-left: 270px;
    flex-shrink: 0;
    transition: margin-left 0.3s ease;
}

.sidebar.collapsed ~ .main-content ~ .app-footer {
    margin-left: 70px;
}

.footer-content {
    color: #868e96;
    font-size: 13px;
}

.footer-content a {
    color: #de2121;
    text-decoration: none;
    margin-left: 16px;
}

.footer-content a:hover {
    color: #a70c0c;
    text-decoration: underline;
}

/* ============================================
   MOBILE OVERLAY
   ============================================ */

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none; /* Prevent blocking touches on iOS when hidden */
}

.sidebar-overlay.show {
    opacity: 1;
    pointer-events: auto; /* Allow clicks when overlay is visible */
}

/* ============================================
   MOBILE HAMBURGER BUTTON (in topbar)
   ============================================ */

.mobile-menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border: none;
    background-color: transparent;
    color: #3b3b3b;
    font-size: 20px;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 12px;
}

.mobile-menu-toggle:hover {
    background-color: #f1f3f5;
}

.mobile-menu-toggle:active {
    background-color: #e9ecef;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 767px) {
    .sidebar {
        transform: translateX(-100%);
        pointer-events: none; /* Prevent touch interception on iOS when off-screen */
    }

    .sidebar.mobile-open {
        transform: translateX(0);
        pointer-events: auto;
    }

    .sidebar-overlay {
        display: block;
        pointer-events: none; /* Don't block touches when hidden on iOS */
    }

    .sidebar-overlay.show {
        display: block;
        pointer-events: auto; /* Allow clicks when overlay is visible */
    }

    .topbar {
        left: 0;
    }

    .main-content {
        margin-left: 0;
    }

    .app-footer {
        margin-left: 0;
    }

    /* Show mobile hamburger button */
    .mobile-menu-toggle {
        display: flex;
    }

    /* ── Customer Portal Mobile Topbar ── */

    /* Hide page title on all pages (Dashboard, Documentation, AI Assistant, etc.) */
    .breadcrumb-wrapper {
        display: none;
    }

    /* Make topbar flexible height so search can breathe */
    .topbar {
        height: auto;
        min-height: 48px;
        padding: 8px 12px;
        flex-wrap: wrap;
        gap: 6px;
    }

    /* Topbar right: search takes full row */
    .topbar-right {
        flex: 1 1 auto;
        min-width: 0;
    }

    /* Search trigger fills available space in topbar */
    .cp-search-trigger-wrapper {
        flex: 1;
        min-width: 0;
    }

    .cp-search-trigger {
        width: 100%;
        min-width: auto;
    }

    /* Hide project-switcher from header on mobile (pages can show it in content) */
    .topbar .project-switcher {
        display: none;
    }

    /* Also hide the static context text on mobile */
    .topbar .current-context {
        display: none;
    }

    /* Adjust main-content top margin for flexible topbar */
    .main-content {
        padding-top: 0;
    }
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-header {
    background-color: #ffffff;
    border-bottom: 1px solid #e9ecef;
    padding: 24px 40px;
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 24px;
    font-weight: 600;
    color: #3b3b3b;
}

.login-logo-img {
    height: 80px;
    width: auto;
    object-fit: contain;
}

body.no-sidebar-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: #f8f9fa;
}

.main-content.no-sidebar {
    margin-left: 0;
    margin-top: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.main-content.no-sidebar .content-wrapper {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.main-content.no-sidebar h2 {
    text-align: center;
    margin-bottom: 32px;
    color: #3b3b3b;
    font-size: 28px;
    font-weight: 600;
}

.main-content.no-sidebar .form-label {
    font-weight: 500;
    color: #3b3b3b;
    margin-bottom: 8px;
}

.main-content.no-sidebar .form-control {
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    font-size: 14px;
}

.main-content.no-sidebar .form-control:focus {
    border-color: #de2121;
    box-shadow: 0 0 0 0.2rem rgba(222, 33, 33, 0.1);
}

.main-content.no-sidebar .btn-primary {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    font-weight: 500;
    border-radius: 8px;
    margin-top: 8px;
}

.main-content.no-sidebar p {
    text-align: center;
    margin-top: 16px;
}

.main-content.no-sidebar a {
    color: #de2121;
    text-decoration: none;
    font-weight: 500;
}

.main-content.no-sidebar a:hover {
    color: #a70c0c;
    text-decoration: underline;
}

/* Override Bootstrap button styles */

body .btn-primary {
    background-color: #de2121;
    color: #fff;
    border-color: #de2121;
}

body .btn-primary:hover {
    background-color: #a70c0c;
    color: #fff;
    border-color: #c60101;
}

body .btn-secondary {
    background-color: #3b3b3b;
    border-color: #3b3b3b;
    color: #fff;
}

body .btn-secondary:hover {
    background-color: #787878;
    border-color: #787878;
    color: #fff;
}

body .pagelink {
    color: #c10303;
}

body .pagelink:hover {
    color: #a70c0c;
}

body .page-link {
    color: #c10303;
}

body .page-link:hover {
    color: #a70c0c;
}

body a {
    color: #c10303;
}

body a:hover {
    color: #a70c0c;
}

/* ============================================
   IS-DATAVERSE: Bootstrap Toast/Modal Theming
   ============================================ */

#appToastContainer {
    z-index: 11000;
}

.isdv-toast {
    opacity: 1;
}

.isdv-toast-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 320px;
    max-width: 520px;
    padding: 12px 12px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    border-left: 4px solid #6c757d;
}

.isdv-toast-icon {
    font-size: 18px;
    color: #6c757d;
    width: 22px;
    text-align: center;
}

.isdv-toast-message {
    flex: 1;
    color: #212529;
    font-size: 0.95rem;
    line-height: 1.25rem;
    word-break: break-word;
}

.isdv-toast-danger { border-left-color: #dc3545; }
.isdv-toast-danger .isdv-toast-icon { color: #dc3545; }

.isdv-toast-warning { border-left-color: #bd2130; }
.isdv-toast-warning .isdv-toast-icon { color: #bd2130; }

.isdv-toast-success { border-left-color: #6c757d; }
.isdv-toast-success .isdv-toast-icon { color: #28a745; }

.isdv-toast-secondary { border-left-color: #6c757d; }
.isdv-toast-secondary .isdv-toast-icon { color: #6c757d; }

.isdv-toast-dark { border-left-color: #343a40; }
.isdv-toast-dark .isdv-toast-icon { color: #343a40; }

.isdv-pre {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.9rem;
    color: #212529;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
    max-height: 60vh;
    overflow: auto;
}

/*Custom button classes*/

.btn-active {
    background-color: #de2121 !important;
    color: #fff;
    border-color: #de2121 !important;
}

    .btn-active:hover {
        background-color: #a70c0c !important;
        color: #fff;
        border-color: #c60101 !important;
    }

.btn-disabled {
    background-color: #3b3b3b !important;
    color: #fff;
    cursor: not-allowed;
    border-color: #3b3b3b !important;
}

.btn-disabled:hover {
    background-color: #787878 !important;
    color: #fff;
    cursor: not-allowed;
    border-color: #787878 !important;
}

/* Highlight row class for tables (scoped to tr to avoid collisions with
   imported content that uses <span class="highlight"> for keyword markup) */
tr.highlight {
    background-color: #ffa0a0;
    font-weight: bold;
}

.dropdown-toggle::after {
    content: none !important; /* Completely removes the arrow */
}

/* ============================================
   DOCUMENTATION CALLOUT BOXES
   Important, Note, Warning, Tip sections
   Used by KB import, DITA import, AI agents
   ============================================ */

.doc-callout {
    border-radius: 6px;
    margin: 16px 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid #dee2e6;
}

.doc-callout-header {
    padding: 8px 14px;
    font-weight: 700;
    font-size: 0.9em;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Icons via CSS ::before so TinyMCE can't strip them */
.doc-callout-header::before {
    font-family: "Font Awesome 6 Free", "Font Awesome 5 Free", FontAwesome;
    font-weight: 900;
    font-size: 0.95em;
    display: inline-block;
}

.doc-callout-important .doc-callout-header::before { content: "\f071"; /* fa-exclamation-triangle */ }
.doc-callout-note .doc-callout-header::before      { content: "\f05a"; /* fa-info-circle */ }
.doc-callout-warning .doc-callout-header::before    { content: "\f06a"; /* fa-exclamation-circle */ }
.doc-callout-tip .doc-callout-header::before        { content: "\f0eb"; /* fa-lightbulb */ }

.doc-callout-body {
    padding: 10px 14px;
    font-size: 0.95em;
    line-height: 1.6;
}

.doc-callout-body > *:first-child { margin-top: 0; }
.doc-callout-body > *:last-child  { margin-bottom: 0; }
.doc-callout-body p { margin: 0.4em 0; }
.doc-callout-body ul,
.doc-callout-body ol { margin: 0.4em 0; padding-left: 1.5em; }

/* --- Important: light red background --- */
.doc-callout-important {
    border-color: #f1aeb5;
    background: #fce8ea;
}

.doc-callout-important .doc-callout-header {
    background: #f8d7da;
    color: #842029;
}

.doc-callout-important .doc-callout-body {
    background: #fce8ea;
    color: #212529;
}

/* --- Note: light gray background --- */
.doc-callout-note {
    border-color: #ced4da;
    background: #eef0f2;
}

.doc-callout-note .doc-callout-header {
    background: #e0e3e6;
    color: #495057;
}

.doc-callout-note .doc-callout-body {
    background: #eef0f2;
    color: #212529;
}

/* --- Warning: amber/red accent --- */
.doc-callout-warning {
    border-color: #f5c6cb;
    background: #ffffff;
}

.doc-callout-warning .doc-callout-header {
    background: #f8d7da;
    color: #842029;
}

.doc-callout-warning .doc-callout-body {
    background: #fff8f0;
    color: #212529;
}

/* --- Tip: green accent --- */
.doc-callout-tip {
    border-color: #a3cfbb;
    background: #ffffff;
}

.doc-callout-tip .doc-callout-header {
    background: #d1e7dd;
    color: #0f5132;
}

.doc-callout-tip .doc-callout-body {
    background: #f8fdf9;
    color: #212529;
}

/* Print-friendly: keep borders, remove background */
@media print {
    .doc-callout {
        page-break-inside: avoid;
    }
}

/* --- CRM-imported class fallback ---
   Dynamics CRM uses <div class="Notes"> and <div class="Important">.
   Style them to match callout boxes even before JS transforms them.
   After JS runs, these rules are superseded by the .doc-callout rules above. */
.doc-content div.Notes,
.doc-content div.Important,
.doc-content div.Warning,
.doc-content div.Tip,
.doc-content div.Caution {
    border-radius: 6px;
    margin: 16px 0;
    padding: 10px 14px;
    font-size: 0.95em;
    line-height: 1.6;
    border: 1px solid #dee2e6;
}

.doc-content div.Notes {
    background: #eef0f2;
    border-color: #ced4da;
}

.doc-content div.Important {
    background: #fce8ea;
    border-color: #f1aeb5;
}

.doc-content div.Warning,
.doc-content div.Caution {
    background: #fff8f0;
    border-color: #f5c6cb;
}

.doc-content div.Tip {
    background: #f8fdf9;
    border-color: #a3cfbb;
}

/* Hide CRM icon images inside note divs (they reference external .ico files) */
.doc-content div.Notes img.icon,
.doc-content div.Important img.icon,
.doc-content div.Warning img.icon,
.doc-content div.Tip img.icon,
.doc-content div.Caution img.icon {
    display: none;
}

/* ============================================
   GLOBAL RESPONSIVE IMAGES FOR DOCUMENTATION
   ============================================ */

/* Ensure images in documentation content never exceed container width */
.doc-content img,
.doc-image,
.documentation-content img {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    display: block;
    border-radius: 6px;
    margin: 10px 0;
}

/* Handle images that may have inline width/height from editors */
img[width],
img[style*="width"] {
    max-width: 100% !important;
    height: auto !important;
}

/* ============================================
   DOCUMENTATION TABLE STYLING
   Red header with white text, alternating rows
   ============================================ */

/* Responsive wrapper for tables */
.table-responsive-doc {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 16px 0;
}

/* Base table styles - applies to tables in .doc-content or with .doc-table class */
.doc-content table,
table.doc-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 14px;
    background: #ffffff;
}

/* Header row - IMOS brand red with white bold text (only in thead) */
.doc-content table thead th,
table.doc-table thead th {
    background: #e41c3d;
    color: #ffffff;
    font-weight: 700;
    padding: 10px 12px;
    text-align: left;
    border: 1px solid #c01830;
}

/* Fallback: Style first row th for tables without thead */
.doc-content table > tr:first-child > th,
table.doc-table > tr:first-child > th {
    background: #e41c3d;
    color: #ffffff;
    font-weight: 700;
    padding: 10px 12px;
    text-align: left;
    border: 1px solid #c01830;
}

/* Row headers in tbody and other rows - should NOT be red */
.doc-content table tbody th,
table.doc-table tbody th,
.doc-content table > tr:not(:first-child) > th,
table.doc-table > tr:not(:first-child) > th {
    background: inherit;
    color: #212529;
    font-weight: 600;
    padding: 8px 12px;
    text-align: left;
    border: 1px solid #dee2e6;
}

/* Body rows - alternating white and light gray */
.doc-content table tbody tr:nth-child(odd),
table.doc-table tbody tr:nth-child(odd) {
    background: #ffffff;
}

.doc-content table tbody tr:nth-child(even),
table.doc-table tbody tr:nth-child(even) {
    background: #f8f9fa;
}

/* For tables without tbody, apply to tr directly (backwards compatibility) */
.doc-content table tr:nth-child(odd):not(:first-child),
table.doc-table tr:nth-child(odd):not(:first-child) {
    background: #ffffff;
}

.doc-content table tr:nth-child(even):not(:first-child),
table.doc-table tr:nth-child(even):not(:first-child) {
    background: #f8f9fa;
}

/* Table cells - black text, compact padding */
.doc-content table td,
table.doc-table td {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    color: #212529;
    vertical-align: top;
}

/* Hover effect for better UX */
.doc-content table tbody tr:hover,
table.doc-table tbody tr:hover {
    background: #e9ecef;
}

/* Ensure first row (header) styling takes precedence when no thead */
/* Use direct child selectors to avoid matching tbody tr:first-child */
.doc-content table > tr:first-child > th,
.doc-content table > tbody > tr:first-child > th:first-child,
table.doc-table > tr:first-child > th,
table.doc-table > tbody > tr:first-child > th:first-child {
    background: #e41c3d;
    color: #ffffff;
    font-weight: 700;
    border-color: #c01830;
}

/* Reset for header cells that shouldn't have header styling */
.doc-content table tbody td,
table.doc-table tbody td {
    background: inherit;
    color: #212529;
    font-weight: normal;
    border-color: #dee2e6;
}

/* Mobile responsiveness - smaller padding on small screens */
@media (max-width: 767px) {
    .doc-content table th,
    .doc-content table td,
    table.doc-table th,
    table.doc-table td {
        padding: 6px 8px;
        font-size: 13px;
    }
}

/* ============================================================
   Chat Markdown Rendering
   Styles for AI assistant responses rendered with marked.js
   ============================================================ */

.chat-markdown {
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chat-markdown > *:first-child { margin-top: 0; }
.chat-markdown > *:last-child  { margin-bottom: 0; }

/* Headings */
.chat-markdown h1,
.chat-markdown h2,
.chat-markdown h3,
.chat-markdown h4,
.chat-markdown h5,
.chat-markdown h6 {
    margin: 0.8em 0 0.4em;
    font-weight: 600;
    line-height: 1.3;
    color: inherit;
}

.chat-markdown h1 { font-size: 1.2em; }
.chat-markdown h2 { font-size: 1.1em; }
.chat-markdown h3 { font-size: 1.05em; }
.chat-markdown h4,
.chat-markdown h5,
.chat-markdown h6 { font-size: 1em; }

/* Paragraphs */
.chat-markdown p {
    margin: 0.4em 0;
}

/* Lists */
.chat-markdown ul,
.chat-markdown ol {
    margin: 0.4em 0;
    padding-left: 1.5em;
}

.chat-markdown li {
    margin: 0.2em 0;
}

.chat-markdown li > p {
    margin: 0.2em 0;
}

/* Nested lists */
.chat-markdown ul ul,
.chat-markdown ul ol,
.chat-markdown ol ul,
.chat-markdown ol ol {
    margin: 0.1em 0;
}

/* Inline code */
.chat-markdown code {
    background: rgba(0, 0, 0, 0.06);
    padding: 0.15em 0.35em;
    border-radius: 3px;
    font-size: 0.88em;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

/* Code blocks */
.chat-markdown pre {
    background: #1e293b;
    color: #e2e8f0;
    border-radius: 6px;
    padding: 10px 12px;
    margin: 0.5em 0;
    overflow-x: auto;
    font-size: 0.84em;
    line-height: 1.5;
}

.chat-markdown pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
    color: inherit;
}

/* Bold and italic */
.chat-markdown strong { font-weight: 600; }
.chat-markdown em { font-style: italic; }

/* Blockquotes */
.chat-markdown blockquote {
    border-left: 3px solid #dc3545;
    margin: 0.5em 0;
    padding: 0.3em 0.8em;
    color: #555;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 0 4px 4px 0;
}

.chat-markdown blockquote > *:first-child { margin-top: 0; }
.chat-markdown blockquote > *:last-child  { margin-bottom: 0; }

/* Horizontal rules */
.chat-markdown hr {
    border: none;
    border-top: 1px solid #dee2e6;
    margin: 0.6em 0;
}

/* Tables */
.chat-markdown table {
    border-collapse: collapse;
    margin: 0.5em 0;
    font-size: 0.88em;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    display: block;
}

.chat-markdown th,
.chat-markdown td {
    border: 1px solid #dee2e6;
    padding: 5px 8px;
    text-align: left;
}

.chat-markdown th {
    background: #f1f5f9;
    font-weight: 600;
}

/* Links */
.chat-markdown a {
    color: #dc3545;
    text-decoration: underline;
}

.chat-markdown a:hover {
    color: #bd2130;
}

/* User bubble overrides -- keep inline code readable on red background */
.message-bubble.user .chat-markdown code,
.message.user .chat-markdown code {
    background: rgba(255, 255, 255, 0.2);
    color: inherit;
}

.message-bubble.user .chat-markdown pre,
.message.user .chat-markdown pre {
    background: rgba(0, 0, 0, 0.25);
    color: #fff;
}

.message-bubble.user .chat-markdown a,
.message.user .chat-markdown a {
    color: #fff;
}

/* Customer portal chatbot widget markdown */
.chatbot-message-content .chat-markdown code {
    background: rgba(0, 0, 0, 0.06);
}

.chatbot-message-content .chat-markdown pre {
    background: #1e293b;
    color: #e2e8f0;
}

/* ========== COPY CODE BUTTON ========== */

.code-block-wrapper {
    position: relative;
}

.copy-code-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 5px 8px;
    cursor: pointer;
    font-size: 13px;
    color: #6c757d;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease, color 0.2s ease;
    z-index: 2;
    line-height: 1;
    display: flex;
    align-items: center;
    gap: 4px;
}

.code-block-wrapper:hover .copy-code-btn {
    opacity: 0.7;
}

.copy-code-btn:hover {
    opacity: 1 !important;
    background: #ffffff;
    color: #dc3545;
    border-color: #dc3545;
}

.copy-code-btn.copied {
    opacity: 1 !important;
    color: #198754;
    border-color: #198754;
    background: #ffffff;
}

/* Touch devices: always show button */
@media (hover: none) and (pointer: coarse) {
    .copy-code-btn {
        opacity: 0.7;
    }
}

/* ============================================
   GLOBAL TOGGLE SWITCH (red/gray design system)
   ============================================ */
.form-switch .form-check-input {
    width: 2.4em;
    height: 1.25em;
    cursor: pointer;
}
.form-switch .form-check-input:checked {
    background-color: #dc3545;
    border-color: #dc3545;
}
.form-switch .form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
    border-color: #dc3545;
}

/* ============================================
   TINYMCE FULLSCREEN MODAL Z-INDEX FIX
   TinyMCE fullscreen uses z-index 1200;
   Bootstrap modals default to 1055.
   ============================================ */
body.tinymce-fullscreen-active .modal {
    z-index: 1300 !important;
}
body.tinymce-fullscreen-active .modal-backdrop {
    z-index: 1299 !important;
}

/* ============================================
   I18N: FOUC Prevention
   Hide translatable elements until translations
   are applied (non-English languages only).
   The i18n-loading class is set by _I18nBootstrap
   when no localStorage cache exists yet.
   The i18n-ready class is set by ui-i18n.js
   after translations are applied.
   ============================================ */
html.i18n-loading [data-i18n],
html.i18n-loading [data-i18n-attr] {
    visibility: hidden;
}

