/* ============================================================================
   Vendix SFA — Material Design 3 Theme
   Overlays Bootstrap 5 with Google Material Design styling.
   Uses Roboto font, Material elevation, ripple effects, and MD3 colour tokens.
   ============================================================================ */

/* ---------- CSS Custom Properties (Material Design 3 colour tokens) ---------- */
:root {
    /* Primary palette — Indigo */
    --md-primary: #4f46e5;
    --md-primary-light: #818cf8;
    --md-primary-dark: #3730a3;
    --md-primary-container: #e0e7ff;
    --md-on-primary: #ffffff;
    --md-on-primary-container: #312e81;

    /* Secondary palette — Teal */
    --md-secondary: #0d9488;
    --md-secondary-light: #2dd4bf;
    --md-secondary-container: #ccfbf1;
    --md-on-secondary: #ffffff;

    /* Tertiary palette — Amber */
    --md-tertiary: #f59e0b;
    --md-tertiary-container: #fef3c7;

    /* Error palette */
    --md-error: #ef4444;
    --md-error-container: #fee2e2;
    --md-on-error: #ffffff;

    /* Surface / Background */
    --md-surface: #ffffff;
    --md-surface-dim: #f8fafc;
    --md-surface-container: #f1f5f9;
    --md-surface-container-high: #e2e8f0;
    --md-surface-variant: #e2e8f0;
    --md-on-surface: #1e293b;
    --md-on-surface-variant: #64748b;
    --md-outline: #cbd5e1;
    --md-outline-variant: #e2e8f0;

    /* Elevation shadows (Material Design 3 levels) */
    --md-elevation-0: none;
    --md-elevation-1: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --md-elevation-2: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.06);
    --md-elevation-3: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.06);
    --md-elevation-4: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.06);

    /* Shape — Material Design rounded corners */
    --md-shape-xs: 4px;
    --md-shape-sm: 8px;
    --md-shape-md: 12px;
    --md-shape-lg: 16px;
    --md-shape-xl: 28px;

    /* Transition */
    --md-transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --md-transition-long: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Base Typography ---------- */
body {
    font-family: 'Roboto', 'Inter', system-ui, -apple-system, sans-serif !important;
    color: var(--md-on-surface);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Roboto', 'Inter', system-ui, sans-serif;
    font-weight: 500;
    color: var(--md-on-surface);
    letter-spacing: -0.01em;
}

/* ---------- Material Cards ---------- */
.card {
    border: 1px solid var(--md-outline-variant) !important;
    border-radius: var(--md-shape-md) !important;
    box-shadow: var(--md-elevation-1) !important;
    transition: box-shadow var(--md-transition), transform var(--md-transition);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--md-elevation-2) !important;
}

.card-header {
    background: var(--md-surface) !important;
    border-bottom: 1px solid var(--md-outline-variant) !important;
    font-weight: 500;
    padding: 1rem 1.25rem !important;
}

.card-body {
    padding: 1.25rem !important;
}

/* ---------- Material Buttons ---------- */
/* Buttons — padding matches input fields for visual consistency */
.btn {
    border-radius: var(--md-shape-xl) !important;
    font-weight: 500;
    font-size: 0.875rem;
    letter-spacing: 0.02em;
    text-transform: none;
    padding: 0.6rem 1.25rem;
    transition: all var(--md-transition);
    position: relative;
    overflow: hidden;
    border: none !important;
}

/* Ripple effect */
.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 10%, transparent 10%);
    transform: scale(10);
    opacity: 0;
    transition: transform 0.5s, opacity 0.8s;
}

.btn:active::after {
    transform: scale(0);
    opacity: 1;
    transition: 0s;
}

/* Filled buttons — Material primary */
.btn-primary {
    background: var(--md-primary) !important;
    color: var(--md-on-primary) !important;
    box-shadow: var(--md-elevation-1);
}

.btn-primary:hover {
    background: var(--md-primary-dark) !important;
    box-shadow: var(--md-elevation-2);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--md-secondary) !important;
    color: var(--md-on-secondary) !important;
    box-shadow: var(--md-elevation-1);
}

.btn-success:hover {
    background: #0f766e !important;
    box-shadow: var(--md-elevation-2);
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--md-error) !important;
    color: var(--md-on-error) !important;
    box-shadow: var(--md-elevation-1);
}

.btn-danger:hover {
    background: #dc2626 !important;
    box-shadow: var(--md-elevation-2);
    transform: translateY(-1px);
}

/* Outlined buttons — Material tonal */
.btn-outline-primary {
    background: var(--md-primary-container) !important;
    color: var(--md-primary) !important;
    border: none !important;
}

.btn-outline-primary:hover {
    background: var(--md-primary) !important;
    color: var(--md-on-primary) !important;
}

.btn-outline-secondary {
    background: var(--md-surface-container) !important;
    color: var(--md-on-surface-variant) !important;
    border: 1px solid var(--md-outline) !important;
}

.btn-outline-secondary:hover {
    background: var(--md-surface-container-high) !important;
    color: var(--md-on-surface) !important;
}

.btn-outline-danger {
    background: var(--md-error-container) !important;
    color: var(--md-error) !important;
    border: none !important;
}

.btn-outline-danger:hover {
    background: var(--md-error) !important;
    color: var(--md-on-error) !important;
}

.btn-outline-info {
    background: #e0f2fe !important;
    color: #0284c7 !important;
    border: none !important;
}

.btn-outline-info:hover {
    background: #0284c7 !important;
    color: #fff !important;
}

/* Small buttons (action icons in tables) */
.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border-radius: var(--md-shape-sm) !important;
}

/* ---------- Material Form Controls ---------- */
.form-control,
.form-select {
    border: 1px solid var(--md-outline) !important;
    border-radius: var(--md-shape-sm) !important;
    padding: 0.6rem 0.875rem;
    font-size: 0.9rem;
    color: var(--md-on-surface);
    background: var(--md-surface);
    transition: border-color var(--md-transition), box-shadow var(--md-transition);
}

/* Placeholder text — light colour to differentiate from actual input values */
.form-control::placeholder {
    color: #b0b8c4 !important;
    opacity: 1;
    font-weight: 300;
}

/* Browser autofill — match input field styling so autofilled fields look consistent */
.form-control:-webkit-autofill,
.form-control:-webkit-autofill:hover,
.form-control:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--md-surface) inset !important;
    -webkit-text-fill-color: var(--md-on-surface) !important;
    border-color: var(--md-outline) !important;
    transition: background-color 5000s ease-in-out 0s;
}
/* MatTextField autofill — override the light-blue browser default */
.mdc-text-field__input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px #fff inset !important;
    -webkit-text-fill-color: var(--md-on-surface) !important;
}

/* Disabled fields — visually distinct from enabled fields */
.form-control:disabled,
.form-select:disabled {
    background: var(--md-surface-container) !important;
    color: var(--md-on-surface-variant) !important;
    opacity: 0.6;
    cursor: not-allowed;
    border-color: var(--md-outline-variant) !important;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--md-primary) !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12) !important;
    outline: none;
}

.form-control-sm,
.form-select-sm {
    padding: 0.4rem 0.65rem;
    font-size: 0.85rem;
}

.form-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--md-on-surface-variant);
    margin-bottom: 0.35rem;
    letter-spacing: 0.01em;
}

/* Input group — icon addon seamlessly attached to input field with consistent border radius */
.input-group-text {
    background: var(--md-surface-container) !important;
    border: 1px solid var(--md-outline) !important;
    border-right: none !important;
    border-radius: var(--md-shape-md) 0 0 var(--md-shape-md) !important;
    color: var(--md-on-surface-variant);
    font-size: 0.9rem;
    padding: 0.6rem 0.75rem;
}
/* Input field inside input-group — matches addon border radius */
.input-group .form-control {
    border-radius: 0 var(--md-shape-md) var(--md-shape-md) 0 !important;
}
/* When a button follows the input (e.g. search/toggle), remove input right radius */
.input-group .form-control:not(:last-child) {
    border-radius: 0 !important;
}
/* Button inside input-group — visually attached to the input field */
.input-group .btn {
    border-radius: 0 var(--md-shape-md) var(--md-shape-md) 0 !important;
    padding: 0.6rem 0.875rem;
    border: 1px solid var(--md-outline) !important;
    border-left: none !important;
}

.form-check-input:checked {
    background-color: var(--md-primary) !important;
    border-color: var(--md-primary) !important;
}

/* Material-style switch */
.form-switch .form-check-input {
    border-radius: var(--md-shape-xl) !important;
    height: 1.25rem;
    width: 2.25rem;
}

/* ---------- Material Tables ---------- */
.table {
    --bs-table-hover-bg: rgba(79, 70, 229, 0.04);
    border-color: var(--md-outline-variant) !important;
    font-size: 0.9rem;
}

/* Table header — vertically centered text for better alignment */
.table thead th {
    background: var(--md-surface-container) !important;
    color: var(--md-on-surface-variant) !important;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--md-outline) !important;
    padding: 0.75rem 1rem;
    vertical-align: middle;
}

.table tbody td {
    padding: 0.5rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--md-outline-variant);
}

/* ---------- Compact Table Row Spacing ---------- */
/* Reduce row height for better data density while maintaining readability */
.table-sm tbody td {
    padding: 0.35rem 0.75rem;
}

/* ---------- Consistent Empty-State Icon ---------- */
/* All empty-state messages use the same "no data" icon for consistency */
.empty-state-icon {
    font-size: 3rem !important;
    color: var(--md-on-surface-variant);
    opacity: 0.4;
}

/* ---------- Activate / Deactivate Action Icons — Consistent App-Wide ---------- */
/* Activate: always green (#16a34a); Deactivate: always red (--md-error) */
.action-icon-activate,
.table .mdc-icon-button[title="Activate"] {
    color: #16a34a !important;
}
.action-icon-deactivate,
.table .mdc-icon-button[title="Deactivate"] {
    color: var(--md-error) !important;
}

/* ---------- MatSlideToggle — remove persistent hover/active effect ---------- */
/* Ensures the toggle ripple/hover state clears after interaction */
.mdc-switch__ripple::before,
.mdc-switch__ripple::after {
    transition: opacity 150ms ease !important;
}
.mdc-switch:not(:hover):not(:focus-within) .mdc-switch__ripple::before {
    opacity: 0 !important;
}
.mdc-switch:not(:active) .mdc-switch__ripple::after {
    opacity: 0 !important;
}

/* ---------- Table Action Icons — semantic colours ---------- */
/* Edit icon — primary/info blue */
.table .mdc-icon-button[title="Edit"],
.action-icon-edit {
    color: #0284c7 !important;
}
/* Delete/Deactivate icon — error red */
.table .mdc-icon-button[title="Delete"],
.table .mdc-icon-button[title="Deactivate"],
.action-icon-delete {
    color: var(--md-error) !important;
}
/* Activate icon — success green */
.table .mdc-icon-button[title="Activate"],
.action-icon-activate {
    color: #16a34a !important;
}
/* View/Configure icon — secondary teal */
.table .mdc-icon-button[title="Configuration"],
.table .mdc-icon-button[title="View"],
.action-icon-view {
    color: var(--md-secondary) !important;
}

/* ---------- Action Button Icon + Text Spacing ---------- */
/* Ensures gap between icon and text in raised/outlined MatButtons */
.mdc-button .mdc-button__icon + .mdc-button__label,
.mdc-button .material-icons + span,
.btn .material-icons + span,
.btn i + span,
.btn .bi + span {
    margin-left: 0.35rem;
}
/* MatButton internal icon spacing */
.mdc-button .mdc-button__icon {
    margin-right: 0.35rem;
}
/* Small action buttons — ensure icon and text have visible gap */
.btn-sm .material-icons + span,
.btn-sm i + span,
.btn-sm .material-icons {
    vertical-align: middle;
}
.btn-sm .material-icons:not(:last-child) {
    margin-right: 0.25rem;
}

.table-light {
    background: var(--md-surface-container) !important;
}

/* ---------- Material Badges ---------- */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    padding: 0.35em 0.75em;
    border-radius: var(--md-shape-xl) !important;
}

.badge.bg-secondary {
    background: var(--md-surface-container-high) !important;
    color: var(--md-on-surface-variant) !important;
}

.badge.bg-primary {
    background: var(--md-primary-container) !important;
    color: var(--md-on-primary-container) !important;
}

.badge.bg-success {
    background: var(--md-secondary-container) !important;
    color: #065f46 !important;
}

.badge.bg-info {
    background: #e0f2fe !important;
    color: #0369a1 !important;
}

.badge.bg-light {
    background: var(--md-surface-container) !important;
}

/* ---------- Material Alerts ---------- */
.alert {
    border: none !important;
    border-radius: var(--md-shape-md) !important;
    font-size: 0.9rem;
    padding: 0.875rem 1.25rem;
    box-shadow: var(--md-elevation-1);
}

.alert-success {
    background: #ecfdf5 !important;
    color: #065f46 !important;
    border-left: 4px solid var(--md-secondary) !important;
}

.alert-danger {
    background: var(--md-error-container) !important;
    color: #991b1b !important;
    border-left: 4px solid var(--md-error) !important;
}

.alert-info {
    background: #eff6ff !important;
    color: #1e40af !important;
    border-left: 4px solid #3b82f6 !important;
}

/* ---------- Material Navigation Tabs ---------- */
.nav-tabs {
    border-bottom: 2px solid var(--md-outline-variant) !important;
}

.nav-tabs .nav-link {
    border: none !important;
    border-radius: 0 !important;
    color: var(--md-on-surface-variant);
    font-weight: 500;
    font-size: 0.875rem;
    letter-spacing: 0.02em;
    padding: 0.75rem 1.25rem;
    position: relative;
    transition: color var(--md-transition);
}

.nav-tabs .nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--md-primary);
    border-radius: 3px 3px 0 0;
    transform: scaleX(0);
    transition: transform var(--md-transition);
}

.nav-tabs .nav-link.active {
    color: var(--md-primary) !important;
    background: transparent !important;
}

.nav-tabs .nav-link.active::after {
    transform: scaleX(1);
}

.nav-tabs .nav-link:hover:not(.active) {
    color: var(--md-primary-light);
    background: var(--md-primary-container);
}

/* ---------- Material Sidebar (Navigation Drawer) ---------- */
.sidebar {
    background: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%) !important;
    box-shadow: var(--md-elevation-3);
}

.sidebar .nav-link {
    border-radius: var(--md-shape-xl) !important;
    margin: 2px 0.75rem;
    padding: 0.6rem 1rem !important;
    font-size: 0.875rem;
    font-weight: 400;
    letter-spacing: 0.01em;
    transition: all var(--md-transition);
}

.sidebar .nav-link:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}

.sidebar .nav-link.active {
    background: rgba(129, 140, 248, 0.25) !important;
    color: #e0e7ff !important;
    font-weight: 500;
}

.sidebar .nav-link.active i {
    color: var(--md-primary-light);
}

.sidebar .sidebar-brand {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.sidebar .sidebar-user-section {
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* ---------- Material Header ---------- */
header.bg-white {
    background: var(--md-surface) !important;
    border-bottom: 1px solid var(--md-outline-variant) !important;
    box-shadow: var(--md-elevation-1) !important;
}

header h5 {
    color: var(--md-on-surface);
    font-weight: 600;
    font-size: 1.1rem;
}

/* ---------- Material Status Bar ---------- */
.status-bar {
    background: var(--md-surface-container) !important;
    color: var(--md-on-surface-variant) !important;
    border-top: 1px solid var(--md-outline-variant) !important;
    font-size: 0.78rem;
}

/* ---------- Material Scrollbar ---------- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--md-outline);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--md-on-surface-variant);
}

/* ---------- Material Page Background ---------- */
main.p-4 {
    background: var(--md-surface-dim);
}

/* ---------- Material Spinner ---------- */
.spinner-border {
    color: var(--md-primary) !important;
}

/* ---------- Collapsed sidebar tooltips — handled by JS in vendix.js ---------- */
/* CSS ::after approach removed — clipped by overflow-x:hidden on scroll container. */

/* ---------- Summary stat cards (Resource Usage, Dashboard) ---------- */
.card-body.text-center h4,
.card-body.text-center h3 {
    font-weight: 700;
    letter-spacing: -0.02em;
}

.card-body.text-center i {
    opacity: 0.85;
}

/* ---------- Material Colour Swatch ---------- */
.rounded-circle[style*="background:"] {
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.4), var(--md-elevation-1);
}

/* ---------- Smooth page transitions ---------- */
main.p-4 > * {
    animation: md-fade-in 0.25s ease-out;
}

@keyframes md-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Material Login Pages ---------- */
body.tenant-login,
body {
    /* Keep gradient backgrounds on login pages; Material surface for admin pages */
}

/* Login card styling */
.card[style*="max-width:420px"],
.card[style*="max-width:440px"],
.card[style*="max-width:600px"] {
    border-radius: var(--md-shape-lg) !important;
    box-shadow: var(--md-elevation-4) !important;
}

/* ---------- Admin Sidebar (Collapsible) ---------- */
.admin-sidebar {
    width: 250px;
    min-width: 250px;
    transition: width 0.25s ease, min-width 0.25s ease;
    overflow: hidden;
    flex-shrink: 0;
}
.admin-sidebar.collapsed {
    width: 64px !important;
    min-width: 64px !important;
}
.admin-sidebar.collapsed .sidebar-brand-text,
.admin-sidebar.collapsed .sidebar-brand-badge,
.admin-sidebar.collapsed .sidebar-link-text {
    display: none !important;
}
/* Collapsed — center hamburger with brand */
.admin-sidebar.collapsed .sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}
.admin-sidebar.collapsed .sidebar-brand-row {
    justify-content: center !important;
}
/* Collapsed — nav items become circular icon buttons */
.admin-sidebar.collapsed .admin-nav-item {
    justify-content: center !important;
    padding: 0 !important;
    margin: 4px auto !important;
    width: 40px;
    height: 40px;
    border-radius: 50% !important;
}

/* Admin sidebar toggle button — circular hover effect, centered */
.admin-sidebar-toggle {
    background: none !important;
    border: none !important;
    cursor: pointer;
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    outline: none;
}
.admin-sidebar-toggle:hover {
    background: rgba(255,255,255,0.15) !important;
}

/* Admin nav items — Material-style pill links.
   Font size and spacing match Tenant sidebar for consistency (Feedback 14, Note 3). */
.admin-nav-item {
    color: rgba(255,255,255,0.75);
    font-size: 0.85rem;
    margin-bottom: 2px;
    transition: background 0.15s ease;
}
.admin-nav-item:hover {
    background: rgba(255,255,255,0.1) !important;
    color: rgba(255,255,255,0.95);
}
.admin-nav-item.active {
    background: rgba(129,140,248,0.2) !important;
    color: #c7d2fe !important;
}

/* ---------- Unified Card Border Radius ---------- */
/* All cards use the same border radius for visual consistency */
.card,
.mdc-card,
.mat-card {
    border-radius: var(--md-shape-md) !important;
}

/* ---------- Page Title Icon Size ---------- */
/* Page title icons should be larger to match the heading prominence */
.page-title-icon,
h4 > .material-icons,
h4 > .mdc-icon {
    font-size: 1.6rem !important;
    vertical-align: middle;
}

/* ---------- Filter Row — Compact and Secondary Visual Weight ---------- */
/* Filter rows should not visually compete with primary content */
.filter-row,
.filter-card {
    background: var(--md-surface-dim) !important;
    border: 1px solid var(--md-outline-variant) !important;
    box-shadow: none !important;
}
.filter-row .form-label,
.filter-row .col-form-label {
    font-size: 0.8rem;
    color: var(--md-on-surface-variant);
}

/* ---------- Modal Button Hierarchy ---------- */
/* Primary action (Save/Create/Next) — uses brand color via inline style */
/* Secondary action (Back/Previous) — outlined with subtle background */
.modal-footer .mdc-button--outlined {
    border: 1px solid var(--md-outline) !important;
}
/* #15 (Feedback 18): Cancel buttons — outlined ghost style so they look interactive,
   not plain text. Uses subtle border + transparent background for secondary appearance. */
.modal-footer .btn-modal-cancel,
.modal-footer .mdc-button--outlined:first-child {
    background: transparent !important;
    border: 1px solid var(--md-outline) !important;
    color: var(--md-on-surface-variant) !important;
    font-weight: 500;
    border-radius: var(--md-shape-sm) !important;
}
.modal-footer .btn-modal-cancel:hover,
.modal-footer .mdc-button--outlined:first-child:hover {
    background: var(--md-surface-container) !important;
    color: var(--md-on-surface) !important;
    border-color: var(--md-on-surface-variant) !important;
}
/* Secondary action (Back) — subtle outlined appearance */
.modal-footer .btn-modal-secondary {
    background: var(--md-surface-container) !important;
    border: 1px solid var(--md-outline) !important;
    color: var(--md-on-surface) !important;
}

/* ---------- Modal Form Spacing & Clutter Reduction ---------- */
/* Section headers in modals — spacing between sections */
.modal-body h6 {
    margin-top: 1rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--md-outline-variant);
}
.modal-body h6:first-child {
    margin-top: 0;
}
/* Hide leading icons inside MatTextField in modals — reduces visual noise.
   Icons are still rendered but hidden via CSS for a cleaner form layout. */
.modal-body .mdc-text-field__icon--leading {
    display: none;
}
.modal-body .mdc-text-field--with-leading-icon .mdc-text-field__input {
    padding-left: 16px !important;
}
.modal-body .mdc-text-field--with-leading-icon .mdc-floating-label {
    left: 16px !important;
}

/* ---------- Modal Form Row Spacing ---------- */
/* Ensure consistent vertical spacing between form field rows in modals */
.modal-body .row.g-3 {
    margin-bottom: 0.75rem;
}
.modal-body .row.g-3:last-child {
    margin-bottom: 0;
}

/* ---------- Consistent Validation Error Messages ---------- */
/* Error messages below all input field types aligned consistently */
.text-danger.small,
div.text-danger.small {
    font-size: 0.75rem !important;
    margin-top: 0.25rem;
    padding-left: 0.125rem;
}

/* ---------- MatTextField Placeholder Visibility ---------- */
/* Show label/placeholder text above the field when unfocused and empty */
.mdc-text-field:not(.mdc-text-field--focused) .mdc-floating-label {
    color: var(--md-on-surface-variant) !important;
    opacity: 0.8;
}

/* ---------- Standardize Input Field Appearance ---------- */
/* Ensure HTML selects and date inputs look similar to MatTextField */
.form-select,
input[type="date"].form-control {
    height: auto;
    padding: 0.6rem 0.875rem;
    font-size: 0.9rem;
    border: 1px solid var(--md-outline) !important;
    border-radius: var(--md-shape-sm) !important;
    background-color: var(--md-surface);
    color: var(--md-on-surface);
}
/* Dropdown indicator — ensure form-select always shows the caret arrow.
   Uses Bootstrap's default SVG chevron so dropdowns are clearly distinguishable
   from regular text inputs. Padding-right reserves space for the indicator. */
.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='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.75rem center !important;
    background-size: 16px 12px !important;
    padding-right: 2.25rem !important;
    appearance: none !important;
    -webkit-appearance: none !important;
}
.form-label.form-label-sm {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--md-on-surface-variant);
    margin-bottom: 0.35rem;
}

/* ---------- Modal Header — icon and text vertically centered ---------- */
.modal-title {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.modal-title .material-icons,
.modal-title .mdc-icon,
.modal-title .mdc-icon-button__icon {
    vertical-align: middle;
}

/* ---------- Consistent Page Margins ---------- */
/* Equal left and right padding on main content area */
main.p-4 {
    padding: 1.5rem !important;
}

/* ---------- Toast Notifications — non-intrusive, bottom-right ---------- */
/* Alerts with .toast-alert class render as fixed-position toasts that
   don't push page content down. Auto-dismissed via JS after 4 seconds. */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
    pointer-events: none;
    max-width: 420px;
}
.toast-container > * {
    pointer-events: auto;
}
.toast-alert {
    animation: toast-slide-in 0.3s ease-out;
    box-shadow: var(--md-elevation-3) !important;
    border-radius: var(--md-shape-md) !important;
    margin: 0 !important;
}
.toast-alert.toast-hiding {
    animation: toast-slide-out 0.3s ease-in forwards;
}
@keyframes toast-slide-in {
    from { opacity: 0; transform: translateX(100%); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-slide-out {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(100%); }
}

/* ---------- Sales Return Add — Products tab editable columns ---------- */
/* SR-VDX-WEB-5215 (2026-07-26): the return-quantity inputs and the Return Reason
   dropdown live in a wide, horizontally-scrolling table. A <th style="width:…">
   is only a sizing HINT — with that many columns the browser compressed the
   editable cells well below it, clipping typed values and collapsing the reason
   select to roughly one character. A min-width on the CONTROL is not negotiable
   by the table layout algorithm, so the entered value stays fully readable.
   Scoped to these two classes so no other table is affected. */
.sra-qty-input {
    min-width: 90px;
    text-align: right;
}
.sra-reason-select {
    min-width: 180px;
}

/* ---------- Date Picker — full input field click area ---------- */
/* Make the entire date input field clickable to open the date picker,
   not just the calendar icon. Uses pointer cursor and transparent overlay. */
input[type="date"].form-control {
    cursor: pointer;
    position: relative;
}
input[type="date"].form-control::-webkit-calendar-picker-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* ---------- Alert Close Button Spacing ---------- */
/* Ensure close button does not overlap with alert text */
.alert-dismissible {
    padding-right: 3rem !important;
}
.alert-dismissible .btn-close {
    padding: 0.75rem 1rem !important;
    top: 50%;
    transform: translateY(-50%);
    right: 0.5rem;
}

/* ---------- Edit Icon — consistent colour app-wide ---------- */
/* All edit icons/buttons use the same info-blue colour regardless of screen */
.mdc-icon-button[title="Edit"],
.mdc-icon-button[title="Edit Comments"],
.action-icon-edit,
[title="Edit"] .material-icons {
    color: #0284c7 !important;
}

/* ============================================================================
   Feedback 12 Fixes — Forms, Popups, Inputs, Consistency
   ============================================================================ */

/* ---------- #12: Popup header vertical center alignment ---------- */
.modal-header {
    display: flex !important;
    align-items: center !important;
    min-height: 52px;
}
.modal-header .modal-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ---------- #13: Unify Edit User section highlight colors ---------- */
/* All wizard step sections use the same neutral card background */
.modal-body .card,
.modal-body .mat-card,
.modal-body MatCard {
    border-color: var(--md-outline-variant) !important;
}
.modal-body h6 {
    color: var(--md-on-surface) !important;
}

/* ---------- #14: MatTextField outlined style (replace underline-only) ---------- */
/* Override MatBlazor's default underline-style text field with outlined borders.
   #11 (Feedback 17): overflow:visible so the label can sit above the field border. */
.mdc-text-field {
    border: 1px solid var(--md-outline) !important;
    border-radius: var(--md-shape-sm) !important;
    background: var(--md-surface) !important;
    height: auto !important;
    padding: 0 !important;
    overflow: visible !important;
    position: relative !important;
}
/* Remove the default bottom-line (underline indicator) */
.mdc-text-field .mdc-line-ripple,
.mdc-text-field .mdc-line-ripple::before,
.mdc-text-field .mdc-line-ripple::after {
    display: none !important;
}
/* Focused outlined state */
.mdc-text-field--focused {
    border-color: var(--md-primary) !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12) !important;
}
/* Input padding inside MatTextField */
.mdc-text-field__input {
    padding: 0.6rem 0.875rem !important;
    font-size: 0.9rem !important;
    color: var(--md-on-surface) !important;
}
/* Disabled MatTextField */
.mdc-text-field--disabled {
    background: var(--md-surface-container) !important;
    opacity: 0.6;
    border-color: var(--md-outline-variant) !important;
}

/* ---------- #16: Card heading/description spacing (TenantProductParameters) ---------- */
/* More space between heading and description, tighter line spacing within description */
.mat-card h6 {
    margin-bottom: 0.5rem !important;
}
.mat-card p.text-muted.small {
    line-height: 1.4 !important;
    margin-bottom: 0.25rem !important;
}

/* ---------- #22: Section titles should use standard text color, not primary ---------- */
/* Override primary-colored section headings in modal forms */
.modal-body .section-title,
.modal-body h6 .material-icons {
    color: var(--md-on-surface-variant) !important;
}

/* ---------- Feedback 10: WCAG AA — brand color as text on white ---------- */
/* Section headings (h6) in modals use brand color as text on white background.
   Override to use --brand1-on-white (WCAG-safe darkened variant) if set. */
.modal-body h6[style*="color"] {
    color: var(--brand1-on-white, inherit) !important;
}

/* ---------- Feedback 13 #25: Spacing between toggle and description ---------- */
/* MatSlideToggle + form-text helper should have clear visual separation */
.mdc-switch + .form-text,
.mdc-form-field + .form-text {
    margin-top: 0.25rem;
}

/* ---------- Feedback 13 #31: Consistent mandatory field indicator color ---------- */
/* Ensure asterisks in labels are always red, not default text color */
.form-label .text-danger,
.mdc-floating-label .text-danger {
    color: var(--md-error) !important;
    font-weight: 600;
}

/* ---------- Feedback 16 #08: Primary button text/icons always white ---------- */
/* Primary (raised) buttons with brand background should always use white text/icons
   for maximum clarity. The WCAG dynamic contrast (ContrastHelper.GetTextColor) was
   over-adjusting on lighter brand colors, making buttons look muted. */
.mdc-button--raised,
.mdc-button--raised .mdc-button__icon,
.mdc-button--raised .material-icons,
.mdc-button--raised .mdc-icon {
    color: #ffffff !important;
}

/* ---------- Sidebar text color ---------- */
/* #03 (Feedback 15): Reverted to white text/icons — WCAG dynamic contrast
   was over-adjusting and reducing visual clarity on the always-dark sidebar. */
.tenant-sidebar .menu-item-link {
    color: rgba(255,255,255,0.85);
}

/* #11 (Feedback 17): MatBlazor field wrappers need top margin so the above-field
   label (which extends above the container via translateY(-50%)) isn't clipped
   by the element above. The MatBlazor wrapper is the parent div around mdc-text-field. */
.matblazor-component,
.mdc-text-field-wrapper {
    margin-top: 10px !important;
}
/* First field in a form group doesn't need extra top margin */
.modal-body .row:first-child .matblazor-component:first-child,
.modal-body > .matblazor-component:first-child {
    margin-top: 4px !important;
}

/* ============================================================================
   Feedback 17 Fixes — Popups, Labels, Loaders
   ============================================================================ */

/* ---------- #09: Smooth popup open transition (fade + scale) ---------- */
/* All modals get a polished entrance animation instead of abrupt appearance. */
.modal.show .modal-dialog {
    animation: modal-entrance 0.25s ease-out;
}
@keyframes modal-entrance {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}
/* Backdrop fade-in synchronized with popup */
.modal-backdrop.show {
    animation: backdrop-fade 0.2s ease-out;
}
@keyframes backdrop-fade {
    from { opacity: 0; }
    to   { opacity: 0.5; }
}

/* ---------- #10: Popup header vertical center (reinforced) ---------- */
/* Already handled by Feedback 12 #12 (.modal-header display:flex + align-items:center).
   Reinforcing with explicit gap and icon alignment for all header patterns. */
.modal-header .btn-close {
    margin: 0 !important;
    padding: 0.5rem !important;
}
.modal-header .modal-title .material-icons,
.modal-header .modal-title .mdc-icon {
    vertical-align: middle;
    line-height: 1;
}

/* ---------- #11 (Feedback 17): Labels ALWAYS above input field ---------- */
/* Force the floating label to always sit ABOVE the input border, never inside.
   Uses position:absolute to place the label on top of the border line with a
   white background "cutout" so the border appears to break around the label text.
   This ensures labels are visible at all times for scan efficiency. */
.mdc-text-field .mdc-floating-label {
    position: absolute !important;
    top: 0 !important;
    transform: translateY(-50%) !important;
    transform-origin: left top !important;
    font-size: 0.8rem !important;
    color: var(--md-on-surface-variant) !important;
    background: var(--md-surface, #fff) !important;
    padding: 0 6px !important;
    left: 10px !important;
    z-index: 1 !important;
    pointer-events: none !important;
    line-height: 1.2 !important;
    transition: color 0.15s ease !important;
    max-width: calc(100% - 24px) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}
/* Focused state — label uses primary color */
.mdc-text-field--focused .mdc-floating-label,
.mdc-text-field .mdc-floating-label--float-above {
    top: 0 !important;
    transform: translateY(-50%) !important;
    font-size: 0.8rem !important;
    color: var(--md-primary) !important;
}
/* Disabled field label — muted on grey background */
.mdc-text-field--disabled .mdc-floating-label {
    background: var(--md-surface-container, #f1f5f9) !important;
}
/* Textarea label — same treatment */
.mdc-text-field--textarea .mdc-floating-label {
    top: 0 !important;
    transform: translateY(-50%) !important;
}
/* Add top padding to inputs so text doesn't crowd the label area */
.mdc-text-field__input {
    margin-top: 2px !important;
}

/* ---------- #12: Ensure circular loader styling ---------- */
/* MatProgressCircle should be perfectly circular and smooth. */
.mdc-circular-progress,
.mdc-circular-progress__indeterminate-container {
    border-radius: 50% !important;
}
/* Spinner-border (Bootstrap) — ensure perfectly round */
.spinner-border {
    border-radius: 50% !important;
    border-width: 0.2em !important;
}
/* Small spinner in buttons — consistent sizing */
.mdc-button .mdc-circular-progress {
    width: 20px !important;
    height: 20px !important;
}

/* ============================================================================
   Feedback 18 Fixes — Primary text, icon hover, cancel buttons, action wrapping
   ============================================================================ */

/* #13: All text/icons on primary backgrounds must be white.
   Covers btn-primary, badge-primary, active states, headers with primary bg. */
.btn-primary,
.btn-primary .material-icons,
.btn-primary .mdc-button__icon,
.badge-primary,
[style*="background"][style*="var(--md-primary)"],
.bg-primary,
.bg-primary * {
    color: #ffffff !important;
}
/* Active nav items with brand background — white text */
.active-brand,
.active-brand .material-icons {
    color: #ffffff !important;
}

/* #14: Table action icon hover — centered on the icon using fixed-size container.
   Wrap icon buttons in a square flexbox for perfectly centered hover effects. */
.table .mdc-icon-button,
.table td .mdc-icon-button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    transition: background 0.15s ease !important;
    vertical-align: middle !important;
}
.table .mdc-icon-button:hover,
.table td .mdc-icon-button:hover {
    background: rgba(0, 0, 0, 0.08) !important;
}
.table .mdc-icon-button .material-icons,
.table td .mdc-icon-button .material-icons {
    font-size: 1.1rem !important;
}

/* #16: Prevent table action icons from wrapping into two rows.
   Action cells use nowrap flexbox with consistent gap. */
.table td:last-child {
    white-space: nowrap !important;
}
.table .actions-cell,
.table td .d-flex {
    flex-wrap: nowrap !important;
    gap: 2px;
}
/* Ensure action column has minimum width to fit icons in one row */
.table th:last-child,
.table td:last-child {
    min-width: 100px;
}

/* ---------- Floating AI Chat FAB ---------- */
.vendix-chat-fab {
    position: fixed;
    bottom: 56px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25), 0 2px 4px rgba(0,0,0,0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
    touch-action: none;
    background: transparent;
    padding: 0;
    overflow: hidden;
    text-decoration: none;
}
.vendix-chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3), 0 3px 8px rgba(0,0,0,0.2);
}
.vendix-chat-fab:active {
    transform: scale(0.95);
}
/* Gentle pulse animation on the FAB to draw attention */
.vendix-chat-fab .vendix-fab-icon {
    animation: vendixFabPulse 3s ease-in-out infinite;
}
@keyframes vendixFabPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ---------- Responsive adjustments ---------- */
@media (max-width: 768px) {
    .btn {
        border-radius: var(--md-shape-sm) !important;
    }

    .card {
        border-radius: var(--md-shape-sm) !important;
    }

    main.p-4 {
        padding: 1rem !important;
    }

    /* Smaller FAB on mobile */
    .vendix-chat-fab {
        bottom: 48px;
        right: 16px;
        width: 48px;
        height: 48px;
    }
    .vendix-chat-fab .vendix-fab-icon {
        width: 48px !important;
        height: 48px !important;
    }
}
