/**
 * AVMS Application CSS Framework
 * Consistent styles for Portal and Admin interfaces
 * Built on top of Bootstrap 5.3
 */

/* ============================
   CSS Custom Properties
   ============================ */
:root {
    /* Brand Colors */
    --avms-primary: #0ea5e9;
    --avms-primary-dark: #0284c7;
    --avms-primary-light: #38bdf8;
    --avms-secondary: #8b5cf6;
    --avms-secondary-dark: #7c3aed;
    --avms-accent: #06b6d4;

    /* Status Colors */
    --avms-success: #22c55e;
    --avms-warning: #f59e0b;
    --avms-danger: #ef4444;
    --avms-info: #3b82f6;

    /* Ticket Status Colors */
    --status-new: #6b7280;
    --status-open: #3b82f6;
    --status-assigned: #06b6d4;
    --status-in-progress: #f59e0b;
    --status-pending: #f97316;
    --status-escalated: #ef4444;
    --status-resolved: #22c55e;
    --status-closed: #9ca3af;
    --status-reopened: #ec4899;

    /* Priority Colors */
    --priority-low: #22c55e;
    --priority-normal: #3b82f6;
    --priority-medium: #f59e0b;
    --priority-high: #f97316;
    --priority-urgent: #ef4444;
    --priority-critical: #dc2626;

    /* Dark Theme (default) */
    --bg-body: #0f172a;
    --bg-surface: #1e293b;
    --bg-surface-hover: #273548;
    --bg-card: #1e293b;
    --bg-card-hover: #263347;
    --bg-input: #0f172a;
    --bg-sidebar: #0b1120;
    --border-color: rgba(148, 163, 184, 0.15);
    --border-color-strong: rgba(148, 163, 184, 0.3);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-link: var(--avms-primary-light);

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 60px;
    --border-radius-sm: 6px;
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --border-radius-xl: 16px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 8px 32px rgba(0, 0, 0, 0.35);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 350ms ease;
}

/* Light Theme Override */
[data-theme="light"] {
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-input: #ffffff;
    --bg-sidebar: #f1f5f9;
    --border-color: rgba(15, 23, 42, 0.1);
    --border-color-strong: rgba(15, 23, 42, 0.2);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-link: var(--avms-primary-dark);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 8px 32px rgba(0, 0, 0, 0.12);
}

/* ============================
   Base Styles
   ============================ */
body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--text-link);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--avms-primary);
}

/* ============================
   Bootstrap Dark-Mode Overrides
   Ensures Bootstrap components respect the dark theme
   ============================ */
.dropdown-menu {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
}

.dropdown-item {
    color: var(--text-primary);
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

.dropdown-item.active,
.dropdown-item:active {
    background-color: var(--avms-primary);
    color: #fff;
}

.dropdown-divider {
    border-color: var(--border-color);
}

.modal-content {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.modal-header {
    border-bottom-color: var(--border-color);
}

.modal-footer {
    border-top-color: var(--border-color);
}

.text-muted {
    color: var(--text-muted) !important;
}

.text-body-secondary {
    color: var(--text-secondary) !important;
}

.card {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.card-header {
    background-color: var(--bg-surface);
    border-bottom-color: var(--border-color);
    color: var(--text-primary);
}

.card-footer {
    background-color: var(--bg-surface);
    border-top-color: var(--border-color);
}

.list-group-item {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.list-group-item:hover {
    background-color: var(--bg-surface-hover);
}

.table {
    color: var(--text-primary);
    border-color: var(--border-color);
}

.table > thead {
    color: var(--text-secondary);
}

.table > :not(caption) > * > * {
    background-color: transparent;
    border-bottom-color: var(--border-color);
    color: var(--text-primary);
}

.table-hover > tbody > tr:hover > * {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

.nav-tabs .nav-link {
    color: var(--text-secondary);
}

.nav-tabs .nav-link:hover {
    border-color: var(--border-color) var(--border-color) transparent;
    color: var(--text-primary);
}

.nav-tabs .nav-link.active {
    background-color: var(--bg-card);
    border-color: var(--border-color) var(--border-color) var(--bg-card);
    color: var(--text-primary);
}

.alert {
    color: var(--text-primary);
}

.breadcrumb-item + .breadcrumb-item::before {
    color: var(--text-muted);
}

.breadcrumb-item.active {
    color: var(--text-muted);
}

/* Light theme: restore Bootstrap defaults */
[data-theme="light"] .dropdown-menu {
    background-color: #fff;
    border-color: rgba(0,0,0,0.15);
    color: #212529;
}

[data-theme="light"] .dropdown-item {
    color: #212529;
}

[data-theme="light"] .dropdown-item:hover,
[data-theme="light"] .dropdown-item:focus {
    background-color: #f8f9fa;
    color: #1e2125;
}

[data-theme="light"] .modal-content {
    background-color: #fff;
    color: #212529;
}

[data-theme="light"] .text-muted {
    color: #6c757d !important;
}

[data-theme="light"] .card {
    background-color: #fff;
    color: #212529;
}

[data-theme="light"] .table {
    color: #212529;
}

[data-theme="light"] .table > :not(caption) > * > * {
    color: #212529;
}

/* ============================
   Navbar Styles
   ============================ */
.avms-navbar {
    background: rgba(15, 23, 42, 0.97) !important;
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    height: var(--header-height);
    z-index: 1030;
}

[data-theme="light"] .avms-navbar {
    background: rgba(255, 255, 255, 0.97) !important;
}

.avms-navbar .navbar-brand {
    font-weight: 700;
    letter-spacing: 0.3px;
    font-size: 1.1rem;
}

.avms-navbar .nav-link {
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 0.85rem !important;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
    color: var(--text-secondary) !important;
}

.avms-navbar .nav-link:hover,
.avms-navbar .nav-link.active {
    color: var(--avms-primary-light) !important;
    background: rgba(14, 165, 233, 0.1);
}

.avms-navbar .nav-link.active {
    font-weight: 600;
}

.avms-navbar .nav-link i {
    font-size: 0.8rem;
    opacity: 0.85;
}

/* ============================
   Role & Status Badges
   ============================ */
.avms-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1.4;
}

.role-badge {
    background: rgba(139, 92, 246, 0.15);
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.25);
}

[data-theme="light"] .role-badge {
    background: rgba(139, 92, 246, 0.1);
    color: #7c3aed;
    border-color: rgba(139, 92, 246, 0.2);
}

.status-badge-new        { background: rgba(107,114,128,0.15); color: var(--status-new); }
.status-badge-open       { background: rgba(59,130,246,0.15);  color: var(--status-open); }
.status-badge-assigned   { background: rgba(6,182,212,0.15);   color: var(--status-assigned); }
.status-badge-in_progress,
.status-badge-in-progress{ background: rgba(245,158,11,0.15);  color: var(--status-in-progress); }
.status-badge-pending_client,
.status-badge-pending    { background: rgba(249,115,22,0.15);  color: var(--status-pending); }
.status-badge-escalated  { background: rgba(239,68,68,0.15);   color: var(--status-escalated); }
.status-badge-resolved   { background: rgba(34,197,94,0.15);   color: var(--status-resolved); }
.status-badge-closed     { background: rgba(156,163,175,0.15); color: var(--status-closed); }
.status-badge-reopened   { background: rgba(236,72,153,0.15);  color: var(--status-reopened); }

.priority-badge-low      { background: rgba(34,197,94,0.15);   color: var(--priority-low); }
.priority-badge-normal   { background: rgba(59,130,246,0.15);  color: var(--priority-normal); }
.priority-badge-medium   { background: rgba(245,158,11,0.15);  color: var(--priority-medium); }
.priority-badge-high     { background: rgba(249,115,22,0.15);  color: var(--priority-high); }
.priority-badge-urgent   { background: rgba(239,68,68,0.15);   color: var(--priority-urgent); }
.priority-badge-critical { background: rgba(220,38,38,0.2);    color: var(--priority-critical); font-weight: 700; }

/* ============================
   Cards & Surfaces
   ============================ */
.avms-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    overflow: hidden;
}

.avms-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--border-color-strong);
}

.avms-card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.avms-card .card-body {
    padding: 1.25rem;
}

.avms-card .card-footer {
    background: transparent;
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1.25rem;
}

/* ============================
   Stat Cards (Dashboard)
   ============================ */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1.25rem;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--avms-primary), var(--avms-secondary));
    opacity: 0;
    transition: opacity var(--transition-base);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

.stat-card .stat-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .stat-change {
    font-size: 0.75rem;
    font-weight: 600;
}

.stat-change.positive { color: var(--avms-success); }
.stat-change.negative { color: var(--avms-danger); }

/* Stat icon color variants */
.stat-icon.primary   { background: rgba(14,165,233,0.12); color: var(--avms-primary); }
.stat-icon.success   { background: rgba(34,197,94,0.12);  color: var(--avms-success); }
.stat-icon.warning   { background: rgba(245,158,11,0.12); color: var(--avms-warning); }
.stat-icon.danger    { background: rgba(239,68,68,0.12);  color: var(--avms-danger); }
.stat-icon.info      { background: rgba(59,130,246,0.12); color: var(--avms-info); }
.stat-icon.secondary { background: rgba(139,92,246,0.12); color: var(--avms-secondary); }

/* ============================
   Tables
   ============================ */
.avms-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.avms-table thead th {
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color-strong);
    white-space: nowrap;
}

.avms-table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
    vertical-align: middle;
    color: var(--text-primary);
}

.avms-table tbody tr {
    transition: background var(--transition-fast);
}

.avms-table tbody tr:hover {
    background: var(--bg-surface-hover);
}

.avms-table tbody tr:last-child td {
    border-bottom: none;
}

/* Sortable columns */
.avms-table th[data-sort] {
    cursor: pointer;
    user-select: none;
}

.avms-table th[data-sort]:hover {
    color: var(--avms-primary-light);
}

/* ============================
   Forms & Inputs
   ============================ */
.avms-input {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    padding: 0.5rem 0.85rem;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

.avms-input:focus {
    background: var(--bg-input);
    border-color: var(--avms-primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
    color: var(--text-primary);
    outline: none;
}

.avms-input::placeholder {
    color: var(--text-muted);
}

.form-control,
.form-select {
    background-color: var(--bg-input);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--bg-input);
    border-color: var(--avms-primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
    color: var(--text-primary);
}

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.form-text {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ============================
   Buttons
   ============================ */
.btn-avms-primary {
    background: linear-gradient(135deg, var(--avms-primary), var(--avms-primary-dark));
    border: none;
    color: #fff;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.5rem 1.25rem;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
    box-shadow: 0 2px 4px rgba(14, 165, 233, 0.25);
}

.btn-avms-primary:hover {
    background: linear-gradient(135deg, var(--avms-primary-light), var(--avms-primary));
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(14, 165, 233, 0.35);
}

.btn-avms-secondary {
    background: transparent;
    border: 1px solid var(--border-color-strong);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.5rem 1.25rem;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
}

.btn-avms-secondary:hover {
    background: var(--bg-surface-hover);
    border-color: var(--avms-primary);
    color: var(--avms-primary-light);
}

.btn-avms-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--avms-danger);
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.5rem 1.25rem;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
}

.btn-avms-danger:hover {
    background: var(--avms-danger);
    color: #fff;
}

/* ============================
   Alerts & Notifications
   ============================ */
.avms-alert {
    padding: 0.85rem 1.15rem;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    border: 1px solid;
}

.avms-alert-success {
    background: rgba(34, 197, 94, 0.08);
    border-color: rgba(34, 197, 94, 0.2);
    color: var(--avms-success);
}

.avms-alert-warning {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.2);
    color: var(--avms-warning);
}

.avms-alert-danger {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.2);
    color: var(--avms-danger);
}

.avms-alert-info {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.2);
    color: var(--avms-info);
}

/* ============================
   Ticket List Items
   ============================ */
.ticket-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem 1.25rem;
    transition: all var(--transition-fast);
    cursor: pointer;
    display: block;
    color: var(--text-primary);
    text-decoration: none;
}

.ticket-item:hover {
    border-color: var(--avms-primary);
    box-shadow: var(--shadow);
    transform: translateX(4px);
    color: var(--text-primary);
}

.ticket-item .ticket-number {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.ticket-item .ticket-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin: 0.25rem 0;
}

.ticket-item .ticket-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.ticket-item .ticket-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ============================
   Pagination
   ============================ */
.avms-pagination .page-link {
    background: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--border-radius-sm) !important;
    margin: 0 2px;
    transition: all var(--transition-fast);
}

.avms-pagination .page-link:hover {
    background: var(--bg-surface-hover);
    border-color: var(--avms-primary);
    color: var(--avms-primary-light);
}

.avms-pagination .page-item.active .page-link {
    background: var(--avms-primary);
    border-color: var(--avms-primary);
    color: #fff;
}

.avms-pagination .page-item.disabled .page-link {
    background: var(--bg-surface);
    color: var(--text-muted);
    opacity: 0.5;
}

/* ============================
   Empty States
   ============================ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state .empty-icon {
    font-size: 3rem;
    color: var(--text-muted);
    opacity: 0.5;
    margin-bottom: 1rem;
}

.empty-state .empty-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.empty-state .empty-text {
    font-size: 0.875rem;
    color: var(--text-muted);
    max-width: 400px;
    margin: 0 auto 1.25rem;
}

/* ============================
   Activity / Timeline
   ============================ */
.activity-timeline {
    position: relative;
    padding-left: 1.5rem;
}

.activity-timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.activity-item {
    position: relative;
    padding: 0.75rem 0;
}

.activity-item::before {
    content: '';
    position: absolute;
    left: -1.15rem;
    top: 1.15rem;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--avms-primary);
    border: 2px solid var(--bg-body);
}

.activity-item .activity-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.activity-item .activity-content {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ============================
   Loading Spinner
   ============================ */
.avms-spinner {
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid var(--border-color);
    border-top-color: var(--avms-primary);
    border-radius: 50%;
    animation: avms-spin 0.6s linear infinite;
}

@keyframes avms-spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
}

/* ============================
   SLA Timer
   ============================ */
.sla-timer {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.2rem 0.65rem;
    border-radius: var(--border-radius-sm);
}

.sla-timer.on-track {
    background: rgba(34, 197, 94, 0.1);
    color: var(--avms-success);
}

.sla-timer.at-risk {
    background: rgba(245, 158, 11, 0.1);
    color: var(--avms-warning);
}

.sla-timer.breached {
    background: rgba(239, 68, 68, 0.15);
    color: var(--avms-danger);
    animation: pulse-danger 2s ease-in-out infinite;
}

@keyframes pulse-danger {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ============================
   Search Bar
   ============================ */
.avms-search {
    position: relative;
}

.avms-search .search-input {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.55rem 0.85rem 0.55rem 2.5rem;
    color: var(--text-primary);
    width: 100%;
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

.avms-search .search-input:focus {
    border-color: var(--avms-primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
    outline: none;
}

.avms-search .search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
}

/* ============================
   Filters Toolbar
   ============================ */
.filters-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    padding: 0.75rem 0;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 500;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-chip:hover,
.filter-chip.active {
    background: rgba(14, 165, 233, 0.1);
    border-color: var(--avms-primary);
    color: var(--avms-primary-light);
}

.filter-chip .filter-remove {
    font-size: 0.7rem;
    opacity: 0.5;
    cursor: pointer;
}

.filter-chip .filter-remove:hover {
    opacity: 1;
}

/* ============================
   Toast Notifications
   ============================ */
.avms-toast-container {
    position: fixed;
    top: calc(var(--header-height) + 1rem);
    right: 1rem;
    z-index: 1080;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 380px;
}

.avms-toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 0.85rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    animation: toast-in 0.3s ease;
    font-size: 0.875rem;
}

.avms-toast.toast-success { border-left: 3px solid var(--avms-success); }
.avms-toast.toast-error   { border-left: 3px solid var(--avms-danger); }
.avms-toast.toast-warning { border-left: 3px solid var(--avms-warning); }
.avms-toast.toast-info    { border-left: 3px solid var(--avms-info); }

@keyframes toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ============================
   Footer
   ============================ */
.avms-footer {
    background: transparent;
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ============================
   Responsive Utilities
   ============================ */
@media (max-width: 991.98px) {
    .avms-navbar .nav-link {
        padding: 0.5rem 0.5rem !important;
        font-size: 0.8rem;
    }

    .stat-card .stat-value {
        font-size: 1.35rem;
    }

    .filters-toolbar {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 767.98px) {
    .stat-card {
        padding: 1rem;
    }

    .avms-card .card-body {
        padding: 1rem;
    }

    .ticket-item {
        padding: 0.85rem;
    }

    .ticket-item .ticket-meta {
        gap: 0.5rem;
    }

    .avms-table {
        font-size: 0.8rem;
    }

    .avms-table thead th,
    .avms-table tbody td {
        padding: 0.5rem 0.65rem;
    }

    /* Stack table on mobile */
    .table-responsive-stack thead {
        display: none;
    }

    .table-responsive-stack tbody tr {
        display: block;
        margin-bottom: 0.75rem;
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius);
        padding: 0.5rem;
    }

    .table-responsive-stack tbody td {
        display: flex;
        justify-content: space-between;
        padding: 0.35rem 0.5rem;
        border-bottom: 1px solid var(--border-color);
    }

    .table-responsive-stack tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.75rem;
        text-transform: uppercase;
        color: var(--text-muted);
    }

    .table-responsive-stack tbody td:last-child {
        border-bottom: none;
    }
}

/* ============================
   Utility Classes
   ============================ */
.text-avms-primary { color: var(--avms-primary) !important; }
.text-avms-secondary { color: var(--avms-secondary) !important; }
.text-avms-success { color: var(--avms-success) !important; }
.text-avms-warning { color: var(--avms-warning) !important; }
.text-avms-danger { color: var(--avms-danger) !important; }
.text-avms-info { color: var(--avms-info) !important; }
.text-avms-muted { color: var(--text-muted) !important; }

.bg-avms-surface { background: var(--bg-surface) !important; }
.bg-avms-card { background: var(--bg-card) !important; }

.border-avms { border-color: var(--border-color) !important; }

.rounded-avms { border-radius: var(--border-radius) !important; }
.rounded-avms-lg { border-radius: var(--border-radius-lg) !important; }

.shadow-avms { box-shadow: var(--shadow) !important; }
.shadow-avms-lg { box-shadow: var(--shadow-lg) !important; }

.font-mono {
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* Truncate text */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.25);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.4);
}

/* ====================================================================
   MOBILE RESPONSIVENESS
   ==================================================================== */

/* Touch-friendly targets */
@media (max-width: 767.98px) {
    .btn { min-height: 44px; min-width: 44px; }
    .form-control, .form-select { min-height: 44px; font-size: 16px; }
    .form-check-input { width: 1.25em; height: 1.25em; }
    .dropdown-item { padding: 0.625rem 1rem; }
}

/* Container & layout adjustments */
@media (max-width: 991.98px) {
    .container-fluid { padding-left: 1rem !important; padding-right: 1rem !important; }
    .avms-card { border-radius: var(--avms-radius-sm, 0.5rem); }
    .avms-card-header { padding: 0.75rem 1rem; }
    .avms-card-body { padding: 0.75rem 1rem; }
}

@media (max-width: 767.98px) {
    .container-fluid { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
    .avms-card { border-radius: 0.375rem; }
    .avms-card-header { padding: 0.625rem 0.75rem; }
    .avms-card-body { padding: 0.625rem 0.75rem; }
}

/* Stat cards: single column on mobile */
@media (max-width: 575.98px) {
    .avms-stat-card-body { padding: 0.875rem; }
    .avms-stat-card-body h3 { font-size: 1.5rem; }
}

/* Sidebar collapse for admin */
@media (max-width: 991.98px) {
    .avms-sidebar {
        position: fixed;
        top: 0; left: -280px;
        width: 280px; height: 100vh;
        z-index: 1050;
        transition: left 0.3s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,0.25);
    }
    .avms-sidebar.open { left: 0; }
    .avms-sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 1040;
    }
    .avms-sidebar-overlay.show { display: block; }
    .avms-main-content { margin-left: 0 !important; width: 100% !important; }
}

/* Table responsiveness */
@media (max-width: 767.98px) {
    .avms-table { font-size: 0.8125rem; }
    .avms-table th, .avms-table td { padding: 0.5rem 0.375rem; }
    /* Hide lower-priority columns on small screens */
    .avms-table .d-mobile-none { display: none !important; }
}

@media (max-width: 575.98px) {
    .avms-table { font-size: 0.75rem; }
    .avms-table th, .avms-table td { padding: 0.375rem 0.25rem; white-space: nowrap; }
}

/* Header / Navbar tweaks */
@media (max-width: 767.98px) {
    .avms-topbar { padding: 0.5rem 0.75rem; }
    .avms-topbar .navbar-brand { font-size: 1rem; }
    .avms-topbar .btn-sm { font-size: 0.75rem; padding: 0.25rem 0.5rem; }
}

/* Page titles */
@media (max-width: 767.98px) {
    h2, .h2 { font-size: 1.25rem; }
    h3, .h3 { font-size: 1.1rem; }
    h4, .h4 { font-size: 1rem; }
}

/* Dashboard flex layouts */
@media (max-width: 767.98px) {
    .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
    }
    .btn-group { flex-wrap: wrap; }
}

/* Charts: ensure they don't overflow */
@media (max-width: 575.98px) {
    canvas { max-height: 250px !important; }
}

/* Badge sizing on mobile */
@media (max-width: 767.98px) {
    .badge { font-size: 0.65rem; padding: 0.25em 0.5em; }
}

/* Modal fullscreen on small screens */
@media (max-width: 575.98px) {
    .modal-dialog { margin: 0; max-width: 100%; min-height: 100vh; }
    .modal-content { border-radius: 0; min-height: 100vh; }
}

/* Form layouts */
@media (max-width: 767.98px) {
    .row.g-3 > [class*="col-md-"], .row.g-3 > [class*="col-lg-"] { flex: 0 0 100%; max-width: 100%; }
}

/* Tab navigation: scrollable */
@media (max-width: 767.98px) {
    .nav-tabs, .nav-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .nav-tabs::-webkit-scrollbar, .nav-pills::-webkit-scrollbar { display: none; }
    .nav-tabs .nav-link, .nav-pills .nav-link { white-space: nowrap; font-size: 0.8125rem; }
}

/* Utility: mobile hamburger toggle */
.avms-sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--avms-text-primary);
    font-size: 1.5rem;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
}
@media (max-width: 991.98px) {
    .avms-sidebar-toggle { display: inline-flex; }
}

/* Print optimization */
@media print {
    .avms-sidebar, .avms-topbar, .btn, form, .modal { display: none !important; }
    .avms-main-content { margin: 0 !important; width: 100% !important; }
    .avms-card { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
    body { background: #fff !important; color: #000 !important; }
}
