/* ── UMR Shared Stylesheet ──────────────────────────────────────────────────
   Included by: index.html, fsr.html, pm.html, field.html, login.html,
                fsr-blank.html, pm-blank.html
   NOTE: If you change brand colors, change the variables here — nowhere else.
   ─────────────────────────────────────────────────────────────────────────── */

:root {
  --brand:        #1a6a99;   /* primary blue */
  --brand-dark:   #155880;   /* hover state */
  --brand-light:  #cde;      /* topbar links, borders */
  --brand-bg:     #f0f7ff;   /* light blue tint */
  --brand-border: #cde;      /* section underlines */
  --pm-purple:    #7b5ea7;   /* PM doc accent */
  --pm-purple-dk: #5e4480;
  --flat-accent:    #b7791f;  /* Flatness Check doc accent (amber) */
  --flat-accent-dk: #8f5c14;
  --danger:       #c0392b;
  --danger-bg:    #fdf0ee;
  --success:      #2e7d32;
  --success-dk:   #1b5e20;
  --save-green:   #4caf50;
  --save-yellow:  #ffc107;
  --text:         #111;
  --text-muted:   #444;
  --text-faint:   #666;
  --border:       #ccc;
  --border-light: #ddd;
  --bg-page:      #d0d0d0;   /* outer background */
  --bg-sidebar:   #fafafa;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: Helvetica, Arial, sans-serif;
  font-size: 9pt;
  color: var(--text);
  background: var(--bg-page);
}

/* ── Topbar ── */
.topbar {
  background: var(--brand); color: #fff; padding: 8px 16px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 9pt; position: sticky; top: 0; z-index: 500;
}
.topbar strong { font-size: 10pt; }
.topbar a { color: var(--brand-light); text-decoration: none; font-size: 8pt; }
.topbar a:hover { text-decoration: underline; }

/* ── Save status dot ── */
.save-status { display: flex; align-items: center; gap: 6px; font-size: 8pt; }
.save-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--save-green); transition: background .2s; }
.save-dot.saving { background: var(--save-yellow); animation: umr-pulse 1s infinite; }
@keyframes umr-pulse { 0%,100%{opacity:1}50%{opacity:.4} }

/* ── Sidebar layout ── */
.layout { display: flex; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  padding: 14px; min-height: calc(100vh - 40px);
}
.sidebar h2 { font-size: 10pt; color: var(--brand); margin-bottom: 10px; }
.sidebar .btn-new {
  display: block; width: 100%; padding: 7px; margin-bottom: 6px;
  background: var(--brand); color: #fff; border: none;
  border-radius: 3px; cursor: pointer; font-size: 8.5pt;
}
.sidebar .btn-new:hover { background: var(--brand-dark); }
.sidebar .btn-new.btn-pm { background: var(--pm-purple); }
.sidebar .btn-new.btn-pm:hover { background: var(--pm-purple-dk); }
.sidebar .btn-del {
  display: block; width: 100%; padding: 5px; margin-top: 10px;
  background: #fff; color: var(--danger); border: 1px solid var(--danger);
  border-radius: 3px; cursor: pointer; font-size: 8pt;
}
.sidebar .btn-del:hover { background: var(--danger-bg); }

/* ── Sidebar list items (generic) ── */
.doc-item, .fsr-item, .pm-item {
  padding: 6px 8px; border: 1px solid #e0e0e0; border-radius: 3px;
  margin-bottom: 5px; cursor: pointer; background: #fff;
}
.doc-item:hover, .fsr-item:hover, .pm-item:hover { background: #eef6ff; border-color: #b0ccdf; }
.doc-item.active, .fsr-item.active, .pm-item.active { background: #ddeeff; border-color: var(--brand); }
.di-title, .fi-title { font-size: 8.5pt; font-weight: 600; color: #222; margin-bottom: 2px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.di-sub, .fi-sub { font-size: 7.5pt; color: var(--text-faint); }

/* ── Sidebar filter tabs ── */
.filter-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.filter-tabs button {
  flex: 1; font-size: 7pt; padding: 4px 2px;
  border: 1px solid var(--border); border-radius: 3px;
  background: #fff; color: #333; cursor: pointer;
}
.filter-tabs button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ── Main area ── */
.main-area { flex: 1; overflow-x: auto; padding: 18px; }
.empty-state { text-align: center; color: #aaa; font-size: 11pt; margin-top: 80px; }

/* ── Action bar ── */
.action-bar { display: flex; gap: 8px; margin-bottom: 10pt; flex-wrap: wrap; }
.action-bar button {
  font-size: 8pt; padding: 5px 12px; border: 1px solid var(--border);
  border-radius: 3px; background: #fff; cursor: pointer;
}
.action-bar button:hover { background: #f0f0f0; }
.btn-create-invoice {
  background: var(--success) !important; color: #fff !important;
  border-color: var(--success) !important;
}
.btn-create-invoice:hover { background: var(--success-dk) !important; }
.btn-create-invoice[disabled] { background: #aaa !important; border-color: #aaa !important; cursor: default !important; }

/* ── Status badges ── */
.status-badge { font-size: 6pt; padding: 1px 5px; border-radius: 6px; color: #fff; }
.status-badge.invoiced, .status-badge.completed { background: var(--success); }
.status-badge.pending { background: #6c757d; }
.type-badge-fsr { font-size: 6pt; padding: 1px 5px; border-radius: 6px; background: #17a2b8; color: #fff; }
.type-badge-pm  { font-size: 6pt; padding: 1px 5px; border-radius: 6px; background: var(--pm-purple); color: #fff; }
.type-badge-flatness { font-size: 6pt; padding: 1px 5px; border-radius: 6px; background: var(--flat-accent); color: #fff; }

/* ── Toast ── */
#toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9000;
  background: var(--success); color: #fff; padding: 10px 18px;
  border-radius: 6px; font-size: 9pt;
  box-shadow: 0 3px 10px rgba(0,0,0,.25); display: none;
}

/* ── Customer autocomplete dropdown ── */
.customer-drop {
  display: none; position: fixed; z-index: 800;
  background: #fff; border: 1px solid var(--border); border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,.15); font-size: 8.5pt;
  min-width: 240px; max-height: 240px; overflow-y: auto;
}
/* Legacy IDs kept for compatibility */
#fsrCustomerDrop, #pmCustomerDrop, #h_fsr_customerDrop, #h_pm_customerDrop {
  display: none; position: fixed; z-index: 800;
  background: #fff; border: 1px solid var(--border); border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,.15); font-size: 8.5pt;
  min-width: 240px; max-height: 240px; overflow-y: auto;
}

/* ── Asset bar ── */
.asset-bar {
  display: none; margin: 6pt 0; align-items: center; gap: 8pt; font-size: 8pt;
  padding: 4pt 6pt; background: var(--brand-bg); border-radius: 3px;
  border: 1px solid var(--brand-border);
}

/* ── Signature block ── */
.sig-table { width: 100%; border-collapse: collapse; margin-top: 10pt; }
.sig-table td { padding: 4pt 6pt; vertical-align: top; }
.sig-field { display: flex; flex-direction: column; gap: 2pt; margin-bottom: 6pt; }
.sig-field label { font-size: 7.5pt; font-weight: 600; color: var(--text-muted); }
.sig-field input {
  border: none; border-bottom: 1px solid #999; font-size: 8.5pt;
  font-family: inherit; padding: 1pt 2pt; outline: none;
  width: 100%; background: transparent;
}
.sig-field input:focus { border-bottom-color: var(--brand); }
.sig-divider { border-left: 1px solid var(--border); width: 0.2in; }

/* ── Parts table ── */
.parts-table { width: 100%; border-collapse: collapse; font-size: 8.5pt; margin-bottom: 6pt; }
.parts-table th {
  background: #f0f4f8; font-size: 7.5pt; font-weight: 700;
  text-align: left; padding: 3pt 5pt; border: 1px solid var(--border); color: #333;
}
.parts-table td { border: 1px solid var(--border-light); padding: 2pt 4pt; }
.parts-table input[type="text"] {
  width: 100%; border: none; font-size: 8.5pt;
  font-family: inherit; padding: 1pt 2pt; outline: none; background: transparent;
}
.parts-table .col-qty  { width: 0.6in; }
.parts-table .col-part { width: 1.1in; }
.parts-table .col-unit { width: 0.85in; text-align: right; }
.parts-table .col-ext  { width: 0.9in; text-align: right; }
.parts-table .col-del  { width: 0.3in; text-align: center; }
.parts-table input.right { text-align: right; }
.btn-del-row { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 10pt; padding: 0 2pt; }
.btn-add-part {
  font-size: 7.5pt; background: #e8f4fb; border: 1px solid #99c4dd;
  border-radius: 3px; padding: 3pt 8pt; cursor: pointer; color: var(--brand);
}
.btn-add-part:hover { background: #cde8f5; }

/* ── Labor fields ── */
.labor-row { display: flex; gap: 12pt; margin-bottom: 4pt; flex-wrap: wrap; }
.labor-field { display: flex; flex-direction: column; gap: 2pt; }
.labor-field label { font-size: 7.5pt; font-weight: 600; color: var(--text-muted); }
.labor-field input {
  border: none; border-bottom: 1px solid #999; font-size: 8.5pt;
  font-family: inherit; padding: 1pt 2pt; outline: none;
  width: 1in; background: transparent;
}
.labor-field input:focus { border-bottom-color: var(--brand); }

/* ── Status radio ── */
.status-row { display: flex; gap: 16pt; align-items: center; margin-bottom: 6pt; flex-wrap: wrap; }
.status-row label { font-size: 8.5pt; display: flex; align-items: center; gap: 4pt; cursor: pointer; }
.status-row input[type="radio"] { cursor: pointer; }

/* ── Mobile sidebar overlay ── */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 490; }
.sidebar-overlay.open { display: block; }
button.hamburger { display: none; }

/* ── Print base ── */
@media print {
  body { background: #fff; font-size: 9pt; }
  .topbar, .sidebar, .sidebar-overlay, .action-bar,
  .btn-del-row, .btn-add-part, .asset-bar,
  #fsrAssetBar, #pmAssetBar, #flAssetBar, #toast, button.hamburger { display: none !important; }
  .layout { display: block; }
  .main-area { padding: 0; }
  .parts-table td, .parts-table th { border-color: #aaa; }
  @page { size: 8.5in 11in portrait; margin: 0.5in; }
}

/* ── Mobile ── */
@media screen and (max-width: 768px) {
  button.hamburger { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 495;
    transform: translateX(-100%); transition: transform .2s;
    box-shadow: 3px 0 12px rgba(0,0,0,.2);
  }
  .sidebar.open { transform: translateX(0); }
  .main-area { padding: 10px; }
  .labor-row { flex-direction: column; gap: 8pt; }
  .labor-field input { width: 100%; }
  .status-row { flex-direction: column; gap: 6pt; }
  .sig-table, .sig-table tbody, .sig-table tr, .sig-table td { display: block; width: 100%; }
  .sig-divider { display: none; }
  input, textarea, select { font-size: 16px !important; }
}

/* ── Photo section ── */
.photo-section { margin: 10pt 0; }
.photo-section-label {
  font-size: 8pt; font-weight: 700; color: var(--brand); text-transform: uppercase;
  letter-spacing: .5px; margin-bottom: 6pt; border-bottom: 1px solid var(--brand-border); padding-bottom: 2pt;
}
.photo-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8pt; }
.photo-thumb { position: relative; width: 120px; }
.photo-thumb img {
  width: 120px; height: 90px; object-fit: cover;
  border: 1px solid var(--border); border-radius: 4px; cursor: pointer; display: block;
}
.photo-thumb input {
  width: 100%; border: none; border-bottom: 1px solid var(--border-light); font-size: 7.5pt;
  font-family: inherit; padding: 2pt; outline: none; margin-top: 3px; background: transparent;
}
.photo-thumb input:focus { border-bottom-color: var(--brand); }
.photo-thumb .photo-del {
  position: absolute; top: 2px; right: 2px;
  background: rgba(0,0,0,.55); color: #fff; border: none; border-radius: 50%;
  width: 18px; height: 18px; font-size: 10px; cursor: pointer; line-height: 18px; text-align: center;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.photo-add-btn {
  display: flex; align-items: center; justify-content: center;
  width: 120px; height: 90px; border: 2px dashed var(--border); border-radius: 4px;
  color: #999; font-size: 22px; cursor: pointer; background: #fafafa;
  flex-direction: column; gap: 4px;
}
.photo-add-btn span { font-size: 8pt; color: #aaa; }
.photo-add-btn:hover { border-color: var(--brand); color: var(--brand); background: #eef5fb; }
#photoLightbox {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.85);
  z-index: 9000; align-items: center; justify-content: center;
}
#photoLightbox.open { display: flex; }
#photoLightbox img { max-width: 92vw; max-height: 88vh; border-radius: 4px; }
#photoLightbox button {
  position: fixed; top: 16px; right: 20px;
  background: none; border: none; color: #fff; font-size: 28px; cursor: pointer;
}
@media print {
  .photo-add-btn, .photo-del { display: none !important; }
  .photo-thumb input { border-bottom: none; }
  .photo-grid { gap: 6px; }
  .photo-thumb img { width: 100px; height: 75px; }
  .photo-section:not(:has(.photo-thumb)) { display: none !important; }
}
@media screen and (max-width: 768px) {
  .photo-thumb { width: 100px; }
  .photo-thumb img { width: 100px; height: 75px; }
  .photo-add-btn { width: 100px; height: 75px; }
}

/* ── Index sidebar: quote/customer items ── */
.customer-group-header {
  padding: 6px 8px; font-size: 8pt; font-weight: 700; color: var(--brand);
  cursor: pointer; margin-top: 4px; border-bottom: 1px solid #e8e8e8;
  display: flex; align-items: center; gap: 4px;
  border-radius: 3px 3px 0 0; transition: background .12s;
  user-select: none;
}
.customer-group-header:hover { background: #eef6ff !important; }
.customer-group-header.active { background: #ddeeff !important; border-bottom-color: var(--brand); }

.quote-item {
  padding: 5px 8px 5px 14px; margin-bottom: 2px;
  cursor: pointer; border-radius: 3px; border-left: 3px solid transparent;
  transition: background .12s, border-color .12s;
  display: flex; flex-direction: column; gap: 1px;
  position: relative;
}
.quote-item:hover { background: #eef6ff; border-left-color: var(--brand-light); }
.quote-item.active { background: #ddeeff; border-left-color: var(--brand); }
.qi-title { display: flex; align-items: center; gap: 4px; font-size: 8pt; }
.qi-sub   { font-size: 7pt; color: var(--text-faint); padding-left: 1px; }
.qi-badge { font-size: 6pt; padding: 1px 5px; border-radius: 6px; color: #fff; font-weight: 700; flex-shrink: 0; }
.badge-QTE { background: var(--brand); }
.badge-INV { background: var(--danger); }
.qi-del {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: #ccc; font-size: 12pt; cursor: pointer;
  padding: 0 4px; line-height: 1; display: none;
}
.quote-item:hover .qi-del { display: block; }
.qi-del:hover { color: var(--danger); }
