/**
 * CloudLedger AI - Executive Drawer & Multi-Column Item Picker Engine
 * Standardized across Quotes, Sales Orders, Invoices, Challans, Credit Notes, and Purchase Orders
 */

/* ── 1. GLOBAL DRAWER & POPUP OVERHAUL ────────────────────────────── */
.im-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6) !important;
  backdrop-filter: blur(5px) !important;
  -webkit-backdrop-filter: blur(5px);
  z-index: 1000;
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s ease;
}

.im-drawer-overlay.active {
  opacity: 1 !important;
  visibility: visible !important;
}

/* Master Drawers opened via shortcut inside transaction drawers stack on top */
#item-drawer.im-drawer-overlay,
#pricelist-drawer.im-drawer-overlay {
  z-index: 2100 !important;
}

.im-drawer {
  background: #f8fafc !important;
  width: min(1140px, 96vw) !important;
  height: 100% !important;
  display: flex;
  flex-direction: column;
  box-shadow: -12px 0 40px rgba(15, 23, 42, 0.22) !important;
  border-left: 1px solid #cbd5e1;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.im-drawer-overlay.active .im-drawer {
  transform: translateX(0) !important;
}

/* ── 2. EXECUTIVE DRAWER HEADER ───────────────────────────────────── */
.im-drawer-head {
  background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%) !important;
  border-bottom: 1px solid #e2e8f0 !important;
  padding: 18px 28px !important;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.im-drawer-eyebrow {
  font-size: 11px !important;
  font-weight: 800 !important;
  letter-spacing: 0.8px !important;
  text-transform: uppercase !important;
  color: #2563eb !important;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.im-drawer-title {
  font-size: 20px !important;
  font-weight: 800 !important;
  color: #0f172a !important;
  letter-spacing: -0.3px;
  margin: 0 !important;
}

.im-close {
  width: 34px !important;
  height: 34px !important;
  border-radius: 50% !important;
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #64748b !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 14px !important;
  cursor: pointer !important;
  transition: all 0.18s ease !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.im-close:hover {
  background: #fee2e2 !important;
  border-color: #fca5a5 !important;
  color: #ef4444 !important;
  transform: scale(1.05);
}

/* ── 3. DRAWER BODY & CARD SECTIONS ───────────────────────────────── */
.im-drawer-body {
  flex: 1 !important;
  overflow-y: auto !important;
  padding: 24px 28px !important;
  background: #f8fafc !important;
}

.im-section {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 14px !important;
  padding: 22px 24px !important;
  margin-bottom: 22px !important;
  box-shadow: 0 2px 8px -2px rgba(15, 23, 42, 0.04) !important;
}

.im-section-head {
  border-bottom: 1px solid #f1f5f9 !important;
  padding-bottom: 12px !important;
  margin-bottom: 16px !important;
}

.im-section-title {
  font-size: 14px !important;
  font-weight: 800 !important;
  color: #0f172a !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
}

.im-field-row {
  margin-bottom: 14px;
}

.im-label {
  display: block !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  color: #475569 !important;
  margin-bottom: 6px !important;
}

.im-req::after {
  content: ' *';
  color: #ef4444;
}

.form-control, .im-input, .im-select {
  height: 40px !important;
  padding: 0 12px !important;
  border-radius: 8px !important;
  border: 1px solid #cbd5e1 !important;
  background: #ffffff !important;
  font-size: 13px !important;
  color: #0f172a !important;
  transition: all 0.15s ease !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.form-control:focus, .im-input:focus, .im-select:focus {
  outline: none !important;
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14) !important;
}

textarea.form-control {
  height: auto !important;
  min-height: 68px !important;
  padding: 10px 12px !important;
  line-height: 1.5 !important;
  resize: vertical;
}

/* ── 4. LINE ITEMS TABLE STYLING ──────────────────────────────────── */
.sd-lines-wrap {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 12px !important;
  overflow: visible !important; /* Allow popover dropdowns to render */
  margin-bottom: 14px !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.sd-lines {
  width: 100% !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

.sd-lines thead th {
  background: #f1f5f9 !important;
  color: #475569 !important;
  font-size: 11px !important;
  font-weight: 800 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.6px !important;
  padding: 11px 12px !important;
  border-bottom: 2px solid #e2e8f0 !important;
}

.sd-lines thead th:first-child {
  border-top-left-radius: 11px;
}

.sd-lines thead th:last-child {
  border-top-right-radius: 11px;
}

.sd-lines tbody td {
  padding: 10px 8px !important;
  border-bottom: 1px solid #f1f5f9 !important;
  vertical-align: top !important;
  background: #ffffff;
}

.sd-lines tbody tr:last-child td {
  border-bottom: none !important;
}

.sd-lines tbody tr:hover td {
  background: #fbfcfe;
}

.sd-lines .sd-name {
  font-weight: 700;
  color: #0f172a;
}

.sd-add-line {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 9px 18px !important;
  border-radius: 9px !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  background: #eff6ff !important;
  color: #2563eb !important;
  border: 1px dashed #93c5fd !important;
  cursor: pointer !important;
  transition: all 0.18s ease !important;
  margin-bottom: 18px !important;
}

.sd-add-line:hover {
  background: #dbeafe !important;
  border-color: #3b82f6 !important;
  transform: translateY(-1px);
}

/* ── 5. TOTALS SUMMARY CARD ───────────────────────────────────────── */
.sd-totals {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 14px !important;
  padding: 18px 20px !important;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.03) !important;
}

.sd-totals-line, .bd-total-row {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  padding: 6px 0 !important;
  font-size: 13px !important;
  color: #475569 !important;
}

.sd-totals-grand {
  border-top: 2px solid #e2e8f0 !important;
  margin-top: 10px !important;
  padding-top: 12px !important;
  font-size: 16px !important;
  font-weight: 800 !important;
  color: #0f172a !important;
}

.sd-totals-grand span:last-child {
  color: #1e40af !important;
  font-size: 18px !important;
  font-family: var(--font-mono, monospace);
}

/* ── 6. DRAWER FOOTER ─────────────────────────────────────────────── */
.im-drawer-foot {
  background: #ffffff !important;
  border-top: 1px solid #e2e8f0 !important;
  padding: 16px 28px !important;
  display: flex !important;
  justify-content: flex-end !important;
  align-items: center !important;
  gap: 12px !important;
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.04) !important;
}

.btn-secondary {
  padding: 9px 20px !important;
  border-radius: 9px !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  color: #475569 !important;
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
}

.btn-secondary:hover {
  background: #f1f5f9 !important;
  color: #0f172a !important;
}

.btn-primary {
  padding: 9px 24px !important;
  border-radius: 9px !important;
  font-size: 13px !important;
  font-weight: 800 !important;
  color: #ffffff !important;
  background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
  border: none !important;
  cursor: pointer !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28) !important;
  transition: all 0.15s ease !important;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af) !important;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35) !important;
  transform: translateY(-1px);
}


/* ── 7. REVOLUTIONARY MULTI-COLUMN ITEM SEARCH DROPDOWN ──────────── */
.cl-item-picker-wrapper {
  position: relative;
  width: 100%;
}

.cl-item-picker-menu {
  position: absolute;
  top: 100%;
  left: 0;
  width: max(560px, 100%);
  max-width: 680px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  box-shadow: 0 12px 36px -4px rgba(15, 23, 42, 0.18), 0 4px 12px rgba(0,0,0,0.06);
  z-index: 1050;
  margin-top: 4px;
  overflow: hidden;
  animation: clPickerFadeIn 0.15s ease-out;
}

@keyframes clPickerFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.cl-ip-header {
  display: flex;
  align-items: center;
  background: #f1f5f9;
  padding: 8px 14px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 11px;
  font-weight: 800;
  color: #64748b;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.cl-ip-list {
  max-height: 260px;
  overflow-y: auto;
}

.cl-ip-row {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #f8fafc;
  cursor: pointer;
  transition: background 0.12s ease;
}

.cl-ip-row:hover, .cl-ip-row.active {
  background: #eff6ff !important;
}

.cl-ip-name {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cl-ip-sku-badge {
  display: inline-block;
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  margin-top: 2px;
}

.cl-ip-stock-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.cl-ip-stock-pill.in-stock {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.cl-ip-stock-pill.out-of-stock {
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fecdd3;
}

.cl-ip-stock-pill.non-tracked {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.cl-ip-price {
  font-family: var(--font-mono, monospace);
  font-weight: 800;
  font-size: 13px;
  color: #0f172a;
}

.cl-ip-hsn {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  color: #64748b;
}

.cl-ip-tax {
  font-size: 11px;
  font-weight: 700;
  color: #2563eb;
}

.cl-ip-footer {
  padding: 8px 14px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cl-ip-add-btn {
  background: none;
  border: none;
  color: #2563eb;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s ease;
}

.cl-ip-add-btn:hover {
  background: #eff6ff;
  text-decoration: underline;
}

/* Metadata pill rendered on selected line */
.cl-item-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.cl-item-meta-chip span {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
}
