/* --- DASHBOARD REDESIGN STYLES (Strictly Scoped) --- */
/* PREFIX: #sales-manager-app */

#sales-manager-app {
    /* Scoped Variables */
    --primary-color: #5600ab;
    --primary-dark: #410082;
    --secondary-bg: #f8f9fa;
    --card-bg: #ffffff;
    --text-main: #2c3e50;
    --text-muted: #6c757d;
    --success-color: #00b09b;
    --gradient-start: #667eea;
    --gradient-end: #764ba2;
    --input-grey-bg: #f8fafc; /* Standardized Light Grey */

    /* Universal Box Variables (Requested Design) */
    --box-bg: #ffffff;
    --box-padding: 1.5rem;
    --box-radius: 1rem; /* approx 16px */
    --box-shadow: 0 4px 20px rgba(0,0,0,0.03);

    /* Base styles */
    background-color: #f0f2f5;
    color: var(--text-main);
    min-height: 100%;
    padding-bottom: 3rem;
    font-family: 'Varela Round', sans-serif !important;
}

/* --- GLOBAL INPUT & BUTTON STYLING (Force Consistency) --- */
#sales-manager-app input.form-control,
#sales-manager-app select.form-control,
#sales-manager-app select.form-select,
#sales-manager-app textarea.form-control {
    border-radius: 8px !important;
    background-color: var(--input-grey-bg) !important; /* Force same light grey */
    border: 1px solid #e2e8f0;
}

/* Standardize Height for single-line inputs */
#sales-manager-app input.form-control,
#sales-manager-app select.form-control,
#sales-manager-app select.form-select {
    height: 45px !important;
    min-height: 45px !important;
}

#sales-manager-app .btn,
#sales-manager-app .btn-action {
    border-radius: 8px !important;
}

/* --- CUSTOM COPY BUTTON (Icon Only, Transparent, No Outline) --- */
#sales-manager-app .btn-icon-only {
    background-color: transparent !important;
    border: none !important; /* REMOVED OUTLINE */
    color: #6c757d !important;
    transition: transform 0.1s ease, background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 45px; /* Match input height */
    width: 45px;
    box-shadow: none !important;
}

#sales-manager-app .btn-icon-only:hover {
    background-color: rgba(0,0,0,0.03) !important; /* Very subtle hover */
    color: #343a40 !important; 
}

#sales-manager-app .btn-icon-only:active {
    transform: translateY(2px); /* Click effect */
    background-color: rgba(0,0,0,0.08) !important; /* Darker on click */
}

/* --- FORCE FONT FAMILY ON TABLES --- */
#sales-manager-app .dataTables_wrapper,
#sales-manager-app table.special-sales-table,
#sales-manager-app table.special-sales-table th,
#sales-manager-app table.special-sales-table td,
#sales-manager-app table.special-sales-table input {
    font-family: 'Varela Round', sans-serif !important;
}

/* --- Universal White Box Class & Overrides --- */
#sales-manager-app .card,
#sales-manager-app .universal-box {
    background: var(--box-bg) !important;
    padding: var(--box-padding) !important;
    border-radius: var(--box-radius) !important;
    box-shadow: var(--box-shadow) !important;
    border: none !important;
    margin-bottom: 1.5rem;
    transition: box-shadow 0.2s ease;
}

/* Ensure card body doesn't add double padding */
#sales-manager-app .card .card-body {
    padding: 0 !important;
    background-color: transparent;
}

/* --- Navbar --- */
#sales-manager-app .dashboard-nav {
    background-color: var(--card-bg);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    padding: 1rem 0;
    margin-bottom: 2rem;
    /* FIX: Correct Z-Index logic. 
       Bootstrap Modals are 1050. 
       Sticky content should be lower than modals but higher than content. */
    position: sticky;
    top: 0;
    z-index: 1020 !important; 
}

/* FIX: Ensure Dropdowns are above nav but below modals */
#sales-manager-app .dropdown-menu {
    z-index: 1030 !important;
}

#sales-manager-app .nav-brand-text {
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 1.25rem;
}

#sales-manager-app .user-pill {
    background: #f0f2f5;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#sales-manager-app .user-pill:hover {
    background: #e2e6ea;
}

#sales-manager-app .avatar-small {
    width: 32px;
    height: 32px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

/* --- Card Headers --- */
#sales-manager-app .card-header {
    background: transparent;    
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding: 0 0 1rem 0;
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#sales-manager-app .card-header.bg-transparent {
    background-color: transparent !important;
}

/* --- Stat Cards --- */
#sales-manager-app .stat-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
}

#sales-manager-app .stat-icon-wrapper {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    background: rgba(86, 0, 171, 0.1);
    color: var(--primary-color);
}

#sales-manager-app .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
    color: #2c3e50;
}

#sales-manager-app .stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    font-weight: 600;
}

#sales-manager-app .stat-sub {
    font-size: 0.8rem;
    color: var(--success-color);
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* --- Action Card Gradient --- */
#sales-manager-app .card-gradient-action {
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%) !important;
    color: white;
    text-align: center;
    padding: 1.5rem !important;
    border-radius: 1rem !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.03);
}

#sales-manager-app .card-gradient-action:hover {
    box-shadow: 0 8px 25px rgba(118, 75, 162, 0.3) !important;
}

/* --- Action Buttons --- */
#sales-manager-app .btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px; /* Reduced gap */
    padding: 0.5rem 1rem;
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.9rem;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
    text-decoration: none;
    border: 1px solid transparent;
}

#sales-manager-app .btn-primary-custom {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}
#sales-manager-app .btn-primary-custom:hover {
    background-color: var(--primary-dark);
    color: white;
}

#sales-manager-app .btn-light-custom {
    background-color: white;
    border-color: #e2e8f0;
    color: var(--text-main);
}
#sales-manager-app .btn-light-custom:hover {
    background-color: #f8f9fa;
    border-color: #cbd5e0;
    color: var(--text-main);
}

/* Table Actions Buttons (Ghost Style) */
#sales-manager-app .btn-table-action {
    background-color: transparent !important;
    border: 1px solid transparent !important;
    color: #000000 !important;
    box-shadow: none !important;
    font-weight: 600;
}
#sales-manager-app .btn-table-action:hover {
    background-color: rgba(0,0,0,0.05) !important;
}

/* FORCE BLACK TEXT/ICONS FOR TABLE ACTION BUTTONS (Always) */
#sales-manager-app table.special-sales-table .btn i,
#sales-manager-app table.special-sales-table .btn span,
#sales-manager-app .btn-table-action i,
#sales-manager-app .btn-table-action span {
    color: #000000 !important;
}

/* NEW: FORCE BLACK TEXT AND ICONS INSIDE TABLE DROPDOWNS ("Handlinger") */
#sales-manager-app table.special-sales-table .dropdown-menu .dropdown-item,
#sales-manager-app table.special-sales-table .dropdown-menu .dropdown-item i {
    color: #000000 !important;
}

/* UPDATED: Remove background on hover for dropdown items */
#sales-manager-app table.special-sales-table .dropdown-menu .dropdown-item:hover,
#sales-manager-app table.special-sales-table .dropdown-menu .dropdown-item:focus {
    background-color: #fff !important; /* Force white/transparent */
    color: #000 !important; /* Maintain black text */
    text-decoration: none;
}

#sales-manager-app .copy-box {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1rem;
    font-family: monospace;
    font-size: 0.9rem;
    color: #495057;
    position: relative;
    margin-top: 0.5rem;
}

/* --- Fancy Tabs --- */
#sales-manager-app .fancy-tab-container {
    background-color: #f0f2f5;
    padding: 5px;
    border-radius: 50px;
    display: inline-flex;
}

#sales-manager-app .fancy-btn {
    border: 1px solid transparent;
    background-color: transparent;
    color: #6c757d;
    font-family: 'Varela Round', sans-serif !important;
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 10px 24px;
    margin: 0;
    border-radius: 40px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: none;
    outline: none !important;
    text-decoration: none !important;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

#sales-manager-app .fancy-btn:hover {
    color: #343a40;
    background-color: rgba(0,0,0,0.03);
}

#sales-manager-app .fancy-btn.active {
    background-color: #ffffff;
    color: var(--primary-color) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* --- DataTables Filter & Header Styles --- */
#sales-manager-app .dataTables_filter {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 0.5rem;
}
#sales-manager-app .dataTables_filter label {
    margin-bottom: 0 !important;
}

#sales-manager-app .card-header-tabs {
    background: transparent;
    padding-bottom: 0;
    margin-bottom: 0;
}

/* ==========================================================================
MODERN REDESIGNED TABLES
========================================================================== */

#sales-manager-app .table-responsive {
    background: #fff;
    /* CHANGED: Disable horizontal scroll on the container to force DataTables hidden column behavior */
    overflow-x: visible !important;
    /* NEW: ADJUST TABLE PADDING FOR MOBILE */
    padding-left: 0 !important;
    padding-right: 0 !important;
    /* Padding top and bottom are inherited from p-3 (1rem) */
}

/* FORCE STANDARD TABLE DISPLAY */
#sales-manager-app table.special-sales-table {
    width: 100% !important;
    margin-bottom: 0 !important;
    border-collapse: collapse !important;
    table-layout: auto !important; 
    display: table !important;
}

#sales-manager-app table.special-sales-table tbody {
    display: table-row-group !important;
}

#sales-manager-app table.special-sales-table tr {
    display: table-row !important;
    flex-wrap: nowrap !important; /* Safety override */
}

#sales-manager-app table.special-sales-table thead th {
    background-color: #fcfcfd;
    color: #64748b;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    border-top: none !important;
    vertical-align: middle;
    white-space: nowrap;
    text-align: left !important;
}

/* Fix width issues */
#sales-manager-app table.special-sales-table td.col-key-name,
#sales-manager-app table.special-sales-table th.col-key-name {
    white-space: normal !important; /* Allow wrapping */
    min-width: 150px;
}

#sales-manager-app table.special-sales-table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    color: #334155;
    font-weight: 500;
    font-size: 0.95rem;
    border-bottom: 1px solid #f1f5f9;
    background-color: #fff;
    transition: background-color 0.2s ease;
    text-align: left !important;
    /* display: table-cell !important; REMOVED TO FIX HIDDEN COLUMNS */
}

#sales-manager-app table.special-sales-table tbody tr:hover td {
    background-color: #f8fafc;
}

#sales-manager-app table.special-sales-table td a:not(.btn) {
    color: var(--primary-color) !important;
    text-decoration: none;
    font-weight: 600;
}
#sales-manager-app table.special-sales-table td a:not(.btn):hover {
    color: var(--primary-dark) !important;
    text-decoration: underline;
}

#sales-manager-app table.special-sales-table .btn {
    background-color: transparent !important;
    border-color: transparent !important;
    color: #000000 !important;
    box-shadow: none !important;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

#sales-manager-app table.special-sales-table .btn:hover {
    background-color: rgba(0,0,0,0.05) !important;
}

#sales-manager-app table.special-sales-table tfoot th,
#sales-manager-app table.special-sales-table tfoot td {
    background-color: #f8fafc;
    border-top: 2px solid #e2e8f0;
    padding: 12px 16px;
    color: #1e293b;
    font-weight: 700;
    font-size: 1rem;
    text-align: left !important;
}

/* --- SPECIFIC COMPONENT STYLING --- */

/* UPDATED: Added margin-right for image spacing */
#sales-manager-app #Producttable td img {
    width: 48px !important;
    height: 48px !important;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border: 1px solid #f1f5f9;
    margin-right: 15px !important; /* Increased space between picture and text */
}

#sales-manager-app #Producttable input.form-control {
    text-align: left;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 8px 12px;
    border-radius: 8px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-color: transparent;
    border: 1px solid transparent;
    box-shadow: none;
    width: 100%;
    min-width: 80px; /* Reduced to help with width issues */
    max-width: none;
    margin-left: 0;
    font-family: 'Varela Round', sans-serif !important;
}

#sales-manager-app #Producttable input.form-control:read-only,
#sales-manager-app #Producttable input.form-control:disabled {
    background-color: transparent !important;
    border-color: transparent !important;
    color: #475569;
    cursor: default;
}

#sales-manager-app #Producttable input.form-control:not(:read-only):not(:disabled) {
    background-color: #fff !important;
    border: 1px solid #cbd5e1 !important;
    color: #1e293b;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

#sales-manager-app #Producttable input.form-control:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 3px rgba(86, 0, 171, 0.1) !important;
    background-color: #fff !important;
}

#sales-manager-app #Producttable .poprony h5 {
    font-size: 0.95rem !important;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 2px;
}
#sales-manager-app #Producttable .poprony span {
    font-size: 0.8rem !important;
    color: #64748b;
}

/* --- DATATABLES CONTROLS RE-STYLING (Scoped) --- */

#sales-manager-app .dataTables_wrapper {
    padding: 0;
    margin-top: 1rem;
}

/* Search Input */
#sales-manager-app .dataTables_filter input {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    background-color: var(--input-grey-bg) !important;
    transition: background-color 0.2s, border-color 0.2s;
    min-height: 45px !important; /* Ensure height alignment */
    height: 45px !important;
}
#sales-manager-app .dataTables_filter input:focus {
    background-color: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(86, 0, 171, 0.1);
    outline: none;
}

/* Dropdown (Length Menu) - HIDE ARROW AND CENTER */
#sales-manager-app .dataTables_length select {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.5rem 1rem !important; /* Standard padding */
    font-size: 0.9rem;
    background-color: var(--input-grey-bg) !important;
    cursor: pointer;
    min-height: 45px !important; 
    height: 45px !important;
    transition: background-color 0.2s, border-color 0.2s;
    
    /* HIDE ARROW */
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-image: none !important;
    text-align: center;
}
#sales-manager-app .dataTables_length select:focus {
    background-color: #fff;
    border-color: var(--primary-color);
    outline: none;
}

/* NEW: Finished Filter Dropdown Style (Exact Match to Search) */
#sales-manager-app #finished_filter {
    background-color: var(--input-grey-bg) !important;  /* Match Search Background */
    border: 1px solid #e2e8f0;  /* Match Search Border */
    /* FORCE RADIUS */
    border-radius: 8px !important; 
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    cursor: pointer;
    /* Force exact height match */
    min-height: 45px !important;
    height: 45px !important;
    transition: background-color 0.2s, border-color 0.2s;
    margin-right: 10px; /* Spacing from button */
    /* Override potential bootstrap sm sizing */
    line-height: 1.5;
    margin-left: 10px; /* Add margin left for spacing next to button */
    
    /* FIXED: Adjusted width as requested */
    width: auto;
    min-width: unset; 
}
#sales-manager-app #finished_filter:focus {
    background-color: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(86, 0, 171, 0.1);
    outline: none;
}

/* --- PAGINATION CENTERING & STYLING --- */
/* Center the pagination container */
#sales-manager-app .dataTables_paginate {
    display: flex;
    justify-content: center;
    width: 100%;
}

/* Ensure the UL inside behaves correctly */
#sales-manager-app .dataTables_paginate .pagination {
    display: flex;
    justify-content: center; /* Center buttons */
    margin-top: 0;
    margin-bottom: 0;
    gap: 5px;
}

#sales-manager-app .pagination .page-item .page-link {
    border: 1px solid #e2e8f0;
    border-radius: 6px !important;
    color: var(--text-main);
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 0.85rem;
    background: #fff;
    padding: 0 0.5rem;
    transition: background-color 0.2s, color 0.2s;
}

#sales-manager-app .pagination .page-item.active .page-link {
    background-color: var(--primary-color) !important;
    color: white !important;
    border-color: var(--primary-color) !important;
    box-shadow: none;
}

#sales-manager-app .pagination .page-item:not(.active) .page-link:hover {
    background-color: #f8fafc !important;
    color: var(--primary-color) !important;
    border-color: #cbd5e1;
}

#sales-manager-app .dataTables_info {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center; /* Center the text */
    padding-top: 0.5rem;
}

/* NEW: FORCE "Vis [10] resultater" ON ONE LINE */
#sales-manager-app .dataTables_length label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem; /* Space between text and select */
    width: 100%; /* Ensure it takes full centering width */
    margin-bottom: 0;
}

/* --- RESPONSIVE ICONS (+/-) --- */
#sales-manager-app table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before,  
#sales-manager-app table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control:before {
    display: none;
}

#sales-manager-app table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control,  
#sales-manager-app table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control {
    position: relative;
    /* UPDATED: Increased padding to accommodate larger plus icon space */
    padding-left: 50px !important;
    cursor: pointer;
}

/* Plus Icon */
#sales-manager-app table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:after,    
#sales-manager-app table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control:after {
    font-family: 'Material Icons';
    content: "\e145";
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    background: #f1f5f9;
    color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background-color 0.2s;
    z-index: 5; /* Ensure icon is above image if overlap occurs */
}

/* Minus Icon */
#sales-manager-app table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td.dtr-control:after {
    content: "\e15b";
    background: #e2e8f0;
    color: #475569;
}

/* --- MOBILE MODAL LIST STYLING (MOVED GLOBALLY) --- */
/* FIXED: Removed #sales-manager-app prefix to support modals appended to body */
/* FIXED: Added !important to enforce widths over Bootstrap grid */

#mobileProductEditModal .sales-mobile-modal-item {
    display: flex;
    align-items: center; /* Vertical Center */
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
    /* Ensure items stay on one row */
    flex-wrap: nowrap;
    justify-content: space-between; /* Spread evenly */
}

#mobileProductEditModal .sales-mobile-modal-img-col {
    width: 30% !important; /* STRICT 30% */
    flex: 0 0 30% !important;
    padding-right: 10px; /* Spacing inside */
    margin-right: 0 !important; /* Remove external margin */
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

/* UPDATED: Added !important to override global img max-width */
#mobileProductEditModal .sales-mobile-modal-img {
    width: 100% !important; /* Fit within col */
    max-width: 100% !important;
    height: auto !important;
    aspect-ratio: 1/1; /* Square aspect ratio */
    object-fit: cover;
    border-radius: 8px;
    background-color: #fff;
    border: 1px solid #e2e8f0;
}

#mobileProductEditModal .sales-mobile-modal-text-col {
    width: 50% !important; /* STRICT 50% */
    flex: 0 0 50% !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-right: 5px;
    overflow: hidden; /* Prevent text overflow */
}

#mobileProductEditModal .sales-mobile-modal-name {
    font-weight: 700;
    color: #1e293b;
    font-size: 0.9rem;
    margin-bottom: 4px; /* Space between name and desc */
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#mobileProductEditModal .sales-mobile-modal-desc {
    color: #6c757d; /* Light Grey */
    font-size: 0.8rem;
    line-height: 1.2;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#mobileProductEditModal .sales-mobile-modal-input-col {
    width: 20% !important; /* STRICT 20% */
    flex: 0 0 20% !important;
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
}

#mobileProductEditModal .sales-mobile-modal-input {
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
    height: 45px !important;
    width: 100%;
    padding: 5px;
}


/* --- NEW: TABLET/SMALL DESKTOP ADJUSTMENTS --- */
/* Forces columns to hide into Plus Icon earlier to prevent overflow */
@media (max-width: 1200px) {
    #sales-manager-app table.special-sales-table {
        /* Force table to respect container width, triggering DataTables collapse logic */
        table-layout: fixed !important; 
        width: 100% !important;
    }
}

/* Mobile adjustments (Global for < 768px) */
@media (max-width: 768px) {
    
    /* UPDATED: Show Table Header on Mobile (As Requested) */
    #sales-manager-app table.special-sales-table thead {
        display: table-header-group !important;
    }

    /* Wrap filters properly on mobile */
    #sales-manager-app .dataTables_filter {
        flex-wrap: wrap; /* Allow wrapping */
        width: 100%;
        gap: 10px;
        margin-bottom: 10px;
    }
    
    /* NEW: CODEXTABLE MOBILE LAYOUT (Side-by-Side Filter & Search) */
    #sales-manager-app #codextable_wrapper .dataTables_filter {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    /* Row 1: Action Buttons take full width */
    #sales-manager-app #codextable_wrapper #participants-actions {
        width: 100% !important;
        margin-bottom: 5px;
    }

    /* Row 2: Filter and Search Side-by-Side */
    /* Filter Dropdown */
    #sales-manager-app #codextable_wrapper #finished_filter {
        width: calc(50% - 5px) !important;
        min-width: 0 !important;
        margin: 0 !important;
    }

    /* Search Label Container */
    #sales-manager-app #codextable_wrapper .dataTables_filter label {
        width: calc(50% - 5px) !important;
        min-width: 0 !important;
        margin: 0 !important;
    }
    
    /* Ensure Input Fills Label */
    #sales-manager-app #codextable_wrapper .dataTables_filter input {
        width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
    }

    /* NEW: PRODUCT TABLE MOBILE LAYOUT (Full Width Search) */
    #sales-manager-app #Producttable_wrapper .dataTables_filter label {
        width: 100% !important;
        margin-left: 0 !important;
    }
    #sales-manager-app #Producttable_wrapper .dataTables_filter input {
        width: 100% !important;
        min-width: 100% !important;
        margin-left: 0 !important;
    }

    /* Target actions container to ensure it separates from search */
    #sales-manager-app #Producttable_wrapper #products-actions {
        width: 100%;
    }

    /* UPDATED: Fix Pagination Select Visibility on Mobile */
    #sales-manager-app .dataTables_length select {
        max-width: none !important; /* Allow it to grow to fit text */
        min-width: 70px !important; /* Ensure minimum space */
        padding-right: 1.5rem !important; /* Ensure space for number + padding */
    }

    #sales-manager-app .pagination {
        justify-content: center;
    }
    
    /* NEW: ADJUST TABLE PADDING FOR MOBILE */
    #sales-manager-app .table-responsive {
        padding-left: 0 !important;
        padding-right: 0 !important;
        /* Padding top and bottom are inherited from p-3 (1rem) */
    }
    
    /* NEW: Adjust Stat Label Font Size */
    #sales-manager-app .stat-label {
        font-size: 0.7rem !important;
    }
    
    /* --- MOBILE PRODUCT TABLE VISIBILITY LOGIC (STRICT) --- */
    
    /* Force table layout fixed to respect percentages exactly */
    #sales-manager-app #Producttable {
        table-layout: fixed !important;
        width: 100% !important;
    }
    
    /* Force hiding of all columns first to ensure cleanliness */
    #sales-manager-app #Producttable > tbody > tr:not(.child) > td,
    #sales-manager-app #Producttable > thead > tr > th {
        display: none;
    }
    
    /* --- PRODUCT COLUMN (Produkt) --- */
    #sales-manager-app #Producttable > tbody > tr:not(.child) > td.col-key-name,
    #sales-manager-app #Producttable > thead > tr > th.col-key-name {
        display: table-cell !important;
        width: 70% !important; /* <--- EDIT THIS for 'Produkt' width */
        max-width: 70% !important; /* <--- EDIT THIS for 'Produkt' width */
        vertical-align: middle !important;
        padding-left: 50px !important; 
        position: relative;
        box-sizing: border-box !important;
        white-space: normal !important;
    }

    /* SPECIFIC: Header Border (Darker) */
    #sales-manager-app #Producttable > thead > tr > th.col-key-name {
        border-bottom: 1px solid #e2e8f0 !important;
    }

    /* SPECIFIC: Content/Body Border (Lighter - Matches Desktop) */
    #sales-manager-app #Producttable > tbody > tr:not(.child) > td.col-key-name {
        border-bottom: 1px solid #f1f5f9 !important;
    }
    
    /* STYLE THE IMAGE INSIDE TABLE CELL */
    #sales-manager-app #Producttable > tbody > tr:not(.child) > td.col-key-name img {
        width: 50px !important; 
        height: 50px !important;
        min-width: 50px !important; 
        margin-right: 10px !important;
        object-fit: cover;
        border-radius: 8px;
        vertical-align: middle !important;
        display: inline-block !important;
    }
    
    /* Force line break for small/muted text if present (Description) */
    #sales-manager-app #Producttable > tbody > tr:not(.child) > td.col-key-name small,
    #sales-manager-app #Producttable > tbody > tr:not(.child) > td.col-key-name span.text-muted,
    #sales-manager-app #Producttable > tbody > tr:not(.child) > td.col-key-name .description {
        display: block; /* Force new line */
        margin-top: 4px;
        color: #6c757d;
    }

    /* --- SOLD QTY COLUMN (Antall solgt) --- */
    /* Updated to allow text wrapping for the Header Title "Antall solgt" */
    #sales-manager-app #Producttable > tbody > tr:not(.child) > td.col-key-qty,
    #sales-manager-app #Producttable > thead > tr > th.col-key-qty {
        display: table-cell !important; 
        vertical-align: middle !important;
        width: 30% !important; /* <--- EDIT THIS for 'Antall solgt' width */
        max-width: 30% !important; /* <--- EDIT THIS for 'Antall solgt' width */
        text-align: center !important;
        box-sizing: border-box !important;
        white-space: normal !important; /* Allows title to wrap if width is small */
        overflow: hidden;
    }

    /* Explicitly SHOW Plus Icon */
    #sales-manager-app #Producttable > tbody > tr:not(.child) > td.dtr-control {
        /* The padding-left on col-key-name handles space, the :after pseudo element handles the icon */
    }

    /* IMPORTANT: Ensure child row content is ALWAYS visible */
    #sales-manager-app #Producttable > tbody > tr.child > td {
        display: table-cell !important;
    }
    
    /* Smaller inputs on mobile to prevent overflow */
    #sales-manager-app #Producttable input.form-control {
        max-width: 100px; /* Reduced from 100% */
        min-width: 60px; /* Reduced from 100px */
        text-align: left;
        padding: 5px;
        height: 38px !important;
        min-height: 38px !important;
        font-size: 14px;
    }

    /* --- TABLE 2: PARTICIPANTS (CODEX) TABLE WIDTHS --- */

    /* 1. Force fixed layout so percentages are strict and headers align */
    #sales-manager-app #codextable {
        table-layout: fixed !important;
        width: 100% !important;
    }

    /* 2. NAME COLUMN (Navn) - Explicitly target TH and TD */
    #sales-manager-app #codextable > thead > tr > th.col-key-name,
    #sales-manager-app #codextable .col-key-name {
        display: table-cell !important;
        width: 60% !important;      /* <--- EDIT THIS for 'Navn' width */
        max-width: 60% !important; /* <--- EDIT THIS for 'Navn' width */
        white-space: normal !important;
        vertical-align: middle !important;
        overflow: hidden; 
    }

    /* 3. ACTION COLUMN (Handlinger) - Explicitly target TH and TD */
    #sales-manager-app #codextable > thead > tr > th.col-key-action,
    #sales-manager-app #codextable .col-key-action {
        display: table-cell !important;
        width: 40% !important;      /* <--- EDIT THIS for 'Handlinger' width */
        max-width: 40% !important; /* <--- EDIT THIS for 'Handlinger' width */
        text-align: right !important;
        vertical-align: middle !important;
        padding-right: 10px !important;
        overflow: visible !important; /* FIXED: Allow menu to show */
    }

    /* CHILD ROW STYLING: Ensure titles are visible */
    #sales-manager-app .dtr-details {
        width: 100%;
        padding: 0;
    }
    #sales-manager-app .dtr-details li {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
        border-bottom: 1px solid #f1f5f9;
    }
    #sales-manager-app .dtr-title {
        font-weight: 700;
        color: #1e293b;
        margin-right: 10px;
        display: inline-block !important; /* Force title visibility */
    }
    #sales-manager-app .dtr-data {
        text-align: right;
        font-weight: 500;
    }
    
    /* --- MOBILE NAVBAR CENTERING --- */
    /* Stack content in Navbar */
    #sales-manager-app .dashboard-nav .container {
        flex-direction: column;
        gap: 1rem;
    }

    /* Center Brand/Lock Section (First child of container) */
    #sales-manager-app .dashboard-nav .container > div:first-child {
        width: 100%;
        justify-content: center;
        display: flex;
    }

    /* Center User/Cart Section (Last child of container) */
    #sales-manager-app .dashboard-nav .container > div:last-child {
        width: 100%;
        justify-content: center;
        display: flex;
    }

    /* Make User Pill Full Width & Centered content */
    #sales-manager-app .user-pill {
        width: 100%;
        justify-content: center;
    }
    
    #sales-manager-app .dropdown-container-mobile {
        width: 100%;
    }
}

/* Lock Status Badge */
#sales-manager-app .lock-status {
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 8px;
}
#sales-manager-app .lock-status.open { background: #e8f5e9; color: #2e7d32; }
#sales-manager-app .lock-status.locked { background: #ffebee; color: #c62828; }

/* REMOVED: Conflicting .d-none override that hid cart buttons */

/* --- CART FIXES --- */

/* 1. MOBILE VIEW (max-width: 767.98px) */
@media (max-width: 767.98px) {
    /* Show the mobile-only controls (wrapped in .d-md-none) */
    .modal#cart .d-md-none {
        display: block !important;
    }
    
    /* Hide the desktop-only columns */
    .modal#cart .d-none.d-md-table-cell {
        display: none !important;
    }

    /* Mobile Delete Button Alignment (from previous fix) */
    .modal#cart td.cart-item-details .d-md-none {
        display: flex !important;
        align-items: center;
        flex-wrap: wrap;
        gap: 0.4rem;
    }
    
    .modal#cart td.cart-item-details .delete-item {
        margin-left: 0.4rem !important;
        margin-top: 0 !important;
        display: inline-flex;
        align-items: center;
    }

    /* Force stat icon wrapper to be smaller on mobile */
    #sales-manager-app .stat-icon-wrapper {
        width: 38px !important;
        height: 38px !important;
    }

    /* Rediger priser modal image fix - smaller picture on mobile */
    #mobileProductEditModal .sales-mobile-modal-img {
        width: 70% !important; /* Force smaller fixed width */
        height: auto !important;
        min-width: 70% !important;
    }
}

/* 2. DESKTOP VIEW (min-width: 768px) */
@media (min-width: 768px) {
    /* HIDE the mobile-only controls */
    .modal#cart .d-md-none {
        display: none !important;
    }

    /* SHOW the desktop-only columns */
    .modal#cart .d-none.d-md-table-cell {
        display: table-cell !important;
    }
}

/* Legacy / Hidden */
#sales-manager-app .vis-meny-chk,   
#sales-manager-app .vis-meny-container, 
#sales-manager-app .vis-meny-target {   
    display: none !important;   
}

/* ==========================================================================
   SALES MANAGER MODAL STYLING (Scoped to .sales-modal-content)
   These styles ensure modals matching the dashboard design even if appended to body
   ========================================================================== */

.sales-modal-content {
    /* Re-declare variables locally to ensure they work outside #sales-manager-app */
    --primary-color: #5600ab;
    --primary-dark: #410082;
    --secondary-bg: #f8f9fa;
    --text-main: #2c3e50;
    --text-muted: #6c757d;
    --success-color: #00b09b;
    --input-grey-bg: #f8fafc;
    --box-radius: 1rem;

    font-family: 'Varela Round', sans-serif !important;
    border-radius: var(--box-radius) !important;
    border: none !important;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15) !important;
    background-color: #ffffff;
    overflow: hidden; /* Ensure radius clips content */
}

/* Modal Header */
.sales-modal-content .modal-header {
    background-color: #ffffff;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding: 1.5rem 1.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sales-modal-content .modal-title {
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 1.25rem;
    margin: 0;
}

.sales-modal-content .btn-close {
    background-size: 10px;
    opacity: 0.5;
    transition: opacity 0.2s;
}
.sales-modal-content .btn-close:hover {
    opacity: 1;
}

/* Modal Body */
.sales-modal-content .modal-body {
    padding: 1.5rem;
    color: var(--text-main);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Modal Footer */
.sales-modal-content .modal-footer {
    border-top: 1px solid rgba(0,0,0,0.05);
    padding: 1rem 1.5rem;
    background-color: #ffffff;
    gap: 10px;
}

/* Form Controls Inside Modals */
.sales-modal-content .form-control,
.sales-modal-content .form-select {
    border-radius: 8px !important;
    background-color: var(--input-grey-bg) !important;
    border: 1px solid #e2e8f0;
    height: 45px !important;
    min-height: 45px !important;
    font-size: 0.95rem;
    padding: 0.5rem 1rem;
    color: var(--text-main);
    box-shadow: none !important;
}

.sales-modal-content .form-control:focus,
.sales-modal-content .form-select:focus {
    background-color: #ffffff !important;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(86, 0, 171, 0.1) !important;
}

/* Textarea specific override */
.sales-modal-content textarea.form-control {
    height: auto !important;
    min-height: 80px !important;
}

/* --- BUTTONS INSIDE MODALS --- */

/* Primary Action */
.sales-modal-content .btn-primary-custom,
.btn-primary-custom {
    background-color: #5600ab !important; /* Fallback */
    background-color: var(--primary-color) !important;
    color: white !important;
    border: 1px solid var(--primary-color) !important;
    border-radius: 8px !important;
    padding: 0.5rem 1.25rem;
    font-weight: 600;
    transition: all 0.2s ease;
    height: 45px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.sales-modal-content .btn-primary-custom:hover,
.btn-primary-custom:hover {
    background-color: var(--primary-dark) !important;
    border-color: var(--primary-dark) !important;
    transform: translateY(-1px);
}

/* Secondary/Close Action */
.sales-modal-content .btn-light-custom,
.btn-light-custom {
    background-color: #ffffff !important;
    color: var(--text-main) !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    padding: 0.5rem 1.25rem;
    font-weight: 600;
    transition: all 0.2s ease;
    height: 45px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.sales-modal-content .btn-light-custom:hover,
.btn-light-custom:hover {
    background-color: #f8fafc !important;
    border-color: #cbd5e0 !important;
    color: var(--text-main) !important;
}

/* Danger Action */
.sales-modal-content .btn-danger-custom,
.btn-danger-custom {
    background-color: #fee2e2 !important;
    color: #dc2626 !important;
    border: 1px solid #fecaca !important;
    border-radius: 8px !important;
    padding: 0.5rem 1.25rem;
    font-weight: 600;
    transition: all 0.2s ease;
    height: 45px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.sales-modal-content .btn-danger-custom:hover,
.btn-danger-custom:hover {
    background-color: #dc2626 !important;
    color: #ffffff !important;
    border-color: #dc2626 !important;
}

/* Alerts / Info Boxes */
.sales-modal-content .text-warning-custom {
    background-color: #fffbeb;
    color: #d97706;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #fcd34d;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 1rem;
    margin-bottom: 0;
    line-height: 1.4;
}

.sales-modal-content .text-danger-custom {
    background-color: #fef2f2;
    color: #dc2626;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #fecaca;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 1rem;
    margin-bottom: 0;
}

/* Product Selection List inside Modals (Revised for Image List) */
.sales-modal-item {
    transition: background-color 0.2s ease;
    cursor: pointer;
}
.sales-modal-item:hover {
    background-color: #f8f9fa;
}

.sales-modal-img-wrapper {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
}

.sales-modal-product-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #f1f5f9;
}

.sales-modal-product-img-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 6px;
    background-color: #f1f5f9;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- EXPORT MODAL & VIEWER STYLES --- */
#exportOptionsModal .modal-content {
    border: none;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

/* --- XLSX VIEWER MODAL STYLES --- */
#xlsxViewerModal .modal-dialog {
    max-width: 95%;
    margin: 1.75rem auto;
    height: 90vh;
}

#xlsxViewerModal .modal-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#xlsxViewerModal .modal-body {
    flex: 1 1 auto;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-color: #f8f9fa;
    /* NEW: Dynamic Font Size */
    font-size: var(--xlsx-font-size, 14px) !important;
}

#xlsx-controls-bar {
    padding: 10px 20px;
    background: #fff;
    border-bottom: 1px solid #dee2e6;
    flex: 0 0 auto;
}

/* NEW: Font size override for the inputs specifically */
#xlsx-controls-bar input,
#xlsx-controls-bar .form-control {
    font-size: 1rem !important;
}

/* NEW: Font size override for Labels (Bredde:, Font:, px) */
#xlsx-controls-bar label,
#xlsx-controls-bar span.text-muted {
    font-size: 1rem !important;
}

#xlsx-table-wrapper {
    flex: 1 1 auto;
    overflow: auto;
    padding: 20px;
}

#xlsx-table {
    background: #fff;
    width: 100%;
    border-collapse: collapse;
}

#xlsx-table th {
    position: sticky;
    top: 0;
    background: #f8f9fa;
    z-index: 10;
    box-shadow: 0 2px 2px -1px rgba(0,0,0,0.1);
    border-bottom: 2px solid #dee2e6;
    padding: 12px;
    font-weight: 600;
    color: #495057;
}

#xlsx-table td {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    vertical-align: middle;
    /* NEW: Changed from nowrap to normal for text wrapping */
    white-space: normal !important;
    /* NEW: Dynamic Min Width */
    min-width: var(--xlsx-cell-width, 100px);
    max-width: 300px; /* Prevent cells from becoming massive with long text */
    overflow: hidden;
    text-overflow: ellipsis;
    
    /* Ensure cells are transparent so row background is visible */
    background-color: transparent !important;
}

/* --- ADDED: ZEBRA STRIPING FOR XLSX VIEWER --- */

/* Zebra Striping: Odd rows white */
#xlsx-table tbody tr:nth-of-type(odd) {
    background-color: #ffffff;
}

/* Zebra Striping: Even rows light grey */
#xlsx-table tbody tr:nth-of-type(even) {
    background-color: #f8f9fa; /* Light grey */
}

/* Hover Effect: Slightly darker grey */
#xlsx-table tbody tr:hover {
    background-color: #e2e6ea !important; /* Darker grey on hover */
    transition: background-color 0.15s ease-in-out;
    cursor: default;
}

/* NEW: Ensure first row header (thead) has white or light grey background */
#xlsx-table thead th {
    background-color: #f8f9fa !important; /* Light grey background for header */
    color: #212529; /* Ensure text is visible */
}

/* --- PRINT VIEW OVERRIDES --- */
@media print {
    body * {
        visibility: hidden;
    }
    
    /* Reset Global Properties to Remove Artifacts */
    * {
        -webkit-print-color-adjust: exact !important;   /* Chrome, Safari */
        print-color-adjust: exact !important;           /* Firefox */
        box-shadow: none !important;
        text-shadow: none !important;
        filter: none !important; /* Remove any CSS filters */
    }

    #xlsxViewerModal, #xlsxViewerModal * {
        visibility: visible;
    }
    
    /* Reset Modal Structure for Print */
    #xlsxViewerModal {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: auto !important; /* Allow height to grow */
        margin: 0;
        padding: 0;
        background: #fff !important; /* Force white background */
        overflow: visible !important; /* Critical for content to spill to next pages */
    }

    #xlsxViewerModal .modal-dialog,
    #xlsxViewerModal .modal-content,
    #xlsxViewerModal .modal-body {
        width: 100%;
        height: auto;
        overflow: visible !important;
        margin: 0;
        padding: 0;
        border: none;
        box-shadow: none;
        background: #fff !important;
    }
    
    /* Explicitly remove any backdrop shadow/overlay */
    .modal-backdrop {
        display: none !important;
        opacity: 0 !important;
    }

    /* Hide non-printable elements inside the modal */
    #xlsxViewerModal .modal-header,
    #xlsxViewerModal .modal-footer,
    #xlsx-controls-bar {
        display: none !important;
    }

    /* Table Wrapper Reset */
    #xlsx-table-wrapper {
        display: block !important;
        overflow: visible !important;
        padding: 0 !important;
        margin: 0 !important;
        height: auto !important;
    }
    
    /* Table Reset */
    #xlsx-table {
        /* Use 99% width to avoid potential right-margin clipping on some printers */
        width: 99% !important; 
        border-collapse: collapse !important;
        table-layout: auto !important; /* Allow browser to calculate widths based on content */
    }

    /* Header Specifics */
    #xlsx-table th {
        background: transparent !important;
        color: #000 !important;
        border: 1px solid #000 !important; /* Force Black Border */
        box-shadow: none !important; /* Remove shadow */
        position: static !important; /* Remove sticky behavior which breaks print */
        overflow: visible !important;
    }

    /* FLATTEN FLEXBOX FOR PRINT (Fixes overlapping and artifacts) */
    #xlsx-table th .d-flex {
        display: block !important; /* Stop flexbox behavior */
        width: auto !important;
    }
    
    #xlsx-table th .d-flex img {
        display: inline-block !important;
        vertical-align: middle !important;
        margin-right: 5px !important;
        max-width: 100% !important;
    }
    
    #xlsx-table th .d-flex span {
        display: inline-block !important;
        vertical-align: middle !important;
    }

    /* Cell Specifics */
    #xlsx-table td {
        border: 1px solid #000 !important; /* Force Black Border */
        color: #000 !important;
        background: transparent !important;
        
        /* Reset sizing constraints to allow "Fit to Page" to work better */
        min-width: auto !important;
        max-width: none !important; 
        width: auto !important;
        
        /* Text wrapping */
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important; /* Remove ellipsis */
        
        /* Font size adjustment for print */
        font-size: 10pt !important;
        padding: 4px !important; /* Reduce padding to save space */
    }
    
    /* Ensure rows also carry border info if browser collapses strangely */
    #xlsx-table tr {
        border: 1px solid #000 !important;
        page-break-inside: avoid;
    }

    /* Ensure images (if any) don't break layout */
    #xlsx-table img {
        max-width: 100% !important;
        height: auto !important;
        /* Ensure images are visible but don't cause artifacts */
        display: inline-block !important; 
    }
}