/* =====================================================
   Brigády - moderní administrace
   ===================================================== */

:root {
  --bs-body-font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --color-bg: #FAF8F4;
  --color-surface: #FFFFFF;
  --color-text: #1C1917;
  --color-text-muted: #6E6A63;
  --color-border: #E8E3D9;
  --color-border-strong: #D4CDC0;
  --color-accent: #1F4D3E;
  --color-accent-soft: #E5EDE9;
  --color-warm: #C4623F;
  --color-warm-soft: #FBEFE8;
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.04);
  --shadow-md: 0 4px 16px rgba(28, 25, 23, 0.06);
  --shadow-lg: 0 12px 32px rgba(28, 25, 23, 0.10);

  --bs-primary: #1F4D3E;
  --bs-primary-rgb: 31, 77, 62;
}

* { -webkit-font-smoothing: antialiased; }

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--bs-body-font-family);
  font-size: 15px;
}

h1, h2, h3, .display-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-text);
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--color-text-muted); }

/* ----- Layout ----- */
.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--color-text);
  color: rgba(255,255,255,0.85);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.5rem;
}
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--color-warm);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 1.1rem;
}
.brand-name {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.15rem;
  color: white;
  line-height: 1.1;
}
.brand-sub {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.55);
  margin-top: 2px;
}

.nav-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  color: rgba(255,255,255,0.7);
  font-size: 0.92rem;
  font-weight: 500;
  transition: all 0.15s;
}
.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: white;
  text-decoration: none;
}
.nav-item.active {
  background: rgba(255,255,255,0.10);
  color: white;
}
.nav-item i {
  font-size: 1.05rem;
  width: 20px;
  text-align: center;
}
.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.10);
  margin: 0.5rem 0;
}
.sidebar-foot {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.45);
  padding: 0 0.5rem;
}

.content {
  padding: 2rem 2.5rem;
  max-width: 1400px;
  width: 100%;
}
.content-plain {
  min-height: 100vh;
}

/* ----- Page header ----- */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-head h1 {
  margin: 0;
}
.page-head .lead {
  color: var(--color-text-muted);
  margin: 0.25rem 0 0;
  font-size: 0.95rem;
}

/* ----- Cards ----- */
.card-soft {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.card-soft .card-body {
  padding: 1.25rem 1.5rem;
}

/* Stat tiles */
.stat-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.stat-label {
  color: var(--color-text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-value {
  font-family: 'Fraunces', serif;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1;
}
.stat-sub {
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

/* ----- Tables ----- */
.table-modern {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  overflow: hidden;
  border-collapse: separate;
  border-spacing: 0;
}
.table-modern thead th {
  background: #FCFAF6;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--color-text-muted);
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}
.table-modern tbody td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.table-modern tbody tr:last-child td {
  border-bottom: none;
}
.table-modern tbody tr:hover {
  background: #FCFAF6;
}

/* ----- Buttons ----- */
.btn-primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  font-weight: 500;
}
.btn-primary:hover,
.btn-primary:focus {
  background: #173A2F;
  border-color: #173A2F;
}
.btn-outline-secondary {
  border-color: var(--color-border-strong);
  color: var(--color-text);
}
.btn-warm {
  background: var(--color-warm);
  color: white;
  border: 1px solid var(--color-warm);
}
.btn-warm:hover { background: #A8512F; color: white; border-color: #A8512F; }

.btn { border-radius: 8px; font-weight: 500; }
.btn-sm { font-size: 0.85rem; padding: 0.35rem 0.7rem; }
.btn-icon {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
}

/* ----- Forms ----- */
.form-control, .form-select {
  border-color: var(--color-border-strong);
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  font-size: 0.95rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(31, 77, 62, 0.12);
}
.form-label {
  font-weight: 500;
  font-size: 0.88rem;
  color: var(--color-text);
  margin-bottom: 0.35rem;
}

/* ----- Badges ----- */
.badge {
  font-weight: 500;
  padding: 0.35em 0.65em;
  border-radius: 6px;
  font-size: 0.78rem;
}
.badge.bg-secondary { background: #E8E3D9 !important; color: #5F5950 !important; }
.badge.bg-success   { background: #DCEFE5 !important; color: #1F4D3E !important; }
.badge.bg-info      { background: #DCE6EF !important; color: #1F3E4D !important; }
.badge.bg-warning   { background: #FBEFD8 !important; color: #8B6914 !important; }
.badge.bg-danger    { background: #FBE0DA !important; color: #8B2D1B !important; }

/* ----- Login ----- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(circle at 20% 10%, rgba(196,98,63,0.08), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(31,77,62,0.10), transparent 50%),
    var(--color-bg);
}
.login-card {
  background: var(--color-surface);
  border-radius: 18px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  max-width: 420px;
  width: 100%;
}
.login-card h1 {
  text-align: center;
  margin: 0 0 0.25rem;
}
.login-card .login-sub {
  text-align: center;
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
}

/* ----- Avatar ----- */
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* ----- Empty state ----- */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--color-text-muted);
}
.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

/* ----- Calendar ----- */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  overflow: hidden;
}
.cal-day-name {
  background: #FCFAF6;
  text-align: center;
  padding: 0.6rem 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cal-day {
  background: var(--color-surface);
  min-height: 110px;
  padding: 0.5rem;
  position: relative;
}
.cal-day.other-month { background: #F8F5EE; opacity: 0.6; }
.cal-day.today .cal-day-num {
  background: var(--color-accent);
  color: white;
}
.cal-day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.cal-event {
  display: block;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  padding: 0.2rem 0.45rem;
  border-radius: 5px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 3px solid var(--color-accent);
}
.cal-event:hover { text-decoration: none; opacity: 0.85; }
.cal-event.warm {
  background: var(--color-warm-soft);
  color: var(--color-warm);
  border-left-color: var(--color-warm);
}

/* ----- Job detail (public) ----- */
.public-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}
.public-header {
  text-align: center;
  margin-bottom: 2rem;
}
.public-card {
  background: var(--color-surface);
  border-radius: 18px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  padding: 2rem;
}
.info-row {
  display: flex;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--color-border);
}
.info-row:last-child { border-bottom: none; }
.info-row .info-icon {
  width: 38px; height: 38px;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.info-row .info-label {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.info-row .info-value {
  font-size: 0.98rem;
  margin-top: 2px;
}

/* ----- Misc ----- */
.search-box {
  position: relative;
  max-width: 320px;
}
.search-box input {
  padding-left: 2.4rem;
}
.search-box i {
  position: absolute;
  left: 0.85rem; top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
}

.tag-pill {
  display: inline-block;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 500;
}

.assignment-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  margin-bottom: 0.5rem;
  background: var(--color-surface);
}
.assignment-row:hover { background: #FCFAF6; }

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 1rem;
  }
  .nav-main {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .nav-item span { display: none; }
  .sidebar-foot { display: none; }
  .content { padding: 1.5rem 1rem; }
}

/* ----- Attachments (admin) ----- */
.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}
.attachment-card {
  position: relative;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--color-surface);
}
.attachment-preview {
  display: block;
  height: 110px;
  background: #FCFAF6;
  overflow: hidden;
}
.attachment-preview img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.attachment-icon {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #FBE0DA, #FBEFE8);
  color: var(--color-warm);
  font-size: 2.5rem;
}
.attachment-meta {
  padding: 0.5rem 0.6rem;
  border-top: 1px solid var(--color-border);
}
.attachment-name {
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.2;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.attachment-size {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}
.attachment-delete {
  position: absolute;
  top: 4px; right: 4px;
  margin: 0;
}
.attachment-delete .btn {
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--color-border);
}
.attachment-delete .btn:hover {
  background: var(--color-warm-soft);
  color: var(--color-warm);
}

/* Upload zone */
.upload-form { margin: 0; }
.upload-drop {
  display: block;
  border: 2px dashed var(--color-border-strong);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: #FCFAF6;
}
.upload-drop:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}
.upload-drop i {
  font-size: 1.75rem;
  color: var(--color-accent);
  display: block;
  margin-bottom: 0.4rem;
}

/* Attachments on public page */
.attachment-card-public {
  display: block;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--color-surface);
  color: var(--color-text);
  text-decoration: none;
  transition: all 0.15s;
}
.attachment-card-public:hover {
  text-decoration: none;
  border-color: var(--color-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.attachment-card-public img {
  width: 100%; height: 90px;
  object-fit: cover;
  display: block;
}
.attachment-card-public .attachment-icon {
  height: 90px;
  font-size: 2rem;
}
.attachment-name-pub {
  font-size: 0.78rem;
  padding: 0.4rem 0.5rem;
  border-top: 1px solid var(--color-border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ----- Function picker (chips) ----- */
.function-picker {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  padding: 0.5rem;
  background: #FCFAF6;
  border-radius: 10px;
  border: 1px solid var(--color-border);
}
.function-chip { cursor: pointer; }
.function-chip input { display: none; }
.function-chip-label {
  display: inline-block;
  padding: 0.4rem 0.85rem;
  border-radius: 16px;
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--color-surface);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border-strong);
  transition: all 0.15s;
}
.function-chip input:checked + .function-chip-label {
  background: var(--c, var(--color-accent));
  color: white;
  border-color: var(--c, var(--color-accent));
}
.function-chip:hover .function-chip-label {
  border-color: var(--color-accent);
}

/* ----- Budget summary ----- */
.budget-summary { font-size: 0.95rem; }
.budget-row { display: flex; justify-content: space-between; padding: 0.3rem 0; }
.budget-row.over-budget strong { color: var(--color-warm); }
.budget-bar {
  height: 8px;
  background: var(--color-border);
  border-radius: 4px;
  overflow: hidden;
}
.budget-bar-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: 4px;
  transition: width 0.3s;
}
.budget-bar-fill.over { background: var(--color-warm); }

/* ----- Discussion ----- */
.discussion-list { display: flex; flex-direction: column; gap: 0.85rem; }
.discussion-msg {
  display: flex; gap: 0.7rem;
  padding: 0.85rem;
  background: #FCFAF6;
  border-radius: 12px;
  border: 1px solid var(--color-border);
}
.discussion-msg.is-internal {
  background: #FFFAF0;
  border-color: #F0DDB0;
}
.discussion-msg .avatar { width: 34px; height: 34px; font-size: 0.78rem; flex-shrink: 0; }
.discussion-body { flex: 1; min-width: 0; }
.discussion-head {
  display: flex; align-items: center; gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}
.discussion-text { font-size: 0.92rem; line-height: 1.45; word-break: break-word; }
.badge-tiny { font-size: 0.65rem !important; padding: 0.15em 0.45em !important; }
.btn-icon-tiny {
  background: none; border: none; color: var(--color-text-muted);
  padding: 2px 4px; cursor: pointer; opacity: 0.5;
  font-size: 1rem;
}
.btn-icon-tiny:hover { opacity: 1; color: var(--color-warm); }

/* ----- Sidebar foot user info ----- */
.muted-sb { font-size: 0.85rem; color: rgba(255,255,255,0.85); margin-bottom: 0.25rem; }

/* ----- Worker dashboard ----- */
.my-job-card {
  display: flex; gap: 1rem;
  padding: 1.25rem 1.5rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  margin-bottom: 0.75rem;
  text-decoration: none;
  color: var(--color-text);
  transition: all 0.15s;
}
.my-job-card:hover {
  text-decoration: none;
  border-color: var(--color-accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.my-job-date {
  flex-shrink: 0;
  text-align: center;
  min-width: 56px;
}
.my-job-date .day {
  font-family: 'Fraunces', serif;
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1;
}
.my-job-date .month {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}
.my-job-info { flex: 1; min-width: 0; }
.my-job-info h3 { margin: 0 0 0.25rem; font-size: 1.1rem; }
.my-job-meta { font-size: 0.85rem; color: var(--color-text-muted); }
.my-job-meta i { margin-right: 0.3rem; }

/* ----- Public page comment form ----- */
.public-comments {
  margin-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  padding-top: 1.5rem;
}

/* ----- Equipment / Accessories ----- */
.equip-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  margin-bottom: 0.45rem;
  background: var(--color-surface);
}
.amort-display {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  font-family: 'Fraunces', serif;
  font-size: 1.05rem;
}
.accessory-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.5rem 1rem;
  padding: 0.75rem;
  background: #FCFAF6;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  max-height: 320px;
  overflow-y: auto;
}
.accessory-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
}
.acc-pill {
  display: inline-block;
  background: var(--color-warm-soft);
  color: var(--color-warm);
  padding: 0.25rem 0.65rem;
  border-radius: 12px;
  font-size: 0.82rem;
  margin: 0.15rem 0.25rem 0.15rem 0;
}
.accessory-summary {
  background: #FCFAF6;
  border: 1px dashed var(--color-border-strong);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
}
.amort-total-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--color-accent);
  color: white;
  border-radius: 10px;
}
.amort-total-box strong {
  font-family: 'Fraunces', serif;
  font-size: 1.15rem;
}

/* ----- Internal notes (admin only) ----- */
.internal-notes {
  background: #FFF8E5;
  border-color: #F0DDB0;
}
.internal-notes:focus {
  background: #FFFCF0;
  border-color: #C4623F;
  box-shadow: 0 0 0 0.2rem rgba(196, 98, 63, 0.15);
}
.internal-note-display {
  background: #FFF8E5;
  border-left: 4px solid #F0DDB0;
  padding: 12px 16px;
  border-radius: 8px;
  margin: 16px 0;
  font-size: 0.92rem;
}
.internal-note-display .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-warm);
  font-weight: 600;
  margin-bottom: 4px;
}
