/* ==========================================================================
   RotaFlux UI — hand-written design system layer.

   Loaded after tailwind.min.css. Owns the shared visual language (tokens,
   cards, buttons, badges, banners, tables, form controls, page scaffolding)
   so templates stop carrying one-off inline styles. Plain CSS on purpose:
   no build step required, works even when the Tailwind bundle is stale.
   ========================================================================== */

:root {
  /* Ink & surfaces (warm bakery palette) */
  --rf-ink:        #231710;
  --rf-ink-soft:   #5A4738;
  --rf-muted:      #8A7965;
  --rf-faint:      #C9BBA6;
  --rf-line:       #EADDCB;
  --rf-line-soft:  #F3EADA;
  --rf-paper:      #FFFFFF;
  --rf-cream:      #F6ECDD;
  --rf-track:      #EFE6D6;

  /* Brand */
  --rf-brand:       #F26B1D;
  --rf-brand-deep:  #C24E1E;
  --rf-brand-soft:  #FDEBDD;

  /* Feedback tones */
  --rf-success:      #1B5E20;
  --rf-success-bg:   #E8F5E9;
  --rf-success-line: #C6E5C9;
  --rf-warn:         #8A5B15;
  --rf-warn-strong:  #B5771A;
  --rf-warn-bg:      #FBF1DA;
  --rf-warn-line:    #EFDCA9;
  --rf-danger:       #B4232A;
  --rf-danger-bg:    #FBE4E4;
  --rf-danger-line:  #F1C6C6;
  --rf-info:         #2B5487;
  --rf-info-strong:  #3568A7;
  --rf-info-bg:      #EDF3FB;
  --rf-info-line:    #C9DCF2;

  /* Depth & shape */
  --rf-shadow-1: 0 1px 2px rgba(80, 50, 20, .05), 0 1px 1px rgba(80, 50, 20, .03);
  --rf-shadow-2: 0 2px 6px rgba(80, 50, 20, .07), 0 8px 24px -12px rgba(80, 50, 20, .18);
  --rf-shadow-brand: 0 2px 5px rgba(194, 78, 30, .28), 0 8px 18px -8px rgba(242, 107, 29, .45);
  --rf-radius:     16px;
  --rf-radius-lg:  20px;
  --rf-radius-sm:  11px;
  --rf-ring: 0 0 0 3px rgba(242, 107, 29, .30);
}

/* --------------------------------------------------------------------------
   Base niceties
   -------------------------------------------------------------------------- */

.rf-serif { font-family: 'Spectral', Georgia, 'Times New Roman', serif; }

*:focus-visible {
  outline: none;
  box-shadow: var(--rf-ring);
  border-radius: 6px;
}

::selection { background: rgba(242, 107, 29, .22); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* --------------------------------------------------------------------------
   Page scaffolding
   -------------------------------------------------------------------------- */

.rf-page { padding: 26px 30px 56px; max-width: 1200px; }
.rf-page-wide { max-width: 1440px; }
@media (max-width: 640px) { .rf-page { padding: 18px 16px 48px; } }

.rf-page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
}
.rf-eyebrow {
  font-size: 14px; color: var(--rf-muted); font-weight: 600;
  letter-spacing: .01em;
}
.rf-eyebrow a { color: var(--rf-muted); text-decoration: underline; text-underline-offset: 3px; }
.rf-eyebrow a:hover { color: var(--rf-brand-deep); }
.rf-h1 {
  font-family: 'Spectral', Georgia, serif;
  font-weight: 700; font-size: clamp(30px, 4vw, 42px);
  line-height: 1.05; margin: 4px 0 0; color: var(--rf-ink);
  letter-spacing: -0.01em;
}
.rf-sub { font-size: 14px; color: var(--rf-muted); margin-top: 6px; }

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.rf-card {
  background: var(--rf-paper);
  border: 1px solid var(--rf-line);
  border-radius: var(--rf-radius-lg);
  box-shadow: var(--rf-shadow-1);
}
.rf-card-pad { padding: 22px 24px; }
@media (max-width: 640px) { .rf-card-pad { padding: 16px 16px; } }

.rf-card-title {
  font-family: 'Spectral', Georgia, serif;
  font-weight: 700; font-size: 20px; color: var(--rf-ink);
}
.rf-card-sub { font-size: 13.5px; color: var(--rf-muted); margin-top: 4px; max-width: 72ch; }

.rf-kpi { padding: 16px 18px; }
.rf-kpi-label { font-size: 12.5px; font-weight: 700; color: var(--rf-muted);
                text-transform: uppercase; letter-spacing: .06em; }
.rf-kpi-value { font-family: 'Spectral', Georgia, serif; font-weight: 700;
                font-size: 27px; color: var(--rf-ink); margin-top: 5px; line-height: 1.15; }
.rf-kpi-value-sm { font-size: 18px; margin-top: 9px; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.rf-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 700; font-size: 14px; line-height: 1;
  border-radius: var(--rf-radius-sm); padding: 11px 20px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: transform .12s ease, box-shadow .15s ease,
              background-color .15s ease, border-color .15s ease, color .15s ease;
  white-space: nowrap;
}
.rf-btn:active { transform: translateY(1px); }
.rf-btn[disabled] { cursor: not-allowed; transform: none; }

.rf-btn-primary {
  background: linear-gradient(180deg, #F97B31, var(--rf-brand) 55%, #E85F14);
  color: #fff; box-shadow: var(--rf-shadow-brand);
}
.rf-btn-primary:hover { background: linear-gradient(180deg, #FA8946, #F26B1D 55%, #DE5A12); box-shadow: 0 3px 8px rgba(194,78,30,.34), 0 10px 22px -8px rgba(242,107,29,.5); }
.rf-btn-primary[disabled] { background: var(--rf-track); color: #A89680; box-shadow: none; }

.rf-btn-outline {
  background: var(--rf-paper); color: var(--rf-brand-deep);
  border-color: rgba(242, 107, 29, .55);
}
.rf-btn-outline:hover { background: var(--rf-brand-soft); border-color: var(--rf-brand); }

.rf-btn-ghost {
  background: var(--rf-paper); color: var(--rf-ink-soft);
  border-color: var(--rf-line); box-shadow: var(--rf-shadow-1);
}
.rf-btn-ghost:hover { background: #FBF6EC; border-color: #DECBAF; }

.rf-btn-danger-ghost {
  background: var(--rf-paper); color: var(--rf-danger);
  border-color: var(--rf-danger-line);
}
.rf-btn-danger-ghost:hover { background: #FDF1F1; border-color: #E7A9A9; }

.rf-btn-sm { padding: 8px 14px; font-size: 13px; }
.rf-btn-lg { padding: 13px 26px; font-size: 15px; }

/* --------------------------------------------------------------------------
   Badges & banners
   -------------------------------------------------------------------------- */

.rf-badge {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 999px; padding: 3px 11px;
  font-weight: 700; font-size: 12px; line-height: 1.5; white-space: nowrap;
}
.rf-badge-success { background: var(--rf-success-bg); color: var(--rf-success); }
.rf-badge-warn    { background: var(--rf-warn-bg);    color: var(--rf-warn); }
.rf-badge-danger  { background: var(--rf-danger-bg);  color: var(--rf-danger); }
.rf-badge-info    { background: var(--rf-info-bg);    color: var(--rf-info); }
.rf-badge-neutral { background: var(--rf-track);      color: var(--rf-ink-soft); }

.rf-banner {
  display: flex; align-items: flex-start; gap: 13px;
  border-radius: 14px; padding: 15px 20px; border: 1px solid;
}
.rf-banner svg { flex: 0 0 21px; margin-top: 1px; }
.rf-banner-title { font-weight: 700; font-size: 15.5px; }
.rf-banner-body  { font-size: 13.5px; margin-top: 2px; }
.rf-banner-info    { background: var(--rf-info-bg);    border-color: var(--rf-info-line); }
.rf-banner-info    .rf-banner-title { color: var(--rf-info); }
.rf-banner-info    .rf-banner-body  { color: #5379A5; }
.rf-banner-warn    { background: var(--rf-warn-bg);    border-color: var(--rf-warn-line); }
.rf-banner-warn    .rf-banner-title { color: var(--rf-warn); }
.rf-banner-warn    .rf-banner-body  { color: #9A7434; }
.rf-banner-danger  { background: var(--rf-danger-bg);  border-color: var(--rf-danger-line); }
.rf-banner-danger  .rf-banner-title { color: var(--rf-danger); }
.rf-banner-danger  .rf-banner-body  { color: #9A4A4A; }
.rf-banner-success { background: var(--rf-success-bg); border-color: var(--rf-success-line); }
.rf-banner-success .rf-banner-title { color: var(--rf-success); }
.rf-banner-success .rf-banner-body  { color: #3D7042; }

/* Flash messages (django.contrib.messages) */
.rf-flash {
  border-radius: 13px; border: 1px solid; padding: 12px 18px;
  font-size: 14px; font-weight: 600;
  animation: rf-flash-in .35s ease both;
}
.rf-flash-success { background: var(--rf-success-bg); border-color: var(--rf-success-line); color: var(--rf-success); }
.rf-flash-error   { background: var(--rf-danger-bg);  border-color: var(--rf-danger-line);  color: var(--rf-danger); }
.rf-flash-info    { background: var(--rf-warn-bg);    border-color: var(--rf-warn-line);    color: var(--rf-warn); }
@keyframes rf-flash-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.rf-table-wrap { overflow-x: auto; border-radius: 12px; }
.rf-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.rf-table thead th {
  text-align: left; color: var(--rf-muted); font-weight: 700; font-size: 12px;
  text-transform: uppercase; letter-spacing: .05em;
  padding: 8px 10px; border-bottom: 1px solid var(--rf-line);
}
.rf-table tbody td {
  padding: 10px; color: var(--rf-ink);
  border-top: 1px solid var(--rf-line-soft);
}
.rf-table tbody tr:first-child td { border-top: 0; }
.rf-table tbody tr { transition: background-color .12s ease; }
.rf-table tbody tr:hover { background: #FCF8F0; }
.rf-num { text-align: right; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   Meters (horizontal bars used in trends)
   -------------------------------------------------------------------------- */

.rf-meter { position: relative; height: 12px; }
.rf-meter-track, .rf-meter-fill {
  position: absolute; left: 0; top: 1px; height: 10px; border-radius: 999px;
}
.rf-meter-track { width: 100%; background: var(--rf-track); }
.rf-meter-fill  { min-width: 2px; background: var(--rf-brand); transition: width .5s cubic-bezier(.22,.8,.36,1); }
.rf-meter-fill-neg  { background: #D9534F; }
.rf-meter-fill-deep { background: var(--rf-warn); opacity: .85; }

.rf-row-line {
  display: grid; gap: 12px; align-items: center;
  padding: 5px 0; border-bottom: 1px solid var(--rf-line-soft);
}
.rf-row-line:last-child { border-bottom: 0; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.rf-label {
  display: block; font-size: 12px; font-weight: 700; color: var(--rf-ink-soft);
  margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em;
}
.rf-select, .rf-input {
  border: 1px solid var(--rf-line); border-radius: 10px;
  padding: 8px 12px; font-size: 13.5px; background: var(--rf-paper);
  color: var(--rf-ink); box-shadow: var(--rf-shadow-1);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.rf-select:hover, .rf-input:hover { border-color: #DECBAF; }
.rf-select:focus, .rf-input:focus { border-color: var(--rf-brand); box-shadow: var(--rf-ring); outline: none; }

/* Upload drop-zone-styled file control */
.rf-file {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border: 1.5px dashed #DEC9A8; border-radius: 14px;
  background: #FDFAF3; padding: 14px 18px;
  transition: border-color .15s ease, background-color .15s ease;
}
.rf-file:hover { border-color: var(--rf-brand); background: #FDF6EC; }
.rf-file input[type="file"] { font-size: 13.5px; color: var(--rf-ink-soft); }
.rf-file input[type="file"]::file-selector-button {
  background: var(--rf-paper); color: var(--rf-ink-soft); font-weight: 700;
  font-size: 13px; border: 1px solid var(--rf-line); border-radius: 9px;
  padding: 8px 14px; margin-right: 12px; cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.rf-file input[type="file"]::file-selector-button:hover { background: #FBF6EC; border-color: #DECBAF; }

/* --------------------------------------------------------------------------
   Empty states
   -------------------------------------------------------------------------- */

.rf-empty { text-align: center; padding: 56px 24px; color: var(--rf-muted); }
.rf-empty-icon {
  width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 16px;
  background: var(--rf-cream); display: flex; align-items: center; justify-content: center;
  color: var(--rf-brand-deep);
}
.rf-empty-title {
  font-family: 'Spectral', Georgia, serif; font-weight: 700;
  font-size: 19px; color: var(--rf-ink);
}
.rf-empty-body { font-size: 14px; margin-top: 5px; max-width: 46ch; margin-left: auto; margin-right: auto; }

/* --------------------------------------------------------------------------
   Sidebar (manager shell)
   -------------------------------------------------------------------------- */

.rf-sidebar {
  background: linear-gradient(180deg, #241811 0%, #1B110B 100%);
  box-shadow: inset -1px 0 0 rgba(255,255,255,.04);
}
.sidebar-link {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  color: #C9B9A6; font-weight: 500; font-size: 14px;
  border-radius: 12px; padding: 10px 14px;
  transition: background-color .15s ease, color .15s ease;
}
.sidebar-link:hover { background: rgba(246, 236, 221, .08); color: #F3E9DB; }
.sidebar-link svg { opacity: .75; transition: opacity .15s ease; }
.sidebar-link:hover svg { opacity: 1; }
.sidebar-link.active {
  background: var(--rf-cream); color: #251710; font-weight: 700;
  box-shadow: 0 2px 8px -2px rgba(0,0,0,.4);
}
.sidebar-link.active::before {
  content: ""; position: absolute; left: 5px; top: 10px; bottom: 10px;
  width: 3px; border-radius: 3px; background: var(--rf-brand);
}
.sidebar-link.active svg { color: var(--rf-brand-deep); opacity: 1; }
.rf-nav-count {
  margin-left: auto; background: #E23D3D; color: #fff;
  font-size: 11px; font-weight: 800; border-radius: 999px;
  min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
}
