﻿@import url('/css/layout-system.css');

/* Matter Contact Entry Styling */
.contact-entry-dropdown {
    max-height: 300px !important;
    overflow-y: auto !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    border: 1px solid #dee2e6 !important;
}

.autocomplete-dropdown {
    max-height: 250px;
    overflow-y: auto;
}

    .autocomplete-dropdown .ac-footer {
        border-top: 1px solid #dee2e6;
        background: #f8f9fa;
        margin-top: 0;
    }

        .autocomplete-dropdown .ac-footer .btn-add-new-client:hover {
            background-color: rgba(0, 102, 204, 0.05) !important;
        }

/* MatterNumber Validation (is the matter number available) */
.matter-number-feedback {
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

    .matter-number-feedback i {
        font-size: 0.9rem;
    }

.is-valid {
    border-color: #198754 !important;
}

.is-invalid {
    border-color: #dc3545 !important;
}

/* Add Note Modal */
.editor-content {
    font-family: inherit;
    font-size: 14px;
    line-height: 1.6;
}

    .editor-content:focus {
        outline: none;
        box-shadow: inset 0 0 0 1px var(--bs-primary);
    }

    /* Placeholder text */
    .editor-content.empty:before {
        content: attr(data-placeholder);
        color: #6c757d;
        pointer-events: none;
        position: absolute;
    }

    .editor-content img {
        max-width: 100%;
        height: auto;
        margin: 10px 0;
    }

.editor-toolbar .btn {
    padding: 0.25rem 0.5rem;
}

    .editor-toolbar .btn:hover {
        background-color: var(--bs-gray-200);
    }

/* ============================================================================
// CSS Additions for Global Search - Add to your main CSS or create global-search.css
// ============================================================================

Global Search Styles */
.navbar-search {
    min-width: 300px;
    max-width: 500px;
}

    .navbar-search .form-control {
        background-color: rgba(255, 255, 255, 0.1);
        border-color: rgba(255, 255, 255, 0.2);
        color: var(--bs-navbar-color);
    }

        .navbar-search .form-control:focus {
            background-color: var(--bs-body-bg);
            color: var(--bs-body-color);
            box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
        }

    .navbar-search .input-group-text {
        border-color: rgba(255, 255, 255, 0.2);
        color: var(--bs-navbar-color);
    }

/* Global search results styling */
.global-search-result {
    padding: 12px !important;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

    .global-search-result:hover {
        border-left-color: var(--bs-primary);
        background-color: var(--bs-primary-bg-subtle);
    }

    .global-search-result .entity-icon {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: var(--bs-light);
        border-radius: 8px;
    }

    .global-search-result:hover .quick-actions {
        display: flex !important;
    }

.global-search-filters {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 5px;
    z-index: 1000;
    background-color: var(--bs-body-bg);
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Quick actions styling */
.quick-actions {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.global-search-result:hover .quick-actions,
.global-search-result:focus-within .quick-actions {
    opacity: 1;
}

.quick-actions .btn-group-sm .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* AI Button Styling */
.btn-ai-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    transition: all 0.3s ease;
}

/* Search metrics badge */
.search-metrics {
    position: absolute;
    bottom: -25px;
    right: 0;
    font-size: 11px;
    color: var(--bs-text-muted);
    background-color: var(--bs-body-bg);
    padding: 2px 6px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Loading state for search input */
.navbar-search.searching .form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cstyle%3E@keyframes spin{to{transform:rotate(360deg)}}%3C/style%3E%3Cg style='animation:spin 1s linear infinite;transform-origin:center'%3E%3Ccircle cx='10' cy='10' r='8' fill='none' stroke='%23dee2e6' stroke-width='2'/%3E%3Cpath d='M10 2 A8 8 0 0 1 18 10' fill='none' stroke='%230d6efd' stroke-width='2' stroke-linecap='round'/%3E%3C/g%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.25rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .navbar-search {
        min-width: 200px;
    }

    .global-search-filters {
        position: fixed;
        left: 10px;
        right: 10px;
        width: auto;
    }
}

/* Global Search CSS */
.search-result-item:hover {
    background-color: var(--bs-gray-100);
}

.search-icon-wrapper {
    width: 32px;
    text-align: center;
}

#globalSearchResults {
    max-height: 500px;
    overflow-y: auto;
}

    #globalSearchResults .badge {
        font-weight: 500;
        font-size: 0.75rem;
    }

    #globalSearchResults mark {
        background-color: #fff3cd;
        padding: 0 2px;
        font-weight: 600;
    }

/* ============================================================================
   Global Search - Bootstrap Enhancement Only
   ============================================================================ */

/* Remove focus outline from individual elements in rounded search */
.navbar-search .rounded-pill .form-control:focus {
    box-shadow: none;
}

/* Add focus style to the parent container */
.navbar-search .rounded-pill:focus-within {
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
    border-color: var(--bs-primary);
}

/* Global search dropdown - using Bootstrap utilities where possible */

#global-search-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    max-height: 400px;
    overflow-y: auto;
    margin-top: 0;
    background: white;
    border: 1px solid rgba(0,0,0,0.15);
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.175);
    /* Width will be set dynamically by JavaScript */
}

    /* Entity group headers */
    #global-search-dropdown .dropdown-header {
        background-color: var(--bs-gray-100);
        border-bottom: 1px solid var(--bs-gray-300);
        text-transform: uppercase;
        font-size: 0.875rem;
    }

    /* Search result hover state */
    #global-search-dropdown .search-result-item:hover,
    #global-search-dropdown .search-result-item.active {
        background-color: var(--bs-gray-100);
        border-left: 3px solid var(--bs-primary);
    }

    /* Search match highlighting */
    #global-search-dropdown mark {
        background-color: var(--bs-warning-bg-subtle);
        padding: 0 2px;
    }

/* Responsive width adjustments */
@media (max-width: 1400px) {
    .navbar-search {
        width: 35rem !important;
    }
}

@media (max-width: 1200px) {
    .navbar-search {
        width: 25rem !important;
    }
}

@media (max-width: 768px) {
    .navbar-search {
        width: 100% !important;
        max-width: none !important;
    }
}

/* ============================================================================
   Timer Sidebar
   ============================================================================ */

/* Timer Sidebar Containment */
#recent_timers .nav-sidebar {
    max-width: 100%;
    overflow-x: hidden;
}

#recent_timers .nav-item {
    max-width: 100%;
    contain: layout style;
}

#recent_timers .nav-link {
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure text truncation works */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Critical flex fix */
.d-flex > .flex-grow-1 {
    min-width: 0; /* This allows flex items to shrink below content size */
}

/* ============================================================================
   Messaging Icon in Navbar
   ============================================================================ */
/* ============================================================================
   MESSAGING DROPDOWN - ENTERPRISE CSS FIXES
   Add to site.css in the messaging dropdown section
   ============================================================================ */

/* Horizontal Scroll Prevention */
.messaging-dropdown {
    width: 350px;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scroll */
    contain: layout style; /* Performance optimization */
}

.messaging-notification-list {
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scroll */
    contain: layout style paint; /* Isolate rendering */
}

/* Flexbox Architecture for Proper Layout */
.messaging-notification-item {
    padding: 12px;
    border-bottom: 1px solid var(--msg-gray-100, #e9ecef);
    transition: background-color 0.2s;
    display: flex !important; /* Force flex */
    align-items: flex-start !important; /* Top-align */
    gap: 12px;
    max-width: 100%;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
}

    .messaging-notification-item:hover {
        background-color: var(--msg-gray-50, #f8f9fa);
        text-decoration: none;
    }

    .messaging-notification-item:last-child {
        border-bottom: none;
    }

/* Avatar - Fixed Width */
.notification-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0; /* Never shrink */
    background-color: var(--bs-primary, #0d6efd);
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
}

/* Content Wrapper - Allows Shrinking */
.messaging-notification-item .flex-fill {
    flex: 1;
    min-width: 0; /* CRITICAL: Enables text truncation */
    overflow: hidden;
}

/* Title - Single Line Truncation */
.messaging-notification-item .fw-semibold {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    max-width: 100%;
    font-size: 0.875rem;
}

/* Message Preview - Two Line Truncation */
.messaging-notification-item .text-truncate {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-wrap: break-word;
    max-width: 100%;
    font-size: 0.8125rem;
    line-height: 1.4;
}

/* Timestamp - Single Line */
.messaging-notification-item .small.text-muted {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    font-size: 0.75rem;
}

/* Badge - Fixed Position */
.messaging-notification-item .badge {
    flex-shrink: 0; /* Never shrink */
    align-self: flex-start; /* Top align */
    min-width: 20px;
    text-align: center;
    margin-left: auto; /* Push to right */
    font-size: 0.75rem;
}

/* Ensure d-flex children work properly */
.messaging-notification-item .d-flex {
    min-width: 0; /* Allows flex children to shrink */
    width: 100%;
}

/* Scrollbar Styling */
.messaging-notification-list::-webkit-scrollbar {
    width: 6px;
}

.messaging-notification-list::-webkit-scrollbar-track {
    background: transparent;
}

.messaging-notification-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

    .messaging-notification-list::-webkit-scrollbar-thumb:hover {
        background: rgba(0, 0, 0, 0.3);
    }

/* Firefox scrollbar */
.messaging-notification-list {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

/* Responsive */
@media (max-width: 575.98px) {
    .messaging-dropdown {
        width: calc(100vw - 32px);
        max-width: 350px;
    }
}

/* Loading State */
.messaging-notification-list .text-center.text-muted {
    padding: 2rem 1rem;
}

/* Empty State */
.messaging-notification-list .ph-check-circle {
    font-size: 2rem;
    opacity: 0.3;
}

.avatar-initials {
    font-weight: 600;
    font-size: 14px;
    color: var(--msg-gray-700);
}

/* Accounting Module Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    min-width: 300px;
    padding: 16px 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 9999;
}

    .notification.show {
        transform: translateX(0);
    }

    .notification i {
        font-size: 20px;
    }

.notification-success {
    border-left: 4px solid #34C759;
}

    .notification-success i {
        color: #34C759;
    }

.notification-error {
    border-left: 4px solid #FF3B30;
}

    .notification-error i {
        color: #FF3B30;
    }

.notification-info {
    border-left: 4px solid #007AFF;
}

    .notification-info i {
        color: #007AFF;
    }

/* ============================================
   XDOCKET PAGE HEADER ICON SYSTEM
   Global standardization for all page header icons
   ============================================ */

/* Universal page header icon class */
.xdocket-header-icon {
    font-size: 2rem !important;
    color: var(--bs-secondary) !important; /* Primary brand color */
    margin-right: 0.75rem !important; /* Consistent spacing */
    vertical-align: middle !important; /* Proper alignment */
    display: inline-block !important;
    line-height: 1 !important;
    flex-shrink: 0; /* Prevent icon from shrinking */
}

/* Ensure it works in flex containers */
.page-header h1,
.page-header h2,
.page-title {
    display: flex;
    align-items: center;
}

/* Optional: Add hover effect for interactive headers */
a .xdocket-header-icon {
    transition: transform 0.2s ease;
}

a:hover .xdocket-header-icon {
    transform: translateX(-2px);
}

/* ============================================================
   APPLE-STYLE GLASSMORPHISM MODAL BACKDROP
   ============================================================ */

.modal-backdrop {
    --backdrop-bg: rgba(0, 0, 0, 0.4);
    --backdrop-opacity: 1;
    background: var(--backdrop-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
}

    .modal-backdrop.fade {
        opacity: 0;
        transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .modal-backdrop.show {
        opacity: var(--backdrop-opacity);
    }

/* Dark mode support */
[data-color-theme=dark] .modal-backdrop {
    --backdrop-bg: rgba(0, 0, 0, 0.7);
}

/* Accessibility: High contrast mode - remove blur */
@media (prefers-contrast: high) {
    .modal-backdrop {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        --backdrop-bg: rgba(0, 0, 0, 0.8);
    }
}

/* Accessibility: Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .modal-backdrop.fade {
        transition: none;
    }
}

/* Matter Timeline Styles */
.timeline {
    position: relative;
    padding: 20px 0;
}

    .timeline::before {
        content: '';
        position: absolute;
        left: 20px;
        top: 0;
        bottom: 0;
        width: 2px;
        background: #dee2e6;
    }

.timeline-item {
    position: relative;
    padding-left: 50px;
    margin-bottom: 30px;
}

.timeline-marker {
    position: absolute;
    left: 11px;
    top: 5px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #0d6efd;
    border: 3px solid #fff;
    box-shadow: 0 0 0 2px #dee2e6;
}

.timeline-content {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 3px solid #0d6efd;
}

    .timeline-content p {
        margin-bottom: 5px;
    }

/* ============================================================================
   NAVBAR NOTIFICATION DROPDOWN - FAANG-QUALITY STICKY HEADER/FOOTER
   FIXED: Dropdown now properly opens/closes
   Add to site.css - REPLACES previous notification dropdown CSS
   ============================================================================ */

/* Dropdown menu container - ONLY apply flex when shown */
#notificationDropdown + .dropdown-menu.show {
    width: 380px;
    max-height: 500px;
    overflow: hidden !important;
    display: flex !important; /* Override Bootstrap's display: block */
    flex-direction: column;
}

/* Fallback for when not shown - ensure it's hidden */
#notificationDropdown + .dropdown-menu:not(.show) {
    display: none !important;
}

/* Sticky header - always visible when dropdown is open */
#notificationDropdown + .dropdown-menu .dropdown-header {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
    background: white;
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
}

    /* Sticky divider after header */
    #notificationDropdown + .dropdown-menu .dropdown-header + .dropdown-divider {
        flex-shrink: 0;
        margin: 0;
    }

/* Notification list - ONLY THIS SCROLLS */
#notification-list {
    flex: 1;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    contain: layout style;
    min-height: 0; /* Critical for flex scrolling */
}

/* Sticky footer divider */
#notificationDropdown + .dropdown-menu .dropdown-divider:last-of-type {
    flex-shrink: 0;
    margin: 0;
}

/* Sticky footer - always visible when dropdown is open */
#notificationDropdown + .dropdown-menu .dropdown-footer {
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 10;
    background: white;
    border-top: 1px solid var(--bs-border-color, #dee2e6);
}

/* Notification item - enterprise-grade overflow prevention */
#notification-list .dropdown-item {
    display: flex !important;
    padding: 12px 16px !important;
    align-items: flex-start !important;
    gap: 12px;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
    border-bottom: 1px solid var(--bs-border-color, #e9ecef);
}

    #notification-list .dropdown-item:last-child {
        border-bottom: none;
    }

    /* Icon container - fixed width */
    #notification-list .dropdown-item > div:first-child {
        flex-shrink: 0;
        width: 40px;
    }

    /* Content container */
    #notification-list .dropdown-item > div:nth-child(2) {
        flex: 1;
        min-width: 0;
        overflow: hidden;
    }

/* Notification title - single line truncation */
#notification-list .fw-semibold {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.875rem;
    line-height: 1.3;
}

/* Notification content - TWO LINE TRUNCATION WITH ELLIPSIS */
#notification-list .small.text-muted.mb-1 {
    font-size: 0.8125rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-wrap: break-word;
    word-break: break-word;
}

/* Time display - prevent overflow */
#notification-list .small.text-muted:not(.mb-1) {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.75rem;
}

/* Badge positioning */
#notification-list .badge {
    flex-shrink: 0;
    align-self: flex-start;
}

/* Unread state */
#notification-list .bg-light {
    background-color: rgba(0, 122, 255, 0.05) !important;
    position: relative;
}

    #notification-list .bg-light::before {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 3px;
        background-color: var(--bs-primary, #007AFF);
    }

/* Hover state */
#notification-list .dropdown-item:hover {
    background-color: var(--bs-gray-100, #f8f9fa);
}

/* Empty state styling */
#notification-list .text-center.text-muted {
    padding: 2rem 1rem;
}

/* Scrollbar styling - clean, minimal */
#notification-list::-webkit-scrollbar {
    width: 6px;
}

#notification-list::-webkit-scrollbar-track {
    background: transparent;
}

#notification-list::-webkit-scrollbar-thumb {
    background: var(--bs-secondary, #6c757d);
    border-radius: 3px;
}

    #notification-list::-webkit-scrollbar-thumb:hover {
        background: var(--bs-secondary-text-emphasis, #495057);
    }

/* Firefox scrollbar */
#notification-list {
    scrollbar-width: thin;
    scrollbar-color: var(--bs-secondary, #6c757d) transparent;
}

/* Responsive adjustments */
@media (max-width: 575.98px) {
    #notificationDropdown + .dropdown-menu.show {
        width: calc(100vw - 32px);
        max-width: 380px;
        left: 16px !important;
        right: 16px !important;
    }
}

/* ============================================================================
   NAVBAR ICON SIZING
   Clean implementation - replaces any existing navbar badge styles
   ============================================================================ */

/* ============================================================================
   ICON SIZING - 30px for balanced look with 40px avatar
   Perfect 75% ratio - classic design proportion
   ============================================================================ */

.navbar-nav .nav-link > i.ph-bell-ringing,
.navbar-nav .nav-link > i.ph-chat-text {
    font-size: 30px !important;
    width: 30px !important;
    height: 30px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Nav link container */
.navbar-nav .nav-link {
    padding: 0.5rem !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

    /* ============================================================================
   BADGE STYLING - Clean, professional notification badges
   ============================================================================ */

    /* Override any existing badge styles - use specific selectors */
    .navbar-nav .nav-link > .badge,
    .navbar-nav .nav-link .badge.bg-danger,
    #navMessageBadge,
    #notification-badge {
        /* Reset any inherited styles */
        position: absolute !important;
        top: -4px !important;
        right: -4px !important;
        /* Size and spacing */
        min-width: 18px !important;
        height: 18px !important;
        padding: 0 5px !important;
        /* Typography */
        font-size: 10px !important;
        font-weight: 700 !important;
        line-height: 1 !important;
        /* Shape */
        border-radius: 9px !important;
        /* Layout */
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        /* Visual polish */
        border: 2px solid #fff !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2) !important;
    }

/* ============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================ */

/* Tablet: 28px icons */
@media (max-width: 991px) {
    .navbar-nav .nav-link > i.ph-bell-ringing,
    .navbar-nav .nav-link > i.ph-chat-text {
        font-size: 28px !important;
        width: 28px !important;
        height: 28px !important;
    }

    .navbar-nav .nav-link > .badge,
    .navbar-nav .nav-link .badge.bg-danger,
    #navMessageBadge,
    #notification-badge {
        min-width: 16px !important;
        height: 16px !important;
        font-size: 9px !important;
        border-radius: 8px !important;
        top: -3px !important;
        right: -3px !important;
    }
}

/* Mobile: 24px icons */
@media (max-width: 575px) {
    .navbar-nav .nav-link > i.ph-bell-ringing,
    .navbar-nav .nav-link > i.ph-chat-text {
        font-size: 24px !important;
        width: 24px !important;
        height: 24px !important;
    }

    .navbar-nav .nav-link > .badge,
    .navbar-nav .nav-link .badge.bg-danger,
    #navMessageBadge,
    #notification-badge {
        min-width: 14px !important;
        height: 14px !important;
        font-size: 8px !important;
        border-radius: 7px !important;
        top: -2px !important;
        right: -2px !important;
        padding: 0 3px !important;
    }
}

/* ============================================================================
   SIDEBAR USER SECTION - Bottom-Pinned User Profile
   Enterprise-grade implementation for dark sidebar theme
   ============================================================================ */

/* ==================== BASE ARCHITECTURE ==================== */
.sidebar-user-section {
    /* Flexbox positioning - pushes to bottom of sidebar */
    margin-top: auto;
    flex-shrink: 0;
    position: relative;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.15);
}

.sidebar-user-container {
    padding: 0.5rem 1.25rem;
}

/* ==================== USER TRIGGER (DROPDOWN TOGGLE) ==================== */
.sidebar-user-trigger {
    width: 100%;
    padding: 0.375rem 0;
    border-radius: 0.375rem;
    transition: background-color 0.2s ease, transform 0.1s ease;
    cursor: pointer;
    text-decoration: none !important;
}

    .sidebar-user-trigger:hover {
        background: rgba(255, 255, 255, 0.05);
    }

    .sidebar-user-trigger:active {
        transform: scale(0.98);
    }

/* ==================== AVATAR CONTAINER ==================== */
.sidebar-user-avatar {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

    /* Status indicator positioning */
    .sidebar-user-avatar .status-indicator {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        border: 2px solid #252b36; /* Dark sidebar background color */
        bottom: 2px;
        right: 2px;
    }

/* ==================== USER INFO ==================== */
.sidebar-user-info {
    min-width: 0; /* Critical for text truncation */
}

.sidebar-user-name {
    font-size: 0.875rem;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: rgba(255, 255, 255, 0.95);
}

/* ==================== DROPDOWN MENU ==================== */
.sidebar-user-dropdown {
    min-width: 200px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* Dropup positioning - menu appears ABOVE trigger */
.sidebar-user-section .dropup .dropdown-menu {
    left: 1.25rem !important;
    right: auto !important;
    /* Let Bootstrap handle vertical positioning naturally */
}

/* Dropdown items */
.sidebar-user-dropdown .dropdown-item {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    transition: background-color 0.15s ease;
}

    .sidebar-user-dropdown .dropdown-item:hover {
        background-color: rgba(0, 122, 255, 0.1);
    }

    .sidebar-user-dropdown .dropdown-item i {
        width: 1.25rem;
        font-size: 1.125rem;
        opacity: 0.8;
    }

/* Logout button styling */
.sidebar-user-dropdown button.dropdown-item {
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    color: inherit;
}

    .sidebar-user-dropdown button.dropdown-item:hover {
        background-color: rgba(220, 53, 69, 0.1);
        color: #dc3545;
    }

/* ==================== COLLAPSED SIDEBAR STATE ==================== */
/* Base collapsed state - avatar centered */
.sidebar-main-resized:not(.sidebar-main-unfold) .sidebar-user-section {
    padding: 0;
}

.sidebar-main-resized:not(.sidebar-main-unfold) .sidebar-user-container {
    padding: 1rem 0;
    display: flex;
    justify-content: center;
}

.sidebar-main-resized:not(.sidebar-main-unfold) .sidebar-user-trigger {
    justify-content: center;
    padding: 0.5rem;
}

.sidebar-main-resized:not(.sidebar-main-unfold) .sidebar-user-avatar {
    margin: 0;
}

/* Hide text and caret in collapsed state */
.sidebar-main-resized:not(.sidebar-main-unfold) .sidebar-user-info,
.sidebar-main-resized:not(.sidebar-main-unfold) .sidebar-user-trigger > i {
    display: none !important;
}

/* Adjust dropup position for collapsed sidebar - menu to the right */
.sidebar-main-resized:not(.sidebar-main-unfold) .sidebar-user-section .dropup .dropdown-menu {
    left: calc(var(--spacer) * 2 + var(--icon-font-size) + 0.5rem) !important;
    bottom: 0 !important;
    top: auto !important;
    margin-bottom: 0;
}

/* ==================== ELASTIC UNFOLD STATE (HOVER) ==================== */
/* When collapsed sidebar is hovered (unfolds), show full user section */
.sidebar-main-resized.sidebar-main-unfold .sidebar-user-section {
    /* Reset to normal expanded state */
    padding: 0;
}

.sidebar-main-resized.sidebar-main-unfold .sidebar-user-container {
    /* Return to left-aligned layout */
    padding: 0.5rem 1.25rem;
    display: block;
    justify-content: flex-start;
}

.sidebar-main-resized.sidebar-main-unfold .sidebar-user-trigger {
    /* Return to full width layout */
    justify-content: flex-start;
    padding: 0.375rem 0;
    display: flex;
}

    /* Show text and caret when unfolded */
    .sidebar-main-resized.sidebar-main-unfold .sidebar-user-info,
    .sidebar-main-resized.sidebar-main-unfold .sidebar-user-trigger > i {
        display: block !important;
    }

.sidebar-main-resized.sidebar-main-unfold .sidebar-user-info {
    display: flex !important;
}

/* Reset dropup position when unfolded */
.sidebar-main-resized.sidebar-main-unfold .sidebar-user-section .dropup .dropdown-menu {
    left: 1.25rem !important;
    /* Let Bootstrap handle vertical positioning naturally */
}

/* ==================== RESPONSIVE BEHAVIOR ==================== */

/* Desktop - Large screens (≥992px) */
@media (min-width: 992px) {
    /* Expanded sidebar */
    .sidebar-expand-lg:not(.sidebar-main-resized) .sidebar-user-trigger {
        display: flex;
    }

    /* Collapsed sidebar - center avatar (not unfolded) */
    .sidebar-expand-lg.sidebar-main-resized:not(.sidebar-main-unfold) .sidebar-user-trigger {
        display: flex;
        justify-content: center;
    }

    /* Unfolded sidebar - return to normal layout */
    .sidebar-expand-lg.sidebar-main-resized.sidebar-main-unfold .sidebar-user-trigger {
        display: flex;
        justify-content: flex-start;
    }
}

/* Tablet (768px - 991px) */
@media (max-width: 991px) {
    .sidebar-user-section {
        background: rgba(0, 0, 0, 0.2);
    }

    .sidebar-user-container {
        padding: 1rem;
    }

    .sidebar-user-dropdown {
        min-width: 180px;
    }
}

/* Mobile (<768px) */
@media (max-width: 767px) {
    .sidebar-user-section {
        border-top-width: 2px;
    }

    .sidebar-user-container {
        padding: 0.875rem 1rem;
    }

    .sidebar-user-trigger {
        padding: 0.625rem 0.5rem;
    }

    .sidebar-user-avatar {
        width: 36px;
        height: 36px;
    }

        .sidebar-user-avatar .status-indicator {
            width: 8px;
            height: 8px;
            border-width: 1.5px;
        }

    .sidebar-user-name {
        font-size: 0.8125rem;
    }

    .sidebar-user-dropdown {
        min-width: 160px;
    }

        .sidebar-user-dropdown .dropdown-item {
            padding: 0.5rem 0.875rem;
            font-size: 0.8125rem;
        }
}

/* ==================== DARK THEME COMPATIBILITY ==================== */
.sidebar-dark .sidebar-user-section {
    border-top-color: rgba(255, 255, 255, 0.125);
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-dark .sidebar-user-trigger:hover {
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-dark .sidebar-user-name {
    color: rgba(255, 255, 255, 0.95);
}

.sidebar-dark .sidebar-user-avatar .status-indicator {
    border-color: #252b36; /* Match dark sidebar background */
}

/* Dark mode dropdown override */
[data-color-theme="dark"] .sidebar-dark .sidebar-user-avatar .status-indicator {
    border-color: #141517;
}

/* ==================== ACCESSIBILITY ==================== */
.sidebar-user-trigger:focus-visible {
    outline: 2px solid rgba(0, 122, 255, 0.5);
    outline-offset: 2px;
}

.sidebar-user-dropdown .dropdown-item:focus-visible {
    outline: 2px solid rgba(0, 122, 255, 0.5);
    outline-offset: -2px;
}

/* ==================== PERFORMANCE OPTIMIZATIONS ==================== */
.sidebar-user-section {
    will-change: transform;
    contain: layout style;
}

.sidebar-user-trigger {
    -webkit-tap-highlight-color: transparent;
}

/* ==================== PRINT STYLES ==================== */
@media print {
    .sidebar-user-section {
        display: none !important;
    }
}

/* ==================== ANIMATION REFINEMENTS ==================== */
@media (prefers-reduced-motion: reduce) {
    .sidebar-user-trigger,
    .sidebar-user-dropdown .dropdown-item {
        transition: none;
    }
}

/* ==================== HIGH CONTRAST MODE ==================== */
@media (prefers-contrast: high) {
    .sidebar-user-section {
        border-top-width: 2px;
        border-top-color: rgba(255, 255, 255, 0.3);
    }

    .sidebar-user-name {
        font-weight: 600;
    }
}



/* ============================================================================
 * AI BILLING NARRATIVE ENHANCER - Time Modal Integration
 * Added for AI-powered time entry description enhancement
 * ============================================================================ */
/* ============================================================================
 * Time Modal AI Narrative Enhancer - FAANG Enterprise Styling
 * Integrates seamlessly with existing xDocket design system
 * ============================================================================ */

/* ============================================
 * PURPLE ACCENT THEME (AI-specific color)
 * ============================================ */
:root {
    --ai-purple: #6f42c1;
    --ai-purple-light: #8b5dd9;
    --ai-purple-subtle: #f3ebff;
    --ai-purple-hover: #5a34a0;
}

.text-purple {
    color: var(--ai-purple) !important;
}

.bg-purple-subtle {
    background-color: var(--ai-purple-subtle) !important;
}

.border-purple {
    border-color: var(--ai-purple) !important;
}

.btn-outline-purple {
    color: var(--ai-purple);
    border-color: var(--ai-purple);
    background-color: transparent;
    transition: all 0.2s ease;
}

    .btn-outline-purple:hover {
        color: #fff;
        background-color: var(--ai-purple);
        border-color: var(--ai-purple);
        transform: translateY(-1px);
        box-shadow: 0 4px 8px rgba(111, 66, 193, 0.2);
    }

    .btn-outline-purple:active {
        transform: translateY(0);
        box-shadow: 0 2px 4px rgba(111, 66, 193, 0.2);
    }

/* ============================================
 * AI QUALITY INDICATOR
 * ============================================ */
.ai-quality-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: fadeIn 0.3s ease-in;
}

#aiQualityBadge {
    font-size: 0.75rem;
    padding: 0.35rem 0.65rem;
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.2s ease;
}

    #aiQualityBadge.badge-danger {
        background-color: #dc3545;
        color: white;
        animation: pulse 2s infinite;
    }

    #aiQualityBadge.badge-warning {
        background-color: #ffc107;
        color: #000;
    }

    #aiQualityBadge.badge-success {
        background-color: #28a745;
        color: white;
    }

#aiQualityHint {
    font-size: 0.875rem;
    font-style: italic;
}

/* ============================================
 * AI ENHANCE BUTTON
 * ============================================ */
.ai-enhance-btn {
    position: relative;
    overflow: hidden;
    font-weight: 600;
    border-radius: 8px;
    animation: slideInRight 0.3s ease-out;
}

    .ai-enhance-btn i {
        animation: sparkle 1.5s ease-in-out infinite;
    }

    .ai-enhance-btn:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

/* ============================================
 * AI SUGGESTIONS PANEL
 * ============================================ */
.ai-suggestions-panel {
    animation: slideDown 0.3s ease-out;
    transform-origin: top;
}

    .ai-suggestions-panel .card {
        border-radius: 12px;
        overflow: hidden;
    }

    .ai-suggestions-panel .card-header {
        padding: 0.875rem 1rem;
        font-size: 0.9rem;
    }

    .ai-suggestions-panel .card-body {
        padding: 1rem;
        max-height: 400px;
        overflow-y: auto;
    }

/* ============================================
 * AI SUGGESTION ITEMS
 * ============================================ */
.ai-suggestion-item {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 0.875rem;
    transition: all 0.2s ease;
    position: relative;
}

    .ai-suggestion-item:last-child {
        margin-bottom: 0;
    }

    .ai-suggestion-item:hover {
        background: #ffffff;
        border-color: var(--ai-purple);
        box-shadow: 0 4px 12px rgba(111, 66, 193, 0.12);
        transform: translateY(-2px);
    }

    .ai-suggestion-item.recommended {
        border-color: var(--ai-purple);
        background: linear-gradient(135deg, #f3ebff 0%, #ffffff 100%);
    }

        .ai-suggestion-item.recommended::before {
            content: '⭐';
            position: absolute;
            top: -8px;
            right: -8px;
            font-size: 1.5rem;
            animation: starPulse 2s ease-in-out infinite;
        }

/* ============================================
 * SUGGESTION HEADER
 * ============================================ */
.ai-suggestion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.ai-suggestion-category {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
}

    .ai-suggestion-category .badge {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
        border-radius: 6px;
    }

.ai-suggestion-quality {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
}

/* ============================================
 * SUGGESTION TEXT
 * ============================================ */
.ai-suggestion-text {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #212529;
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 6px;
}

.ai-suggestion-reason {
    font-size: 0.8rem;
    color: #6c757d;
    font-style: italic;
    margin-bottom: 0.75rem;
    padding-left: 1rem;
    border-left: 3px solid var(--ai-purple);
}

/* ============================================
 * SUGGESTION ACTIONS
 * ============================================ */
.ai-suggestion-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

    .ai-suggestion-actions .btn {
        font-size: 0.875rem;
        padding: 0.4rem 0.875rem;
        border-radius: 6px;
        font-weight: 600;
        transition: all 0.2s ease;
    }

    .ai-suggestion-actions .btn-primary {
        background-color: var(--ai-purple);
        border-color: var(--ai-purple);
    }

        .ai-suggestion-actions .btn-primary:hover {
            background-color: var(--ai-purple-hover);
            border-color: var(--ai-purple-hover);
            transform: translateY(-1px);
            box-shadow: 0 4px 8px rgba(111, 66, 193, 0.25);
        }

    .ai-suggestion-actions .btn-outline-secondary {
        border-width: 1px;
    }

        .ai-suggestion-actions .btn-outline-secondary:hover {
            background-color: #6c757d;
            color: white;
        }

/* ============================================
 * LOADING & EMPTY STATES
 * ============================================ */
.ai-loading-state {
    text-align: center;
    padding: 2rem 1rem;
}

    .ai-loading-state .spinner-border {
        color: var(--ai-purple);
    }

.ai-empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: #6c757d;
}

    .ai-empty-state i {
        font-size: 3rem;
        color: #dee2e6;
        margin-bottom: 1rem;
    }

.ai-error-state {
    background: #f8d7da;
    border: 1px solid #f5c2c7;
    border-radius: 8px;
    padding: 1rem;
    color: #842029;
}

    .ai-error-state i {
        color: #dc3545;
    }

/* ============================================
 * ANIMATIONS
 * ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        max-height: 500px;
        transform: translateY(0);
    }
}

@keyframes sparkle {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }

    50% {
        transform: scale(1.2) rotate(180deg);
        opacity: 0.8;
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

@keyframes starPulse {
    0%, 100% {
        transform: scale(1) rotate(0deg);
    }

    50% {
        transform: scale(1.2) rotate(15deg);
    }
}

/* ============================================
 * RESPONSIVE DESIGN
 * ============================================ */
@media (max-width: 768px) {
    .ai-suggestion-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .ai-suggestion-actions {
        width: 100%;
        flex-direction: column;
    }

        .ai-suggestion-actions .btn {
            width: 100%;
        }

    .ai-suggestions-panel .card-body {
        max-height: 300px;
    }
}

/* ============================================
 * ACCESSIBILITY
 * ============================================ */
.ai-enhance-btn:focus,
.ai-suggestion-actions .btn:focus {
    outline: 2px solid var(--ai-purple);
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
 * DARK MODE SUPPORT (Future-proofing)
 * ============================================ */
@media (prefers-color-scheme: dark) {
    .ai-suggestion-item {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }

        .ai-suggestion-item:hover {
            background: #374151;
            border-color: var(--ai-purple-light);
        }

    .ai-suggestion-text {
        background: rgba(0, 0, 0, 0.2);
        color: #e2e8f0;
    }

    .ai-suggestion-reason {
        color: #a0aec0;
    }
}
