/* =====================================================
   COMPONENT STYLES - Reusable UI Components
   ===================================================== */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 500;
    border-radius: var(--radius-lg);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--primary-500);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-600);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-300);
}

.btn-success {
    background: var(--success-500);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: var(--success-600);
}

.btn-danger {
    background: var(--danger-500);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-600);
}

.btn-warning {
    background: var(--warning-500);
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: var(--warning-600);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--bg-tertiary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--font-size-base);
}

.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--font-size-xs);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
}

.btn-icon.btn-sm {
    width: 28px;
    height: 28px;
}

.btn-icon.btn-lg {
    width: 44px;
    height: 44px;
}

.btn-action {
    background-color: #fff;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-action:hover:not(:disabled) {
    background-color: var(--bg-tertiary);
    border-color: var(--gray-400);
    color: var(--text-primary);
}

.btn-action:active:not(:disabled) {
    background-color: var(--gray-200);
    transform: scale(0.98);
}

.btn-action:disabled {
    background-color: var(--bg-secondary);
    color: var(--text-tertiary);
    border-color: var(--border-color);
    opacity: 0.5;
    cursor: not-allowed;
}

/* CSS-only Spinner */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Loading state for buttons */
.btn.loading {
    pointer-events: none;
    opacity: 0.8;
}


/* Cards */
.card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.card-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
    margin-top: var(--space-1);
}

.card-body {
    padding: var(--space-5);
}

.card-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

/* Form Elements */
.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.form-label.required::after {
    content: '*';
    color: var(--danger-500);
    margin-left: var(--space-1);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
    background: var(--bg-secondary);
    cursor: not-allowed;
    opacity: 0.7;
}

.form-input.error,
.form-select.error,
.form-textarea.error {
    border-color: var(--danger-500);
}

.form-input.error:focus,
.form-select.error:focus,
.form-textarea.error:focus {
    box-shadow: 0 0 0 3px var(--danger-50);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-hint {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    margin-top: var(--space-1);
}

.form-error {
    font-size: var(--font-size-xs);
    color: var(--danger-500);
    margin-top: var(--space-1);
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    cursor: pointer;
}

.form-check-input {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--primary-500);
    cursor: pointer;
}

.form-check-label {
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    cursor: pointer;
}

/* Container that looks like an input field but holds checkboxes */
.checkbox-group-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-4); /* Matches .form-input padding */
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.checkbox-group-title {
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
    display: block;
    border-bottom: 1px solid var(--border-color); /* Optional: separator line */
    padding-bottom: var(--space-2);
}

/* Ensure the grid stretches nicely */
.check-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* Hover effect for better UX on the individual rows */
.checkbox-row {
    padding: 4px 0;
    transition: opacity 0.2s;
}
.checkbox-row:hover {
    opacity: 0.8;
}


/* File Upload Area */
.file-upload-area {
    margin-bottom: var(--space-4);
}

.file-list {
    margin-top: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.file-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--gray-300);
}

.file-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex: 1;
    min-width: 0; /* Allow text truncation */
}

.file-icon {
    width: 24px;
    height: 24px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.file-details {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-width: 0; /* Allow text truncation */
    flex: 1;
}

.file-name {
    font-weight: 500;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    word-break: break-word;
    line-height: 1.4;
}

.file-size {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

.file-remove {
    padding: var(--space-2);
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--danger-500);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-remove:hover {
    background: var(--danger-50);
    color: var(--danger-600);
}

.file-remove:active {
    transform: scale(0.95);
}

.file-remove svg {
    width: 18px;
    height: 18px;
}

/* Drop Zone Styles */
.drop-zone {
    border: 2px dashed var(--border-color, #e2e8f0);
    border-radius: var(--radius-lg, 0.5rem);
    background: var(--bg-secondary, #f8fafc);
    padding: var(--space-8, 2rem) var(--space-4, 1rem);
    text-align: center;
    transition: all var(--transition-fast, 0.2s);
    cursor: pointer;
    position: relative;
    margin-bottom: var(--space-4);
}

/* State: Hovering over the zone with a file */
.drop-zone.drop-zone--over {
    border-color: var(--primary-500, #3b82f6);
    background: var(--primary-50, #eff6ff);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2, 0.5rem);
    pointer-events: none; /* Prevents child elements from blocking drag events */
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--text-tertiary, #94a3b8);
    margin-bottom: var(--space-2);
}

.drop-zone-text {
    font-size: var(--font-size-md, 1rem);
    color: var(--text-primary, #1e293b);
    font-weight: 500;
}

.browse-link {
    color: var(--primary-500, #3b82f6);
    text-decoration: underline;
}

.drop-zone-hint {
    font-size: var(--font-size-xs, 0.75rem);
    color: var(--text-tertiary, #94a3b8);
}

/* Green Checkmark for Ready State */
.file-status-icon {
    width: 20px;
    height: 20px;
    color: #10B981; /* Emerald Green */
    margin-right: var(--space-2, 0.5rem);
    flex-shrink: 0;
}

.user-menu-wrapper { position: relative; }
.user-menu-trigger { background: transparent; border: 0; padding: 0; cursor: pointer; }

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.08);
  padding: 8px;
  z-index: 50;
}
.user-dropdown.hidden { display: none; }

.user-dropdown-item {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
}
.user-dropdown-item:hover { background: #f3f4f6; }

.user-dropdown-item.danger { color: #dc2626; }
.user-dropdown-item.danger:hover { background: rgba(220,38,38,0.08); }

.user-dropdown-separator {
  height: 1px;
  background: #e5e7eb;
  margin: 8px 6px;
}

/* Container for alignment */
.filter-menu-container {
    display: inline-block;
    position: relative;
}

/* The Floating Popover */
.filter-popover {
    position: absolute;
    top: calc(100% + 8px); /* 8px below the button */
    right: 0;
    width: 260px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    display: none; /* Hidden by default */
    flex-direction: column;
    animation: fadeInScale 0.2s ease-out;
}

.filter-popover.active {
    display: block;
}

/* Header inside popover */
.filter-popover-header {
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 14px;
}

/* Content area */
.filter-popover-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Internal groups */
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 11px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.filter-group select, .filter-group input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}

.filter-group select:focus, .filter-group input:focus {
    border-color: #6366f1;
    ring: 2px solid rgba(99, 102, 241, 0.2);
}

.btn-text-danger {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 12px;
    cursor: pointer;
    font-weight: 500;
}

/* Animation */
@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Teeth Selector Styles */
.teeth-chart {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #f3f4f6;
    padding: 1rem;
    border-radius: 8px;
    width: fit-content;
    margin: 0 auto;
}
.teeth-row {
    display: flex;
    gap: 20px; /* Space between left and right quadrants */
}
.quadrant {
    display: flex;
    gap: 4px;
}
.tooth-checkbox {
    display: none; /* Hide actual checkbox */
}
.tooth-label {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
}
.tooth-checkbox:checked + .tooth-label {
    background: var(--primary-color, #0066cc);
    color: white;
    border-color: var(--primary-color, #0066cc);
}
.case-item-summary {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    position: relative;
}
.remove-item-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    color: #ef4444;
    cursor: pointer;
}
.check-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.category-sub-group {
    background: #fff;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 4px;
}

/* Item Card Styles */
.case-item-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}
.case-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: 600;
    color: #334155;
}
.item-badge {
    background: #e0f2fe;
    color: #0369a1;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.item-edit-wrapper {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    position: relative;
}
.item-edit-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #334155;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
}
.removable-grid {
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 10px; 
    margin-bottom: 10px;
}

/* Skeleton Loader Animation */
@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

.skeleton-row td {
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.skeleton-box {
    height: 20px;
    background: #f6f7f8;
    background-image: linear-gradient(to right, #f6f7f8 0%, #edeef1 20%, #f6f7f8 40%, #f6f7f8 100%);
    background-repeat: no-repeat;
    background-size: 2000px 60px; 
    border-radius: 4px;
    animation: shimmer 2s infinite linear;
}

/* Specific widths to match your real data roughly */
.skeleton-box.w-short { width: 40%; }
.skeleton-box.w-medium { width: 70%; }
.skeleton-box.w-long { width: 90%; }

.id-wrapper {
    position: relative;
    display: inline-block; /* Allows the wrapper to hug the text width */
}

/* The Lightning Icon */
.urgent-bolt {
    position: absolute;
    left: -20px; /* Moves icon 20px to the left of the text start */
    top: 50%;
    transform: translateY(-50%); /* Vertically centers the icon */
    
    color: #dc2626; /* Red color */
    width: 16px;
    height: 16px;
    pointer-events: none; /* Ensures clicking the icon clicks the ID behind it */
}

.sidebar-badge {
        background-color: #ef4444; 
        color: white; 
        padding: 2px 8px; 
        border-radius: 99px; 
        font-size: 0.75rem; 
        font-weight: 600; 
        margin-left: auto; /* Pushes to right in flex container */
        min-width: 20px;
        text-align: center;
        transition: all 0.2s ease;
    }

  /* Shipping Center Layout */
.shipping-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 15px;
}

.shipping-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.shipping-tabs {
    display: flex;
    gap: 5px;
    background: #f3f4f6;
    padding: 4px;
    border-radius: 8px;
}

.shipping-tab-btn {
    padding: 6px 16px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    color: #6b7280;
}

.shipping-tab-btn.active {
    background: white;
    color: #0369a1;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* Split View for Batch Creation */
.batch-creation-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    height: calc(100vh - 140px); /* Adjust based on your header/nav height */
}

/* Left Panel */
.batch-sidebar {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.scanner-box {
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  display: none;
  width: 100%;
}

.scanner-box.active {
  display: block;
  margin-bottom: 12px;

  /* Give the camera more pixels to work with */
  height: min(60vh, 520px);
  min-height: 340px;
}

/* Ensure the video fills the box nicely */
#reader video, #reader canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.draft-list-container {
    flex: 1;
    overflow-y: auto;
    border-top: 1px solid #e5e7eb;
    margin-top: 10px;
    
}

.draft-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f9fafb;
    font-size: 0.85rem;
}

/* Right Panel */
.batch-table-area {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 16px;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .batch-creation-grid {
        grid-template-columns: 1fr;
        height: auto;
    }
    .batch-sidebar {
        max-height: 1000px;
    }
    .batch-table-area {
        min-height: 500px;
    }
}

/* Manual Input Styling */
.manual-entry-wrapper {
    display: flex;
    gap: 8px; /* Space between input and button */
    margin-top: 16px; /* Space from QR button */
    margin-bottom: 24px; /* Space from list */
}

.manual-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #374151;
    transition: all 0.2s;
    background-color: #f9fafb;
}

.manual-input:focus {
    background-color: white;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
}

/* Batch Summary Header */
.batch-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 8px;
}

.batch-summary-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    font-weight: 600;
}


.batch-count-badge {
    background: #eff6ff;
    color: #1d4ed8;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.8rem;
    border: 1px solid #dbeafe;
}

/* Draft List Items */
.draft-list-container {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px; /* Space for scrollbar */
}

.draft-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: white;
    border: 1px solid #f3f4f6;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.draft-item:hover {
    border-color: #e5e7eb;
    background: #f9fafb;
    transform: translateX(2px);
}

.draft-item-id {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 600;
    color: #374151;
    font-size: 0.9rem;
}

.draft-remove-btn {
    color: #9ca3af;
    padding: 4px;
    border-radius: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.draft-remove-btn:hover {
    color: #ef4444; /* Red */
    background: #fef2f2;
}


/* Sidebar base (safe, non intrusif) */
#sidebar {
  display: block;                /* forcer visible */
  position: fixed;
  left: 0;
  top: 0;
  height: 100dvh;
  width: var(--sidebar-width, 260px);
  background: var(--sidebar-bg, #fff);
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  overflow-y: auto;
  transform: translateX(0);
  transition: transform 240ms ease, width 200ms ease;
  z-index: 1000;
}

/* desktop collapsed state (existing behaviour) */
#sidebar.collapsed {
  width: 72px; /* petite largeur de collapsed sur desktop */
}

/* mobile: convert to overlay and hide by default for small screens */
@media (max-width: 1024px) {
  /* make sidebar overlay and hidden by default */
  #sidebar {
    transform: translateX(-110%); /* cachée hors écran */
    width: min(80vw, 320px);
    background: var(--sidebar-bg, #fff);
    height: 100dvh;
    transition: transform 220ms cubic-bezier(.2,.9,.2,1);
    /* ensure above app content */
    z-index: 2000;
  }

  /* when opened, add a class .open to slide in */
  #sidebar.open {
    transform: translateX(0);
  }

  @media (max-width: 1024px) {
    /* 1. Change the main container to stack vertically */
    .dashboard-split {
        grid-template-columns: 1fr !important; /* Force single column */
        height: auto !important; /* Stop forcing full screen height */
        gap: 30px; /* Add space between the stacked panels */
        display: flex; 
        flex-direction: column;
    }

    /* 2. Give the panels a fixed height so internal scrolling still works */
    .action-panel, 
    .chat-app-panel {
        /* We set a fixed height so the "Action List" and "Chat List" 
           can still scroll internally within this box */
        height: 500px; 
        width: 100%;
    }

    /* 3. Ensure the chat panel handles the slide-in view correctly */
    .chat-app-panel {
        position: relative; /* Ensure chat room slides within this box */
    }
}

  /* dim the page when sidebar open: create overlay element via CSS pseudo (requires body class) */
  body.sidebar-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.36);
    z-index: 1500; /* less than sidebar (2000) so sidebar is above */
    pointer-events: auto;
  }

  /* make the sidebar toggle button visible on mobile if present */
  .mobile-sidebar-toggle {
    display: inline-flex;
    position: fixed;
    left: 12px;
    top: 12px;
    z-index: 2100;
    align-items: center;
    justify-content: center;
    height: 40px;
    width: 40px;
    border-radius: 8px;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    cursor: pointer;
  }
}

/* small touch target for footer/collapse button */
.sidebar-footer .sidebar-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
}

/* avoid body scroll when sidebar overlay is open */
@media (max-width: 1024px) {
  body.no-scroll {
    overflow: hidden;
    height: 100vh;
  }
}

.main-content {
  height: 100dvh;
  overflow-y: auto;
}

.btn-text-danger {
    color: #dc2626;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
}
.btn-text-danger:hover {
    text-decoration: underline;
}

/* Wrapper to keep dropdown relative to button */
.relative-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    margin-right: 15px; /* Spacing between Lang and User Profile */
}

/* The Globe Button */
.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: #64748b; /* Slate-500 */
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.icon-btn:hover {
    background-color: #f1f5f9; /* Slate-100 */
    color: #0f172a; /* Slate-900 */
}

.lang-label {
    font-size: 14px;
    font-weight: 600;
}

/* Reusing your existing .user-dropdown class, but ensuring placement */
#lang-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 50;
    overflow: hidden;
    padding: 4px;
}

/* Dropdown items */
.user-dropdown-item {
    display: flex;
    width: 100%;
    align-items: center;
    padding: 8px 12px;
    font-size: 14px;
    color: #334155;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    border-radius: 4px;
}

.user-dropdown-item:hover {
    background-color: #f8fafc;
}

/* Highlight the active language */
.user-dropdown-item.active-lang {
    background-color: #eff6ff; /* Light Blue */
    color: #2563eb; /* Blue */
    font-weight: 600;
}




.dashboard-split {
    display: grid;
    grid-template-columns: 1fr 1fr; /* 50% - 50% */
    gap: 24px;
    height: calc(100vh - 120px);
    min-height: 600px;
    overflow: hidden;
}

/* LEFT SIDE: ACTION TABLE */
.action-panel {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.compact-table-container {
    overflow-y: auto;
    flex: 1;
}
/* Reduce padding for compact look */
.compact-table td, .compact-table th {
    padding: 10px 12px; 
    font-size: 0.85rem;
}

/* RIGHT SIDE: CHAT APP */
.chat-app-panel {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* CHAT LIST VIEW (WhatsApp Style) */
.chat-thread-list {
    overflow-y: auto;
    flex: 1;
}

.chat-thread-item {
    display: flex;
    padding: 15px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.1s;
}
.chat-thread-item:hover {
    background-color: #f8fafc;
}
.chat-thread-item.unread {
    background-color: #eff6ff;
}
.chat-thread-item.active {
    background-color: #e0f2fe;
}

.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-right: 12px;
    flex-shrink: 0;
}

.thread-content {
    flex: 1;
    min-width: 0; /* Needed for text-overflow to work in flex */
}

.thread-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}
.thread-name {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.9rem;
}
.thread-time {
    font-size: 0.75rem;
    color: #94a3b8;
}

.thread-msg-preview {
    font-size: 0.85rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.unread .thread-msg-preview {
    font-weight: 600;
    color: #1e293b;
}

/* CHAT ROOM VIEW (Slide in) */
.chat-room-view {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #fff;
    z-index: 10;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
}
.chat-room-view.open {
    transform: translateX(0);
}
.chat-room-header {
    padding: 10px 15px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
}

/* --- Message Bubbles --- */
.chat-message {
    display: flex;
    margin-bottom: 12px;
    flex-direction: column;
}

.chat-message.sent {
    align-items: flex-end; /* Align to right */
}

.chat-message.received {
    align-items: flex-start; /* Align to left */
}

.chat-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 12px;
    position: relative;
    font-size: 0.95rem;
    line-height: 1.4;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* User's messages (Right) */
.chat-message.sent .chat-bubble {
    background-color: var(--primary-color, #2563eb); /* Fallback blue */
    color: white;
    border-bottom-right-radius: 2px; /* Visual accent */
}

/* Others' messages (Left) */
.chat-message.received .chat-bubble {
    background-color: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 2px; /* Visual accent */
}

.chat-meta {
    font-size: 0.7rem;
    margin-top: 4px;
    opacity: 0.8;
}

.chat-message.sent .chat-meta {
    text-align: right;
    color: #94a3b8;
    margin-right: 2px;
}

.chat-message.received .chat-meta {
    text-align: left;
    color: #94a3b8;
    margin-left: 2px;
}

/* Link color adjustment for sent messages */
.chat-message.sent .chat-attachment {
    color: rgba(255,255,255,0.9) !important;
    border-color: rgba(255,255,255,0.3) !important;
}

/* --- File Upload Preview Area --- */
.chat-file-preview-area {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 10px;
    /* Only show padding if there are files, handled by JS usually, 
       but here we assume it sits above input */
}

.file-preview-chip {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.8rem;
    color: #475569;
}

.file-preview-remove {
    margin-left: 8px;
    cursor: pointer;
    color: #94a3b8;
    display: flex;
    align-items: center;
}
.file-preview-remove:hover {
    color: #ef4444;
}

/* Drag Over Effect for the whole chat window */
.chat-room-view.drop-zone--over {
    border: 2px dashed #3b82f6;
    background-color: rgba(59, 130, 246, 0.05);
}

/* --- 1. Back Button (Ghost Style) --- */
.btn-back {
    background: transparent;
    border: none; /* Removes the black outline */
    color: #64748b; /* Slate-500 */
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-back:hover {
    background-color: #f1f5f9; /* Slate-100 */
    color: #334155; /* Slate-700 */
}

/* --- 2. View Details Button (Soft Style) --- */
.btn-soft {
    background-color: #f8fafc; /* Very light gray */
    border: 1px solid #e2e8f0; /* Subtle border */
    color: #475569; /* Slate-600 */
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-soft:hover {
    background-color: #ffffff;
    border-color: #cbd5e1;
    color: #0f172a; /* Darker text on hover */
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* --- 3. Send Button (Solid Circle) --- */
.btn-send {
    background-color: var(--primary-color, #3b82f6); /* Use your app's blue */
    border: none; /* Removes the black outline */
    color: white;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3); /* Nice glow shadow */
    
    /* Centering icon */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-send:hover {
    background-color: #2563eb; /* Darker Blue */
    transform: translateY(-1px); /* Slight lift effect */
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.4);
}

.btn-send:active {
    transform: translateY(0);
}

.page-container {
    padding: 2rem; /* Fixes the "invisible header" by adding spacing from edges */
    max-width: 1200px;
    margin: 0 auto;
}

.import-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.import-card {
    background: white;
    border-radius: 12px; /* Smooth corners */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 3rem;
    text-align: center;
}

/* Designing the Drop Zone to work with your existing logic */
.custom-drop-zone {
    border: 2px dashed #e5e7eb;
    border-radius: 12px;
    padding: 4rem 2rem;
    transition: all 0.2s ease;
    background: #f9fafb;
    cursor: pointer;
    position: relative;
}

/* This is the class your existing highlight() function adds */
.custom-drop-zone.drop-zone--over {
    border-color: #2563eb; /* Primary Blue */
    background-color: #eff6ff; /* Light Blue tint */
    transform: scale(1.01);
}

.file-preview-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: #f3f4f6;
    border-radius: 8px;
    margin-top: 1.5rem;
    border: 1px solid #e5e7eb;
}


/* Custom Product Dropdown Styles */
.product-input-wrapper {
    position: relative;
    width: 100%;
}

.product-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 600px; /* Wide enough for 3 columns */
    max-height: 300px;
    overflow-y: auto;
    background: white;
    border: 1px solid #2563eb;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    z-index: 50; /* Above everything else */
    display: none; /* Hidden by default */
    border-radius: 4px;
}

.product-dropdown.active {
    display: block;
}

.product-option {
    display: grid;
    /* 3 Columns: Code (Short), English (Auto), Chinese (Auto) */
    grid-template-columns: 60px 1fr 1fr; 
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.85rem;
    align-items: center;
}

.product-option:hover, .product-option.selected {
    background-color: #eff6ff; /* Light blue */
}

.col-code {
    font-weight: bold;
    color: #2563eb;
    background: #e0e7ff;
    padding: 2px 6px;
    border-radius: 4px;
    text-align: center;
    font-size: 0.75rem;
}

.col-en {
    font-weight: 500;
    color: #374151;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-zh {
    color: #6b7280;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Collapse/Expand Toggle Styles */
.collapse-toggle {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    color: #6b7280;
    transition: background-color 0.2s, transform 0.2s;
    margin-right: 4px;
}

.collapse-toggle:hover {
    background-color: #e5e7eb;
    color: #111827;
}

.collapse-toggle svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s;
}

/* Rotate arrow when expanded */
.collapse-toggle.expanded svg {
    transform: rotate(90deg);
}

/* Summary Row (Collapsed State) */
.summary-row {
    background-color: #f9fafb;
    color: #6b7280;
    font-size: 0.9rem;
    font-style: italic;
}
.summary-row:hover {
    background-color: #f3f4f6;
}

.action-group {
    position: relative;
    display: inline-block;
}

.action-group { position: relative; display: inline-block; }
.dropdown-menu {
    display: none; position: absolute; right: 0; top: 100%; margin-top: 4px;
    background-color: white; min-width: 200px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb; border-radius: 6px; z-index: 50; text-align: left;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
    display: flex; align-items: center; width: 100%; padding: 10px 16px;
    font-size: 0.85rem; color: #374151; border: none; background: none;
    cursor: pointer; transition: background-color 0.15s;
}
.dropdown-item:hover { background-color: #eff6ff; color: #2563eb; }

.product-dropdown-fixed {
    position: absolute; /* Actually absolute relative to body, calculated by JS */
    background: white;
    border: 1px solid #2563eb; /* Blue border when active */
    border-radius: 6px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    z-index: 9999; /* Higher than everything */
    max-height: 250px;
    overflow-y: auto;
}

.product-option {
    padding: 10px 12px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background 0.1s;
}
.product-option:hover { background: #eff6ff; }

/* Typography for Results */
.opt-main {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 2px;
}
.opt-sub {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 0.8rem;
    color: #6b7280;
}
.opt-code {
    background: #f3f4f6;
    padding: 1px 4px;
    border-radius: 3px;
    font-family: monospace;
}


.kiosk-flex-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.btn-icon-add { 
    background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; 
    border-radius: 50%; width: 24px; height: 24px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.btn-icon-del {
    background: transparent; color: #ef4444; border: none; cursor: pointer; padding: 4px;
}
.btn-icon-del:hover { background: #fee2e2; border-radius: 4px; }

/* Editable Row Layout */
.editable-row { align-items: center !important; }
.pos-inputs { flex: 1; display: flex; flex-direction: column; gap: 6px; }

.kiosk-input-sm {
    width: 100%; border: 1px solid #d1d5db; border-radius: 6px; padding: 6px 10px; font-size: 0.9rem;
    transition: border-color 0.2s;
}
.kiosk-input-sm:focus { border-color: #3b82f6; outline: none; box-shadow: 0 0 0 2px rgba(59,130,246,0.1); }
.product-search { font-weight: 600; color: #374151; }

/* Autocomplete Dropdown (reused from shipping but scoped) */
.product-input-wrapper { position: relative; width: 100%; }
.product-dropdown {
    position: absolute; top: 100%; left: 0; right: 0;
    background: white; border: 1px solid #e5e7eb; border-radius: 6px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); z-index: 50;
    max-height: 200px; overflow-y: auto;
    display: none;
}
.product-dropdown.active { display: block; }
.col-code { font-family: monospace; color: #6b7280; font-size: 0.8rem; }
.col-en { font-weight: 600; color: #1f2937; font-size: 0.9rem; }
.col-zh { color: #9ca3af; font-size: 0.8rem; margin-left: auto; }


.materials-chip-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 5px;
    padding: 4px 0;
}

/* The individual item (Chip) */
.material-chip {
    display: inline-flex;
    align-items: center;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 20px; /* Pill shape */
    padding: 4px 10px 4px 4px; /* Left padding smaller for icon circle */
    font-size: 0.85rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: all 0.2s;
    max-width: 100%;
}

/* Visual feedback for the item just scanned */
.chip-new {
    border-color: #34d399; /* Green border */
    background: #ecfdf5;   /* Light green bg */
    animation: flashChip 1s ease-out;
}

@keyframes flashChip {
    0% { transform: scale(0.95); box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2); }
    100% { transform: scale(1); box-shadow: none; }
}

/* Icon Circle */
.chip-icon {
    width: 24px;
    height: 24px;
    background: #f3f4f6;
    color: #6b7280;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
    flex-shrink: 0;
}
.chip-new .chip-icon {
    background: #10b981;
    color: white;
}

/* Text Content */
.chip-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    margin-right: 8px;
}

.chip-name {
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px; /* Prevent huge chips */
}

.chip-lot {
    font-size: 0.7rem;
    color: #9ca3af;
    font-family: monospace;
}

/* Delete Button (Small 'x') */
.chip-delete {
    background: none;
    border: none;
    color: #9ca3af;
    font-weight: bold;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    display: flex;
    align-items: center;
}
.chip-delete:hover {
    color: #ef4444;
}

.text-muted-sm {
    color: #9ca3af;
    font-size: 0.85rem;
    font-style: italic;
    padding: 10px 0;
}


.client-code-big {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.05em;
    color: #fff;
}

#tech-modal.kiosk-modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
}

#tech-modal .kiosk-modal {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
}


#tech-modal .kiosk-modal-body {
  padding: 20px !important;
  box-sizing: border-box;
}

#tech-modal .kiosk-modal-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 16px 20px !important;
  box-sizing: border-box;
}

/* Title should not add weird spacing */
#tech-modal .kiosk-modal-header h3{
  margin:0;
  flex:1;               /* take remaining space */
}

/* Close button pinned to the right, not full width */
#tech-modal .kiosk-modal-header .btn-text{
  margin-left:auto;
  width:auto !important;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:6px 10px;
  line-height:1;
}