/**
 * FilterFinder Clean Theme CSS
 * Only custom styles that extend Bootstrap functionality
 * No unnecessary Bootstrap overrides
 */

/* Import Raleway font from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Raleway:wght@300;400;500;600;700&display=swap');

/* Custom Color Variables - Only non-Bootstrap colors */
:root {
  /* TM Filters Brand Colors */
  --tm-filters-red: rgb(152, 23, 20);
  --tm-filters-red-hover: rgb(121, 18, 24);
  --tm-filters-red-active: rgb(106, 16, 21);

  /* Clean Backgrounds - Custom colors not in Bootstrap */
  --clean-bg-primary: #ffffff;
  --clean-bg-secondary: #f8f9fa;
  --clean-border: #dee2e6;
  --clean-text: #212529;
  --clean-text-muted: #6c757d;

  /* Form Colors - Custom form styling */
  --form-border: #ced4da;
  --form-bg: #ffffff;
}

/* Override Bootstrap btn-primary with TM Filters Red */
.btn-primary {
  --bs-btn-bg: var(--tm-filters-red);
  --bs-btn-border-color: var(--tm-filters-red);
  --bs-btn-hover-bg: var(--tm-filters-red-hover);
  --bs-btn-hover-border-color: var(--tm-filters-red-hover);
  --bs-btn-active-bg: var(--tm-filters-red-active);
  --bs-btn-active-border-color: var(--tm-filters-red-active);
  --bs-btn-disabled-bg: var(--tm-filters-red);
  --bs-btn-disabled-border-color: var(--tm-filters-red);
}

/* Custom Body Background - Only non-default styling */
body {
    background-color: var(--clean-bg-secondary);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Sticky Footer Layout */
body > main {
    flex: 1 0 auto;
}

body > footer {
    flex-shrink: 0;
    margin-top: auto;
}

/* H1 Styling with Raleway Font */
h1 {
    font-family: 'Raleway', sans-serif;
    font-weight: 600;
    color: var(--clean-text);
    font-size: 40px;
}

/*
 * Z-Index Stacking Strategy (layered from bottom to top):
 * 1. Watermark layer: z-1 (1) - Bootstrap utility class
 * 2. Page content (cards, etc): z-2 (2) - Bootstrap utility class
 * 3. Sticky navbar: 1040 - Custom (above page content)
 * 4. Dropdown menus: 1050 - Custom (above navbar, matches modal-backdrop)
 * 5. Modal backdrop: 1050 - Custom (darkens background)
 * 6. Modal: 1055 - Custom (above backdrop)
 * 7. Modal dialog: 1056 - Custom (top interactive layer)
 */

/* Bootstrap Navbar Background and Shadow */
.navbar.navbar-expand-lg {
    background-color: var(--bs-body-bg);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 1040; /* Above page content, allows dropdowns to be even higher */
}

/* User Dropdown Styling */
#userDropdownBtn {
    text-decoration: none;
    color: inherit;
    padding: 0.5rem 0;
    background: transparent;
    border: none;
}

#userDropdownBtn:hover {
    color: var(--bs-primary);
}

/* Ensure dropdown menu appears above all content including cards */
.navbar .dropdown-menu {
    z-index: 1050 !important; /* Custom: matches modal-backdrop level, above all page content */
}

/* Ensure navbar itself doesn't create stacking context issues */
.navbar {
    position: relative;
    z-index: 1040; /* Above page content but below dropdowns */
}

/* Additional fallback - ensure all dropdown menus are above content */
.dropdown-menu {
    z-index: 1050 !important;
}

/* Sortable Table Headers */
.sortable-header {
    /* Removed background-color to match non-sortable headers */
    transition: background-color 0.15s ease-in-out;
}

.sortable-header:hover {
    background-color: var(--bs-gray-100);
}

.sortable-header a {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0; /* Remove padding - let th padding apply */
    color: var(--bs-dark) !important;
    text-decoration: none !important;
}

.sortable-header .sort-icon {
    opacity: 0.8;
    font-size: 0.875rem;
}

/* Semantic Component Classes */

/* Sortable Table Components */
.sortable-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    width: 100%;
    height: 100%;
    padding: 0; /* Remove padding - let th padding apply */
    color: var(--bs-dark) !important;
    text-decoration: none !important;
}

/* Action Button Groups */
.action-buttons {
    display: flex;
    gap: 0.25rem;
    justify-content: center;
    align-items: center;
}

.action-buttons .btn {
    transition: all 0.2s ease-in-out;
}

.action-btn-view:hover {
    background-color: var(--bs-info);
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.action-btn-edit:hover {
    background-color: var(--bs-warning);
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.action-btn-delete:hover {
    background-color: var(--bs-danger);
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

/* Status Badge Variants */
.status-badge {
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
}

.status-badge i {
    font-size: 0.75rem;
}

/* Card Components */
.card-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.card-actions .btn {
    white-space: nowrap;
}

/* Pagination Components */
.pagination-counter {
    display: block;
    line-height: 2.25rem;
}

/* Enhanced Pagination Styling */
.pagination-wrapper {
    margin-top: 1rem;
}

.pagination-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.pagination-counter-text {
    color: var(--bs-gray-600);
    font-size: 0.875rem;
}

/* Pagination Size Variants */
.pagination-lg .page-link {
    padding: 0.75rem 1rem;
    font-size: 1rem;
}

.pagination-sm .page-link {
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
}

/* Pagination Style Variants */
.pagination-simple {
    background: none;
    border: none;
    padding: 0;
}

.pagination-compact {
    margin-bottom: 0.5rem;
}

.pagination-card {
    background: var(--clean-bg-primary);
    border-top: 1px solid var(--clean-border);
    padding: 1rem;
}

/* Custom Pagination Colors */
.pagination .page-item.active .page-link {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: white;
}

.pagination .page-item:not(.active) .page-link {
    color: var(--bs-primary);
}

.pagination .page-item:not(.active) .page-link:hover {
    background-color: var(--bs-gray-100);
    color: var(--bs-primary);
}

.pagination .page-item.disabled .page-link {
    color: var(--bs-gray-400);
    background-color: var(--bs-gray-100);
    border-color: var(--bs-gray-300);
}

/* Responsive Pagination */
@media (max-width: 576px) {
    .pagination-info {
        flex-direction: column;
        text-align: center;
    }
    
    .pagination-counter {
        order: 2;
        margin-top: 0.5rem;
    }
    
    .pagination {
        justify-content: center;
    }
    
    /* Hide first/last buttons on small screens */
    .pagination .page-item:first-child,
    .pagination .page-item:last-child {
        display: none;
    }
}

@media (max-width: 768px) {
    .pagination-counter-text {
        font-size: 0.8rem;
    }
}

/* Form Components */
.form-section {
    margin-bottom: 2rem;
}

.form-section-header {
    color: var(--bs-gray-600);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--bs-gray-200);
}

.form-section-header i {
    margin-right: 0.5rem;
}

.form-row {
    margin-bottom: 1rem;
}

.form-help {
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--bs-gray-600);
}

.form-help i {
    margin-right: 0.25rem;
}

/* Table Components */
/* Ensure Bootstrap 5 default left-aligned table headers */
.table th,
.table thead th,
.data-table th {
    text-align: left !important;
}

.data-table {
    margin-bottom: 0;
    font-size: 0.875rem; /* Slightly smaller for better fit */
}

.data-table th {
    font-weight: 600;
    font-size: 0.8rem; /* Smaller headers */
    text-transform: uppercase;
    letter-spacing: 0.025em;
    border-bottom: 2px solid var(--bs-gray-200);
    padding: 0.5rem 0.6rem; /* More compact padding */
    white-space: nowrap; /* Prevent header wrapping */
}

.data-table td {
    vertical-align: middle;
    padding: 0.6rem 0.6rem; /* More compact padding */
    border-bottom: 1px solid var(--bs-gray-100);
}

/* Compact action buttons for table cells */
.data-table .action-buttons .btn {
    padding: 0.25rem 0.4rem;
    font-size: 0.75rem;
}

/* Smaller badges in tables */
.data-table .badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.4rem;
}

/* Compact table cell content */
.data-table td .d-flex i {
    font-size: 0.8rem;
    margin-right: 0.4rem;
}

.data-table td small {
    font-size: 0.75rem;
}

/* Enhanced row styling */
.data-table tbody tr {
    transition: all 0.2s ease-in-out;
}

.data-table tbody tr:hover {
    background-color: var(--bs-gray-50) !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Ensure striped styling works with custom CSS */
.data-table.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.05);
}

.data-table.table-striped tbody tr:nth-of-type(odd):hover {
    background-color: var(--bs-gray-50) !important;
}

/* Icon alignment in table cells */
.data-table td .d-flex {
    align-items: center;
}

.data-table td .d-flex i {
    flex-shrink: 0;
}

.table-container {
    background: var(--clean-bg-primary);
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Empty State Components */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--bs-gray-600);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Layout Helpers */
.section-spacing {
    margin-bottom: 2rem;
}

.content-wrapper {
    padding: 1.5rem 0;
}

.clickable {
    cursor: pointer;
    user-select: none;
}

.no-select {
    user-select: none;
}

/* User Avatar Components */
.user-avatar-admin {
    color: white !important;
    background-color: var(--tm-filters-red) !important;
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar-regular {
    color: white !important;
    background-color: var(--bs-primary) !important;
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar i {
    font-size: 1rem;
    transition: all 0.15s ease-in-out;
}

/* Custom Navbar Styling - Minimal overrides without !important - DISABLED */
/* .navbar {
    background-color: var(--clean-bg-primary);
    border-bottom: 1px solid var(--clean-border);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
} */

/* Custom Page Header - Not a Bootstrap component */
.page-header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1.5rem 0;
    background: var(--clean-bg-primary);
    border-radius: 0.5rem;
    border: 1px solid var(--clean-border);
}

.page-header h1 {
    color: var(--bs-dark);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.page-header p {
    color: var(--clean-text-muted);
    font-size: 1rem;
    margin-bottom: 0;
}

/* Custom Form Row - Not a Bootstrap component */
.form-row {
    margin-bottom: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--clean-border);
}

.form-row:last-child {
    border-bottom: none;
}

/* Custom User Avatar - Not a Bootstrap component */
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bs-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.875rem;
}

/* Custom Connection Status - Not a Bootstrap component */
.connection-status-light {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.connection-status-light[data-status="connected"] {
    background: #28a745;
    box-shadow: 0 0 6px rgba(40, 167, 69, 0.3);
}

.connection-status-light[data-status="disconnected"] {
    background: #dc3545;
    box-shadow: 0 0 6px rgba(220, 53, 69, 0.3);
}

.connection-status-light[data-status="error"] {
    background: #ffc107;
    box-shadow: 0 0 6px rgba(255, 193, 7, 0.3);
}

/* Legacy support for old status values */
.connection-status-light[data-status="green"] {
    background: #28a745;
}

.connection-status-light[data-status="yellow"] {
    background: #ffc107;
}

.connection-status-light[data-status="grey"] {
    background: #6c757d;
}

/* Custom Row Styling for Form Layout - DISABLED */
/* .row.mb-3 {
    align-items: center;
    padding: 0.75rem 0;
}

.row.mb-3:last-child {
    padding-bottom: 0;
} */

/* Custom Logo Styling - Not a Bootstrap component */
.logo-styled .logo-f.inverted {
    display: inline-block;
    background-color: var(--bs-primary);
    color: white;
    padding: 0.2rem 0.35rem;
    border-radius: 0.25rem;
    font-weight: 700;
    margin: 0 0.05rem;
    font-size: 1.1em;
    line-height: 1;
}

.logo-styled {
    font-weight: 600;
    letter-spacing: -0.02em;
}

.logo-styled .logo-f.inverted:hover {
    background-color: var(--bs-primary);
    transform: scale(1.05);
    transition: transform 0.2s ease-in-out;
}

/* Organization Logo Styling */
.organization-logo {
    transition: transform 0.2s ease-in-out;
    filter: brightness(1) contrast(1.1);
}

.navbar-brand:hover .organization-logo {
    transform: scale(1.02);
}

/* Responsive logo styling - DISABLED (contains !important) */
/* @media (max-width: 576px) {
    .organization-logo {
        height: 32px !important;
        max-width: 120px !important;
    }
    
    .navbar-brand span {
        font-size: 0.9rem;
    }
} */


/* Custom Gradient Removal - Only for specific legacy classes - DISABLED */
/* .text-gradient,
.bg-primary-gradient,
.bg-secondary-gradient {
    background: var(--bs-primary) !important;
    color: white !important;
    -webkit-background-clip: initial !important;
    -webkit-text-fill-color: initial !important;
    background-clip: initial !important;
} */

/* Responsive Design - Custom breakpoints */
@media (max-width: 768px) {
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    .form-row {
        padding: 0.5rem 0;
    }
}

/* Role-Based Navigation Styling */
.admin-menu-item {
    transition: opacity 0.3s ease-in-out;
    display: none; /* Hidden by default */
}

/* Show admin menu items for admin users */
body[data-user-role="admin"] .admin-menu-item {
    display: block;
}

/* Debug mode role switching (cleaner approach without !important) */
body.debug-role-user .admin-menu-item {
    display: none;
}

body.debug-role-admin .admin-menu-item {
    display: block;
}

/* Debug mode role switcher styling - DISABLED (contains !important) */
/* .debug-role-user .admin-menu-item {
    display: none !important;
}

.debug-role-admin .admin-menu-item {
    display: block !important;
} */

/* Role switcher visual feedback */
#roleSwitcher {
    border: 2px solid transparent;
    transition: border-color 0.2s ease-in-out;
}

#roleSwitcher:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.25);
}

/* Role display styling */
#currentRoleDisplay {
    font-weight: 500;
    transition: color 0.2s ease-in-out;
}

/* .debug-role-admin #currentRoleDisplay {
    color: var(--bs-danger) !important;
}

.debug-role-user #currentRoleDisplay {
    color: var(--bs-primary) !important;
} */

/* Enhanced Admin CRUD Styling */
.admin-crud-header {
    background: linear-gradient(135deg, var(--clean-bg-primary) 0%, var(--clean-bg-secondary) 100%);
    border-bottom: 2px solid var(--clean-border);
}

.admin-crud-header h1 {
    color: var(--bs-primary);
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.admin-crud-header p {
    color: var(--clean-text-muted);
    font-size: 1.1rem;
    margin-bottom: 0;
}

/* Sortable Table Headers - Minimal styling for functionality only - DISABLED */
/* .table thead th a {
    color: inherit;
    text-decoration: none;
    display: block;
    width: 100%;
    height: 100%;
}

.table thead th a:hover {
    color: var(--bs-primary);
} */

/* Sort indicators - styled via JavaScript-inserted HTML elements */
.table thead th .sort-icon {
    float: right;
    margin-left: 0.5rem;
    color: var(--bs-primary);
    font-size: 0.75rem;
}

/* Enhanced Form Styling - DISABLED */
/* .form-row {
    background: var(--clean-bg-primary);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: all 0.2s ease-in-out;
}

.form-row:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    transform: translateY(-1px);
}

.form-row:last-child {
    border-bottom: none;
} */

/* Enhanced Button Styling - DISABLED */
/* .btn-group .btn {
    transition: all 0.2s ease-in-out;
}

.btn-group .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
} */

/* Enhanced Card Styling - DISABLED */
/* .card {
    border: 1px solid var(--clean-border);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.2s ease-in-out;
}

.card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.card-header {
    background: linear-gradient(135deg, var(--clean-bg-secondary) 0%, var(--clean-bg-primary) 100%);
    border-bottom: 1px solid var(--clean-border);
} */

/* Clickable Table Rows - Use Bootstrap's standard table-hover behavior */
.table-row-clickable {
    cursor: pointer;
}

/* Flash Message Components */
.flash-message {
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: none;
    transition: all 0.3s ease-in-out;
}

.flash-message:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.flash-message i {
    font-size: 1rem;
    vertical-align: middle;
}

/* Flash message animations */
.flash-message.fade {
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
}

.flash-message.fade.show {
    opacity: 1;
    transform: translateY(0);
}

.flash-message.fade:not(.show) {
    opacity: 0;
    transform: translateY(-10px);
}

/* Auto-dismiss styling */
.flash-message.d-none {
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease-in-out;
}

/* Custom Flash message colors for better visibility */
.flash-message.alert-success {
    background-color: #d1edff;
    border-left: 4px solid var(--bs-success);
    color: #0f5132;
}

.flash-message.alert-danger {
    background-color: #f8d7da;
    border-left: 4px solid var(--bs-danger);
    color: #721c24;
}

.flash-message.alert-warning {
    background-color: #fff3cd;
    border-left: 4px solid var(--bs-warning);
    color: #664d03;
}

.flash-message.alert-info {
    background-color: #cff4fc;
    border-left: 4px solid var(--bs-info);
    color: #055160;
}

.flash-message.alert-secondary {
    background-color: #f8f9fa;
    border-left: 4px solid var(--bs-secondary);
    color: #41464b;
}

/* Flash message positioning */
.flash-message-container {
    position: relative;
    z-index: 1050;
}

/* Responsive Flash messages */
@media (max-width: 576px) {
    .flash-message {
        margin-left: 0.5rem;
        margin-right: 0.5rem;
        font-size: 0.875rem;
    }
    
    .flash-message i {
        font-size: 0.875rem;
    }
}

/* Change Password Modal Styling */
#changePasswordModal .modal-header {
    background-color: var(--tm-filters-red);
    color: white;
    border-bottom: none;
}

#changePasswordModal .modal-header .btn-close {
    filter: brightness(0) invert(1);
}

#changePasswordModal .modal-body {
    padding: 2rem;
}

#changePasswordModal .form-floating {
    margin-bottom: 1.5rem;
}

#changePasswordModal .form-floating:last-of-type {
    margin-bottom: 1rem;
}

#changePasswordModal .form-control {
    border: 2px solid var(--form-border);
    border-radius: 0.5rem;
    transition: all 0.3s ease-in-out;
}

#changePasswordModal .form-control:focus {
    border-color: var(--tm-filters-red) !important;
    box-shadow: 0 0 0 0.25rem rgba(152, 23, 20, 0.25) !important;
    transform: translateY(-1px);
}

#changePasswordModal .form-floating > label {
    color: var(--clean-text-muted);
    font-weight: 500;
}

#changePasswordModal .modal-footer {
    border-top: 1px solid var(--clean-border);
    padding: 1.5rem 2rem;
    gap: 0.5rem;
}

#changePasswordModal .btn {
    border-radius: 0.5rem;
    font-weight: 500;
    padding: 0.75rem 1.5rem;
    transition: all 0.3s ease-in-out;
}

#changePasswordModal .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

#changePasswordModal .btn-primary {
    background: var(--tm-filters-red) !important;
    border-color: var(--tm-filters-red) !important;
}

#changePasswordModal .btn-primary:hover {
    background: var(--tm-filters-red-hover) !important;
    border-color: var(--tm-filters-red-hover) !important;
}

#changePasswordModal .btn-primary:active {
    background: var(--tm-filters-red-active) !important;
    border-color: var(--tm-filters-red-active) !important;
}

#changePasswordModal .btn-secondary {
    background: var(--bs-secondary);
    border-color: var(--bs-secondary);
}

/* Password strength indicator */
.password-strength-indicator {
    height: 4px;
    background-color: var(--bs-gray-300);
    border-radius: 2px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.password-strength-bar {
    height: 100%;
    border-radius: 2px;
    transition: all 0.3s ease-in-out;
    width: 0%;
}

.password-strength-weak .password-strength-bar {
    background-color: var(--bs-danger);
    width: 33.33%;
}

.password-strength-medium .password-strength-bar {
    background-color: var(--bs-warning);
    width: 66.66%;
}

.password-strength-strong .password-strength-bar {
    background-color: var(--bs-success);
    width: 100%;
}

/* Modal animation enhancement */
#changePasswordModal.fade .modal-dialog {
    transition: transform 0.3s ease-out;
    transform: translate(0, -50px);
}

#changePasswordModal.show .modal-dialog {
    transform: none;
}

/* Error state styling for form fields */
#changePasswordModal .form-control.is-invalid {
    border-color: var(--bs-danger);
    background-image: none;
}

#changePasswordModal .invalid-feedback {
    color: var(--bs-danger);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Success state styling */
#changePasswordModal .form-control.is-valid {
    border-color: var(--bs-success);
    background-image: none;
}

/* Loading state for submit button */
#changePasswordModal .btn-primary.loading {
    pointer-events: none;
    opacity: 0.6;
}

#changePasswordModal .btn-primary.loading::before {
    content: '';
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 0.5rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Placeholder Styling - Style Guide Requirement */
.form-control::placeholder,
.form-select::placeholder,
input::placeholder,
textarea::placeholder,
input[type="text"]::placeholder,
input[type="email"]::placeholder,
input[type="password"]::placeholder,
input[type="number"]::placeholder,
input[type="tel"]::placeholder,
input[type="url"]::placeholder,
input[type="search"]::placeholder {
    font-style: italic;
    color: var(--bs-gray-500);
    opacity: 0.7;
}

/* Enhanced placeholder styling for better visibility */
.form-floating input::placeholder {
    font-style: italic;
    color: var(--bs-gray-400);
    opacity: 0.8;
}

/* Select Placeholder Options - Style Guide Requirement */
/* Style for placeholder/dummy options in select boxes */
.form-select option[value=""],
.form-select option[value=""]:first-child,
.form-control option[value=""],
.form-control option[value=""]:first-child,
select option[value=""],
select option[value=""]:first-child,
select option:disabled,
option:disabled,
option[disabled] {
    font-style: italic;
    color: var(--bs-gray-500) !important;
}

/* Enhanced placeholder option styling for better visibility */
.form-select option[value=""]:first-child,
select option[value=""]:first-child {
    font-style: italic;
    color: var(--bs-gray-500) !important;
    background-color: var(--bs-gray-50);
}

/* When select has placeholder value selected, style the select itself */
.form-select:invalid,
.form-select[data-placeholder="true"],
select:invalid,
select[data-placeholder="true"] {
    font-style: italic;
    color: var(--bs-gray-500);
}

/* Reset styling when valid option is selected */
.form-select:valid,
select:valid {
    font-style: normal;
    color: var(--clean-text);
}

/* Modern HTML5 placeholder support for select elements */
.form-select[data-placeholder]:invalid,
select[data-placeholder]:invalid {
    font-style: italic;
    color: var(--bs-gray-500);
}

/* Enhanced styling for select elements with placeholder attributes */
.form-select[data-placeholder] option[value=""]:first-child,
select[data-placeholder] option[value=""]:first-child {
    font-style: italic;
    color: var(--bs-gray-500) !important;
    font-weight: normal;
}

/* Support for common placeholder text patterns */
.form-select option[value=""]:first-child,
select option[value=""]:first-child {
    font-style: italic;
    color: var(--bs-gray-500) !important;
}

/* Additional support for disabled placeholder options */
.form-select option[value=""][disabled],
select option[value=""][disabled] {
    font-style: italic;
    color: var(--bs-gray-400) !important;
    background-color: var(--bs-gray-100);
}

/* JavaScript-enhanced placeholder state */
.form-select.placeholder-selected,
select.placeholder-selected {
    font-style: italic;
    color: var(--bs-gray-500);
}

.form-select.placeholder-selected option[value=""]:first-child,
select.placeholder-selected option[value=""]:first-child {
    font-style: italic;
    color: var(--bs-gray-500) !important;
}

/* Watermark Background Styling
 * Z-Index: Watermark uses z-1 (1), page content uses z-2 (2)
 * These align with Bootstrap's z-index utility classes (.z-1, .z-2)
 */
body.page-with-watermark {
    position: relative;
}

body.page-with-watermark::before {
    content: '';
    position: absolute;
    top: -45px;
    left: 50%;
    transform: translateX(-50%);
    /* Consistent sizing across pages: clamp to viewport, cap at container width */
    width: clamp(960px, 85vw, 1320px);
    aspect-ratio: 2481 / 3508; /* Keep original image ratio */
    height: auto;
    background-image: url('../img/watermark/tm_filters-2481x3508.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center center;
    opacity: 0.40; /* Increased visibility to 40% */
    pointer-events: none;
    z-index: 1; /* Bootstrap .z-1 equivalent - bottom layer */
}

body.page-with-watermark main,
body.page-with-watermark header,
body.page-with-watermark footer {
    position: relative;
    z-index: 2; /* Bootstrap .z-2 equivalent - page content layer */
}

/* Reduce z-index of main to not interfere with navbar dropdowns */
body.page-with-watermark main {
    z-index: 1 !important; /* Lower than navbar (1040), allows dropdown to work */
}

/* Add top padding to main content to create space for watermark logo */
body.page-with-watermark main {
    padding-top: 100px;
}

/* Make form cards half transparent on watermark pages - BUT NOT MODALS */
body.page-with-watermark > main .card,
body.page-with-watermark .page-header {
    background-color: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(5px);
}

/* Ensure modal elements are NEVER affected by watermark transparency */
.modal-content {
    background-color: #ffffff !important;
    backdrop-filter: none !important;
}

.modal-header {
    background-color: #ffffff !important;
}

.modal-body {
    background-color: #ffffff !important;
}

.modal-footer {
    background-color: #ffffff !important;
}

.modal .card {
    background-color: #ffffff !important;
    backdrop-filter: none !important;
}

.modal .alert {
    background-color: inherit !important;
}

/* Modal Z-Index Stacking
 * Bootstrap doesn't provide utility classes for these high z-index values (1050+)
 * Custom values required to ensure proper layering:
 * - Backdrop (1050): Darkens background, doesn't intercept clicks
 * - Modal (1055): Modal container above backdrop
 * - Modal Dialog (1056): Interactive content layer
 */
.modal-backdrop {
    z-index: 1050 !important; /* Matches Bootstrap dropdown level */
    pointer-events: none !important; /* Allow clicks through to modal */
}

.modal {
    z-index: 1055 !important; /* Above backdrop */
}

.modal-dialog {
    z-index: 1056 !important; /* Top interactive layer */
    pointer-events: auto !important; /* Receives user interactions */
    position: relative !important;
}

/* Make result modal 25% wider than default and position 10% lower */
#resultModal .modal-dialog {
    max-width: 1000px !important;
    margin-top: 10vh !important;
}

/* Ensure modal is isolated from backdrop opacity */
.modal-content {
    position: relative;
    z-index: 1;
    isolation: isolate;
    background-color: #ffffff !important;
    opacity: 1 !important;
}

/* Ensure modal dialog is completely isolated from backdrop */
.modal-dialog {
    z-index: 1056 !important; /* Top interactive layer */
    pointer-events: auto !important; /* Receives user interactions */
    position: relative !important;
    isolation: isolate !important;
    background-color: transparent !important;
}

/* ============================================
   Link Styling (TM Filters Red)
   ============================================ */
a {
    color: var(--tm-filters-red);
}

a:hover {
    color: var(--tm-filters-red-hover);
}

/* Text utility class for TM Filters Red */
.text-tm-red {
    color: var(--tm-filters-red) !important;
}

/* ============================================
   Form Fields Focus Styling (TM Filters Red)
   ============================================ */
.form-control:focus,
.form-select:focus {
    border-color: var(--tm-filters-red);
    box-shadow: 0 0 0 0.25rem rgba(196, 18, 48, 0.25);
}

.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23c41230' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

.form-check-input:focus {
    border-color: var(--tm-filters-red);
    box-shadow: 0 0 0 0.25rem rgba(196, 18, 48, 0.25);
}

.form-check-input:checked {
    background-color: var(--tm-filters-red);
    border-color: var(--tm-filters-red);
}

/* ============================================
   Login Page Styles
   ============================================ */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: url('/img/background/hero-background.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
}

.login-logo-hero {
    max-width: 250px;
    width: 100%;
    margin: 0 auto 1rem;
}

.login-logo-hero img {
    width: 100%;
    height: auto;
}

.login-divider {
    width: 250px;
    height: 2px;
    background-color: #495057;
    margin: 0 auto 1rem;
}

.login-title {
    margin-bottom: 0;
    line-height: 1.2;
}

.login-card {
    max-width: 400px;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

.login-header {
    text-align: center;
    padding: 2rem 2rem 1rem;
}

.login-logo {
    font-size: 1.8rem;
    font-weight: bold;
    color: #495057;
}

.logo-f {
    color: #007bff;
    background: #007bff;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    margin: 0 1px;
}

.login-copyright {
    position: absolute;
    bottom: 1.5rem;
    right: 2rem;
    text-align: right;
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.login-copyright a {
    color: #ffffff;
    text-decoration: none;
}

.login-copyright a:hover {
    color: rgba(255, 255, 255, 0.9);
}

/* ============================================
   Users Table Styles
   ============================================ */
.users-table-container {
    overflow-x: auto;
    overflow-y: visible;
}

.users-table {
    table-layout: auto;
    width: 100%;
}

.users-table td,
.users-table th {
    white-space: nowrap;
    padding: 0.4rem 0.5rem;
}

.users-table .col-email {
    white-space: normal;
    word-break: break-word;
    max-width: 200px;
}

.users-table td:first-child {
    white-space: normal;
    word-break: break-word;
    max-width: 150px;
}

@media (max-width: 1400px) {
    .users-table .col-organization {
        display: none;
    }
}

@media (max-width: 1100px) {
    .users-table .col-email {
        display: none;
    }
}

@media (max-width: 900px) {
    .users-table td,
    .users-table th {
        padding: 0.3rem 0.4rem !important;
        font-size: 0.85rem;
    }

    .users-table .btn-sm {
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
    }
}

/* ============================================
   Form Validation Page Styles
   ============================================ */
.dependency-group {
    border-left: 4px solid #0d6efd;
}

.form-validation-page .accordion-button:not(.collapsed) {
    background-color: #f8f9fa;
    color: #000;
}

.form-validation-page code {
    background-color: #f8f9fa;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9em;
}

/* ============================================
   User Debug Panel Styles
   ============================================ */
.user-debug-panel h4 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #ddd;
    padding-bottom: 0.25rem;
}

.user-debug-panel h4:first-child {
    margin-top: 0;
}

.user-debug-panel table {
    width: 100%;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.user-debug-panel table td {
    padding: 0.25rem 0.5rem;
    border-bottom: 1px solid #f0f0f0;
}

.user-debug-panel table td:first-child {
    font-weight: 600;
    color: #666;
    width: 40%;
}

.user-debug-panel .status-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.user-debug-panel .status-connected {
    background-color: #d4edda;
    color: #155724;
}

.user-debug-panel .status-disconnected {
    background-color: #f8d7da;
    color: #721c24;
}

.user-debug-panel .status-error {
    background-color: #fff3cd;
    color: #856404;
}

.user-debug-panel .status-unknown {
    background-color: #e2e3e5;
    color: #383d41;
}

/* ============================================
   reCAPTCHA Plugin Override
   ============================================ */
.voxilo-form-policy-term {
    display: none;
}

/* ============================================
   Password Toggle Visibility
   ============================================ */
.password-toggle-container {
    position: relative;
}

.password-toggle-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    padding: 0.375rem 0.5rem;
    color: var(--bs-gray-600);
    cursor: pointer;
    z-index: 10;
    transition: color 0.2s ease-in-out;
}

.password-toggle-btn:hover {
    color: var(--tm-filters-red);
}

.password-toggle-btn:focus {
    outline: none;
    color: var(--tm-filters-red);
}

.password-toggle-btn i {
    font-size: 1rem;
}

/* Adjust padding for password fields to make room for toggle button */
.password-toggle-container input[type="password"],
.password-toggle-container input[type="text"] {
    padding-right: 2.5rem;
}

/* For floating labels, adjust button position */
.form-floating .password-toggle-btn {
    top: 50%;
    right: 10px;
}

/* Adjust password toggle button position when validation state is present */
.password-toggle-container input.is-valid ~ .password-toggle-btn,
.password-toggle-container input.is-invalid ~ .password-toggle-btn,
.was-validated .password-toggle-container input:valid ~ .password-toggle-btn,
.was-validated .password-toggle-container input:invalid ~ .password-toggle-btn {
    right: 2.75rem; /* Move button left to make room for validation icon */
}

/* Additional rule to handle when button is direct child of container (not sibling of input) */
.was-validated .password-toggle-container .password-toggle-btn {
    right: 2.75rem; /* Move button left to make room for validation icon */
}

/* Increase padding on validated password fields to accommodate both icons */
.password-toggle-container input[type="password"].is-valid,
.password-toggle-container input[type="text"].is-valid,
.password-toggle-container input[type="password"].is-invalid,
.password-toggle-container input[type="text"].is-invalid,
.was-validated .password-toggle-container input[type="password"]:valid,
.was-validated .password-toggle-container input[type="text"]:valid,
.was-validated .password-toggle-container input[type="password"]:invalid,
.was-validated .password-toggle-container input[type="text"]:invalid {
    padding-right: 5rem; /* Extra padding for both toggle button and validation icon */
}

/* For form-floating with validation */
.form-floating.password-toggle-container input.is-valid ~ .password-toggle-btn,
.form-floating.password-toggle-container input.is-invalid ~ .password-toggle-btn,
.was-validated .form-floating.password-toggle-container input:valid ~ .password-toggle-btn,
.was-validated .form-floating.password-toggle-container input:invalid ~ .password-toggle-btn {
    right: 2.75rem;
}

/* Focus border color for password fields - use TM Filters red */
.password-toggle-container input[type="password"]:focus,
.password-toggle-container input[type="text"]:focus {
    border-color: var(--tm-filters-red);
    box-shadow: 0 0 0 0.25rem rgba(220, 38, 38, 0.25);
}