@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

/* ==========================================================================
   SHADCN-DJANGO CRM CORE PALETTE & TYPOGRAPHY
   ========================================================================== */
body, 
.wrapper, 
.sidebar, 
.main-panel, 
input, 
button, 
select, 
textarea,
.form-control,
.btn,
.card-title,
.navbar {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
}

body {
    background-color: #f8fafc !important; /* Elegant canvas bg */
    color: #0f172a !important;
}

/* Custom Scrollbar for the whole system */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ==========================================================================
   SIDEBAR NAV DESIGN (SHADCN PATTERN)
   ========================================================================== */
.sidebar {
    background-color: #ffffff !important;
    border-right: 1px solid #e2e8f0 !important; /* Zinc/Slate border */
    box-shadow: none !important;
    width: 260px !important;
    z-index: 100 !important;
}

/* Remove sidebar backgrounds and filters */
.sidebar::before,
.sidebar .sidebar-background {
    display: none !important;
}

/* Sidebar Wrapper */
.sidebar-wrapper {
    background-color: #ffffff !important;
    padding-top: 10px !important;
    height: calc(100vh - 80px) !important;
}

/* Logo Area */
.sidebar .logo {
    padding: 0.65rem 1.5rem !important; /* Compact dynamic padding for elite feel */
    margin: 0 !important;
    border-bottom: 1px solid #f1f5f9 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    background: #ffffff !important;
}

.sidebar .logo .simple-text {
    padding: 0 !important;
    margin: 0 !important;
}

.sidebar .logo img {
    max-width: 75px !important; /* Slightly more compact logo size */
    transition: transform 0.2s ease;
}

.sidebar .logo img:hover {
    transform: scale(1.05);
}

/* Navigation List */
.sidebar .nav {
    margin-top: 0.25rem !important; /* Brings menu items closer to the logo area */
    padding: 0 12px !important;
}

.sidebar .nav li {
    margin: 4px 0 !important;
}

.sidebar .nav li a {
    margin: 0 !important;
    padding: 10px 14px !important;
    border-radius: 8px !important;
    color: #475569 !important; /* Slate-600 */
    font-weight: 500 !important;
    font-size: 0.875rem !important;
    display: flex !important;
    align-items: center !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: none !important;
    background-color: transparent !important;
}

/* Ensure the text container paragraph in the menu behaves as a full-width flexbox */
.sidebar .nav li a p {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: normal !important;
}

/* Style the dynamic pending notes badge perfectly without overlapping or misalignment */
.sidebar .nav li a .badge {
    margin-left: auto !important;
    background-color: #ef4444 !important; /* Crimson Red */
    color: #ffffff !important;
    font-size: 0.7rem !important;
    font-weight: 700 !important;
    padding: 2px 6px !important;
    border-radius: 9999px !important;
    box-shadow: none !important;
    line-height: 1 !important;
    float: none !important;
    margin-top: 0 !important;
}

/* Icons */
.sidebar .nav li a i,
.sidebar .nav li a .material-icons {
    color: #64748b !important; /* Slate-500 */
    margin-right: 12px !important;
    font-size: 1.25rem !important;
    width: 24px !important;
    text-align: center !important;
    transition: color 0.2s ease !important;
}

/* Hover States */
.sidebar .nav li a:hover {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
}

.sidebar .nav li a:hover i {
    color: #0f172a !important;
}

/* Active State (Perfect Shadcn Active Style with Purple Theme Accent) */
.sidebar .nav li.active > a {
    background-color: #f3e8ff !important; /* Light Lavender/Purple tint */
    color: #7e22ce !important; /* Premium Purple text */
    font-weight: 600 !important;
    position: relative !important;
}

.sidebar .nav li.active > a i,
.sidebar .nav li.active > a .material-icons {
    color: #9c27b0 !important; /* Purple icon */
}

/* Left Accent border for active item */
.sidebar .nav li.active > a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    height: 60%;
    width: 4px;
    background-color: #9c27b0;
    border-radius: 0 4px 4px 0;
}

/* Submenu/Collapse styling */
.sidebar .nav li .collapse {
    padding-left: 16px !important;
}

.sidebar .nav li .collapse .nav {
    margin-top: 2px !important;
    padding: 0 !important;
}

.sidebar .nav li .collapse .nav li a {
    padding: 8px 12px !important;
    font-size: 0.8125rem !important;
}

/* Caret/Dropdown indicator */
.sidebar .nav li a .caret {
    margin-left: auto !important;
    border-top-color: #64748b !important;
    transition: transform 0.2s ease !important;
}

.sidebar .nav li a[aria-expanded="true"] .caret {
    transform: rotate(180deg) !important;
}

/* ==========================================================================
   MAIN PANEL & HEADER NAVBAR
   ========================================================================== */
.main-panel {
    background-color: #f8fafc !important;
    min-height: 100vh !important;
    margin-left: 0 !important;
    width: 100% !important;
    transition: all 0.25s ease !important;
    float: none !important;
}

.main-panel > .content {
    padding: 24px !important;
    margin-top: 0 !important;
}

/* Sleek Topbar Navigation */
.topbar-navbar {
    background-color: #ffffff !important;
    border-bottom: 1px solid #e2e8f0 !important;
    padding: 12px 24px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    min-height: 64px !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 99 !important;
}

.topbar-brand {
    font-size: 1.125rem !important;
    font-weight: 700 !important;
    color: #0f172a !important;
}

.topbar-actions {
    display: flex !important;
    align-items: center !important;
    gap: 16px !important;
}

/* User Profile Dropdown Button */
.user-profile-btn {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 6px 12px !important;
    border-radius: 9999px !important;
    border: 1px solid #e2e8f0 !important;
    background: #ffffff !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

.user-profile-btn:hover {
    background-color: #f8fafc !important;
    border-color: #cbd5e1 !important;
}

.user-avatar-circle {
    width: 28px !important;
    height: 28px !important;
    border-radius: 50% !important;
    background-color: #f3e8ff !important;
    color: #7e22ce !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: 700 !important;
    font-size: 0.75rem !important;
    border: 1px solid #d8b4fe !important;
}

.user-profile-name {
    font-size: 0.8125rem !important;
    font-weight: 600 !important;
    color: #334155 !important;
}

/* ==========================================================================
   CARDS & PANELS (INTEGRATED TITLE INSIDE CARD - AS REQUESTED)
   ========================================================================== */
.card {
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px 0 rgba(0, 0, 0, 0.02) !important;
    background: #ffffff !important;
    margin-bottom: 24px !important;
    overflow: hidden !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}

/* Subtle micro-animation on panel hover */
.card:hover {
    box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.05) !important;
}

/* Header inside the panel (card) is flat and elegant */
.card .card-header {
    margin: 0 !important;
    padding: 1.25rem 1.5rem !important;
    background-color: #ffffff !important;
    border-bottom: 1px solid #f1f5f9 !important;
    border-radius: 12px 12px 0 0 !important;
    box-shadow: none !important;
    position: relative !important;
    float: none !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: 12px !important;
}

/* Top accent color bar for Primary headers */
.card .card-header-primary {
    border-top: 4px solid #9c27b0 !important; /* Dynamic Purple top line */
}

.card .card-header-info {
    border-top: 4px solid #00bcd4 !important;
}

.card .card-header-warning {
    border-top: 4px solid #ff9800 !important;
}

.card .card-header-danger {
    border-top: 4px solid #f44336 !important;
}

.card .card-header-success {
    border-top: 4px solid #4caf50 !important;
}

/* Card headers and titles with perfect readability and contrast */
.card .card-header .card-title,
.card .card-header h4 {
    color: #9c27b0 !important; /* Roxo Clínico */
    font-weight: 700 !important;
    font-size: 1.25rem !important;
    margin: 0 !important;
    letter-spacing: -0.02em !important;
}

/* Styling primary card headers with solid premium purple background and crisp white title text */
.card .card-header-primary {
    background: linear-gradient(135deg, #9c27b0 0%, #7b1fa2 100%) !important; /* Elegant flat purple gradient */
    border-bottom: none !important;
    border-top: none !important; /* Remove top border since background is filled */
    padding: 1.25rem 1.5rem !important;
}

.card .card-header-primary .card-title,
.card .card-header-primary h4,
.card-header-primary .card-title {
    color: #ffffff !important; /* Highlight white title */
    font-weight: 700 !important;
    font-size: 1.25rem !important;
    margin: 0 !important;
    letter-spacing: -0.02em !important;
}

.card .card-header-primary .card-category,
.card .card-header-primary p {
    color: rgba(255, 255, 255, 0.85) !important; /* High contrast soft white category */
    font-size: 0.8125rem !important;
    margin: 4px 0 0 0 !important;
    font-weight: 500 !important;
}

/* Card sub-categories */
.card .card-header .card-category,
.card .card-header p {
    color: #64748b !important; /* Zinc/Slate-500 */
    font-size: 0.8125rem !important;
    margin: 4px 0 0 0 !important;
    font-weight: 400 !important;
}

/* Card body */
.card .card-body {
    padding: 1.5rem !important;
}

/* ==========================================================================
   BUTTONS (CLEAN & PREMIUM SHADCN STYLE)
   ========================================================================== */
.btn {
    border-radius: 8px !important;
    font-weight: 600 !important;
    font-size: 0.8125rem !important;
    padding: 8px 18px !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    box-shadow: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    border: 1px solid transparent !important;
    height: 40px !important;
    min-width: 140px !important; /* Professional standard minimum button width */
}

/* Reset min-width for table action buttons, icon buttons and small buttons */
.td-actions .btn,
.btn-sm,
.btn-icon,
.user-profile-btn,
.close {
    min-width: auto !important;
    height: auto !important;
}

.btn i, .btn .material-icons {
    font-size: 1.125rem !important;
}

/* Button variants keeping active colors */
.btn-primary {
    background-color: #9c27b0 !important;
    border-color: #9c27b0 !important;
    color: #ffffff !important;
}

.btn-primary:hover, .btn-primary:focus {
    background-color: #7b1fa2 !important;
    border-color: #7b1fa2 !important;
    box-shadow: 0 0 0 2px rgba(156, 39, 176, 0.2) !important;
}

.btn-white {
    background-color: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    color: #9c27b0 !important;
}

.btn-white:hover {
    background-color: #f8fafc !important;
    border-color: #cbd5e1 !important;
    color: #7b1fa2 !important;
}

.btn-secondary {
    background-color: #f59e0b !important; /* Elegant Warning Orange matching voltar */
    border-color: #f59e0b !important;
    color: #ffffff !important;
}

.btn-secondary:hover {
    background-color: #d97706 !important; /* Deep warm orange hover */
    border-color: #d97706 !important;
    color: #ffffff !important;
}

.btn-default {
    background-color: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    color: #334155 !important;
}

.btn-default:hover {
    background-color: #f8fafc !important;
    border-color: #cbd5e1 !important;
}

.btn-warning {
    background-color: #f59e0b !important;
    border-color: #f59e0b !important;
    color: #ffffff !important;
}

.btn-warning:hover {
    background-color: #d97706 !important;
    border-color: #d97706 !important;
}

.btn-danger {
    background-color: #ef4444 !important;
    border-color: #ef4444 !important;
    color: #ffffff !important;
}

.btn-danger:hover {
    background-color: #dc2626 !important;
    border-color: #dc2626 !important;
}

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

.btn-success:hover {
    background-color: #059669 !important;
    border-color: #059669 !important;
}

/* Round / small adjustments */
.btn-round {
    border-radius: 9999px !important;
}

.btn-sm {
    height: 32px !important;
    padding: 4px 12px !important;
    font-size: 0.75rem !important;
}

/* Custom icon buttons in tables */
.td-actions .btn {
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    border-radius: 6px !important;
    margin: 0 2px !important;
}

.td-actions .btn.btn-warning {
    background-color: #fef3c7 !important;
    border: 1px solid #fde68a !important;
    color: #d97706 !important;
}

.td-actions .btn.btn-warning:hover {
    background-color: #fde68a !important;
}

.td-actions .btn.btn-danger {
    background-color: #fee2e2 !important;
    border: 1px solid #fecaca !important;
    color: #dc2626 !important;
}

.td-actions .btn.btn-danger:hover {
    background-color: #fecaca !important;
}

/* ==========================================================================
   TABELAS DE DADOS (FLAT & CLEAN STYLE)
   ========================================================================== */
.table-responsive {
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    margin-bottom: 0 !important;
    box-shadow: none !important;
}

.table {
    margin-bottom: 0 !important;
    width: 100% !important;
    border-collapse: collapse !important;
}

.table thead th {
    background-color: #f8fafc !important;
    border-bottom: 1px solid #e2e8f0 !important;
    color: #475569 !important; /* Slate-600 */
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    padding: 12px 16px !important;
    border-top: none !important;
}

.table tbody tr {
    transition: background-color 0.15s ease !important;
}

.table tbody td {
    padding: 14px 16px !important;
    border-bottom: 1px solid #f1f5f9 !important;
    border-top: none !important;
    font-size: 0.875rem !important;
    color: #334155 !important; /* Slate-700 */
    vertical-align: middle !important;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: #fafafa !important;
}

.table tbody tr:hover {
    background-color: #f1f5f9 !important;
}

/* Remove Material Dashboard custom column shadows and background cards */
.table thead th.text-primary,
.table thead .text-primary {
    color: #475569 !important;
}

/* ==========================================================================
   FORM CONTROLS & INPUTS
   ========================================================================== */
/* Spacing and layout fixes for form groups and overlapping material labels */
.form-group, 
.bmd-form-group {
    position: relative !important;
    margin-top: 0.5rem !important; /* Small top margin to separate rows gently */
    margin-bottom: 1rem !important; /* Compact, balanced spacing between rows */
    padding-top: 0 !important;
    display: block !important;
    width: 100% !important;
}

/* Strip absolute positioning & floating transformations from Material Design labels */
.form-group label,
.bmd-form-group label,
label,
.bmd-label-floating,
.bmd-label-static {
    position: static !important;
    display: block !important;
    transform: none !important;
    font-size: 0.8125rem !important; /* Extremely elegant and crisp typography */
    font-weight: 600 !important;
    color: #475569 !important; /* Slate-600 */
    margin-bottom: 4px !important; /* Label stays close to its own input below it! */
    margin-top: 6px !important; /* Label pushes away from any input or line above it! */
    pointer-events: auto !important;
    transition: none !important;
    letter-spacing: normal !important;
}

/* Ensure labels are properly spaced in modals */
.modal-body .form-group {
    margin-top: 0.5rem !important;
    margin-bottom: 1rem !important;
}

.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="date"],
select.form-control,
textarea.form-control {
    border: 1px solid #cbd5e1 !important; /* Slate-300 */
    border-radius: 8px !important;
    font-size: 0.875rem !important;
    padding: 8px 12px !important;
    background-color: #ffffff !important;
    color: #0f172a !important;
    height: 38px !important;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out !important;
    box-shadow: none !important;
    background-image: none !important; /* Strip Material line */
}

.form-control:focus,
input:focus,
select:focus,
textarea:focus {
    border-color: #a855f7 !important; /* Purple accent */
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15) !important;
    outline: none !important;
}

/* Placeholders */
::placeholder {
    color: #94a3b8 !important; /* Slate-400 */
}

/* Styling native select */
select.form-control {
    padding-right: 24px !important;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2364748b%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 10px auto !important;
    appearance: none !important;
}

/* ==========================================================================
   MODAL WINDOWS (SHADCN PATTERN)
   ========================================================================== */
.modal-content {
    border-radius: 12px !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
    overflow: hidden !important;
}

.modal-header {
    background-color: #ffffff !important;
    border-bottom: 1px solid #e2e8f0 !important;
    color: #0f172a !important;
    padding: 1.25rem 1.5rem !important;
}

.modal-header .close {
    color: #94a3b8 !important;
    font-size: 1.5rem !important;
    opacity: 0.7 !important;
    text-shadow: none !important;
    padding: 1.25rem 1.5rem !important;
    margin: -1.25rem -1.5rem -1.25rem auto !important;
    transition: color 0.15s ease !important;
    outline: none !important;
}

.modal-header .close:hover {
    color: #0f172a !important;
    opacity: 1 !important;
}

.modal-title {
    font-weight: 700 !important;
    font-size: 1.125rem !important;
    color: #9c27b0 !important;
    letter-spacing: -0.02em !important;
}

.modal-body {
    padding: 1.5rem !important;
}

.modal-footer {
    background-color: #f8fafc !important;
    border-top: 1px solid #e2e8f0 !important;
    padding: 1rem 1.5rem !important;
    display: flex !important;
    justify-content: flex-end !important;
    gap: 10px !important;
}

.modal-footer .btn {
    margin: 0 !important;
}

/* ==========================================================================
   ALERTS AND NOTIFICATIONS
   ========================================================================== */
.alert {
    border-radius: 8px !important;
    border: 1px solid transparent !important;
    padding: 12px 16px !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    margin-bottom: 20px !important;
    box-shadow: none !important;
}

.alert-success {
    background-color: #ecfdf5 !important;
    border-color: #a7f3d0 !important;
    color: #065f46 !important;
}

.alert-danger, .alert-error {
    background-color: #fef2f2 !important;
    border-color: #fca5a5 !important;
    color: #991b1b !important;
}

.alert-warning {
    background-color: #fffbeb !important;
    border-color: #fde68a !important;
    color: #92400e !important;
}

.alert-info {
    background-color: #eff6ff !important;
    border-color: #bfdbfe !important;
    color: #1e40af !important;
}

/* ==========================================================================
   FIXES & UTILITIES
   ========================================================================== */
.d-flex.gap-10 {
    gap: 10px !important;
}

.d-flex.gap-15 {
    gap: 15px !important;
}

/* Material Design specific layout overrides */
.bmd-form-group {
    padding: 0 !important;
    margin: 0 !important;
}

/* Fix flatpickr inputs */
.flatpickr-input {
    background-color: #ffffff !important;
}

/* Smooth global transition for theme toggling */
body {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}

/* Theme Toggle Button Style in Topbar */
.theme-toggle-btn {
    width: 38px !important;
    height: 38px !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 1px solid #e2e8f0 !important;
    background-color: #ffffff !important;
    color: #64748b !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    outline: none !important;
    padding: 0 !important;
    margin-right: 8px !important;
}

.theme-toggle-btn:hover {
    background-color: #f8fafc !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
}

.theme-toggle-btn i,
.theme-toggle-btn .material-icons {
    font-size: 1.25rem !important;
}

/* ==========================================================================
   DARK THEME OVERRIDES (SHADCN PATTERN STYLE)
   ========================================================================== */
body.dark {
    background-color: #09090b !important; /* Zinc-955 background */
    color: #f4f4f5 !important; /* Zinc-100 text */
}

/* Sidebar Dark mode */
body.dark .sidebar {
    background-color: #09090b !important;
    border-right: 1px solid #27272a !important; /* Zinc-800 border */
}

body.dark .sidebar-wrapper,
body.dark .sidebar .logo {
    background-color: #09090b !important;
    border-bottom-color: #27272a !important;
}

body.dark .sidebar .logo {
    background-color: #09090b !important;
}

body.dark .sidebar .nav li a {
    color: #a1a1aa !important; /* Zinc-400 */
}

body.dark .sidebar .nav li a:hover {
    background-color: #18181b !important; /* Zinc-900 */
    color: #f4f4f5 !important;
}

body.dark .sidebar .nav li a:hover i {
    color: #f4f4f5 !important;
}

body.dark .sidebar .nav li.active > a {
    background-color: #2e1065 !important; /* Deep dark purple active background */
    color: #e9d5ff !important; /* Light purple text */
}

body.dark .sidebar .nav li.active > a i,
body.dark .sidebar .nav li.active > a .material-icons {
    color: #c084fc !important;
}

body.dark .sidebar .nav li a .caret {
    border-top-color: #a1a1aa !important;
}

/* Topbar Dark mode */
body.dark .topbar-navbar {
    background-color: #09090b !important;
    border-bottom: 1px solid #27272a !important;
}

body.dark .topbar-brand {
    color: #f4f4f5 !important;
}

body.dark .user-profile-btn {
    background-color: #18181b !important;
    border-color: #27272a !important;
}

body.dark .user-profile-btn:hover {
    background-color: #27272a !important;
}

body.dark .user-profile-name {
    color: #e4e4e7 !important;
}

body.dark .user-avatar-circle {
    background-color: #2e1065 !important;
    color: #e9d5ff !important;
    border-color: #6b21a8 !important;
}

body.dark .theme-toggle-btn {
    background-color: #18181b !important;
    border-color: #27272a !important;
    color: #a1a1aa !important;
}

body.dark .theme-toggle-btn:hover {
    background-color: #27272a !important;
    color: #f4f4f5 !important;
    border-color: #3f3f46 !important;
}

/* Main Panel Canvas Dark mode */
body.dark .main-panel {
    background-color: #09090b !important;
}

/* Cards Dark mode */
body.dark .card {
    background-color: #0c0c0e !important; /* Extremely dark card body */
    border-color: #27272a !important;
}

body.dark .card:hover {
    box-shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.4) !important;
}

body.dark .card .card-header {
    background-color: #0c0c0e !important;
    border-bottom-color: #27272a !important;
}

/* Primary card headers stay gorgeous deep purple in dark mode */
body.dark .card .card-header-primary {
    background: linear-gradient(135deg, #7e22ce 0%, #581c87 100%) !important; /* Rich deep purple gradient */
}

body.dark .card .card-header-primary .card-category,
body.dark .card .card-header-primary p {
    color: rgba(233, 213, 255, 0.8) !important; /* Soft lavender subtext */
}

body.dark .card .card-header:not(.card-header-primary):not(.card-header-warning):not(.card-header-danger):not(.card-header-success):not(.card-header-info) .card-title,
body.dark .card .card-header:not(.card-header-primary):not(.card-header-warning):not(.card-header-danger):not(.card-header-success):not(.card-header-info) h4 {
    color: #f4f4f5 !important;
}

/* Tables Dark mode */
body.dark .table-responsive {
    border-color: #27272a !important;
}

body.dark .table thead th {
    background-color: #18181b !important;
    border-bottom-color: #27272a !important;
    color: #a1a1aa !important;
}

body.dark .table tbody td {
    border-bottom-color: #18181b !important;
    color: #e4e4e7 !important;
}

body.dark .table-striped tbody tr:nth-of-type(odd) {
    background-color: #0c0c0e !important;
}

body.dark .table tbody tr:hover {
    background-color: #18181b !important;
}

/* Form inputs Dark mode */
body.dark .form-group label,
body.dark label,
body.dark .bmd-label-floating,
body.dark .bmd-label-static {
    color: #cbd5e1 !important; /* Light Slate-300 */
}

body.dark .form-control,
body.dark input[type="text"],
body.dark input[type="email"],
body.dark input[type="password"],
body.dark input[type="tel"],
body.dark input[type="number"],
body.dark input[type="date"],
body.dark select.form-control,
body.dark textarea.form-control {
    background-color: #09090b !important;
    border-color: #27272a !important;
    color: #f4f4f5 !important;
}

body.dark .form-control:focus,
body.dark input:focus,
body.dark select:focus,
body.dark textarea:focus {
    border-color: #a855f7 !important;
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.25) !important;
}

body.dark ::placeholder {
    color: #52525b !important; /* Zinc-600 */
}

body.dark select.form-control {
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23a1a1aa%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E") !important;
}

body.dark .flatpickr-input {
    background-color: #09090b !important;
}

/* Modals Dark mode */
body.dark .modal-content {
    background-color: #09090b !important;
    border-color: #27272a !important;
}

body.dark .modal-header {
    background-color: #09090b !important;
    border-bottom-color: #27272a !important;
    color: #f4f4f5 !important;
}

body.dark .modal-header .close {
    color: #71717a !important;
}

body.dark .modal-header .close:hover {
    color: #f4f4f5 !important;
}

body.dark .modal-footer {
    background-color: #0c0c0e !important;
    border-top-color: #27272a !important;
}

body.dark hr {
    border-top-color: #27272a !important;
}

/* Dynamic calendar styles check */
body.dark .agenda-container ::-webkit-scrollbar-track {
    background: #09090b !important;
}
body.dark .agenda-container ::-webkit-scrollbar-thumb {
    background: #27272a !important;
    border-color: #09090b !important;
}
body.dark .agenda-container ::-webkit-scrollbar-thumb:hover {
    background: #3f3f46 !important;
}

/* Explicit native option overrides for Dark Mode */
body.dark select option,
body.dark .custom-select option,
body.dark .agenda-select-styled option,
body.dark .form-control option,
body.dark .form-input option {
    background-color: #0c0c0e !important;
    color: #f4f4f5 !important;
}

/* Bootstrap Dropdown overrides for Dark Mode */
body.dark .dropdown-menu {
    background-color: #0c0c0e !important;
    border: 1px solid #27272a !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.1) !important;
}

body.dark .dropdown-item {
    color: #e4e4e7 !important;
}

body.dark .dropdown-item:hover,
body.dark .dropdown-item:focus {
    background-color: #18181b !important;
    color: #ffffff !important;
}

body.dark .dropdown-divider {
    border-top-color: #27272a !important;
}

/* Global headings and labels overrides in Dark Mode to solve contrast/rgb(51,51,51) issues */
body.dark h1,
body.dark h2,
body.dark h3,
body.dark h4,
body.dark h5,
body.dark h6,
body.dark .card-body h1,
body.dark .card-body h2,
body.dark .card-body h3,
body.dark .card-body h4,
body.dark .card-body h5,
body.dark .card-body h6,
body.dark .form-section-title {
    color: #f4f4f5 !important;
}

body.dark label,
body.dark .form-group label,
body.dark .bmd-form-group label,
body.dark .bmd-label-floating,
body.dark .bmd-label-static,
body.dark .form-group.is-focused label,
body.dark .bmd-form-group.is-focused label {
    color: #cbd5e1 !important;
}

body.dark .form-group.is-focused label,
body.dark .bmd-form-group.is-focused label {
    color: #a855f7 !important; /* Focused state in dark mode is a nice light purple */
}

/* ==========================================================================
   CPF SEARCH MODAL AND INPUT LEGIBILITY CORRECTIONS
   ========================================================================== */

/* Search Result Box */
.search-result-box {
    border: 1px solid #e2e8f0 !important;
    padding: 16px !important;
    border-radius: 8px !important;
    background-color: #f8fafc !important; /* Premium Slate/Zinc Light bg */
    color: #0f172a !important; /* Slate-900 */
    transition: all 0.2s ease-in-out;
}

.search-result-box p {
    margin-bottom: 8px !important;
    color: #334155 !important; /* Slate-700 */
    font-size: 0.95rem !important;
}

.search-result-box p:last-child {
    margin-bottom: 0 !important;
}

.search-result-box strong {
    color: #0f172a !important;
}

/* Dark Mode Overrides for Search Result Box */
body.dark .search-result-box {
    background-color: #18181b !important; /* Zinc-900 */
    border-color: #27272a !important; /* Zinc-800 */
    color: #f4f4f5 !important; /* Zinc-100 */
}

body.dark .search-result-box p {
    color: #d4d4d8 !important; /* Zinc-300 */
}

body.dark .search-result-box strong {
    color: #ffffff !important;
}

/* Active/Focused/Autofilled Input background correction in Dark Mode */
body.dark .form-control:focus,
body.dark .form-control:active,
body.dark .form-control.active,
body.dark input:focus,
body.dark input:active,
body.dark select:focus,
body.dark select:active,
body.dark textarea:focus,
body.dark textarea:active,
body.dark input:-webkit-autofill,
body.dark input:-webkit-autofill:hover,
body.dark input:-webkit-autofill:focus {
    background-color: #09090b !important;
    color: #f4f4f5 !important;
    -webkit-text-fill-color: #f4f4f5 !important;
    transition: background-color 5000s ease-in-out 0s; /* Prevent chrome autofill bg */
}

/* Readonly and Disabled fields background override in Dark Mode */
    background-color: #09090b !important;
    border-color: #27272a !important;
    color: #a1a1aa !important; /* Zinc-400 */
    opacity: 0.85 !important;
}

/* ==========================================================================
   HORIZONTAL TOPBAR LAYOUT OVERRIDES
   ========================================================================== */

/* Hide vertical sidebar */
.sidebar {
    display: none !important;
}

/* Adjust topbar-navbar layout to support Left/Right separation */
.topbar-navbar {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 0 24px !important;
    height: 70px !important;
    background-color: #ffffff !important;
    border-bottom: 1px solid #e2e8f0 !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 99 !important;
}

.topbar-left {
    display: flex !important;
    align-items: center !important;
    gap: 24px !important;
    height: 100% !important;
    flex: 1 1 auto !important;
}

.topbar-right {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
}

/* Logo Sizing */
.topbar-left .logo {
    display: flex !important;
    align-items: center !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border-bottom: none !important;
}

.topbar-left .logo a {
    display: flex !important;
    align-items: center !important;
}

.topbar-left .logo img {
    max-height: 35px !important;
    width: auto !important;
    transition: transform 0.2s ease !important;
}

.topbar-left .logo img:hover {
    transform: scale(1.05) !important;
}

/* Horizontal Nav menu styling */
.horizontal-menu {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 6px !important;
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    height: 100% !important;
    flex-wrap: nowrap !important;
}

.horizontal-menu .nav-item {
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    height: 100% !important;
    position: relative !important;
}

/* Rule 5: Same width for all main menu items on the left */
.horizontal-menu .nav-item > a.nav-link {
    width: 110px !important;
    height: 40px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    padding: 0 10px !important;
    border-radius: 8px !important;
    color: #475569 !important; /* Slate-600 */
    font-weight: 600 !important;
    font-size: 0.85rem !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    background-color: transparent !important;
    border: 1px solid transparent !important;
    text-align: center !important;
    margin: 0 !important;
}

.horizontal-menu .nav-item > a.nav-link p,
.horizontal-menu .nav-item > a.nav-link span {
    margin: 0 !important;
    padding: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: inline-block !important;
}

.horizontal-menu .nav-item > a.nav-link i,
.horizontal-menu .nav-item > a.nav-link .material-icons {
    color: #64748b !important;
    font-size: 1.2rem !important;
    margin: 0 !important;
    width: auto !important;
    text-align: center !important;
}

/* Hover and Active States */
.horizontal-menu .nav-item > a.nav-link:hover {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
}

.horizontal-menu .nav-item > a.nav-link:hover i,
.horizontal-menu .nav-item > a.nav-link:hover .material-icons {
    color: #0f172a !important;
}

.horizontal-menu .nav-item.active > a.nav-link {
    background-color: #f3e8ff !important; /* Light Lavender active background */
    color: #7e22ce !important; /* Premium Purple text */
}

.horizontal-menu .nav-item.active > a.nav-link i,
.horizontal-menu .nav-item.active > a.nav-link .material-icons {
    color: #9c27b0 !important;
}

/* Notification badges inside menu links */
.horizontal-menu .nav-item > a.nav-link .badge {
    position: relative !important;
    top: -1px !important;
    right: auto !important;
    margin-left: 6px !important;
    font-size: 0.75rem !important;
    padding: 2px 6px !important;
    display: inline-block !important;
    vertical-align: middle !important;
}


/* Rule 6: Navigation dropdown menu styling */
.horizontal-menu .dropdown-menu {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    margin-top: 6px !important;
    background-color: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04) !important;
    padding: 6px 0 !important;
    min-width: 170px !important;
    z-index: 1000 !important;
    display: none;
}

.horizontal-menu .nav-item.dropdown:hover .dropdown-menu,
.horizontal-menu .nav-item.dropdown.show .dropdown-menu {
    display: block !important;
}

.horizontal-menu .dropdown-menu .dropdown-item {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 8px 14px !important;
    font-size: 0.8125rem !important;
    font-weight: 500 !important;
    color: #475569 !important;
    transition: all 0.15s ease !important;
}

.horizontal-menu .dropdown-menu .dropdown-item i,
.horizontal-menu .dropdown-menu .dropdown-item .material-icons {
    font-size: 1.1rem !important;
    color: #64748b !important;
    margin: 0 !important;
}

.horizontal-menu .dropdown-menu .dropdown-item:hover {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
}

.horizontal-menu .dropdown-menu .dropdown-item:hover i {
    color: #0f172a !important;
}

.horizontal-menu .dropdown-menu .dropdown-item.active {
    background-color: #f3e8ff !important;
    color: #7e22ce !important;
    font-weight: 600 !important;
}

.horizontal-menu .dropdown-menu .dropdown-item.active i {
    color: #9c27b0 !important;
}

/* Hide Bootstrap dropdown toggles' default caret or style them nicely */
.horizontal-menu .nav-item.dropdown > a.dropdown-toggle::after {
    display: inline-block !important;
    margin-left: 0.35em !important;
    vertical-align: 0.2em !important;
    content: "" !important;
    border-top: 0.3em solid !important;
    border-right: 0.3em solid transparent !important;
    border-bottom: 0 !important;
    border-left: 0.3em solid transparent !important;
    transition: transform 0.2s ease !important;
    color: #64748b !important;
}

.horizontal-menu .nav-item.dropdown:hover > a.dropdown-toggle::after,
.horizontal-menu .nav-item.dropdown.show > a.dropdown-toggle::after {
    transform: rotate(180deg) !important;
    color: #0f172a !important;
}

/* Adjust theme-toggle-btn dropdown styles to hide caret */
.theme-toggle-btn.dropdown-toggle::after {
    display: none !important;
}

/* Dark theme overrides for topbar horizontal menu */
body.dark .topbar-navbar {
    background-color: #09090b !important;
    border-bottom: 1px solid #27272a !important;
}

body.dark .horizontal-menu .nav-item > a.nav-link {
    color: #a1a1aa !important;
}

body.dark .horizontal-menu .nav-item > a.nav-link i,
body.dark .horizontal-menu .nav-item > a.nav-link .material-icons {
    color: #71717a !important;
}

body.dark .horizontal-menu .nav-item > a.nav-link:hover {
    background-color: #18181b !important;
    color: #f4f4f5 !important;
}

body.dark .horizontal-menu .nav-item > a.nav-link:hover i,
body.dark .horizontal-menu .nav-item > a.nav-link:hover .material-icons {
    color: #f4f4f5 !important;
}

body.dark .horizontal-menu .nav-item.active > a.nav-link {
    background-color: #2e1065 !important;
    color: #e9d5ff !important;
}

body.dark .horizontal-menu .nav-item.active > a.nav-link i,
body.dark .horizontal-menu .nav-item.active > a.nav-link .material-icons {
    color: #c084fc !important;
}

body.dark .horizontal-menu .dropdown-menu {
    background-color: #0c0c0e !important;
    border-color: #27272a !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4) !important;
}

body.dark .horizontal-menu .dropdown-menu .dropdown-item {
    color: #a1a1aa !important;
}

body.dark .horizontal-menu .dropdown-menu .dropdown-item i {
    color: #71717a !important;
}

body.dark .horizontal-menu .dropdown-menu .dropdown-item:hover {
    background-color: #18181b !important;
    color: #f4f4f5 !important;
}

body.dark .horizontal-menu .dropdown-menu .dropdown-item:hover i {
    color: #f4f4f5 !important;
}

body.dark .horizontal-menu .dropdown-menu .dropdown-item.active {
    background-color: #2e1065 !important;
    color: #e9d5ff !important;
}

body.dark .horizontal-menu .dropdown-menu .dropdown-item.active i {
    color: #c084fc !important;
}

/* Default Toggle Button (Desktop hidden) */
.mobile-menu-toggle-btn {
    display: none !important;
}

/* Mobile Sidebar Drawer styling */
.mobile-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: -280px !important; /* slide-out position */
    width: 280px !important;
    height: 100vh !important;
    background-color: #ffffff !important;
    border-right: 1px solid #e2e8f0 !important;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
    z-index: 2000 !important;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.mobile-sidebar.show {
    left: 0 !important;
}

.mobile-sidebar-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 16px 20px !important;
    border-bottom: 1px solid #f1f5f9 !important;
    height: 70px !important;
}

.mobile-sidebar-header .logo img {
    max-height: 35px !important;
    width: auto !important;
}

.mobile-sidebar-close-btn {
    width: 38px !important;
    height: 38px !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 1px solid #e2e8f0 !important;
    background-color: #ffffff !important;
    color: #64748b !important;
    cursor: pointer !important;
    outline: none !important;
    padding: 0 !important;
}

.mobile-sidebar-close-btn:hover {
    background-color: #f8fafc !important;
    color: #0f172a !important;
}

.mobile-sidebar-wrapper {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 16px !important;
}

/* Mobile Sidebar navigation items */
.mobile-sidebar .nav {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.mobile-sidebar .nav-item {
    margin: 4px 0 !important;
    width: 100% !important;
}

.mobile-sidebar .nav-item a.nav-link {
    display: flex !important;
    align-items: center !important;
    padding: 10px 14px !important;
    border-radius: 8px !important;
    color: #475569 !important;
    font-weight: 500 !important;
    font-size: 0.875rem !important;
    transition: all 0.2s ease !important;
}

.mobile-sidebar .nav-item a.nav-link i,
.mobile-sidebar .nav-item a.nav-link .material-icons {
    color: #64748b !important;
    margin-right: 12px !important;
    font-size: 1.25rem !important;
    text-align: center !important;
    width: 24px !important;
}

.mobile-sidebar .nav-item a.nav-link:hover {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
}

.mobile-sidebar .nav-item a.nav-link:hover i {
    color: #0f172a !important;
}

.mobile-sidebar .nav-item.active > a.nav-link {
    background-color: #f3e8ff !important;
    color: #7e22ce !important;
    font-weight: 600 !important;
}

.mobile-sidebar .nav-item.active > a.nav-link i {
    color: #9c27b0 !important;
}

/* Backdrop */
.mobile-sidebar-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background-color: rgba(15, 23, 42, 0.4) !important; /* Slate-900 with opacity */
    z-index: 1999 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.3s ease !important;
}

.mobile-sidebar-backdrop.show {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Dark theme overrides for mobile sidebar */
body.dark .mobile-sidebar {
    background-color: #09090b !important;
    border-right-color: #27272a !important;
}

body.dark .mobile-sidebar-header {
    border-bottom-color: #27272a !important;
}

body.dark .mobile-sidebar-close-btn {
    background-color: #18181b !important;
    border-color: #27272a !important;
    color: #a1a1aa !important;
}

body.dark .mobile-sidebar-close-btn:hover {
    background-color: #27272a !important;
    color: #f4f4f5 !important;
}

body.dark .mobile-sidebar .nav-item a.nav-link {
    color: #a1a1aa !important;
}

body.dark .mobile-sidebar .nav-item a.nav-link i {
    color: #71717a !important;
}

body.dark .mobile-sidebar .nav-item a.nav-link:hover {
    background-color: #18181b !important;
    color: #f4f4f5 !important;
}

body.dark .mobile-sidebar .nav-item a.nav-link:hover i {
    color: #f4f4f5 !important;
}

body.dark .mobile-sidebar .nav-item.active > a.nav-link {
    background-color: #2e1065 !important;
    color: #e9d5ff !important;
}

body.dark .mobile-sidebar .nav-item.active > a.nav-link i {
    color: #c084fc !important;
}

/* RESPONSIVE LAYOUT BREAKPOINT */
@media (max-width: 1100px) {
    .horizontal-menu {
        display: none !important;
    }

    .mobile-menu-toggle-btn {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 38px !important;
        height: 38px !important;
        border-radius: 50% !important;
        border: 1px solid #e2e8f0 !important;
        background-color: #ffffff !important;
        color: #64748b !important;
        cursor: pointer !important;
        outline: none !important;
        padding: 0 !important;
        margin-right: 8px !important;
    }
    
    body.dark .mobile-menu-toggle-btn {
        background-color: #18181b !important;
        border-color: #27272a !important;
        color: #a1a1aa !important;
    }

    body.dark .mobile-menu-toggle-btn:hover {
        background-color: #27272a !important;
        color: #f4f4f5 !important;
    }

    .mobile-menu-toggle-btn:hover {
        background-color: #f8fafc !important;
        color: #0f172a !important;
    }

    .topbar-navbar {
        padding: 0 16px !important;
    }

    .topbar-left {
        gap: 12px !important;
    }
}

/* Checkbox dark mode contrast fixes */
body.dark .form-check .form-check-sign .check {
    border-color: rgba(255, 255, 255, 0.45) !important;
}

body.dark .form-check-input:checked ~ .form-check-sign .check {
    background-color: #9c27b0 !important;
    border-color: #9c27b0 !important;
}

body.dark .form-check-input:focus ~ .form-check-sign .check {
    border-color: #a855f7 !important;
}


