/* 
 * Inventory Management System - Modern Automotive Design
 * Color Scheme: Black and Orange
 */

:root {
    --primary-color: #ff8c00;
    --primary-dark: #e67e00;
    --primary-light: #ffb84d;
    --primary-rgb: 255, 140, 0;
    --primary-dark-rgb: 230, 126, 0;
    --primary-light-rgb: 255, 184, 77;
    --primary-contrast: #000000;
    --primary-dark-contrast: #ffffff;
    --secondary-contrast: #ffffff;
    --secondary-color: #1a1a1a;
    --secondary-dark: #0d0d0d;
    --gray-light: #f8f9fa;
    --gray-medium: #e8eaed;
    --text-color: #333333;
    --text-rgb: 51, 51, 51;
    --text-light: #ffffff;
    --border-color: #e0e0e0;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --background-start: #f8f9fa;
    --background-end: #f0f1f3;
    --card-bg: #ffffff;
    --form-bg: #ffffff;
    --table-bg: #ffffff;
    --card-contrast: #000000;
    --table-contrast: #000000;
    --form-contrast: #000000;
    --border-contrast: #000000;
    --table-row-hover: #fafafa;
    --modal-bg: #ffffff;
    --dropdown-bg: #ffffff;
    --dropdown-border: #dee2e6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--background-start) 0%, var(--background-end) 100%);
    color: var(--text-color);
    scroll-behavior: smooth;
}

/* ============= NAVIGATION ============= */
nav.navbar {
    background: linear-gradient(90deg, var(--secondary-dark) 0%, var(--secondary-color) 100%);
    padding: 1rem 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 3px solid var(--primary-color);
    backdrop-filter: blur(10px);
}

.navbar-brand {
    color: var(--primary-color) !important;
    font-weight: 800;
    font-size: 1.3rem;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-brand i {
    font-size: 1.5rem;
}

.navbar-nav .nav-link {
    color: var(--text-light) !important;
    margin: 0 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    position: relative;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.navbar-nav .nav-link::after {
    content: '';
    position: absolute;
    bottom: -1rem;
    left: 0;
    width: 0;
    height: 3px;
    background: var(--primary-color);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.navbar-nav .nav-link:hover {
    color: var(--primary-light) !important;
}

.navbar-nav .nav-link:hover::after {
    width: 100%;
}

.navbar-nav .nav-link.active {
    color: var(--primary-color) !important;
}

.navbar-nav .nav-link.active::after {
    width: 100%;
}

/* ============= SIDEBAR ============= */
.sidebar {
    background: linear-gradient(180deg, var(--secondary-dark) 0%, var(--secondary-color) 100%);
    min-height: 100vh;
    padding: 0;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.25);
}

.sidebar .nav-link {
    color: var(--text-light);
    padding: 14px 20px;
    border-left: 4px solid transparent;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0;
}

.sidebar .nav-link i {
    font-size: 1.1rem;
    min-width: 24px;
    text-align: center;
}

.sidebar .nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary-color);
    transform: scaleY(0);
    transform-origin: top;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar .nav-link:hover {
    background-color: rgba(var(--primary-rgb), 0.08);
    border-left-color: transparent;
    color: var(--primary-light);
    padding-left: 24px;
}

.sidebar .nav-link:hover::before {
    transform: scaleY(1);
}

.sidebar .nav-link.active {
    background-color: rgba(var(--primary-rgb), 0.15);
    color: var(--primary-color);
    border-left-color: transparent;
}

.sidebar .nav-link.active::before {
    transform: scaleY(1);
}

.sidebar-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 20px 15px;
    text-align: center;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.2);
}

.sidebar-header i {
    font-size: 2rem;
    display: block;
    margin-bottom: 8px;
    opacity: 0.9;
}

.sidebar-header div:last-child {
    font-size: 0.8rem;
    margin-top: 8px;
    opacity: 0.85;
}

/* ============= LAYOUT FIX ============= */
.container-fluid {
    padding: 0 !important;
}

.container-fluid > .row {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
}

.col-lg-2.d-none.d-lg-block {
    width: 16.666667% !important;
    min-height: calc(100vh - 60px);
}

.col-lg-10 {
    width: 83.333333% !important;
}

.col-lg-10 > div {
    width: 100%;
}

/* ============= FORMS ============= */
.form-control, .form-select {
    border: 2px solid var(--gray-medium);
    border-radius: 8px;
    padding: 11px 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: var(--form-bg);
    color: var(--form-contrast);
    font-size: 0.95rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.3rem rgba(var(--primary-rgb), 0.1), inset 0 0 0 3px rgba(var(--primary-rgb), 0.05);
    background-color: var(--form-bg);
}

.form-label {
    font-weight: 700;
    color: var(--secondary-color);
    margin-bottom: 8px;
    font-size: 0.9rem;
    letter-spacing: -0.3px;
}

/* ============= BUTTONS ============= */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border: none;
    color: var(--primary-contrast);
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.25);
    border-radius: 8px;
    letter-spacing: -0.3px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(var(--primary-rgb), 0.4);
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    color: var(--primary-dark-contrast);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.3);
}

.btn-secondary {
    background-color: var(--secondary-color);
    border: none;
    color: white;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.btn-secondary:hover {
    background-color: var(--secondary-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.btn-outline-primary {
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    background-color: transparent;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    color: var(--primary-contrast);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.25);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* ============= CARDS ============= */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: var(--card-bg);
    color: var(--card-contrast);
    overflow: hidden;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.15);
}

.card-header {
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--primary-contrast);
    font-weight: 700;
    border: none;
    padding: 18px 20px;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.card-header i {
    font-size: 1.1rem;
}

.card-body {
    padding: 24px;
}

/* ============= TABLES ============= */
.table {
    --bs-table-bg: var(--table-bg);
    --bs-table-color: var(--text-color);
    background-color: var(--table-bg);
    color: var(--text-color);
    border-collapse: collapse;
    margin-bottom: 0;
}

.table thead {
    background: linear-gradient(90deg, var(--secondary-dark) 0%, var(--secondary-color) 100%);
    color: #ffffff;
}

.table thead th {
    border: none;
    padding: 14px;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: linear-gradient(90deg, var(--secondary-dark) 0%, var(--secondary-color) 100%);
    color: #ffffff !important;
}

.table tbody tr {
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
    border-bottom: 1px solid var(--gray-medium);
}

.table tbody tr:hover {
    background-color: var(--table-row-hover);
    box-shadow: inset 0 0 8px rgba(var(--primary-rgb), 0.05);
}

.table tbody td {
    padding: 14px;
    vertical-align: middle;
    font-size: 0.95rem;
    color: var(--table-contrast);
}

/* ============= DASHBOARD WIDGETS ============= */
.stat-widget {
    background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
    border: none;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.stat-widget::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

.stat-widget:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
}

.stat-widget.stat-success::before {
    background: linear-gradient(90deg, var(--success-color) 0%, #1e7e34 100%);
}

.stat-widget.stat-danger::before {
    background: linear-gradient(90deg, var(--danger-color) 0%, #bd2130 100%);
}

.stat-widget.stat-warning::before {
    background: linear-gradient(90deg, var(--warning-color) 0%, #e0a800 100%);
}

.stat-number {
    font-size: 2.4rem;
    font-weight: 800;
    color: var(--primary-color);
    letter-spacing: -1px;
}

.stat-widget.stat-success .stat-number {
    color: var(--success-color);
}

.stat-widget.stat-danger .stat-number {
    color: var(--danger-color);
}

.stat-widget.stat-warning .stat-number {
    color: var(--warning-color);
}

.stat-label {
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============= BADGES ============= */
.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.badge-success {
    background: linear-gradient(135deg, var(--success-color) 0%, #1e7e34 100%);
    color: white;
}

.badge-danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, #bd2130 100%);
    color: white;
}

.badge-warning {
    background: linear-gradient(135deg, var(--warning-color) 0%, #e0a800 100%);
    color: white;
}

.badge-info {
    background: linear-gradient(135deg, var(--info-color) 0%, #117a8b 100%);
    color: white;
}

.badge-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #545b62 100%);
    color: white;
}

/* ============= ALERTS ============= */
.alert {
    border: none;
    border-radius: 10px;
    padding: 16px;
    border-left: 4px solid;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.alert-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border-left-color: var(--success-color);
}

.alert-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border-left-color: var(--danger-color);
}

.alert-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
    border-left-color: var(--warning-color);
}

.alert-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
    border-left-color: var(--info-color);
}

/* ============= MODALS ============= */
.modal-header {
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

.modal-body {
    padding: 28px;
}

/* ============= PAGINATION ============= */
.pagination {
    gap: 6px;
}

.page-link {
    color: var(--primary-color);
    border: 2px solid var(--gray-medium);
    border-radius: 6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
}

.page-link:hover {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.25);
}

.page-item.active .page-link {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.25);
}

/* ============= FOOTER ============= */
footer {
    background: linear-gradient(90deg, var(--secondary-dark) 0%, var(--secondary-color) 100%);
    color: var(--text-light);
    padding: 24px;
    text-align: center;
    margin-top: 40px;
    border-top: 3px solid var(--primary-color);
}

/* ============= UTILITIES ============= */
.text-primary {
    color: var(--primary-color) !important;
}

.text-secondary {
    color: var(--secondary-color) !important;
}

.bg-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%) !important;
}

.bg-secondary {
    background-color: var(--secondary-color) !important;
}

.border-primary {
    border-color: var(--primary-color) !important;
}

.shadow-lg {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2) !important;
}

.rounded-lg {
    border-radius: 12px;
}

/* ============= RESPONSIVE ============= */
@media (max-width: 991px) {
    .container-fluid > .row > .col-lg-2 {
        display: none !important;
    }

    .container-fluid > .row > .col-lg-10 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .sidebar {
        display: none;
    }

    .stat-widget {
        margin-bottom: 16px;
    }

    .table-responsive {
        font-size: 0.875rem;
    }

    .card-body {
        padding: 16px;
    }
}

/* ============= DARK MODE ============= */
body.dark-theme {
    background: linear-gradient(135deg, #111111 0%, #161616 100%);
    color: #e6e6e6;
}

body.dark-theme .navbar,
body.dark-theme .navbar-expand-lg,
body.dark-theme .navbar-dark .navbar-nav .nav-link {
    color: #e6e6e6;
}

body.dark-theme .navbar {
    background: linear-gradient(90deg, #121212 0%, #1f1f1f 100%);
}

body.dark-theme .sidebar {
    background: linear-gradient(180deg, #0d0d0d 0%, #141414 100%);
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.35);
}

body.dark-theme .sidebar-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

body.dark-theme .form-control,
body.dark-theme .form-select {
    background-color: #202020;
    color: #ececec;
    border-color: #3b3b3b;
}

body.dark-theme .form-control::placeholder,
body.dark-theme .form-select::placeholder {
    color: #9a9a9a;
}

body.dark-theme .form-control:focus,
body.dark-theme .form-select:focus {
    background-color: #1b1b1b;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.3rem rgba(var(--primary-rgb), 0.15), inset 0 0 0 3px rgba(var(--primary-rgb), 0.05);
}

body.dark-theme .card,
body.dark-theme .stat-widget,
body.dark-theme .modal-content,
body.dark-theme .dropdown-menu {
    background-color: #1f1f1f;
    color: #e6e6e6;
    border-color: #2d2d2d;
}

body.dark-theme .table {
    background-color: #1d1d1d;
    color: #e6e6e6;
}

body.dark-theme .table thead {
    background: #1a1a1a;
}

body.dark-theme .table tbody tr {
    border-color: #2d2d2d;
}

body.dark-theme .table tbody tr:hover {
    background-color: #252525;
    box-shadow: none;
}

body.dark-theme .page-link {
    background-color: #1d1d1d;
    border-color: #3a3a3a;
    color: #e6e6e6;
}

body.dark-theme .page-link:hover,
body.dark-theme .page-item.active .page-link {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: #ffffff;
}

body.dark-theme footer {
    background: #111111;
    color: #c7c7c7;
    border-top-color: #3a3a3a;
}

body.dark-theme .alert {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}

body.dark-theme .dropdown-item {
    color: #e6e6e6;
}

body.dark-theme .dropdown-item:hover,
body.dark-theme .dropdown-item:focus {
    background-color: #2a2a2a;
}

/* ============= ANIMATIONS ============= */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInFromLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

.fade-in {
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.slide-in {
    animation: slideInFromLeft 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============= CUSTOM SCROLLBAR ============= */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--gray-light);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border-radius: 10px;
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
}

/* ============= FORM IMPROVEMENTS ============= */
.form-control {
    min-height: 44px;
    font-size: 1rem;
    padding: 10px 14px;
}

.form-select {
    min-height: 44px;
    font-size: 1rem;
    padding: 8px 14px;
}

.form-control:focus, 
.form-select:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 0.3rem rgba(var(--primary-rgb), 0.1) !important;
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

.form-label {
    font-weight: 700;
    color: var(--secondary-color);
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.mb-3 {
    margin-bottom: 1.35rem;
}

/* ============= BATCH TABLE IMPROVEMENTS ============= */
.table-responsive {
    margin-bottom: 1rem;
}

#batchTable {
    width: 100% !important;
    margin-bottom: 0;
}

#batchTable tbody tr {
    height: auto;
}

#batchTable td {
    padding: 12px;
    vertical-align: middle;
}

#batchTable input,
#batchTable select {
    font-size: 0.95rem;
}

/* ============= TAB IMPROVEMENTS ============= */
.nav-tabs {
    border-bottom: 3px solid var(--gray-medium);
    gap: 8px;
}

.nav-tabs .nav-link {
    color: var(--secondary-color);
    border: none;
    border-radius: 8px 8px 0 0;
    margin-bottom: 0;
    font-weight: 600;
    padding: 12px 18px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-tabs .nav-link:hover {
    border-color: transparent;
    color: var(--primary-color);
    background-color: rgba(var(--primary-rgb), 0.05);
}

.nav-tabs .nav-link.active {
    color: white;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border: none;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.25);
}

/* ============= PAGE HEADER STYLING ============= */
.page-header {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--gray-medium);
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--secondary-color);
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}

.page-header p {
    color: #6c757d;
    font-weight: 500;
    margin: 0;
}

/* ============= QUICK ACTIONS ============= */
.quick-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.quick-actions .btn {
    border-radius: 10px;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 10px 18px;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.quick-actions .btn:hover {
    transform: translateY(-2px);
}

/* ============= SECTION HEADERS ============= */
h2 {
    font-weight: 800;
    color: var(--secondary-color);
    margin-bottom: 20px;
    font-size: 1.4rem;
    letter-spacing: -0.3px;
}

h3 {
    font-weight: 700;
    color: var(--secondary-color);
    margin-bottom: 16px;
    font-size: 1.1rem;
}

/* ============= DROPDOWN MENU ============= */
.dropdown-menu {
    border: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    padding: 6px 0;
}

.dropdown-item {
    padding: 10px 16px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background-color: rgba(var(--primary-rgb), 0.1);
    color: var(--primary-color);
}

.dropdown-item i {
    margin-right: 8px;
    min-width: 16px;
}

/* ============= LINKS ============= */
a {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

a:hover {
    color: var(--primary-color);
    text-decoration: none;
}

/* ============= BTN GROUP ============= */
.btn-group {
    gap: 8px;
    flex-wrap: wrap;
}

.btn-group .btn {
    border-radius: 8px;
}

.nav-tabs .nav-link.active {
    background-color: transparent;
    border-bottom-color: var(--primary-color);
    color: var(--primary-color);
    border: none;
}

.tab-content {
    padding: 1.5rem 0;
}

/* ============= DOCUMENT GENERATION STYLES ============= */
.document-card {
    border: 1px solid rgba(var(--primary-rgb), 0.15);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.07);
}

.document-preview {
    padding: 20px;
    margin-top: 20px;
    background-color: var(--card-bg);
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.print-heading {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
}

/* Compact delivery status controls used in payment_tracking and delivery lists */
.delivery-control {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.delivery-control .delivery-badge {
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    line-height: 1;
}
.btn-edit-delivery {
    padding: 6px 8px;
    line-height: 1;
    min-width: 36px;
}
.delivery-editor-controls {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.delivery-status-select {
    min-width: 120px;
    padding: 4px 6px;
    font-size: 0.85rem;
}
.delivery-control .btn-sm {
    padding: 5px 8px;
}

/* Ensure icons inside small table buttons are perfectly centered */
.table .btn-sm i,
.table a.btn-sm i {
    display: inline-block;
    width: 100%;
    text-align: center;
    line-height: 36px; /* match .btn-sm height */
    vertical-align: middle;
}

@media (max-width: 768px) {
    .delivery-control { flex-wrap: wrap; }
    .delivery-status-select { min-width: 100px; }
}

/* Standardize small buttons inside tables to reduce visual clutter */
.table .btn-sm,
.table a.btn-sm {
    width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    font-size: 0.92rem !important;
}

/* Allow slightly larger action buttons when they have text */
.table .btn-sm.wide,
.table a.btn-sm.wide {
    width: auto !important;
    height: 36px !important;
    min-width: 110px !important;
    padding: 6px 10px !important;
}

.table .btn-sm.wide i,
.table a.btn-sm.wide i {
    width: auto;
    line-height: 1;
    margin-right: 6px;
}

/* Ensure icon buttons don't overflow */
.table .btn-sm i,
.table a.btn-sm i {
    font-size: 14px;
    line-height: 1;
}

/* Tighter spacing for delivery-control items */
.delivery-control { gap: 8px; }
.delivery-control .delivery-badge { min-height: 30px; }
.delivery-control .btn-edit-delivery { width: 36px; height: 36px; padding: 0; }
.delivery-editor-controls .btn { width: 36px; height: 36px; padding: 0; }
.btn-square { width: 36px !important; height: 36px !important; padding: 0 !important; display: inline-flex !important; align-items: center !important; justify-content: center !important; border-radius: 10px !important; }
.action-buttons { display: grid; grid-template-columns: repeat(2, minmax(36px, 1fr)); gap: 8px; justify-items: center; }

@media (max-width: 1200px) {
    #deliveries-table tbody tr td {
        white-space: normal;
    }
}

/* Product list table polish */
.product-table {
    font-size: 0.92rem;
}
.product-table th,
.product-table td {
    vertical-align: middle;
}
.product-table td:nth-last-child(1),
.product-table th:nth-last-child(1) {
    white-space: nowrap;
}
.product-actions-cell {
    min-width: max-content;
}
.product-table .product-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}
.product-actions .btn-group {
    flex: 0 0 auto;
}
.product-actions .btn {
    flex: 0 0 auto;
}
.product-table .badge {
    white-space: nowrap;
}
.product-table code {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

@media (max-width: 992px) {
    .product-actions-cell {
        min-width: max-content;
    }
}

.label-card {
    min-height: 220px;
}

.label-content {
    background: linear-gradient(180deg, #ffffff 0%, #f7f7f7 100%);
    border: 1px dashed rgba(34, 34, 34, 0.14);
    border-radius: 14px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
    min-height: 100%;
}

.label-content h5 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.barcode-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #ffffff;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid #e9ecef;
}

.barcode-svg {
    width: 100%;
    height: auto;
}

/* ============================================================
   ============= PRINT STYLES - FULL WIDTH, SEPARATED =========
   ============================================================ */
@media print {
    /* Page setup - Letter size with minimal margins for max width */
    @page {
        size: letter portrait;
        margin: 10mm 8mm 10mm 8mm;
    }

    /* Reset base */
    html, body {
        background: #ffffff !important;
        color: #000000 !important;
        margin: 0 !important;
        padding: 0 !important;
        font-size: 10pt !important;
        line-height: 1.35 !important;
        width: 100% !important;
        height: auto !important;
    }

    /* Hide all UI chrome */
    nav, .sidebar, footer, .btn, .page-header, .form-control, 
    .form-select, .form-label, .card-header, .card-body > form, 
    .alert, .dropdown, .navbar, .navbar-expand-lg, .navbar-nav, 
    .sidebar-header, .dropdown-menu, .column-toggles, .btn-group,
    .quick-actions, .nav-tabs, .tab-content, .pagination,
    .stat-widget, .modal, .modal-backdrop, .toast,
    .container-fluid > .row > .col-lg-2,
    .d-none, .d-lg-block, .document-card > .card-header,
    .document-card > .card-body > form,
    .document-card > .card-body > .column-toggles,
    .document-card > .card-body > .btn-success {
        display: none !important;
    }

    /* Reset layout to FULL WIDTH */
    .container-fluid, .container, .row, .col-lg-10, 
    .col-xl-6, .col-md-6, .col-md-8, .col-md-4,
    .col-6, .col-12, .col-lg-6, .col-xl-12,
    .col-xl-6 > .card, .col-xl-6 > .document-card {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        left: 0 !important;
        right: 0 !important;
    }

    .card, .document-card, .document-preview, 
    .label-card, .label-content {
        width: 100% !important;
        max-width: 100% !important;
        box-shadow: none !important;
        border: none !important;
        background: #ffffff !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .card-body {
        padding: 0 !important;
        width: 100% !important;
    }

    /* Document preview - full width, no constraints */
    #deliveryPrintSection,
    #invoicePrintSection,
    #stockTakePrintSection,
    #barcodePrintSection {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        box-sizing: border-box !important;
    }

    /* All direct children of document preview stretch full width */
    #deliveryPrintSection > div,
    #invoicePrintSection > div,
    #stockTakePrintSection > div {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* ===== COMPANY HEADER - Centered, standalone ===== */
    #deliveryPrintSection .receipt-copy > div:first-child {
        text-align: center !important;
        margin-bottom: 8px !important;
        padding-bottom: 8px !important;
        border-bottom: 2px solid #333 !important;
        width: 100% !important;
    }

    #deliveryPrintSection .receipt-copy > div:first-child h1 {
        font-size: 26pt !important;
        margin: 0 !important;
        color: var(--primary-color) !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    #deliveryPrintSection .receipt-copy > div:first-child p {
        font-size: 9pt !important;
        margin: 2px 0 0 0 !important;
        color: #666 !important;
    }

    /* ===== RECEIPT HEADER - Separate from company name ===== */
    #deliveryPrintSection .receipt-copy > div:nth-child(3) {
        margin-bottom: 10px !important;
        padding-bottom: 8px !important;
        border-bottom: 2px solid #333 !important;
        width: 100% !important;
    }

    #deliveryPrintSection .receipt-copy > div:nth-child(3) > div {
        display: flex !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        width: 100% !important;
    }

    #deliveryPrintSection .receipt-copy > div:nth-child(3) h2 {
        font-size: 16pt !important;
        margin: 0 0 4px 0 !important;
        color: #000 !important;
        font-weight: bold !important;
    }

    #deliveryPrintSection .receipt-copy > div:nth-child(3) p {
        font-size: 9pt !important;
        margin: 2px 0 !important;
        color: #666 !important;
    }

    #deliveryPrintSection .receipt-copy > div:nth-child(3) strong {
        font-size: 10pt !important;
    }

    #deliveryPrintSection .receipt-copy > div:nth-child(3) span {
        font-size: 9pt !important;
    }

    /* ===== DELIVERY DETAILS ROW ===== */
    #deliveryPrintSection .receipt-copy > div:nth-child(4) {
        display: flex !important;
        justify-content: space-between !important;
        margin-bottom: 12px !important;
        font-size: 9pt !important;
        width: 100% !important;
    }

    #deliveryPrintSection > div:nth-child(3) p {
        margin: 2px 0 !important;
        font-size: 9pt !important;
    }

    /* ===== TABLE - Full width ===== */
    #deliveryPrintSection .table-responsive {
        margin-bottom: 12px !important;
        width: 100% !important;
        overflow: visible !important;
    }

    #deliveryPrintSection .table {
        font-size: 9pt !important;
        width: 100% !important;
        border-collapse: collapse !important;
        margin-bottom: 0 !important;
        table-layout: auto !important;
    }

    #deliveryPrintSection .table thead th {
        padding: 5px 6px !important;
        font-size: 8pt !important;
        background: #f0f0f0 !important;
        color: #000 !important;
        border: 1px solid #333 !important;
        font-weight: bold !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    #deliveryPrintSection .table tbody td {
        padding: 4px 6px !important;
        font-size: 8pt !important;
        border: 1px solid #ccc !important;
        vertical-align: middle !important;
    }

    #deliveryPrintSection .table tbody tr {
        border-bottom: 1px solid #ccc !important;
    }

    /* Prevent table rows from breaking */
    #deliveryPrintSection .table tr {
        page-break-inside: avoid !important;
    }

    /* ===== NOTES SECTION - Directly under table, LEFT side ===== */
    #deliveryPrintSection .notes-section {
        width: 100% !important;
        margin-bottom: 15px !important;
        margin-top: 5px !important;
    }

    #deliveryPrintSection .notes-section p:first-child {
        font-size: 9pt !important;
        margin: 0 0 4px 0 !important;
        font-weight: bold !important;
    }

    #deliveryPrintSection .notes-section .notes-box {
        border: 1px solid #ccc !important;
        padding: 8px !important;
        min-height: 50px !important;
        font-size: 8pt !important;
        color: #333 !important;
        width: 60% !important;
    }

    /* ===== TOTAL AMOUNT - Right aligned, beside or under notes ===== */
    #deliveryPrintSection .total-section {
        text-align: right !important;
        margin-left: auto !important;
        margin-bottom: 15px !important;
    }

    #deliveryPrintSection .total-section p:first-child {
        font-size: 10pt !important;
        margin: 0 0 4px 0 !important;
    }

    #deliveryPrintSection .total-section .total-amount {
        font-size: 14pt !important;
        font-weight: bold !important;
        color: #000 !important;
        border-top: 2px solid #000 !important;
        padding-top: 4px !important;
        margin-top: 6px !important;
        display: inline-block !important;
        min-width: 140px !important;
    }

    /* ===== SIGNATURE SECTION - Bottom of page ===== */
    #deliveryPrintSection .signature-section {
        margin-top: 20px !important;
        width: 100% !important;
    }

    #deliveryPrintSection .signature-section > div {
        display: flex !important;
        justify-content: space-between !important;
        width: 100% !important;
    }

    #deliveryPrintSection .signature-section .sig-block {
        margin-bottom: 12px !important;
    }

    #deliveryPrintSection .signature-section .sig-label {
        font-size: 9pt !important;
        font-weight: bold !important;
        margin: 0 0 25px 0 !important;
    }

    #deliveryPrintSection .signature-section .sig-line {
        border-top: 1px solid #000 !important;
        width: 150px !important;
        margin-bottom: 2px !important;
    }

    #deliveryPrintSection .signature-section .sig-caption {
        font-size: 7pt !important;
        color: #666 !important;
        margin: 0 !important;
    }

    /* Right-aligned signature block */
    #deliveryPrintSection .signature-section .sig-right {
        text-align: right !important;
    }

    #deliveryPrintSection .signature-section .sig-right .sig-line {
        margin-left: auto !important;
    }

    /* ===== INVOICE SECTION ===== */
    #invoicePrintSection .print-heading {
        margin-bottom: 10px !important;
        padding-bottom: 8px !important;
        border-bottom: 1px solid #333 !important;
    }

    #invoicePrintSection .table {
        font-size: 9pt !important;
        width: 100% !important;
    }

    #invoicePrintSection .table th,
    #invoicePrintSection .table td {
        padding: 5px 6px !important;
        font-size: 8pt !important;
        border: 1px solid #ccc !important;
    }

    /* ===== STOCK TAKE ===== */
    #stockTakePrintSection .table {
        font-size: 9pt !important;
        width: 100% !important;
    }

    #stockTakePrintSection .table th,
    #stockTakePrintSection .table td {
        padding: 5px 6px !important;
        font-size: 8pt !important;
        border: 1px solid #ccc !important;
    }

    /* ===== BARCODE LABELS ===== */
    .label-content {
        border: 1px solid #ccc !important;
        padding: 10px !important;
        margin-bottom: 10px !important;
        page-break-inside: avoid !important;
    }

    .barcode-wrapper {
        border: 1px solid #ccc !important;
        padding: 5px !important;
    }

    /* ===== GENERAL PRINT OVERRIDES ===== */
    h1 { font-size: 26pt !important; margin: 0 0 4px 0 !important; }
    h2 { font-size: 16pt !important; margin: 0 0 4px 0 !important; }
    h3 { font-size: 11pt !important; margin: 0 0 4px 0 !important; }
    h4 { font-size: 10pt !important; margin: 0 0 2px 0 !important; }
    h5 { font-size: 9pt !important; margin: 0 0 2px 0 !important; }
    p { margin: 2px 0 !important; font-size: 9pt !important; }

    /* Ensure colors print */
    .badge, .btn, .card-header, .table thead {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Dark theme override for print */
    body.dark-theme .document-preview,
    body.dark-theme .label-content,
    body.dark-theme .card,
    body.dark-theme .table {
        background: #ffffff !important;
        color: #000000 !important;
    }

    body.dark-theme .table thead th {
        background: #f0f0f0 !important;
        color: #000 !important;
    }

    /* Prevent page breaks inside */
    .document-preview,
    .label-content,
    .label-card,
    .print-heading,
    .table-responsive {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .document-preview {
        page-break-after: avoid !important;
    }
}

.delivery-receipt-heading-row {
    flex: 1 1 100%;
    width: 100%;
}

.delivery-receipt-title {
    margin-left: auto;
    text-align: right;
}

/* Theme legacy inline sidebar accents without requiring page-specific colors. */
.sidebar [style*="color: #ff8c00"] {
    color: var(--primary-color) !important;
}

.sidebar [style*="rgba(255,140,0,0.2)"] {
    border-color: rgba(var(--primary-rgb), 0.2) !important;
}

.sidebar [style*="rgba(255,140,0,0.1)"] {
    background: rgba(var(--primary-rgb), 0.1) !important;
}

/* ============= MOBILE LAYOUT ============= */
.mobile-menu-toggle {
    color: var(--primary-color);
    border: 1px solid rgba(var(--primary-rgb), 0.55);
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
}

.mobile-sidebar-offcanvas {
    width: min(88vw, 340px);
    background: var(--secondary-dark);
    color: var(--text-light);
}

.mobile-sidebar-offcanvas .offcanvas-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: #fff;
}

.mobile-sidebar {
    display: block;
    min-height: 100%;
    box-shadow: none;
}

@media (min-width: 992px) {
    .mobile-menu-toggle,
    .mobile-sidebar-offcanvas {
        display: none !important;
    }
}

@media (max-width: 991.98px) {
    .container-fluid > .row > .col-lg-10,
    .col-lg-10 {
        width: 100% !important;
    }

    nav.navbar {
        padding: 0.65rem 0;
    }

    nav.navbar > .container-fluid {
        gap: 0.5rem;
        padding-right: 0.75rem !important;
        padding-left: 0.75rem !important;
    }

    .mobile-menu-toggle {
        display: inline-flex;
        order: 0;
    }

    .navbar-brand {
        order: 1;
        margin-right: auto;
    }

    .navbar-toggler {
        order: 2;
        min-width: 44px;
        min-height: 44px;
    }

    .navbar-collapse {
        order: 3;
        flex-basis: 100%;
    }

    .navbar-nav {
        padding: 0.5rem 0;
    }

    .navbar-nav .nav-link {
        min-height: 44px;
        margin: 0;
        padding: 0.65rem 0.75rem;
    }

    .navbar-nav .nav-link::after {
        bottom: 0;
    }

    .navbar-nav .nav-item > .btn {
        min-height: 44px;
        margin: 0.25rem 0 !important;
        width: 100%;
    }
}

@media (max-width: 768px) {
    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    .col-lg-10 > .p-4 {
        padding: 1rem !important;
    }

    h1,
    .h1 {
        font-size: clamp(1.65rem, 8vw, 2.1rem);
    }

    h2,
    .h2 {
        font-size: clamp(1.4rem, 7vw, 1.8rem);
    }

    .card {
        padding: 0;
    }

    .card-body,
    .card-header,
    .card-footer {
        padding: 1rem;
    }

    .row > [class*="col-"] {
        min-width: 0;
    }

    .table-responsive {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive:focus-visible {
        outline: 3px solid rgba(var(--primary-rgb), 0.4);
        outline-offset: 2px;
    }

    .table-responsive > .table {
        width: max-content;
        min-width: 100%;
        margin-bottom: 0;
    }

    .table th,
    .table td {
        white-space: nowrap;
        vertical-align: middle;
    }

    .form-control,
    .form-select,
    .select2-container,
    .input-group {
        width: 100% !important;
        max-width: 100%;
    }

    .form-control,
    .form-select,
    .select2-container .select2-selection {
        min-height: 44px;
        font-size: 16px;
    }

    textarea.form-control {
        min-height: 120px;
    }

    .btn:not(.btn-close),
    button:not(.btn-close),
    [role="button"] {
        min-height: 44px;
    }

    .btn-group,
    .quick-actions,
    .filters,
    .product-actions,
    .delivery-editor-controls {
        max-width: 100%;
        flex-wrap: wrap;
    }

    .product-table .product-actions {
        flex-wrap: nowrap;
    }

    .filters {
        align-items: stretch;
    }

    .filters > * {
        flex: 1 1 100%;
    }

    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.25rem;
    }

    .pagination .page-link {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-footer {
        gap: 0.5rem;
    }

    .modal-footer > .btn {
        flex: 1 1 auto;
        margin: 0;
    }

    .offcanvas {
        max-width: 90vw;
    }

    footer {
        text-align: center;
    }

    footer .text-end {
        text-align: center !important;
    }

    .scroll-top-button {
        right: 12px !important;
        bottom: 12px !important;
    }
}
