/* =========================================================================
   COSTLESS WMS - CONSOLIDATED STYLESHEET
   Complete CSS architecture consolidation - Phase 1C
   Generated: 2025-08-01
   ========================================================================= */

/* CSS Variables - Consistent Design System */
:root {
    /* Layout */
    --sidebar-width: 250px;
    --navbar-height: 60px;
    --content-padding: 1.5rem;

    /* Colors - Bootstrap 5 Aligned */
    --bs-primary: #0d6efd;
    --bs-secondary: #6c757d;
    --bs-success: #198754;
    --bs-warning: #ffc107;
    --bs-danger: #dc3545;
    --bs-info: #0dcaf0;

    /* Sidebar Theme */
    --sidebar-bg: #343a40;
    --sidebar-text: #ffffff;
    --sidebar-text-muted: rgba(255, 255, 255, 0.8);
    --sidebar-border: rgba(255, 255, 255, 0.1);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.1);
    --sidebar-active-bg: rgba(255, 255, 255, 0.2);
    --sidebar-dropdown-bg: #2c3036;

    /* Typography */
    --font-family-sans-serif: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    --font-size-base: 1rem;
    --font-weight-normal: 400;
    --font-weight-semibold: 500;
    --font-weight-bold: 600;
    --line-height-base: 1.5;

    /* Spacing Scale */
    --spacer: 1rem;
    --spacer-1: calc(var(--spacer) * 0.25);
    --spacer-2: calc(var(--spacer) * 0.5);
    --spacer-3: var(--spacer);
    --spacer-4: calc(var(--spacer) * 1.5);
    --spacer-5: calc(var(--spacer) * 3);

    /* Border Radius */
    --border-radius: 0.375rem;
    --border-radius-sm: 0.25rem;
    --border-radius-lg: 0.5rem;
    --border-radius-pill: 50rem;

    /* Shadows */
    --box-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --box-shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);

    /* Z-index Scale */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    --z-toast: 1080;

    /* Transitions - Optimized for Performance */
    --transition-base: all 0.08s ease-in-out;
    --transition-fade: opacity 0.08s linear;
    --transition-collapse: height 0.18s ease;
}

/* =========================================================================
   BASE STYLES
   ========================================================================= */

body {
    font-family: var(--font-family-sans-serif);
    background-color: #f8f9fa;
    line-height: var(--line-height-base);
}

/* =========================================================================
   TOP NAVIGATION BAR
   ========================================================================= */

.top-navbar {
    height: var(--navbar-height);
    background: linear-gradient(135deg, var(--bs-primary) 0%, #0b5ed7 100%);
    box-shadow: var(--box-shadow-sm);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-fixed);
}

.top-navbar .navbar-brand {
    color: white !important;
    font-weight: var(--font-weight-bold);
    font-size: 1.25rem;
    text-decoration: none;
}

.top-navbar .nav-link {
    color: rgba(255, 255, 255, 0.9) !important;
    transition: var(--transition-base);
}

.top-navbar .nav-link:hover,
.top-navbar .nav-link:focus {
    color: white !important;
}

.navbar-toggler {
    border: none;
    background: transparent;
    padding: 0.25rem 0.5rem;
}

.navbar-toggler:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
}

/* =========================================================================
   SIDEBAR NAVIGATION - CONSOLIDATED SOLUTION
   ========================================================================= */

.sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--navbar-height));
    background-color: var(--sidebar-bg);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: var(--z-sticky);
    transform: translateX(0) translateZ(0);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    backface-visibility: hidden;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

/* Sidebar Header */
.sidebar-header {
    padding: var(--spacer);
    background-color: rgba(0, 0, 0, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    color: var(--sidebar-text);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius-pill);
    background: linear-gradient(135deg, var(--bs-success), #20c997);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: var(--font-weight-bold);
    margin-right: 0.75rem;
}

/* Navigation List */
.sidebar-nav {
    padding: 0;
    margin: 0;
    list-style: none;
    width: 100%;
}

.sidebar-nav .nav-item {
    border-bottom: 1px solid var(--sidebar-border);
    width: 100%;
}

/* Override ALL Bootstrap link colors for sidebar - Bulletproof */
.sidebar a,
.sidebar a:link,
.sidebar a:visited,
.sidebar .nav-link,
.sidebar .nav-sublink,
nav.sidebar a,
#sidebar a,
.sidebar-nav a,
.sidebar-nav .nav-item a,
.sidebar-nav li a {
    color: rgba(255, 255, 255, 0.8) !important;
    text-decoration: none !important;
}

.sidebar a:hover,
.sidebar a:focus,
.sidebar a:active,
.sidebar .nav-link:hover,
.sidebar .nav-sublink:hover,
nav.sidebar a:hover,
#sidebar a:hover,
.sidebar-nav a:hover,
.sidebar-nav .nav-item a:hover,
.sidebar-nav li a:hover {
    color: #ffffff !important;
    text-decoration: none !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
}

/* Ensure active links are also white */
.sidebar a.active,
.sidebar .nav-link.active,
.sidebar .nav-sublink.active {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.2) !important;
}

/* Force white text for navigation text elements */
.sidebar .nav-text,
.sidebar .nav-content {
    color: inherit !important;
}

/* Navigation Links */
.sidebar-nav .nav-link,
.sidebar-nav a.nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem var(--spacer);
    color: var(--sidebar-text-muted) !important;
    text-decoration: none !important;
    background-color: transparent;
    border: none;
    width: 100%;
    cursor: pointer;
    transition: var(--transition-base);
    font-size: 0.95rem;
    font-weight: var(--font-weight-normal);
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link:focus {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-text) !important;
    text-decoration: none;
    outline: none;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.sidebar-nav .nav-link.active {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-text) !important;
    font-weight: var(--font-weight-semibold);
}

/* Icon and Text Layout */
.sidebar-nav .nav-content {
    display: flex;
    align-items: center;
    flex: 1;
}

.sidebar-nav .nav-icon {
    width: 20px;
    height: 20px;
    margin-right: 0.75rem;
    text-align: center;
    flex-shrink: 0;
    line-height: 1;
}

.sidebar-nav .nav-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Accordion-Style Submenus */
.sidebar-nav .nav-arrow {
    width: 16px;
    height: 16px;
    margin-left: 0.5rem;
    flex-shrink: 0;
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.7;
    transform: translateZ(0);
    will-change: transform;
}

.sidebar-nav .nav-arrow.expanded {
    transform: rotate(90deg);
}

.sidebar-nav .nav-arrow::before {
    content: '>';
    font-weight: bold;
    font-size: 0.8rem;
    display: block;
    text-align: center;
    line-height: 16px;
}

/* Submenu Containers */
.sidebar-nav .nav-submenu {
    max-height: 0;
    overflow: hidden;
    background-color: var(--sidebar-dropdown-bg);
    transition: max-height 0.18s cubic-bezier(0.4, 0, 0.2, 1), padding 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
    margin: 0;
    list-style: none;
    transform: translateZ(0);
}

.sidebar-nav .nav-submenu.expanded {
    max-height: 500px;
    padding: 0.25rem 0;
}

/* Submenu Items */
.sidebar-nav .nav-submenu .nav-subitem {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-nav .nav-submenu .nav-subitem:last-child {
    border-bottom: none;
}

.sidebar-nav .nav-submenu .nav-sublink {
    display: flex;
    align-items: center;
    padding: 0.6rem var(--spacer) 0.6rem 3rem;
    color: rgba(255, 255, 255, 0.9) !important;
    text-decoration: none;
    background-color: transparent;
    transition: var(--transition-base);
    font-size: 0.9rem;
    line-height: 1.4;
}

.sidebar-nav .nav-submenu .nav-sublink:hover,
.sidebar-nav .nav-submenu .nav-sublink:focus {
    background-color: rgba(255, 255, 255, 0.15);
    color: white !important;
    text-decoration: none;
    outline: none;
}

.sidebar-nav .nav-submenu .nav-sublink.active {
    background-color: var(--sidebar-active-bg);
    color: white !important;
    font-weight: var(--font-weight-semibold);
}

.sidebar-nav .nav-submenu .nav-subicon {
    width: 16px;
    margin-right: 0.6rem;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.8;
}

/* Legacy Bootstrap Cleanup */
.sidebar .dropdown,
.sidebar .dropdown-toggle,
.sidebar .dropdown-menu,
.sidebar [data-bs-toggle="dropdown"] {
    position: static !important;
    transform: none !important;
    float: none !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.sidebar .dropdown-toggle::after,
.sidebar .dropdown-toggle::before {
    display: none !important;
}

/* =========================================================================
   MAIN CONTENT AREA
   ========================================================================= */

.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--navbar-height);
    padding: var(--content-padding);
    min-height: calc(100vh - var(--navbar-height));
    transition: margin-left 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content.expanded {
    margin-left: 0;
}

/* Content Header */
.content-header {
    background: white;
    padding: var(--spacer) var(--content-padding);
    margin: calc(-1 * var(--content-padding)) calc(-1 * var(--content-padding)) var(--content-padding) calc(-1 * var(--content-padding));
    border-bottom: 1px solid #dee2e6;
    box-shadow: var(--box-shadow-sm);
}

.content-header h1 {
    margin: 0;
    color: #495057;
    font-size: 1.75rem;
    font-weight: var(--font-weight-bold);
}

/* =========================================================================
   COMPONENT STYLES
   ========================================================================= */

/* Cards */
.card {
    border: none;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow-sm);
    margin-bottom: var(--spacer);
}

.card-header {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-bottom: 1px solid #dee2e6;
    font-weight: var(--font-weight-bold);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

/* Buttons */
.btn {
    border-radius: var(--border-radius);
    font-weight: var(--font-weight-semibold);
    transition: var(--transition-base);
}

.btn-primary {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}

.btn-primary:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
}

.btn-success {
    background-color: var(--bs-success);
    border-color: var(--bs-success);
}

.btn-success:hover {
    background-color: #157347;
    border-color: #146c43;
}

/* Forms */
.form-control,
.form-select {
    border-radius: var(--border-radius);
    border-color: #ced4da;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus,
.form-select:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.form-label {
    font-weight: var(--font-weight-semibold);
    margin-bottom: 0.5rem;
    color: #495057;
}

/* Tables */
.table {
    background: white;
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--box-shadow-sm);
}

.table th {
    border-top: none;
    font-weight: var(--font-weight-bold);
    background-color: #f8f9fa;
    color: #495057;
}

/* Alerts */
.alert {
    border: none;
    border-radius: var(--border-radius-lg);
}

/* Dashboard Info Boxes */
.info-box {
    background: white;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow-sm);
    padding: var(--spacer-4);
    margin-bottom: var(--spacer);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.info-box:hover {
    transform: translateY(-2px);
    box-shadow: var(--box-shadow);
}

.small-box {
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow-sm);
    overflow: hidden;
    position: relative;
    margin-bottom: var(--spacer);
}

.small-box .inner {
    padding: var(--spacer-4);
    color: white;
}

.small-box .icon {
    position: absolute;
    top: 50%;
    right: var(--spacer);
    transform: translateY(-50%);
    font-size: 3rem;
    opacity: 0.3;
}

/* Background Gradients */
.bg-info { background: linear-gradient(135deg, var(--bs-info), #0aa2c0); }
.bg-success { background: linear-gradient(135deg, var(--bs-success), #146c43); }
.bg-warning { background: linear-gradient(135deg, var(--bs-warning), #e0a800); }
.bg-danger { background: linear-gradient(135deg, var(--bs-danger), #c82333); }

/* =========================================================================
   LOADING STATES
   ========================================================================= */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: var(--z-modal);
}

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--bs-primary);
    border-radius: var(--border-radius-pill);
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =========================================================================
   RESPONSIVE BREAKPOINTS - Bootstrap 5 Aligned
   ========================================================================= */

/* Small devices (576px and up) */
@media (min-width: 576px) {
    .container-sm { max-width: 540px; }
}

/* Medium devices (768px and up) */
@media (min-width: 768px) {
    .container-md { max-width: 720px; }
}

/* Large devices (992px and up) */
@media (min-width: 992px) {
    .container-lg { max-width: 960px; }
}

/* Extra large devices (1200px and up) */
@media (min-width: 1200px) {
    .container-xl { max-width: 1140px; }
}

/* Extra extra large devices (1400px and up) */
@media (min-width: 1400px) {
    .container-xxl { max-width: 1320px; }
}

/* Mobile Responsive Styles */
@media (max-width: 767.98px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: var(--z-modal);
        box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .sidebar.show::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
        pointer-events: none;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: var(--spacer);
    }
    
    .content-header h1 {
        font-size: 1.5rem;
    }
    
    .card-body {
        padding: var(--spacer);
    }
    
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .btn {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }
}

/* Tablet Responsive Styles */
@media (min-width: 768px) and (max-width: 991.98px) {
    .sidebar-nav .nav-link {
        font-size: 0.9rem;
        padding: 0.7rem var(--spacer);
    }
    
    .sidebar-nav .nav-submenu .nav-sublink {
        padding: 0.55rem var(--spacer) 0.55rem 2.5rem;
        font-size: 0.85rem;
    }
}

/* =========================================================================
   MOBILE TOUCH ENHANCEMENTS
   ========================================================================= */

/* Touch feedback states */
.touch-active {
    background-color: rgba(0, 0, 0, 0.1) !important;
    transform: scale(0.98);
    transition: all 0.1s ease;
}

.sidebar-nav .nav-link.touch-active {
    background-color: rgba(255, 255, 255, 0.2) !important;
}

.sidebar-nav .nav-sublink.touch-active {
    background-color: rgba(255, 255, 255, 0.25) !important;
}

/* =========================================================================
   ACCESSIBILITY & MOTION
   ========================================================================= */

/* Focus States */
.sidebar-nav .nav-link:focus,
.sidebar-nav .nav-submenu .nav-sublink:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: -2px;
}

.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .sidebar {
        border-right: 2px solid white;
    }
    
    .sidebar-nav .nav-item {
        border-bottom-color: rgba(255, 255, 255, 0.3);
    }
    
    .form-control.is-invalid,
    .form-control.is-valid {
        border-width: 2px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* =========================================================================
   PRINT STYLES
   ========================================================================= */

@media print {
    .sidebar,
    .top-navbar,
    .main-footer,
    .btn {
        display: none !important;
    }
    
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .card {
        border: 1px solid #000;
        box-shadow: none;
        break-inside: avoid;
    }
}

/* =========================================================================
   UTILITY CLASSES
   ========================================================================= */

.full-width { width: 100% !important; max-width: 100% !important; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

/* Elevation Classes */
.elevation-1 { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24); }
.elevation-2 { box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23); }
.elevation-3 { box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23); }
.elevation-4 { box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22); }