/* ═══════════════════════════════════════════════════════════════════════════
   IMS — Inventory Management System
   Bootstrap 5 Custom Theme with calm, professional aesthetic
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    --ims-primary: #2563eb;
    --ims-secondary: #64748b;
    --ims-success: #10b981;
    --ims-danger: #ef4444;
    --ims-warning: #f59e0b;
    --ims-info: #3b82f6;
    --ims-dark: #1e293b;
    --ims-light: #f8fafc;
    --ims-sidebar-width: 260px;
    --ims-navbar-height: 56px;
}

/* ── Reset & Base ──────────────────────────────────────────────────────────── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--ims-dark);
    background-color: #f1f5f9;
    overflow-x: hidden;
}

/* ── Top Navbar ─────────────────────────────────────────────────────────────── */
.ims-navbar {
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
    height: var(--ims-navbar-height);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1030;
}

/* ── Sidebar Navigation ────────────────────────────────────────────────────── */
.ims-sidebar {
    position: fixed;
    top: var(--ims-navbar-height);
    left: 0;
    width: var(--ims-sidebar-width);
    height: calc(100vh - var(--ims-navbar-height));
    background: white;
    border-right: 1px solid #e2e8f0;
    overflow-y: auto;
    transition: transform 0.3s ease-in-out;
    z-index: 1020;
}

@media (max-width: 991.98px) {
    .ims-sidebar {
        transform: translateX(-100%);
    }
    .ims-sidebar.show {
        transform: translateX(0);
    }
}

.ims-sidebar-overlay {
    position: fixed;
    top: var(--ims-navbar-height);
    left: 0;
    width: 100vw;
    height: calc(100vh - var(--ims-navbar-height));
    background: rgba(0, 0, 0, 0.5);
    z-index: 1015;
}

.ims-nav-inner {
    padding: 0;
}

.ims-nav-section-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    padding: 1rem 1.25rem 0.5rem;
    margin-top: 0.5rem;
}

.ims-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #475569;
    text-decoration: none;
    transition: all 0.15s ease-in-out;
    border-left: 3px solid transparent;
}

.ims-nav-link i {
    font-size: 1.125rem;
    width: 20px;
    text-align: center;
}

.ims-nav-link:hover {
    background-color: #f1f5f9;
    color: var(--ims-primary);
}

.ims-nav-link.active {
    background-color: #eff6ff;
    color: var(--ims-primary);
    border-left-color: var(--ims-primary);
    font-weight: 600;
}

/* ── Main Content Area ─────────────────────────────────────────────────────── */
.ims-main-content {
    margin-left: var(--ims-sidebar-width);
    min-height: calc(100vh - var(--ims-navbar-height));
    background-color: #f8fafc;
    padding: 1.75rem 2rem;
}

@media (max-width: 991.98px) {
    .ims-main-content {
        margin-left: 0;
    }
}

/* ── Single-Row KPI Container ────────────────────────────────────────────── */
.ims-kpi-container {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.75rem;
    width: 100%;
    margin-bottom: 1.5rem;
}

.ims-kpi-col {
    flex: 1 1 0px;
    min-width: 0;
}

/* ── KPI Dashboard Cards ───────────────────────────────────────────────────── */
.ims-kpi-card {
    background: white;
    border-radius: 12px;
    padding: 1rem 1.15rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.ims-kpi-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.ims-kpi-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.ims-kpi-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.ims-kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
}

.ims-kpi-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

/* Responsive Card & Font Scaling for laptops & smaller screens */
@media (max-width: 1400px) {
    .ims-kpi-container {
        gap: 0.5rem;
    }
    .ims-kpi-card {
        padding: 0.75rem 0.85rem;
        border-radius: 10px;
    }
    .ims-kpi-value {
        font-size: 1.3rem;
    }
    .ims-kpi-icon {
        width: 30px;
        height: 30px;
        font-size: 0.95rem;
    }
    .ims-kpi-label {
        font-size: 0.65rem;
    }
    .ims-kpi-badge {
        font-size: 0.65rem;
        padding: 0.15rem 0.4rem;
    }
}

@media (max-width: 1100px) {
    .ims-kpi-card {
        padding: 0.625rem 0.65rem;
    }
    .ims-kpi-value {
        font-size: 1.15rem;
    }
    .ims-kpi-icon {
        width: 26px;
        height: 26px;
        font-size: 0.85rem;
    }
    .ims-kpi-label {
        font-size: 0.6rem;
    }
    .ims-kpi-badge {
        font-size: 0.6rem;
        padding: 0.1rem 0.35rem;
    }
}

@media (max-width: 768px) {
    .ims-kpi-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.5rem;
    }
    .ims-kpi-col {
        flex: 0 0 150px;
        min-width: 150px;
    }
}

/* ── Table Cards ───────────────────────────────────────────────────────────── */
.ims-table-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

/* Compact density for operational tables. Keeps column-heavy records readable. */
.ims-compact-table {
    font-size: 0.78rem;
}

.ims-compact-table > :not(caption) > * > * {
    padding: 0.62rem 0.55rem;
    vertical-align: middle;
}

.ims-compact-table thead th {
    color: #475569;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.045em;
    text-transform: uppercase;
    white-space: nowrap;
}

.ims-compact-table .badge {
    font-size: 0.68rem;
    font-weight: 700;
}

.btn-review-edit {
    align-items: center;
    background: #fffaf0;
    border: 1px solid #f3b73f;
    color: #9a6500;
    display: inline-flex;
    gap: 0.35rem;
    white-space: nowrap;
}

.btn-review-edit:hover,
.btn-review-edit:focus {
    background: #fff3d2;
    border-color: #d99a16;
    color: #704800;
}

.receipt-modal-header {
    align-items: center;
    background: linear-gradient(135deg, #f8fafc, #eef4ff);
    border-bottom: 1px solid #dbe5f1;
    padding: 1.1rem 1.35rem;
}

.receipt-modal-eyebrow {
    color: #64748b;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.receipt-modal-number {
    color: #2563eb;
    font-size: 0.8em;
    font-weight: 700;
    margin-left: 0.35rem;
}

.review-banner {
    align-items: flex-start;
    background: #fff8e6;
    border: 1px solid #f4d58b;
    border-left: 4px solid #e5a91a;
    border-radius: 0.65rem;
    color: #77520b;
    display: flex;
    font-size: 0.82rem;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
}

.review-banner i {
    color: #d69200;
    font-size: 1.1rem;
    margin-top: 0.08rem;
}

.review-banner strong,
.review-banner span {
    display: block;
}

.review-banner strong {
    color: #674500;
    margin-bottom: 0.15rem;
}

.review-panel {
    border-radius: 0.75rem;
    overflow: hidden;
}

.review-panel .card-header {
    align-items: center;
    display: flex;
    gap: 0.65rem;
    padding: 0.85rem 1rem;
}

.review-panel .card-header strong,
.review-panel .card-header small {
    display: block;
}

.review-panel .card-header strong {
    font-size: 0.9rem;
}

.review-panel .card-header small {
    font-size: 0.7rem;
    font-weight: 500;
    margin-top: 0.1rem;
    opacity: 0.75;
}

.review-panel-icon {
    align-items: center;
    border-radius: 0.5rem;
    display: inline-flex;
    height: 2rem;
    justify-content: center;
    width: 2rem;
}

.review-panel-original {
    border: 1px solid #dbe2ea;
}

.review-panel-original .card-header {
    background: #f8fafc;
    color: #334155;
}

.review-panel-original .review-panel-icon {
    background: #e2e8f0;
    color: #475569;
}

.review-panel-proposed {
    border: 1px solid #f1cf75;
    box-shadow: 0 4px 16px rgba(217, 154, 22, 0.08);
}

.review-panel-proposed .card-header {
    background: #fff8e6;
    color: #8a5b00;
}

.review-panel-proposed .review-panel-icon {
    background: #ffedb8;
    color: #a66b00;
}

.review-panel .card-body {
    padding: 1rem;
}

.review-panel .table {
    font-size: 0.76rem;
}

.ims-table-card.h-100 {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.ims-table-card.h-100 .table-responsive {
    flex: 1;
}

.ims-table-toolbar {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9375rem;
}

/* Responsive Table Padding Scaling */
@media (max-width: 1400px) {
    .table > thead > tr > th,
    .table > tbody > tr > td {
        padding: 0.55rem 0.75rem;
        font-size: 0.8375rem;
    }
    .ims-table-toolbar {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 1200px) {
    .table > thead > tr > th,
    .table > tbody > tr > td {
        padding: 0.45rem 0.65rem;
        font-size: 0.8125rem;
    }
}

/* ── Login Page ────────────────────────────────────────────────────────────── */
.ims-login-panel {
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
    padding: 3rem;
}

.text-blue {
    color: var(--ims-primary) !important;
}

.text-white {
    color: white !important;
}

/* ── Animation Helpers ─────────────────────────────────────────────────────── */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ── Table Enhancements ────────────────────────────────────────────────────── */
.table-hover tbody tr:hover {
    background-color: #f8fafc;
}

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

/* ── Form Controls ─────────────────────────────────────────────────────────── */
.form-control:focus,
.form-select:focus {
    border-color: var(--ims-primary);
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.15);
}

/* ── Utilities ─────────────────────────────────────────────────────────────── */
.rounded-3 {
    border-radius: 0.75rem !important;
}

.rounded-4 {
    border-radius: 1rem !important;
}

.shadow-sm {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
}

/* ── Blazor Reconnect Modal ────────────────────────────────────────────────── */
#components-reconnect-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    max-width: 400px;
}

/* ── Accessibility Enhancements ───────────────────────────────────────────────── */
/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--ims-primary);
    outline-offset: 2px;
}

/* Skip to main content link for screen readers */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--ims-primary);
    color: white;
    padding: 8px 16px;
    z-index: 10000;
    transition: top 0.3s;
}

.skip-to-main:focus {
    top: 0;
}

/* Screen reader only class */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .card,
    .btn,
    .form-control,
    .form-select {
        border: 2px solid currentColor;
    }
}

/* ── Responsive Design Enhancements ───────────────────────────────────────────── */
/* Responsive table wrapper */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* Responsive card grid */
@media (max-width: 768px) {
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .row.g-4 > [class*="col-"] {
        padding-bottom: 1rem;
    }
    
    .ims-kpi-value {
        font-size: 1.5rem;
    }
    
    .ims-kpi-icon {
        width: 36px;
        height: 36px;
        font-size: 1.125rem;
    }
}

/* Mobile-first button sizing */
@media (max-width: 576px) {
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
}

/* Touch-friendly targets for mobile */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .form-control,
    .form-select,
    .nav-link {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Landscape mobile adjustments */
@media (max-width: 991.98px) and (orientation: landscape) {
    .ims-sidebar {
        height: calc(100vh - var(--ims-navbar-height));
        max-height: 50vh;
    }
}

/* ── Modern Modal System ───────────────────────────────────────────────────── */
.ims-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1050;
    animation: fadeIn 0.2s ease-out;
}

.ims-modal-wrap {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1055;
    overflow-y: auto;
    animation: fadeIn 0.2s ease-out;
}

.ims-modal-wrap .modal-dialog {
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ims-modal-wrap .modal-content {
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(226, 232, 240, 0.8);
}

.ims-modal-header {
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(to bottom, #ffffff, #f8fafc);
    border-radius: 1rem 1rem 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.ims-modal-header .modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.ims-modal-header .btn-close {
    padding: 0.75rem;
    margin: -0.75rem -0.75rem -0.75rem auto;
    opacity: 0.5;
    transition: all 0.15s ease;
}

.ims-modal-header .btn-close:hover {
    opacity: 1;
    transform: scale(1.1);
}

.ims-modal-footer {
    padding: 1.25rem 1.75rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 0 0 1rem 1rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Modal animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Enhanced form styling inside modals */
.ims-modal-wrap .modal-body {
    padding: 1.5rem 1.75rem;
    background: #ffffff;
}
.modal-body .form-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.5rem;
}

.modal-body .form-control,
.modal-body .form-select {
    border: 1.5px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    transition: all 0.15s ease;
}

.modal-body .form-control:focus,
.modal-body .form-select:focus {
    border-color: var(--ims-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.modal-body .input-group-text {
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-right: none;
    color: #64748b;
    font-weight: 500;
}

.modal-body .form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid #cbd5e1;
    cursor: pointer;
}

.modal-body .form-check-input:checked {
    background-color: var(--ims-primary);
    border-color: var(--ims-primary);
}

.modal-body .form-check-label {
    cursor: pointer;
    margin-left: 0.5rem;
    color: #475569;
}

/* Darker checkbox border */
.darker-border-checkbox {
    border-color: #94a3b8 !important;
}

/* Validation messages */
.validation-message {
    font-size: 0.8125rem;
    color: var(--ims-danger);
    margin-top: 0.375rem;
    display: block;
}

/* Responsive modal */
@media (max-width: 767.98px) {
    .ims-modal-wrap .modal-dialog {
        max-width: 95% !important;
        margin: 0.5rem;
    }
    
    .ims-modal-header {
        padding: 1.25rem 1.5rem;
    }
    
    .ims-modal-header .modal-title {
        font-size: 1.125rem;
    }
    
    .ims-modal-footer {
        padding: 1rem 1.5rem;
        flex-direction: column-reverse;
    }
    
    .ims-modal-footer .btn {
        width: 100%;
    }
}

/* Print styles */
@media print {
    .ims-sidebar,
    .ims-navbar,
    .btn,
    .pagination,
    .ims-modal-backdrop,
    .ims-modal-wrap,
    #components-reconnect-modal {
        display: none !important;
    }
    
    .ims-main-content {
        margin-left: 0 !important;
    }
    
    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    body {
        background: white;
        color: black;
    }
}


/* ── Receipt Items Dropdown - High Z-Index Fix ─────────────────────────────────── */
.ims-table-card {
  position: relative;
  z-index: 1;
}

.ims-table-card .table-responsive {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
  position: relative;
  z-index: 1;
}

.ims-table-card table {
  position: relative;
  z-index: 1;
}

.dropdown-menu li:last-child {
  border-bottom: none !important;
}

.dropdown-menu li:hover {
  background-color: rgba(13, 110, 253, 0.05);
}

.ims-table-card .dropdown-toggle {
  font-size: 0.875rem;
  padding: 0.25rem 0.75rem;
  position: relative;
  z-index: 1050;
}

.ims-table-card .dropdown-menu {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  position: absolute !important;
  z-index: 9999 !important;
  background: white !important;
}

/* Inventory issues workspace */
.issue-rate-banner {
    background: linear-gradient(110deg, #e5f8ff, #f0fbff);
    border: 1px solid #b9e9f5;
    border-radius: 12px;
    color: #164e63;
    padding: .85rem 1.1rem;
}

.issue-rate-icon {
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 10px;
    background: #c7f1fb;
    color: #087f9f;
    font-size: 1.1rem;
}

.issue-rate-label {
    display: block;
    color: #4b7280;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.issue-rate-banner small {
    color: #5f7d8b;
    margin-left: .6rem;
}

.issue-metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .85rem;
}

.issue-metric-card {
    align-items: center;
    background: #fff;
    border: 1px solid #e5eaf0;
    border-left: 4px solid;
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(24, 39, 75, .04);
    display: flex;
    gap: .8rem;
    min-height: 82px;
    padding: .9rem 1rem;
}

.issue-metric-card > div {
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.issue-metric-card span:not(.issue-metric-icon) {
    color: #718096;
    font-size: .73rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.issue-metric-card strong {
    color: #1e293b;
    font-size: 1.45rem;
    line-height: 1;
}

.issue-metric-icon {
    align-items: center;
    border-radius: 10px;
    display: inline-flex;
    font-size: 1.1rem;
    height: 2.35rem;
    justify-content: center;
    width: 2.35rem;
}

.issue-metric-blue { border-left-color: #2563eb; }
.issue-metric-blue .issue-metric-icon { background: #eaf1ff; color: #2563eb; }
.issue-metric-green { border-left-color: #16a36a; }
.issue-metric-green .issue-metric-icon { background: #e9f8f0; color: #168957; }
.issue-metric-amber { border-left-color: #f59e0b; }
.issue-metric-amber .issue-metric-icon { background: #fff6df; color: #c47b00; }
.issue-metric-red { border-left-color: #dc5b68; }
.issue-metric-red .issue-metric-icon { background: #fff0f1; color: #c73f4d; }

.issues-table-card {
    border: 1px solid #e4e9f0;
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(24, 39, 75, .06);
}

.issues-table-card table {
    font-size: .82rem;
    min-width: 1320px;
    width: max-content;
    border-collapse: separate;
    border-spacing: 0;
}

.issues-table-card thead th {
    background: #f8fafc;
    border-bottom: 1px solid #e3e8ef;
    color: #64748b;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .06em;
    padding: .85rem .7rem;
    text-transform: uppercase;
    white-space: nowrap;
}

.issues-table-card tbody td {
    border-color: #edf0f4;
    padding: .8rem .7rem;
}

.issues-table-card .issue-actions-column {
    background: #fff;
    position: sticky !important;
    left: auto !important;
    right: 0 !important;
    width: 120px;
    min-width: 120px;
    max-width: 120px;
    z-index: 12;
    box-shadow: -2px 0 5px rgba(15, 23, 42, .08);
}

.issues-table-card .issue-actions-column .issue-actions-menu {
    left: auto;
    right: 0;
}

.issues-table-card thead .issue-actions-column {
    z-index: 13;
}

.issues-table-card tbody tr:hover {
    background: #fbfdff;
}

.issues-table-card tbody tr:hover .issue-actions-column {
    background: #fbfdff;
}

.issue-actions {
    position: relative;
}

.issue-actions summary {
    cursor: pointer;
    list-style: none;
    white-space: nowrap;
}

.issue-actions summary::-webkit-details-marker {
    display: none;
}

.issue-actions summary:hover {
    background: #eef4ff;
    border-color: #b9ccef !important;
    color: #2457b8;
}

.issue-actions-menu {
    background: #fff;
    border: 1px solid #e1e7ef;
    border-radius: 10px;
    min-width: 175px;
    padding: .35rem;
    position: absolute;
    right: 0;
    top: calc(100% + .35rem);
    z-index: 20;
}

/* Keep issue row menus above the table and prevent the responsive wrapper
   from clipping the menu when it opens downward. */
.issues-table-card {
    overflow: visible;
    position: relative;
    z-index: 10;
}

.issues-table-card .table-responsive {
    overflow-x: auto !important;
    overflow-y: visible;
    position: relative;
    z-index: 10;
}

.issues-table-card tbody tr {
    position: relative;
    z-index: 1;
}

.issues-table-card tbody tr:has(.issue-actions[open]) {
    z-index: 100;
}

.issues-table-card tbody tr:has(.issue-actions[open]) td {
    position: relative;
    z-index: 100;
}

.issues-table-card .issue-actions[open] {
    position: relative;
    z-index: 1000;
}

.issues-table-card .issue-actions-menu {
    z-index: 1100;
}

.issue-action-item {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 7px;
    color: #334155;
    display: flex;
    gap: .65rem;
    padding: .55rem .65rem;
    text-align: left;
    text-decoration: none;
    width: 100%;
}

.issue-action-item:hover {
    background: #f1f5f9;
    color: #1d4ed8;
}

.issue-action-item i {
    color: #64748b;
    width: 1rem;
}

.issue-action-review {
    color: #a16207;
}

.issue-action-review:hover {
    background: #fff8e6;
    color: #92400e;
}

.issue-action-danger {
    color: #b42332;
}

.issue-action-danger:hover {
    background: #fff1f2;
    color: #b42332;
}

@media (max-width: 900px) {
    .issue-metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .issue-metrics-grid {
        grid-template-columns: 1fr;
    }
}

.ims-table-card .dropdown {
  position: relative;
}

.ims-table-card tbody .dropdown {
  position: relative;
  z-index: 1050;
}

.ims-table-card tbody tr {
  position: relative;
  z-index: 1;
}

.ims-table-card .dropdown.show {
  z-index: 9998 !important;
}

/* Global dropdown menu override for tables */
.table-responsive .dropdown-menu,
.ims-table-card .dropdown-menu {
  z-index: 9999 !important;
}

/* Force dropdown to be appended to body for proper z-index stacking */
body > .dropdown-menu {
  z-index: 9999 !important;
}

/* ══════════════════════════════════════════════════════════════════════════
   Workflow Timeline Styles
   ══════════════════════════════════════════════════════════════════════════ */

.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0.875rem;
    top: 0.5rem;
    bottom: 0.5rem;
    width: 2px;
    background: #e9ecef;
}

.timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-marker {
    position: absolute;
    left: -2rem;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    z-index: 1;
    box-shadow: 0 0 0 4px #fff;
}

.timeline-item.completed .timeline-marker {
    animation: pulse 0.5s ease-in-out;
}

.timeline-content {
    padding-left: 1rem;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

/* ── Notification Preferences ──────────────────────────────────────────────── */
.notification-settings-page {
    width: 100%;
}

.notification-settings-hero .card-body {
    background: linear-gradient(120deg, #eff6ff 0%, #ffffff 72%);
}

.notification-settings-page .notification-group-card {
    border: 1px solid #e2e8f0 !important;
}

.notification-group-header {
    gap: 1rem;
}

.notification-group-actions {
    flex-shrink: 0;
}

.notification-preferences-table {
    min-width: 0;
}

.notification-preferences-table thead th {
    color: #64748b;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.notification-preferences-table tbody td {
    border-color: #edf0f4;
}

.notification-preferences-table tbody tr:last-child td {
    border-bottom: 0;
}

.notification-preferences-table .custom-switch {
    margin: 0;
    float: none;
}

@media (max-width: 767.98px) {
    .notification-settings-page {
        padding-top: 1rem !important;
    }

    .notification-settings-hero .card-body {
        padding: 1.25rem !important;
    }

    .notification-settings-hero h2 {
        font-size: 1.35rem !important;
        line-height: 1.25;
    }

    .notification-settings-hero .card-body > div > div:first-child {
        align-items: flex-start;
    }

    .notification-settings-hero .card-body > div > div:first-child > div:last-child > div {
        align-items: flex-start !important;
        flex-direction: column;
        gap: 0.5rem !important;
    }

    .notification-settings-hero .btn {
        justify-content: center;
        width: 100%;
    }

    .notification-permission-card .card-body {
        padding: 1rem !important;
    }

    .notification-permission-card .card-body > div {
        align-items: stretch !important;
    }

    .notification-permission-card .card-body > div > div:first-child {
        align-items: flex-start;
    }

    .notification-permission-card .btn {
        white-space: normal !important;
        width: 100%;
    }

    .notification-group-header {
        align-items: flex-start !important;
        flex-direction: column;
        padding: 1rem !important;
    }

    .notification-group-header > div:first-child {
        align-items: flex-start !important;
    }

    .notification-group-header > div:first-child > div:last-child {
        min-width: 0;
    }

    .notification-group-header > div:first-child > div:last-child span {
        display: block;
    }

    .notification-group-actions {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .notification-group-actions .btn {
        white-space: nowrap;
    }

    .notification-table-wrap {
        overflow: visible;
    }

    .notification-preferences-table,
    .notification-preferences-table tbody {
        display: block;
        width: 100%;
    }

    .notification-preferences-table thead {
        display: none;
    }

    .notification-preferences-table tbody tr {
        background: #fff;
        border-bottom: 1px solid #e8edf3;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: 0.75rem 1rem;
    }

    .notification-preferences-table tbody tr:last-child {
        border-bottom: 0;
    }

    .notification-preferences-table tbody td {
        align-items: center;
        border: 0;
        display: flex;
        justify-content: space-between;
        min-width: 0;
        padding: 0.6rem 0 !important;
    }

    .notification-preferences-table tbody td:first-child {
        border-bottom: 1px solid #edf0f4;
        display: block;
        grid-column: 1 / -1;
        margin-bottom: 0.25rem;
        padding: 0.25rem 0 0.85rem !important;
    }

    .notification-preferences-table tbody td:not(:first-child)::before {
        color: #64748b;
        content: attr(data-label);
        font-size: 0.75rem;
        font-weight: 600;
        padding-right: 0.5rem;
    }

    .notification-preferences-table tbody td:not(:first-child) .form-check {
        flex: 0 0 auto;
        padding: 0;
    }

    .notification-preferences-table .custom-switch {
        height: 1.1rem !important;
        width: 2rem !important;
    }
}

@media (max-width: 420px) {
    .notification-group-actions {
        grid-template-columns: 1fr;
    }

    .notification-group-actions .btn {
        width: 100%;
    }

    .notification-settings-page .card.rounded-4 {
        border-radius: 0.9rem !important;
    }
}
