/* PrintFlow — layered on Bootstrap 5.3 */
:root {
  --sidebar-w: 248px;
  --sidebar-bg: #111827;
  --sidebar-fg: #d1d5db;
  --page-bg: #f4f6fa;
  --muted: #6c757d;
  --bubble: #f0f2f5;
}
body { background: var(--page-bg); }

/* ---- shell ---- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--sidebar-bg) !important; color: var(--sidebar-fg); flex-shrink: 0; }
@media (min-width: 992px) { .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; } }
@media (max-width: 991.98px) { .sidebar.offcanvas-lg { background: var(--sidebar-bg); } }
.sidebar-brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.3rem; color: #fff; padding: 1.4rem 1.4rem 1.1rem; }
.sidebar .nav { padding: 0 .75rem 1rem; gap: .15rem; }
.sidebar .nav-link { color: var(--sidebar-fg); border-radius: .5rem; padding: .6rem .85rem; display: flex; gap: .7rem; align-items: center; font-size: 1.02rem; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar .nav-link.active { background: #3b6ef5; color: #fff; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .75rem; background: #fff; border-bottom: 1px solid #e5e7eb; padding: .6rem 1.5rem; position: sticky; top: 0; z-index: 1020; }
.topbar-search { width: min(26rem, 40vw); }
.content { padding: 1.5rem; max-width: 1500px; width: 100%; }
@media (max-width: 575.98px) { .content { padding: 1rem; } .topbar { padding: .5rem 1rem; } }

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.card { border-color: #e5e7eb; border-radius: .75rem; }
.card-header { background: #fff; font-weight: 600; border-bottom-color: #eef0f3; }
.table-card { overflow: hidden; }
.table-card thead th { background: #f8f9fb; font-weight: 600; white-space: nowrap; }
.row-link { cursor: pointer; }
.sort-link { color: inherit; text-decoration: none; }
.sort-link.active, .sort-link:hover { color: var(--bs-primary); }
.filters .form-label { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 1.5rem 1rem; }
.empty i { font-size: 1.9rem; display: block; margin-bottom: .3rem; opacity: .6; }
.empty p { margin: 0 0 .6rem; }
.rich { overflow-wrap: anywhere; }
.badge .bi-flag-fill { font-size: .75em; }

/* ---- stats & cards ---- */
.stat { text-decoration: none; color: inherit; transition: box-shadow .15s; }
.stat:hover { box-shadow: 0 .25rem .9rem rgba(17,24,39,.08); }
.stat-label { color: var(--muted); font-size: .9rem; }
.stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1.2; }
.dept-card { text-decoration: none; color: inherit; transition: box-shadow .15s, transform .15s; }
.dept-card:hover { box-shadow: 0 .4rem 1.2rem rgba(17,24,39,.09); transform: translateY(-1px); }

/* ---- avatars ---- */
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 1.75rem; height: 1.75rem; border-radius: 50%; color: #fff; font-size: .7rem; font-weight: 700; flex-shrink: 0; margin-right: -.25rem; border: 2px solid #fff; vertical-align: middle; }
.avatar-md { width: 2.4rem; height: 2.4rem; font-size: .85rem; margin-right: 0; }

/* ---- work-order detail ---- */
.section-title { display: flex; align-items: center; gap: .45rem; font-weight: 600; margin-bottom: 1rem; }
.detail-section { border-top: 1px solid var(--bs-border-color); margin-top: 1.75rem; padding-top: 1.5rem; scroll-margin-top: 5rem; }
.staff-picker { max-height: 22rem; overflow-y: auto; }
.flash-target { animation: flash 2s ease-out; border-radius: .5rem; }
@keyframes flash { from { background: #fff3cd; } to { background: transparent; } }

/* ---- timeline ---- */
.timeline-item { display: flex; gap: .75rem; position: relative; padding-bottom: 1rem; }
.timeline-item:not(:last-child)::before { content: ''; position: absolute; left: .95rem; top: 2rem; bottom: 0; width: 2px; background: #e5e7eb; }
.timeline-icon { width: 2rem; height: 2rem; border-radius: 50%; background: #eef2ff; color: #3b6ef5; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.timeline-body { min-width: 0; overflow-wrap: anywhere; }

/* ---- comments (Facebook-style) ---- */
.comments { margin-bottom: 1.25rem; }
.comment { display: flex; gap: .6rem; margin-bottom: 1rem; scroll-margin-top: 6rem; }
.comment-main { min-width: 0; flex: 1; }
.comment-bubble { display: inline-block; max-width: 100%; background: var(--bubble); border-radius: 1.1rem; padding: .55rem .9rem; }
.comment-bubble.is-deleted { background: transparent; border: 1px dashed #ced4da; }
.comment-head { font-size: .9rem; }
.comment-text { white-space: normal; }
.comment-meta { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; font-size: .8rem; color: var(--muted); padding: .25rem .9rem 0; }
.comment-meta .btn-link { font-size: .8rem; text-decoration: none; font-weight: 600; color: var(--muted); }
.comment-meta .btn-link:hover { text-decoration: underline; }
.comment-photos { display: grid; gap: 3px; margin-top: .4rem; max-width: 30rem; border-radius: .9rem; overflow: hidden; }
.comment-photos.photos-1 { grid-template-columns: 1fr; }
.comment-photos.photos-2 { grid-template-columns: 1fr 1fr; }
.comment-photos.photos-3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; }
.comment-photos.photos-3 .comment-photo:first-child { grid-row: span 2; }
.comment-photos.photos-4 { grid-template-columns: 1fr 1fr; }
.comment-photo { position: relative; display: block; background: #e9ecef; }
.comment-photo img { width: 100%; height: 100%; object-fit: cover; display: block; max-height: 22rem; }
.comment-photos:not(.photos-1) .comment-photo img { aspect-ratio: 1; }
.comment-photo .more { position: absolute; inset: 0; background: rgba(0,0,0,.45); color: #fff; font-size: 1.8rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.comment-files { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.file-chip { display: inline-grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: .55rem; align-items: center; max-width: 22rem;
  background: #fff; border: 1px solid #dee2e6; border-radius: .7rem; padding: .4rem .75rem; text-decoration: none; color: inherit; }
.file-chip:hover { border-color: var(--bs-primary); }
.file-chip i { grid-row: span 2; font-size: 1.5rem; color: var(--bs-primary); }
.file-chip.is-link i { color: #fd7e14; }
.file-name { font-weight: 600; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font-size: .75rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.revisions { border-left: 3px solid #e5e7eb; padding-left: .75rem; margin: .5rem 0 0 .9rem; }
.revision + .revision { margin-top: .5rem; }

.composer { display: flex; gap: .6rem; align-items: flex-start; }
.composer-main { flex: 1; min-width: 0; background: var(--bubble); border-radius: 1.1rem; padding: .5rem; border: 2px solid transparent; transition: border-color .15s; }
.composer-form.is-drop .composer-main { border-color: var(--bs-primary); background: #eef4ff; }
.composer textarea { border: 0; background: transparent; resize: none; box-shadow: none !important; min-height: 2.6rem; }
.composer-previews { display: flex; flex-wrap: wrap; gap: .5rem; padding: 0 .5rem; }
.composer-previews:empty, .composer-links:empty { display: none; }
.composer-links { display: flex; flex-wrap: wrap; gap: .4rem; padding: .5rem .5rem 0; }
.preview { position: relative; border-radius: .6rem; background: #fff; border: 1px solid #dee2e6; }
.preview.is-image { width: 5.5rem; height: 5.5rem; overflow: hidden; }
.preview.is-image img { width: 100%; height: 100%; object-fit: cover; }
.preview.is-file { display: flex; align-items: center; gap: .4rem; padding: .4rem 2rem .4rem .6rem; max-width: 16rem; font-size: .85rem; }
.preview.is-file i { font-size: 1.3rem; color: var(--bs-primary); }
.preview-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.preview-size { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.preview.is-loading { opacity: .6; }
.preview-spin { position: absolute; top: 50%; left: 50%; margin: -.5rem 0 0 -.5rem; }
.preview.is-error { border-color: var(--bs-danger); }
.preview-error { position: absolute; inset: auto 0 0 0; background: rgba(220,53,69,.92); color: #fff; font-size: .65rem; padding: .15rem .3rem; line-height: 1.2; }
.preview.is-file .preview-error { position: static; background: none; color: var(--bs-danger); }
.preview-remove { position: absolute; top: .2rem; right: .2rem; width: 1.5rem; height: 1.5rem; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; display: flex; align-items: center; justify-content: center; padding: 0; }
.composer-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; padding: .4rem .4rem 0; border-top: 1px solid #e3e6ea; margin-top: .4rem; }
.composer-bar .btn-light { background: transparent; border: 0; font-weight: 600; color: #495057; }
.composer-bar .btn-light:hover { background: #e4e6e9; }

/* ---- invoices ---- */
.totals > div { display: flex; justify-content: space-between; padding: .2rem 0; }
.totals dt { font-weight: 400; color: var(--muted); }
.totals dd { margin: 0; font-variant-numeric: tabular-nums; }
.totals .grand { border-top: 1px solid #dee2e6; margin-top: .3rem; padding-top: .5rem; font-weight: 700; }
.totals .grand dt { color: inherit; font-weight: 700; }
#inv-lines textarea { min-height: 2.1rem; }

/* ---- calendar ---- */
.cal-legend { display: flex; flex-wrap: wrap; gap: .25rem .8rem; color: var(--muted); }
.cal-legend i { display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }
.fc .ev-done .fc-event-title { text-decoration: line-through; }
.fc a { text-decoration: none; }
.fc .fc-toolbar-title { font-size: 1.3rem; }
@media (max-width: 575.98px) { .fc .fc-toolbar { flex-direction: column; gap: .5rem; } }

/* ---- notifications ---- */
.notif-unread { background: #f3f7ff; }

/* ---- login ---- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: linear-gradient(135deg, #111827, #1e3a8a); }
.login-card { width: 100%; max-width: 26rem; border: 0; }

/* ---- quotations ---- */
.qtn-tabs .nav-link { padding: .3rem .9rem; font-weight: 600; }
.qtn-preview-card { overflow: hidden; background: #fff; }
.qtn-preview-card iframe { display: block; width: 100%; min-height: 60rem; border: 0; background: #fff; }
@media (min-width: 1400px) { .qtn-preview-card { position: sticky; top: 4.5rem; max-height: calc(100vh - 5.5rem); overflow-y: auto; } }

/* ---- department status cards ---- */
.status-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .75rem; }
.status-card { text-decoration: none; color: inherit; border-top: 4px solid var(--status-color); transition: box-shadow .15s, transform .15s; }
.status-card:hover { box-shadow: 0 .4rem 1.2rem rgba(17,24,39,.09); transform: translateY(-1px); }
.status-card.active { outline: 2px solid var(--status-color); outline-offset: -1px; box-shadow: 0 .4rem 1.2rem rgba(17,24,39,.12); }
.status-card .card-body { padding: .9rem 1rem; }
.status-card-name { font-weight: 600; font-size: .92rem; display: flex; align-items: center; gap: .4rem; min-height: 2.4em; }
.status-step { display: inline-flex; align-items: center; justify-content: center; width: 1.35rem; height: 1.35rem; border-radius: 50%; background: var(--status-color); color: #fff; font-size: .72rem; flex-shrink: 0; }
.status-card-count { font-size: 2rem; font-weight: 700; line-height: 1.1; color: var(--status-color); }
.status-card-meta { font-size: .8rem; color: var(--muted); }
.status-row { display: flex; gap: .5rem; align-items: center; }
.status-row .form-control-color { width: 3rem; flex-shrink: 0; }
