/* ── Rincol Web ERP — Global Styles ─────────────────────────────────────── */
:root {
  --sidebar-width: 220px;
  --topbar-height: 52px;
  --brand-dark: #1a1a2e;
  --accent-blue: #89b4fa;
  --accent-green: #a6e3a1;
  --sidebar-bg: #111827;
  --sidebar-hover: #1f2937;
  --card-bg: #1e2130;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
body { background: #131625; color: #e2e8f0; min-height: 100vh; }

#sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.main-content { min-width: 0; }

.topbar {
  height: var(--topbar-height);
  background: #161929;
  border-bottom: 1px solid #2a2d45;
  position: sticky;
  top: 0;
  z-index: 90;
}

.content-body { min-height: calc(100vh - var(--topbar-height)); }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar-brand { line-height: 1; }
.brand-logo { width: 36px; height: 36px; object-fit: contain; border-radius: 8px; flex-shrink: 0; }
.brand-text { display: block; font-size: 1.25rem; font-weight: 800; color: var(--accent-blue); letter-spacing: 2px; }
.brand-sub  { font-size: .65rem; color: #6b7280; letter-spacing: 1px; text-transform: uppercase; }

.sidebar .nav-link {
  color: #9ca3af;
  border-radius: 8px;
  padding: .45rem .75rem;
  font-size: .875rem;
  transition: background .15s, color .15s;
  display: flex;
  align-items: center;
  gap: .55rem;
}
.sidebar .nav-link:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.sidebar .nav-link.active { background: rgba(137,180,250,.15); color: var(--accent-blue); font-weight: 600; }
.sidebar .nav-link i { font-size: 1rem; }

.sidebar-divider { border-color: #2a2d45; margin: .5rem 0; }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent-blue);
  color: #1a1a2e;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem; flex-shrink: 0;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid #2a2d45;
  border-radius: 12px;
}
.card-header { background: transparent; border-bottom: 1px solid #2a2d45; }

/* ── Stat cards ──────────────────────────────────────────────────────────── */
.stat-card { border-radius: 12px; padding: 1.25rem; }
.stat-card .stat-icon { font-size: 2rem; opacity: .8; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-card .stat-label { font-size: .75rem; opacity: .7; text-transform: uppercase; letter-spacing: .5px; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table { color: #e2e8f0; }
.table th { color: #89b4fa; font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
.table > :not(caption) > * > * { background: transparent; }
.table-hover tbody tr:hover > * { background: rgba(255,255,255,.04); }

/* Resizable table wrapper */
.table-responsive-resizable { overflow-x: auto; }
.table-resizable th { position: relative; user-select: none; }
.table-resizable th .col-resizer {
  position: absolute; right: 0; top: 0; width: 5px; height: 100%;
  cursor: col-resize; z-index: 1;
}
.table-resizable th .col-resizer:hover,
.table-resizable th.resizing .col-resizer { background: var(--accent-blue); }

/* Drag-to-reorder rows */
.drag-handle {
  cursor: grab;
  color: #4b5563;
  font-size: 1.1rem;
  padding: 0 6px !important;
  user-select: none;
  text-align: center;
  width: 24px;
}
.drag-handle:hover { color: #9ca3af; }
.drag-handle:active { cursor: grabbing; }
tr.dragging { opacity: 0.35; }

/* ── Badges / status ─────────────────────────────────────────────────────── */
.badge-draft      { background: rgba(148,163,184,.2); color: #94a3b8; }
.badge-pending    { background: rgba(251,191,36,.2);  color: #fbbf24; }
.badge-approved   { background: rgba(137,180,250,.2); color: var(--accent-blue); }
.badge-in-progress{ background: rgba(167,139,250,.2); color: #a78bfa; }
.badge-completed  { background: rgba(166,227,161,.2); color: var(--accent-green); }
.badge-cancelled  { background: rgba(255,100,100,.2); color: #f87171; }
.badge-open       { background: rgba(251,191,36,.2);  color: #fbbf24; }
.badge-resolved   { background: rgba(166,227,161,.2); color: var(--accent-green); }
.badge-pending-parts { background: rgba(167,139,250,.2); color: #a78bfa; }
.badge-warranty   { background: rgba(137,180,250,.2); color: var(--accent-blue); }
.badge-paid-type  { background: rgba(166,227,161,.2); color: var(--accent-green); }
.badge-scheduled  { background: rgba(56,189,248,.2);  color: #38bdf8; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-control, .form-select {
  background: #1a1d2e;
  border-color: #374151;
  color: #e2e8f0;
}
.form-control:focus, .form-select:focus {
  background: #1a1d2e;
  border-color: var(--accent-blue);
  color: #e2e8f0;
  box-shadow: 0 0 0 .2rem rgba(137,180,250,.2);
}
.form-label { font-size: .8rem; color: #9ca3af; margin-bottom: .25rem; text-transform: uppercase; letter-spacing: .4px; }

/* ── Quotation line items table ──────────────────────────────────────────── */
#line-items-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
#line-items-table th, #line-items-table td { padding: 6px 8px; vertical-align: middle; }
#line-items-table th { background: var(--brand-dark); color: var(--accent-blue); font-size: .75rem; text-transform: uppercase; white-space: nowrap; }
#line-items-table td input, #line-items-table td select {
  width: 100%; background: #1a1d2e; border: 1px solid #374151;
  color: #e2e8f0; border-radius: 4px; padding: 3px 6px; font-size: .85rem;
}
#line-items-table td input:focus, #line-items-table td select:focus {
  border-color: var(--accent-blue); outline: none;
}
#line-items-table .td-total { color: var(--accent-green); font-weight: 600; text-align: right; }
#line-items-table .td-no { color: #6b7280; text-align: center; }
#line-items-table tbody tr:nth-child(even) { background: rgba(255,255,255,.02); }

/* Grand total row */
.grand-total-row td { border-top: 2px solid var(--accent-green) !important; font-weight: 700; }
.grand-total-label { text-align: right; color: #e2e8f0; }
.grand-total-value { color: var(--accent-green); text-align: right; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary   { background: var(--accent-blue); border-color: var(--accent-blue); color: #1a1a2e; }
.btn-primary:hover { background: #6da5f0; border-color: #6da5f0; color: #1a1a2e; }
.btn-success   { background: var(--accent-green); border-color: var(--accent-green); color: #1a1a2e; }
.btn-success:hover { background: #85c982; border-color: #85c982; color: #1a1a2e; }

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-page { background: var(--brand-dark); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: #1e2130; border: 1px solid #2a2d45; border-radius: 16px; padding: 2.5rem; width: 100%; max-width: 400px; }
.login-logo { font-size: 1.8rem; font-weight: 800; color: var(--accent-blue); letter-spacing: 3px; }

/* ── Global loading spinner ──────────────────────────────────────────────── */
.spinner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

/* ── Markup sub-line in price cell ───────────────────────────────────────── */
.col-markup {
  font-size: 0.65rem;
  text-align: right;
  line-height: 1.2;
  margin-top: 1px;
  letter-spacing: 0.01em;
}

/* ── Mobile responsive ───────────────────────────────────────────────────── */
@media (max-width: 767px) {
  /* Sidebar slides in as overlay */
  #sidebar {
    position: fixed;
    left: 0; top: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 200;
    width: 240px;
  }
  #sidebar.show { transform: translateX(0); }

  /* Backdrop behind open sidebar */
  #sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 199;
  }
  #sidebar-backdrop.show { display: block; }

  /* Main content takes full width */
  .main-content { width: 100%; }

  /* Topbar: show hamburger, tighten padding */
  .topbar { padding: 0 1rem !important; }
  #sidebarToggle { display: flex !important; }

  /* Stat cards: 2 columns */
  .stat-card { padding: .9rem; }
  .stat-card .stat-value { font-size: 1.3rem; }

  /* Content padding */
  .content-body { padding: 1rem !important; }

  /* Tables scroll horizontally (non-line-items tables only) */
  .table-responsive-resizable { overflow-x: visible; }

  /* ── Quotation line items: card-per-row layout on mobile ── */
  #line-items-table,
  #line-items-table tbody { display: block; }

  #line-items-table colgroup,
  #line-items-table thead { display: none; }

  /* Tfoot stays as table so colspan works */
  #line-items-table tfoot { display: table; width: 100%; border-collapse: collapse; }
  #line-items-table tfoot tr { display: table-row; }
  #line-items-table tfoot td { display: table-cell; padding: 6px 8px; font-size: .8rem; }

  /* Each item row becomes a card */
  #line-items-table tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    border: 1px solid #2a2d45;
    border-radius: 8px;
    margin-bottom: 8px;
    padding: 8px;
    background: rgba(26,29,46,0.6);
  }

  /* Hide drag handle and line number — not useful on touch */
  #line-items-table .drag-handle,
  #line-items-table .td-no { display: none; }

  /* Description: full width, prominent */
  #line-items-table .td-desc {
    flex: 0 0 100%;
    padding: 0;
  }
  #line-items-table .td-desc input {
    font-size: 0.95rem;
    padding: 8px 10px;
    height: auto;
  }

  /* UOM, Qty, Price in a flex row */
  #line-items-table .td-uom { flex: 0 0 68px; padding: 0; }
  #line-items-table .td-qty { flex: 0 0 64px; padding: 0; }
  #line-items-table .td-price { flex: 1 1 100px; padding: 0; }

  /* Total — right-aligned, fills remaining space */
  #line-items-table .td-total {
    flex: 1 1 auto;
    text-align: right;
    padding: 0 4px;
    font-size: 0.85rem;
    align-self: center;
  }

  /* Delete button — far right */
  #line-items-table .td-delete { flex: 0 0 auto; padding: 0; }

  /* Inputs inside the row */
  #line-items-table tbody td input,
  #line-items-table tbody td select {
    font-size: 0.85rem;
    padding: 5px 6px;
  }
}

/* ── Misc ────────────────────────────────────────────────────────────────── */
.text-blue  { color: var(--accent-blue) !important; }
.text-green { color: var(--accent-green) !important; }
.section-header { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: #6b7280; margin-bottom: .75rem; }
.money { font-family: 'SF Mono', 'Fira Code', monospace; }
hr.section-sep { border-color: #2a2d45; }
