/* ═══════════════════════════════════════════════════════════════════════════
   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;
    }
}

/* ── KPI Dashboard Cards ───────────────────────────────────────────────────── */
.ims-kpi-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
}

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

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

.ims-kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.ims-kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: #1e293b;
}

.ims-kpi-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.625rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
}

/* ── 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;
}

.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;
}

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

/* ── 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: visible !important;
  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;
}

.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);
    }
}
