/* THEME TOKENS */
:root {
    --bg: #ffffff;
    --fg: #0f172a;
    --muted: #64748b;
    --card: #f8fafc;
    --border: #e2e8f0;
    --accent: #3b82f6;
    --sidebar-bg: #f3f6ff;
  }
  .theme-dark {
    --bg: #0b1020;
    --fg: #e5e7eb;
    --muted: #9aa2b1;
    --card: #111827;
    --border: #1f2937;
    --accent: #60a5fa;
    --sidebar-bg: #0d1326;
  }

  /*Adding the text selection color */
  ::selection {
    background-color: #f3f6ff; /* Gold highlight */
    color: #60a5fa; /* Black text */
  }
  ::-moz-selection {
    background-color: #f3f6ff;
    color: #60a5fa;
  }

  .skip-link {
    display: none;
  }
  
  /* APP SHELL */
  .lp-pack-app {
    background: var(--bg);
    color: var(--fg);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    font-family: "Inter", "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
  }
  
  /* GRID LAYOUT */
  .lp-grid {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 0;
    min-height: calc(100dvh - 56px);
  }
  
  /* SIDEBAR */
  .lp-sidebar {
    border-right: 1px solid var(--border);
    background: var(--sidebar-bg);
    overflow: hidden;
    transition: width 0.2s ease, transform 0.2s ease;
    font-size: 16px;
  }
  .lp-sidebar .lp-sidebar-inner {
    padding: 20px;
  }
  .lp-pack-title {
    font-size: 22px;
    font-weight: 600;
    margin: 0 0 12px;
  }
  .lp-muted {
    color: var(--muted);
    font-size: 16px;
  }
  
  /* MAIN CONTENT */
  .lp-main {
    background: var(--bg);
    font-size: 16px;
    margin: 0 auto;
  }
  .lp-main-inner {
    padding: 20px;
    max-width: 1300px;
    width: 1800px;
  }
  .lp-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    font-size: 16px;
    transition: box-shadow 0.2s ease;
  }
  .lp-card-body {
    padding: 20px;
  }
  
  /* BUTTONS & INPUTS */
  .lp-btn {
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--fg);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    text-wrap: nowrap;
  }
  .lp-btn:hover {
    border-color: var(--accent);
  }
  .lp-select {
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--fg);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 16px;
  }

  .form-select {
    background-color: var(--card);
    color: var(--fg);
    border-color: var(--border);
  }
  .form-select:focus {
    border-color: var(--accent);
    box-shadow: none;
  }
  .form-select option { color: var(--fg); background-color: var(--bg); }
  .form-control {
    background-color: var(--card);
    color: var(--fg);
    border-color: var(--border);
  }
  .form-control:focus { border-color: var(--accent); box-shadow: none;}
  .form-control, .lp-wunit {
    height: 40px; 
    border-radius: 8px;
  }
  
  
  /* COLLAPSED SIDEBAR STATE */
  .lp-grid.sidebar-collapsed {
    grid-template-columns: 64px 1fr;
  }
  .lp-grid.sidebar-collapsed #lp-sidebar .lp-sidebar-inner {
    padding-left: 8px;
    padding-right: 8px;
  }
  .lp-grid.sidebar-hidden {
    grid-template-columns: 0 1fr;
  }
  
  /* THEME TOGGLE */
  .lp-theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
  }
  .lp-theme-toggle .lp-btn {
    background: var(--card);
    border: 1px solid var(--border);
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
  }
  .lp-theme-toggle .lp-btn.is-active,
  .lp-theme-toggle .lp-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
  }
  .lp-theme-toggle .lp-btn i {
    font-size: 18px;
  }
  
  /* HEADINGS & TEXT */
  h1, h2, h3, h4, h5, h6 {
    color: var(--fg);
    font-weight: 600;
    margin: 0 0 10px;
  }
  h1 { font-size: 28px; }
  h2 { font-size: 24px; }
  h3 { font-size: 20px; }
  h4 { font-size: 18px; }
  p, li, span, a {
    font-size: 16px;
    color: var(--fg);
  }
  
  /* UTILS */
  .lp-muted a {
    color: var(--muted);
  }
  .lp-muted a:hover {
    color: var(--accent);
  }
  hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 12px 0;
  }
  
  .lp-has-ph:empty::before {
    content: attr(data-placeholder);
    color: var(--muted);
    pointer-events: none;
  }

  /* ===== DRAG & DROP ENHANCEMENTS ===== */
  
  .lp-dnd-ph {
    height: 48px;
    border: 2px dashed var(--accent);
    border-radius: 10px;
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    animation: lpPulse .6s ease-in-out infinite alternate;
    margin: 4px 0;
  }
  
  .lp-dnd-cat { 
    height: 120px; 
    margin: 8px 0; 
  }
  
  .lp-dragging { 
    opacity: .5; 
    transform: scale(0.98);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  }
  
  .lp-dnd-handle {
    transition: color 0.2s ease;
  }
  
  .lp-dnd-handle:hover {
    color: var(--accent) !important;
  }
  
  .lp-dnd-handle i { 
    font-size: 18px; 
  }
  
  @keyframes lpPulse { 
    from { opacity:.4; transform: scale(0.98); } 
    to { opacity:.8; transform: scale(1.0); } 
  }

  /* Sidebar item dragging */
  .lp-sidebar-item {
    transition: transform 0.1s ease, box-shadow 0.2s ease;
  }
  
  .lp-sidebar-item:not(.lp-dragging):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  }
  
  .lp-sidebar-item.lp-dragging {
    opacity: 0.6;
    transform: scale(0.95);
  }

  /* Category card drag states */
  .lp-dnd-cat-card {
    transition: transform 0.1s ease, box-shadow 0.2s ease;
  }
  
  .lp-dnd-cat-card.lp-dragging {
    opacity: 0.5;
    transform: rotate(2deg) scale(0.98);
    box-shadow: 0 12px 32px rgba(0,0,0,0.2);
  }

  /* Item row drag states - FIXED */
  .lp-dnd-item {
    transition: box-shadow 0.2s ease;
    cursor: default;
  }
  
  .lp-dnd-item:not(.lp-dragging):hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  }
  
  .lp-dnd-item.lp-dragging {
    opacity: 0.5;
    transform: scale(0.97);
  }

  /* Drop zone highlighting */
  .lp-cat-items:has(.lp-dnd-ph) {
    background: color-mix(in srgb, var(--accent) 5%, transparent);
    border-radius: 8px;
  }

  /* ===== PACK ITEM LAYOUT ===== */

  .lp-item-compact {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
  }

  .lp-item-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border: 1px solid var(--border);
    border-radius: 8px;
    flex: 0 0 44px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }
  
  .lp-item-thumb:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  }

  .lp-item-thumb.lp-item-thumb-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
  }

  .lp-item-mid {
    display: flex;
    align-items: center;
    gap: 0;
    min-width: 0;
    flex: 1 1 auto;
  }

  .lp-item-title-edit {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    cursor: text;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 40%;
    border-radius: 4px;
    padding: 2px 4px;
    transition: background 0.2s ease;
  }
  
  .lp-item-title-edit:hover {
    background: color-mix(in srgb, var(--border) 50%, transparent);
  }
  
  .lp-item-title-edit:focus {
    outline: 1px solid var(--accent);
    background: var(--card);
  }

  .lp-item-spacer {
    display: inline-block;
    width: 15px;
  }

  .lp-item-desc {
    font-size: 14px;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--muted);
    max-width: 60%;
    border-radius: 4px;
    padding: 2px 4px;
    transition: background 0.2s ease;
  }
  
  .lp-item-desc:hover {
    background: color-mix(in srgb, var(--border) 50%, transparent);
  }
  
  .lp-item-desc:focus {
    outline: 1px solid var(--accent);
    background: var(--card);
  }

  .lp-item-actions {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .lp-item-actions i {
    font-size: 16px;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
  }
  
  .lp-item-actions i:hover {
    color: var(--accent);
    transform: scale(1.1);
  }

  .lp-wval {
    width: 64px !important;
    padding: 4px 6px;
  }

  .lp-wunit {
    width: 82px !important;
    padding: 0px 6px;
  }

  .dashboard-select .lp-sel, .dashboard-select .lp-sel-menu {
    min-width: 100px !important;
    width: 100px !important;
  }

  #lp-share-url {
    height: 40px;
  }

  .lp-qty {
    width: 64px !important;
    padding: 4px 6px;
  }

  .lp-link {
    padding: 4px 8px;
    height: 38px;
    width: 38px;
    display: flex;
    justify-content: center;
    align-items:center;
  }

  body.bricks-is-frontend :focus-visible {outline: none !important}

  .lp-item-remove i {
    pointer-events: none;
  }
  
  .lp-item-handle {
    opacity: 0.6;
    transition: opacity 0.2s ease, color 0.2s ease;
  }
  
  .lp-dnd-item:hover .lp-item-handle {
    opacity: 1;
  }

  .lp-item-handle {
    opacity: 0.6;
    transition: opacity 0.2s ease, color 0.2s ease, background 0.2s ease;
    border-radius: 4px;
    margin: -4px 0;
  }
  
  .lp-item-handle:hover {
    opacity: 1;
    background: color-mix(in srgb, var(--border) 50%, transparent);
  }
  
  .lp-item-handle:active {
    background: color-mix(in srgb, var(--border) 80%, transparent);
  }
  
  .lp-dnd-item:hover .lp-item-handle {
    opacity: 1;
  }

#lp-pack-editor .form-select{height:40px}
#lp-pack-editor .lp-btn{height:40px;display:inline-flex;align-items:center}

#lp-pack-editor {
  padding: 10px !important;
}

#lp-pack-title {
  margin-bottom: 25px !important;
}

.lp-btn span {
    text-wrap: nowrap;
}
.lp-btn {
    gap: 5px;   
}
#lp-pack-editor.lp-card {
    position: relative;
    overflow: visible;          /* override .lp-card overflow */
    isolation: isolate;         /* new stacking context so z-index wins */
  }
  
  .lp-sel {
    position: relative;
    display: inline-block;
    min-width: 260px;
    z-index: 1000;
  }
  
  .lp-sel-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
  }
  
  .lp-sel.open .lp-sel-menu { display: block; }
  
  .lp-sel-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: auto;
    z-index: 1001;
    width: max(260px, 100%);
    min-width: 260px;
    max-height: 70vh;           /* tall, but bounded to viewport */
    overflow-y: auto;           /* scroll long lists */
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 14px 40px rgba(0,0,0,.25);
    padding: 6px 0;
    display: none;
  }
  
  .lp-sel-opt {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
    padding: 10px 12px;
    font-size: 16px;
    background: transparent;
    border: 0;
    cursor: pointer;
    text-align: left;
    line-height: 1.4;
  }
  
  .lp-sel-opt:hover,
  .lp-sel-opt[aria-selected="true"] {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
  }
  
  .lp-sel-label {
    white-space: nowrap;
    overflow: auto;
    min-height: 20px;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  
  /* If your header container was clipping the menu, unclip it: */
  .site-header,
  .brx-header { overflow: visible; }

  /* Dark theme adjustments for pack editor dropdown */
.theme-dark .lp-sel-menu {
  background: var(--card);
  border-color: var(--border);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6);
}

.theme-dark .lp-sel-opt {
  color: var(--fg);
}

.theme-dark .lp-sel-opt:hover,
.theme-dark .lp-sel-opt[aria-selected="true"] {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--fg);
}

.theme-dark .lp-sel-label {
  color: var(--fg);
}

:root {
    --bg:#ffffff; --fg:#0f172a; --muted:#64748b; --card:#f8fafc; --border:#e2e8f0; --accent:#3b82f6; --sidebar-bg:#f3f6ff;
    --destructive:#ef4444;
  }
  .theme-dark {
    --bg:#0b1020; --fg:#e5e7eb; --muted:#9aa2b1; --card:#111827; --border:#1f2937; --accent:#60a5fa; --sidebar-bg:#0d1326;
    --destructive:#f87171;
  }
  
  .lp-btn-danger,
  .lp-icon-danger {
    color: var(--fg);
    border-color: var(--border);
    background: var(--card);
    transition: color .2s ease, border-color .2s ease, background .2s ease, transform .2s ease;
  }
  
  .lp-btn-danger:hover,
  .lp-icon-danger:hover {
    color: var(--destructive);
    border-color: var(--border);
    background: var(--card);
  }
  
  .lp-btn-danger i,
  .lp-icon-danger i { transition: color .2s ease, transform .2s ease; }
  
  .lp-btn-danger:hover i,
  .lp-icon-danger:hover i { color: var(--destructive); transform: scale(1.05); }
  
  .lp-btn-danger:focus-visible,
  .lp-icon-danger:focus-visible { outline:2px solid var(--destructive); outline-offset:2px; }
  
  .lp-item-remove { background: var(--card); border-color: var(--border); }
  
  .theme-dark .lp-btn-danger,
  .theme-dark .lp-icon-danger { color: var(--fg); background: var(--card); border-color: var(--border); }
  .theme-dark .lp-btn-danger:hover,
  .theme-dark .lp-icon-danger:hover { color: var(--destructive); background: var(--card); border-color: var(--border); }

  .lp-pack-app .lp-share {
    max-width: 1100px;
  }
  

/* Base responsive adjustments - applies to all screen sizes */
.lp-main-inner {
  max-width: 100% !important;
  width: 100% !important;
  padding: 20px;
  box-sizing: border-box;
}

.lp-pack-app {
  overflow-x: hidden;
}

.lp-grid {
  width: 100%;
  max-width: 100%;
}

/* Tablet and below */
@media (max-width: 1024px) {
  /* Adjust sidebar width for tablets */
  .lp-grid {
    grid-template-columns: 320px 1fr !important;
  }
  
  .lp-main-inner {
    padding: 18px;
    max-width: 100%;
  }
  
  /* Make items more compact on tablets */
  .lp-item-mid {
    flex: 1 1 auto;
  }
  
  .lp-item-title-edit {
    max-width: 45%;
  }
  
  .lp-item-desc {
    max-width: 55%;
  }
}

/* Mobile-specific responsive styles */
@media (max-width: 768px) {
  /* Stack layout vertically on mobile */
  .lp-grid {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto 1fr;
  }
  
  /* Sidebar becomes full-width at top */
  .lp-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 60vh;
    overflow-y: auto;
  }
  
  /* Hide sidebar when collapsed on mobile */
  .lp-grid.sidebar-collapsed .lp-sidebar {
    max-height: 56px;
    overflow: hidden;
  }
  
  .lp-grid.sidebar-collapsed .lp-sidebar-content {
    display: none;
  }
  
  /* Adjust sidebar padding */
  .lp-sidebar .lp-sidebar-inner {
    padding: 16px;
  }
  
  /* Main content adjustments */
  .lp-main-inner {
    padding: 16px;
    max-width: 100%;
    width: 100%;
  }
  
  /* Pack title sizing */
  #lp-pack-title {
    font-size: 22px !important;
  }
  
  .lp-pack-title {
    font-size: 18px !important;
  }
  
  /* Dashboard adjustments */
  #lp-pack-dashboard {
    padding: 12px !important;
  }
  
  /* Weight counters - stack vertically on very small screens */
  #lp-weight-counters {
    width: 100%;
  }
  
  #lp-weight-counters > div {
    flex: 1 1 auto;
    min-width: calc(50% - 4px);
    text-align: center;
  }
  
  /* Chart container */
  #lp-pack-chart {
    height: 180px !important;
  }
  
  /* Item rows - make more compact */
  .lp-item-compact {
    gap: 8px !important;
    padding: 8px !important;
    flex-wrap: wrap;
  }
  
  /* Item thumbnail smaller on mobile */
  .lp-item-thumb {
    width: 36px !important;
    height: 36px !important;
    flex: 0 0 36px !important;
  }
  
  /* Item middle section adjustments */
  .lp-item-mid {
    flex: 1 1 100%;
    min-width: 0;
    order: 2;
  }
  
  .lp-item-title-edit {
    max-width: 60% !important;
    font-size: 14px !important;
  }
  
  .lp-item-desc {
    max-width: 60% !important;
    font-size: 14px !important;
  }
  
  .lp-item-spacer {
    width: 8px !important;
  }
  
  /* Item actions - wrap to new line if needed */
  .lp-item-actions {
    gap: 6px !important;
    flex-wrap: wrap;
    order: 3;
    width: 100%;
    justify-content: flex-start;
  }
  
  /* Make input fields smaller */
  .lp-wval {
    width: 52px !important;
    font-size: 14px !important;
  }
  
  .lp-wunit {
    width: 70px !important;
    font-size: 14px !important;
  }
  
  .lp-qty {
    width: 52px !important;
    font-size: 14px !important;
  }
  
  /* Buttons smaller */
  .lp-btn {
    padding: 6px 10px !important;
    font-size: 14px !important;
  }
  
  .lp-link {
    width: 34px !important;
    height: 34px !important;
  }
  
  /* Category cards */
  .lp-dnd-cat-card {
    margin-bottom: 12px;
  }
  
  /* Handle visibility */
  .lp-item-handle,
  .lp-cat-handle {
    padding: 6px !important;
  }
  
  /* Sidebar items more compact */
  .lp-sidebar-item {
    padding: 10px !important;
  }
  
  /* Modal adjustments */
  .lp-sel-menu {
    max-width: 90vw;
    left: 50% !important;
    transform: translateX(-50%);
  }
  
  /* Select elements */
  .lp-select, .form-control, .form-select {
    font-size: 14px !important;
  }
}

@media (max-width: 480px) {
  /* Extra small screens */
  .lp-sidebar .lp-sidebar-inner,
  .lp-main-inner {
    padding: 12px;
  }
  
  #lp-pack-title {
    font-size: 20px !important;
  }
  
  /* Weight counters full width */
  #lp-weight-counters > div {
    min-width: calc(50% - 4px);
  }
  
  /* Hide chart on very small screens - optional */
  #lp-pack-chart {
    height: 150px !important;
  }
  
  /* Item actions stack more aggressively */
  .lp-item-actions {
    gap: 4px !important;
  }
  
  /* Further reduce input sizes */
  .lp-wval,
  .lp-qty {
    width: 48px !important;
  }
  
  .lp-wunit {
    width: 65px !important;
  }
  
  /* Buttons even more compact */
  .lp-btn {
    padding: 5px 8px !important;
    font-size: 13px !important;
  }
  
  .lp-btn i {
    font-size: 14px !important;
  }
  
  /* Hide button text, show only icons on very small screens */
  .lp-btn span {
    display: none;
  }
  
  .lp-item-title-edit,
  .lp-item-desc {
    font-size: 14px !important;
  }
}

/* Touch improvements */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  .lp-btn,
  .lp-item-actions i,
  .lp-item-thumb {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Easier dragging on touch */
  .lp-item-handle,
  .lp-cat-handle {
    padding: 12px !important;
  }
  
  /* Prevent text selection during drag */
  .lp-dnd-item,
  .lp-dnd-cat-card {
    -webkit-user-select: none;
    user-select: none;
  }
}

