/* =============================================================
   rrm-base.css  —  Structural layout, shared components
   Requires: design-tokens.css (loaded before this file)
   Requires: rrm-responsive.css (loaded after this file)
   ============================================================= */

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }

body {
  font-family: var(--font-sans);
  background: var(--mist);
  color: var(--ink);
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: var(--font-sans); cursor: pointer; border: none; background: none; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── SIDEBAR ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--ink);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--duration-slow) var(--ease);
}

.sidebar-logo {
  padding: 28px 24px 20px;
  border-bottom: var(--border-dark-subtle);
  flex-shrink: 0;
}

.logo-wordmark {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: var(--weight-normal);
  letter-spacing: .02em;
  color: var(--white);
  line-height: 1.2;
}

.logo-wordmark span { color: var(--sage-light); font-style: italic; }

.logo-sub {
  font-size: var(--text-xs);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  margin-top: 4px;
}

/* Sidebar user card */
.sidebar-user {
  padding: 16px 20px;
  border-bottom: var(--border-dark-subtle);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  background: var(--sage);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  font-weight: var(--weight-semibold);
  color: var(--white);
  letter-spacing: .05em;
  flex-shrink: 0;
}

.sidebar-user-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.user-name {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout {
  background: none;
  border: none;
  padding: 0;
  font-size: .7rem;
  color: rgba(255,255,255,.35);
  cursor: pointer;
  font-family: var(--font-sans);
  letter-spacing: .02em;
  transition: color .12s;
  text-align: left;
}

.sidebar-logout:hover {
  color: rgba(255,255,255,.7);
}

.user-role {
  font-size: var(--text-xs);
  color: rgba(255,255,255,.4);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  margin-top: 2px;
}

/* Sidebar nav */
.sidebar-nav {
  flex: 1;
  padding: var(--space-4) 0;
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section-label {
  font-size: .6rem;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: rgba(255,255,255,.25);
  padding: 16px 24px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: var(--space-2) 24px;
  font-size: var(--text-base);
  color: rgba(255,255,255,.55);
  transition: all var(--duration-base);
  border-left: 2px solid transparent;
}

.nav-item:hover {
  color: var(--white);
  background: rgba(255,255,255,.04);
}

.nav-item.active {
  color: var(--white);
  border-left-color: var(--sage);
  background: rgba(107,148,120,.12);
}

.nav-icon {
  font-size: .95rem;
  width: 18px;
  text-align: center;
  opacity: .7;
}
.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--status-problem);
  color: var(--white);
  font-size: .6rem;
  font-weight: var(--weight-semibold);
  padding: 2px 6px;
  border-radius: var(--radius-full);
}
.nav-badge.sage { background: var(--sage); }

/* Sidebar bottom */
.sidebar-bottom {
  padding: 20px 24px;
  border-top: var(--border-dark-subtle);
  font-size: .75rem;
  color: rgba(255,255,255,.3);
  flex-shrink: 0;
}

.sidebar-clock {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: rgba(255,255,255,.7);
  margin-bottom: 4px;
}

/* Hamburger (mobile) */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 8px;
  border: none;
  background: none;
}
.hamburger span {
  display: block;
  width: 22px; height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: all var(--duration-base) var(--ease);
}
.hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(26,35,24,.5);
  z-index: 99;
  opacity: 0;
  transition: opacity var(--duration-base);
}
.sidebar-backdrop.visible { opacity: 1; }

/* ── MAIN ───────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── TOPBAR ─────────────────────────────────────────────────── */
.topbar {
  background: var(--white);
  border-bottom: var(--border-subtle);
  padding: 10px var(--content-pad);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}

.topbar-main {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 40px;
  min-width: 0;
  flex-wrap: nowrap;
}

.topbar-inline-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
}

.topbar-view-switcher {
  display: flex;
  background: var(--mist);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}

.view-tab {
  padding: 5px 14px;
  border-radius: 6px;
  font-size: .75rem;
  font-weight: var(--weight-medium);
  color: var(--ink-soft);
  letter-spacing: .03em;
  transition: all var(--duration-base);
  cursor: pointer;
  display: block;
}
.view-tab.active, .view-tab:hover {
  background: var(--white);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.topbar-date {
  font-size: .78rem;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.topbar-date-label {
  font-family: var(--font-serif);
  font-size: .95rem;
  color: var(--ink);
}

/* Page context: title + optional date in topbar */
.topbar-page-context {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
}

.topbar-page-title {
  font-size: .8rem;
  font-weight: var(--weight-semibold);
  color: var(--ink);
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-page-date {
  font-size: .72rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-page-title--serif {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 1;
}

.topbar-page-title--serif em {
  font-style: italic;
  color: var(--sage);
}

.topbar-week-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: nowrap;
  flex: 0 1 auto;
}

.topbar-day-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: nowrap;
  flex: 0 1 auto;
}

.topbar-week-btn,
.topbar-week-today {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--sage-light) 72%, white);
  background: color-mix(in srgb, var(--white) 92%, var(--sage-xpale));
  color: var(--ink);
  text-decoration: none;
  transition: border-color .12s, color .12s, background .12s;
  flex-shrink: 0;
}

.topbar-week-btn:hover,
.topbar-week-today:hover {
  border-color: var(--sage);
  color: var(--sage);
  background: var(--mist);
}

.topbar-week-form {
  margin: 0;
  min-width: 0;
  max-width: 100%;
}

.topbar-week-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--sage-light) 72%, white);
  background: color-mix(in srgb, var(--white) 92%, var(--sage-xpale));
  color: var(--ink);
  cursor: pointer;
  font-size: .76rem;
  text-decoration: none;
  max-width: 100%;
  white-space: nowrap;
}

.topbar-week-range {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-week-range em {
  font-style: normal;
  color: var(--ink-soft);
  margin: 0 4px;
}

.topbar-week-icon {
  width: 15px;
  height: 15px;
  color: var(--ink-soft);
  flex-shrink: 0;
}

.topbar-week-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.topbar-week-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--sage);
  color: var(--white);
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1.7;
}

/* Flex spacer — pushes topbar-actions to far right */
.topbar-spacer {
  flex: 1;
}

/* Language selector: clean, no ghost button styling */
.topbar-lang-select {
  padding: 6px 10px;
  font-size: .75rem;
  color: var(--ink-soft);
  border: 1px solid color-mix(in srgb, var(--sage-light) 72%, white);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  transition: color .12s, border-color .12s;
}
.topbar-lang-select:hover {
  color: var(--ink);
  border-color: var(--sage-light);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Thin divider between lang selector and logout */
.topbar-separator {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: color-mix(in srgb, var(--sage-light) 80%, transparent);
  margin: 0 2px;
  vertical-align: middle;
}

/* Per-page inline search in topbar (e.g. /employees) */
.topbar-search-form {
  display: flex;
  align-items: center;
  flex: 0 1 260px;
  min-width: 140px;
}

.topbar-search {
  width: 100%;
  height: 32px;
  padding: 0 12px;
  border: 1px solid color-mix(in srgb, var(--sage-light) 80%, white);
  border-radius: 999px;
  font-size: .75rem;
  font-family: var(--font-sans);
  color: var(--ink);
  background: color-mix(in srgb, var(--white) 88%, var(--sage-xpale));
  transition: border-color .12s, box-shadow .12s;
  outline: none;
}

.topbar-search::placeholder {
  color: var(--ink-soft);
  opacity: .7;
}

.topbar-search:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 2px var(--sage-pale);
  background: var(--white);
}

@media (max-width: 768px) {
  .topbar-search-form { display: none; }
  .topbar {
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .topbar-main {
    flex-wrap: wrap;
    min-height: 0;
  }
  .topbar-page-context {
    order: 1;
    flex: 1 1 100%;
    width: 100%;
  }
  .topbar-inline-nav {
    order: 3;
    width: 100%;
    gap: 8px;
    overflow: visible;
  }
  .topbar-week-switcher,
  .topbar-day-switcher {
    width: 100%;
  }
  .topbar-spacer {
    display: none;
  }
  .topbar-actions {
    order: 2;
    margin-left: auto;
  }

  .topbar-week-switcher,
  .topbar-day-switcher {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .topbar-week-switcher::-webkit-scrollbar,
  .topbar-day-switcher::-webkit-scrollbar {
    display: none;
  }

  .topbar-week-picker {
    flex: 1 0 auto;
  }
}

.btn-icon {
  width: 34px; height: 34px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem;
  color: var(--ink-soft);
  position: relative;
  transition: background var(--duration-base);
  cursor: pointer;
}
.btn-icon:hover { background: var(--mist); }
.btn-icon.has-dot::after {
  content: '';
  position: absolute;
  top: 7px; right: 8px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--status-problem);
  border: 2px solid var(--white);
}

/* ── BUTTONS ────────────────────────────────────────────────── */
.btn-primary {
  padding: 7px 18px;
  background: var(--sage);
  color: var(--white);
  border-radius: var(--radius);
  font-size: .75rem;
  font-weight: var(--weight-medium);
  letter-spacing: .05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background var(--duration-base);
  border: none;
  display: inline-block;
}
.btn-primary:hover { background: var(--sage-mid); }
.btn-primary.btn--problem  { background: var(--status-problem); }
.btn-primary.btn--problem:hover { background: #a04e3e; }
.btn-primary.btn--paused   { background: var(--status-paused); }
.btn-primary.btn--paused:hover { background: #7a8b98; }
.btn-primary.btn--warm     { background: var(--warm); }

.btn-ghost {
  padding: 6px 14px;
  border: var(--border-soft);
  border-radius: var(--radius);
  font-size: .75rem;
  font-weight: var(--weight-medium);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all var(--duration-base);
  background: transparent;
}
.btn-ghost:hover { background: var(--mist); color: var(--ink); }

/* ── PAGE CONTENT ───────────────────────────────────────────── */
.content {
  padding: 28px var(--content-pad);
  flex: 1;
}

.page-header { margin-bottom: 28px; }

.eyebrow {
  font-size: .65rem;
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--sage);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 6px;
}
.eyebrow::before {
  content: '';
  display: block;
  width: 24px; height: 1px;
  background: var(--sage);
}

.page-title {
  font-family: var(--font-serif);
  font-size: var(--text-2xl);
  font-weight: var(--weight-light);
  line-height: 1.15;
  color: var(--ink);
}
.page-title em { color: var(--sage); font-style: italic; }

.page-sub { font-size: .8rem; color: var(--ink-soft); margin-top: 6px; }

/* ── PANEL ──────────────────────────────────────────────────── */
.panel {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: var(--border-subtle);
  overflow: hidden;
}

.panel-header {
  padding: 18px var(--panel-pad) 14px;
  border-bottom: var(--border-subtle);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.panel-title {
  font-size: .72rem;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--ink-soft);
  flex: 1;
}

.panel-action {
  font-size: .7rem;
  color: var(--sage);
  cursor: pointer;
  font-weight: var(--weight-medium);
}

.panel-body { padding: var(--space-4) var(--panel-pad); }

/* ── GRIDS ──────────────────────────────────────────────────── */
.grid-2    { display: grid; grid-template-columns: 1fr 1fr;         gap: 20px; margin-bottom: 20px; }
.grid-3    { display: grid; grid-template-columns: repeat(3,1fr);   gap: 20px; margin-bottom: 20px; }
.grid-3-2  { display: grid; grid-template-columns: 1.6fr 1fr;       gap: 20px; margin-bottom: 20px; }

/* ── PROCESS LIST (shared in admin) ─────────────────────────── */
.process-list { display: flex; flex-direction: column; }

.process-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px var(--panel-pad);
  border-bottom: var(--border-subtle);
  cursor: pointer;
  transition: background var(--duration-fast);
  margin: 0 calc(var(--panel-pad) * -1);
  padding-left: var(--panel-pad);
  padding-right: var(--panel-pad);
}
.process-item:last-child { border-bottom: none; }
.process-item:hover { background: var(--mist); }

.process-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-planned     { background: var(--status-planned); box-shadow: 0 0 0 2px rgba(159,168,160,.3); }
.dot-in_progress { background: var(--status-in-progress); }
.dot-done_on_time{ background: var(--status-done); }
.dot-done_late   { background: var(--status-late); }
.dot-not_done    { background: var(--status-problem); }
.dot-paused      { background: var(--status-paused); }
.dot-cancelled   { background: var(--status-cancelled); }

.process-info { flex: 1; min-width: 0; }
.process-name {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.process-meta { font-size: .7rem; color: var(--ink-soft); margin-top: 2px; }
.process-time { font-size: .7rem; font-weight: var(--weight-medium); color: var(--ink-soft); flex-shrink: 0; }

.process-badge {
  font-size: .6rem;
  font-weight: var(--weight-semibold);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}
.badge-planned      { background: var(--status-planned-bg);     color: var(--status-planned); }
.badge-in_progress  { background: var(--status-in-progress-bg); color: var(--status-in-progress); }
.badge-done_on_time { background: var(--status-done-bg);        color: var(--status-done); }
.badge-done_late    { background: var(--status-late-bg);        color: var(--earth); }
.badge-not_done     { background: var(--status-problem-bg);     color: var(--status-problem); }
.badge-paused       { background: var(--status-paused-bg);      color: var(--status-paused); }
.badge-cancelled    { background: var(--status-cancelled-bg);   color: var(--status-cancelled); }

/* ── STATUS LABELS (used by multiple partials) ───────────────── */
.status-label {
  font-size: .6rem;
  font-weight: var(--weight-semibold);
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* ── FLASH MESSAGE ──────────────────────────────────────────── */
.flash-message {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--sage-pale);
  border-left: 3px solid var(--sage);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: .8rem;
  color: var(--ink);
  margin-bottom: 20px;
}
.flash-message.flash-error {
  background: var(--status-problem-bg);
  border-left-color: var(--status-problem);
}
.flash-message.flash-success {
  background: var(--status-done-bg);
  border-left-color: var(--status-done);
}
.flash-message.flash-warning {
  background: var(--status-late-bg);
  border-left-color: var(--status-late);
}
.flash-message.flash-info {
  background: var(--sage-pale);
  border-left-color: var(--sage);
}
.flash-close {
  flex-shrink: 0;
  color: var(--ink-soft);
  font-size: .95rem;
  line-height: 1;
}
.flash-close:hover {
  color: var(--ink);
}

.empty-state,
.feed-empty,
.detail-empty,
.empty-inline {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 22px 18px;
  text-align: center;
  border: var(--border-subtle);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(107,148,120,.06), rgba(107,148,120,0));
  color: var(--ink-soft);
}

.empty-state-icon,
.feed-empty-icon,
.detail-empty-icon {
  font-size: 1.7rem;
  opacity: .65;
}

.empty-state-title,
.feed-empty-text,
.detail-empty-text {
  font-family: var(--font-serif);
  font-size: 1.02rem;
  color: var(--ink);
}

.empty-state-subtitle,
.feed-empty-sub,
.detail-empty-sub {
  font-size: .76rem;
  color: var(--ink-soft);
}

/* ── SCROLLBAR (global) ─────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(26,35,24,.12); border-radius: 3px; }
