/* ============================================================
   Jennings Report System — UI theme (Bootstrap 5 base)
   ============================================================ */
:root {
  --orange:       #F26A21;
  --orange-d:     #d65a16;
  --orange-soft:  #fff1e8;
  --charcoal:     #2b2c30;
  --charcoal-2:   #36373d;
  --ink:          #2d2d2d;
  --muted:        #6c757d;
  --line:         #e9ecef;
  --topbar-h:     56px;
  --sidebar-w:    240px;
  --bs-primary:   #F26A21;
}

* { -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'Montserrat', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f4f5f7;
  color: var(--ink);
  padding-top: var(--topbar-h);
  margin: 0;
}

/* ---------- Top navbar ---------- */
.jr-topbar {
  height: var(--topbar-h);
  background: var(--charcoal);
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 0 .75rem;
  z-index: 1040;
  box-shadow: 0 1px 0 rgba(0,0,0,.15);
}
.jr-burger {
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  padding: .25rem .5rem;
  border-radius: 8px;
}
.jr-burger:active { background: rgba(255,255,255,.12); }
.jr-brand { display: flex; align-items: center; }
.jr-brand img { height: 34px; width: auto; display: block; }
.jr-user-btn {
  background: transparent;
  border: 0;
  color: #d7d8db;
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .9rem;
  font-weight: 600;
  padding: .35rem .5rem;
  border-radius: 8px;
}
.jr-user-btn:hover { color: #fff; background: rgba(255,255,255,.08); }
.jr-user-btn::after { display: none; }
.jr-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
}

/* ---------- Layout ---------- */
.jr-layout { display: flex; align-items: flex-start; }
.jr-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; min-height: calc(100vh - var(--topbar-h)); }
.jr-content { flex: 1 0 auto; padding: 1.25rem; max-width: 1280px; width: 100%; }
.jr-footer { padding: 1rem 1.25rem; text-align: center; color: var(--muted); font-size: .8rem; }

/* ---------- Sidebar ---------- */
.jr-sidebar {
  --bs-offcanvas-width: 250px;
  --bs-offcanvas-bg: var(--charcoal);
  color: #cfd0d4;
}
.jr-sidebar .offcanvas-header { background: var(--charcoal-2); }
.jr-sidebar-title { color: #fff; font-weight: 700; }
.jr-nav { display: flex; flex-direction: column; padding: .75rem; gap: .15rem; }
.jr-nav-link {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .7rem .85rem;
  border-radius: 9px;
  color: #c3c4c9;
  text-decoration: none;
  font-weight: 600;
  font-size: .92rem;
  transition: background .15s, color .15s;
}
.jr-nav-link i { font-size: 1.15rem; }
.jr-nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.jr-nav-link.active { background: var(--orange); color: #fff; box-shadow: 0 3px 10px rgba(242,106,33,.4); }
.jr-sidebar-foot { margin-top: auto; padding: 1rem; font-size: .72rem; color: #80828a; }

@media (min-width: 992px) {
  .jr-sidebar.offcanvas-lg {
    background: var(--charcoal) !important;
    position: sticky;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    display: flex;
    flex-direction: column;
    border: 0;
    overflow-y: auto;
  }
}

/* ---------- Page header ---------- */
.jr-page-head {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.jr-page-head h1 {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 0;
  color: var(--ink);
}
.jr-page-head .spacer { flex: 1 1 auto; }

/* ---------- Cards ---------- */
.card { border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.card-header { border-radius: 12px 12px 0 0 !important; font-weight: 600; }
.card-head-brand { background: var(--orange); color: #fff; border-bottom: 0; }
.card-head-brand h5, .card-head-brand h6 { margin: 0; font-weight: 700; }
.card-head-line { background: #fff; border-bottom: 2px solid var(--orange); }
.card-head-line h5 { color: var(--orange); font-weight: 700; margin: 0; }

/* ---------- Buttons ---------- */
.btn { font-weight: 600; border-radius: 9px; }
.btn-brand { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn-brand:hover, .btn-brand:focus { background: var(--orange-d); border-color: var(--orange-d); color: #fff; }
.btn-outline-brand { border: 1px solid var(--orange); color: var(--orange); background: #fff; }
.btn-outline-brand:hover { background: var(--orange); color: #fff; }
.btn-soft { background: var(--orange-soft); color: var(--orange-d); border: 1px solid #f7d9c4; }
.btn-soft:hover { background: #ffe7d6; color: var(--orange-d); }
.text-brand { color: var(--orange) !important; }
.bg-brand { background: var(--orange) !important; }

/* ---------- Badges ---------- */
.badge { font-weight: 600; font-size: .72rem; padding: .4em .65em; }
.badge-approved { background: #e7f6ec; color: #1b7a3d; }
.badge-draft    { background: #fff3df; color: #9a6700; }

/* ---------- Tables ---------- */
.table { margin: 0; }
.table thead th {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 700;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
  white-space: nowrap;
}
.table td { vertical-align: middle; }
.table-hover tbody tr:hover { background: var(--orange-soft); }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: .85rem; margin-bottom: .3rem; color: #45464b; }
.form-control, .form-select { border-radius: 9px; border-color: #dfe1e6; padding: .55rem .8rem; }
.form-control:focus, .form-select:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 .2rem rgba(242,106,33,.15);
}
.req { color: #dc3545; }

/* ---------- Stat tiles ---------- */
.stat-tile { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.25rem; }
.stat-ico {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
}
.stat-tile .num { font-size: 1.6rem; font-weight: 800; line-height: 1; }
.stat-tile .lbl { color: var(--muted); font-size: .82rem; font-weight: 600; margin: 0; }

/* ---------- Quick-action cards ---------- */
.quick-card { display: block; text-decoration: none; border-radius: 12px; transition: transform .15s, box-shadow .15s; }
.quick-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,.12); }

/* ---------- Edit page layout (details / items / actions) ---------- */
.edit-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 992px) {
  .edit-grid {
    grid-template-columns: 350px minmax(0, 1fr);
    grid-template-areas: "details items" "actions items";
    align-items: start;
  }
  .edit-details { grid-area: details; }
  .edit-items   { grid-area: items; }
  .edit-actions { grid-area: actions; }
}

/* ---------- Report item editor ---------- */
.item-card { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 1rem; overflow: hidden; background: #fff; }
.item-card-head {
  display: flex; align-items: center; gap: .6rem;
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
  padding: .5rem .6rem .5rem .85rem;
}
.item-num {
  width: 26px; height: 26px; flex: 0 0 26px;
  border-radius: 7px;
  background: var(--orange); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .82rem;
}
.item-head-title {
  flex: 1 1 auto; min-width: 0;
  font-weight: 700;
  font-size: .95rem;
  color: #3a3b40;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Clearly visible, tappable delete button */
.item-del {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px;
  border: 1px solid #f1aeb5;
  background: #fdecee;
  color: #d22d3d;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.item-del:hover { background: #dc3545; border-color: #dc3545; color: #fff; }

.item-card-body { padding: .85rem; display: flex; flex-direction: column; gap: 1rem; }
.item-section-label {
  font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--orange); margin: 0 0 .5rem;
}

/* Up-to-three photo slots — stacked on mobile (roomy for the two icons), 3-in-a-row on wider screens */
.photo-slots { display: grid; grid-template-columns: 1fr; gap: .5rem; }
.photo-slot { min-width: 0; }
.upload-box {
  border: 2px dashed #d3d6db;
  border-radius: 10px;
  padding: .5rem .75rem;
  min-height: 54px;
  display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: .5rem;
  color: var(--muted);
}
.upload-box .ub-title { font-size: .78rem; font-weight: 600; color: var(--muted); }
.upload-box .ub-actions { display: flex; gap: .4rem; flex: 0 0 auto; }

@media (min-width: 576px) {
  .photo-slots { grid-template-columns: repeat(3, 1fr); }
  .upload-box {
    flex-direction: column; justify-content: center; text-align: center;
    min-height: 96px; padding: .55rem .3rem; gap: .45rem;
  }
}
.ub-btn {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; line-height: 1;
  border: 1px solid #f1d4bf;
  border-radius: 9px;
  background: var(--orange-soft);
  color: var(--orange-d);
  font-size: 1.05rem;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.ub-btn:hover, .ub-btn:active { background: var(--orange); color: #fff; border-color: var(--orange); }
.img-preview { position: relative; }
.img-preview img { width: 100%; height: 110px; object-fit: cover; border-radius: 10px; display: block; border: 1px solid var(--line); }
.img-preview .slot-remove {
  position: absolute; top: 5px; right: 5px;
  width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.62); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .8rem; cursor: pointer;
}
.img-preview .slot-remove:hover { background: #dc3545; }
.img-preview .slot-ok { font-size: .68rem; color: #1b7a3d; margin: .2rem 0 0; text-align: center; }

/* Report notes (Quill) */
.note-wrap { min-width: 0; }
.quill-editor { background: #fff; }
.ql-toolbar.ql-snow { border: 1px solid #dfe1e6; border-bottom: 0; border-radius: 9px 9px 0 0; background: #f8f9fa; }
.ql-container.ql-snow { border: 1px solid #dfe1e6; border-radius: 0 0 9px 9px; font-family: inherit; font-size: .92rem; }
.ql-editor { min-height: 130px; }
.ql-editor.ql-blank::before { font-style: normal; color: #adb5bd; }

/* Three service fields — equal width columns */
.item-fields { display: grid; grid-template-columns: 1fr; gap: .6rem; }
@media (min-width: 576px) { .item-fields { grid-template-columns: 1fr 1fr 1fr; } }
.item-fields > div { min-width: 0; }
.item-fields .form-label { font-size: .78rem; margin-bottom: .2rem; }
/* full width on the direct field controls only — NOT the input inside the £ input-group
   (that one must keep Bootstrap's inline flex behaviour, or the £ wraps onto its own line) */
.item-fields > div > .form-control,
.item-fields > div > .form-select,
.item-fields > div > .input-group { width: 100%; }

/* Action bar (edit page) */
.action-bar { display: grid; gap: .55rem; }
.action-bar .btn { width: 100%; padding: .65rem 1rem; }
@media (min-width: 576px) {
  .action-row { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 1.25rem;
  background: linear-gradient(135deg, var(--orange) 0%, #c0581a 45%, var(--charcoal) 100%);
}
.login-card {
  width: 100%; max-width: 410px;
  background: #fff; border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0,0,0,.3);
  overflow: hidden;
}
.login-card .inner { padding: 2rem 1.75rem; }

/* ---------- Misc ---------- */
.alert { border-radius: 10px; border: 0; }
.empty-state { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }
.empty-state i { font-size: 2.75rem; color: #cfd2d8; }
hr { color: var(--line); opacity: 1; }

/* Loading state for submit buttons */
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: '';
  position: absolute; inset: 0; margin: auto;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.55);
  border-top-color: #fff;
  border-radius: 50%;
  animation: jr-spin .6s linear infinite;
}
.btn-outline-brand.is-loading::after, .btn-soft.is-loading::after, .btn-light.is-loading::after { border-color: rgba(242,106,33,.4); border-top-color: var(--orange); }
@keyframes jr-spin { to { transform: rotate(360deg); } }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #c4c6cc; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--orange); }
