/* =========================================================
   R2V Unified Portal — components.css
   Buttons, cards, badges, tables, forms, modals, toasts
   ========================================================= */

/* ---- Buttons ---- */
.r2v-btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  height: 44px; padding: 0 18px; min-width: 0;
  border-radius: 10px; font-size: 14px; font-weight: 700; line-height: 1;
  font-family: var(--r2v-font-sans);
  border: 1px solid transparent; cursor: pointer;
  background: var(--r2v-surface); color: var(--r2v-ink);
  box-shadow: 0 1px 0 rgba(20,30,46,.04);
  transition: background var(--r2v-dur), border-color var(--r2v-dur), color var(--r2v-dur), transform .1s;
}
.r2v-btn:hover { text-decoration: none; }
.r2v-btn:active { transform: translateY(1px); }
.r2v-btn i { width: 18px; height: 18px; }

.r2v-btn--primary {
  background: var(--r2v-blue); color: #fff;
  border-color: var(--r2v-blue-dark);
  box-shadow: 0 2px 0 var(--r2v-blue-dark), 0 6px 14px rgba(14,81,139,.25);
}
.r2v-btn--primary:hover { background: #0c447a; color: #fff; }

.r2v-btn--accent {
  background: var(--r2v-red); color: #fff;
  border-color: #7B2625;
  box-shadow: 0 2px 0 #7B2625, 0 6px 14px rgba(162,53,51,.25);
}
.r2v-btn--accent:hover { background: #8B2B2A; color: #fff; }

.r2v-btn--ghost {
  background: transparent; border-color: var(--r2v-border);
  color: var(--r2v-ink);
}
.r2v-btn--ghost:hover { background: var(--r2v-surface-2); border-color: var(--r2v-border-2); }

.r2v-btn--soft {
  background: var(--r2v-blue-soft); border-color: var(--r2v-blue-soft);
  color: var(--r2v-blue-dark);
}
.r2v-btn--soft:hover { background: #d7e9f4; }

.r2v-btn--sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.r2v-btn--lg { height: 52px; padding: 0 22px; font-size: 15px; }
.r2v-btn--block { width: 100%; }

.r2v-btn[disabled], .r2v-btn:disabled { opacity: .5; pointer-events: none; }

/* ---- Cards ---- */
.r2v-card {
  background: var(--r2v-surface);
  border: 1px solid var(--r2v-border);
  border-radius: var(--r2v-radius-lg);
  box-shadow: var(--r2v-shadow-1);
  overflow: hidden;
}
.r2v-card__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--r2v-border);
}
.r2v-card__head h2, .r2v-card__head h3 { margin: 0; font-size: 16px; }
.r2v-card__body { padding: 18px 20px; }
.r2v-card__foot {
  padding: 12px 20px; border-top: 1px solid var(--r2v-border);
  background: var(--r2v-surface-2);
}

/* ---- Badge / pill ---- */
.r2v-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  background: var(--r2v-surface-2); color: var(--r2v-ink-soft); border: 1px solid var(--r2v-border);
}
.r2v-badge i { width: 12px; height: 12px; }
.r2v-badge--info     { background: var(--r2v-blue-soft); color: var(--r2v-blue-dark); border-color: #C6DFEF; }
.r2v-badge--success  { background: #E1F4EC; color: #0E6C53; border-color: #B7E5D2; }
.r2v-badge--warn     { background: #FBEFC8; color: #7A5A05; border-color: #F1DD9A; }
.r2v-badge--danger   { background: var(--r2v-red-soft); color: var(--r2v-red); border-color: #F2C4C1; }
.r2v-badge--ink      { background: #E5E7EB; color: var(--r2v-ink); }

/* Event category chip */
.r2v-cat {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
  color: #fff;
}
.r2v-cat::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.85); }
.r2v-cat[data-cat="Driver"]        { background: var(--cat-driver); }
.r2v-cat[data-cat="Dispatch"]      { background: var(--cat-dispatch); }
.r2v-cat[data-cat="Phone Bank"]    { background: var(--cat-phonebank); }
.r2v-cat[data-cat="Outreach"]      { background: var(--cat-outreach); }
.r2v-cat[data-cat="Meeting"]       { background: var(--cat-meeting); }
.r2v-cat[data-cat="Virtual Event"] { background: var(--cat-virtual); }
.r2v-cat[data-cat="Special Event"] { background: var(--cat-special); }
.r2v-cat[data-cat="Training"]      { background: var(--cat-training); }

/* ---- Tables ---- */
.r2v-table-wrap {
  background: var(--r2v-surface); border: 1px solid var(--r2v-border);
  border-radius: var(--r2v-radius-lg); overflow: hidden;
  box-shadow: var(--r2v-shadow-1);
}
.r2v-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.r2v-table th, .r2v-table td {
  padding: 12px 16px; text-align: left;
  border-bottom: 1px solid var(--r2v-border);
}
.r2v-table th {
  font-weight: 700; font-size: 12px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--r2v-ink-mute); background: var(--r2v-surface-2);
}
.r2v-table tbody tr:hover { background: var(--r2v-surface-2); cursor: pointer; }
.r2v-table tbody tr:last-child td { border-bottom: 0; }
.r2v-table td.is-num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Forms ---- */
.r2v-field { margin-bottom: 16px; }
.r2v-field__label {
  display: block; font-size: 12px; font-weight: 700;
  color: var(--r2v-ink-soft); letter-spacing: .03em; text-transform: uppercase;
  margin-bottom: 6px;
}
.r2v-field__label .req { color: var(--r2v-red); margin-left: 3px; }
.r2v-input, .r2v-select, .r2v-textarea {
  width: 100%; height: 44px;
  padding: 0 14px;
  font: inherit; color: var(--r2v-ink);
  background: var(--r2v-surface);
  border: 1px solid var(--r2v-border); border-radius: 10px;
  transition: border-color var(--r2v-dur), box-shadow var(--r2v-dur);
}
.r2v-textarea { height: auto; padding: 12px 14px; min-height: 100px; resize: vertical; }
.r2v-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2356657A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.r2v-input:focus, .r2v-select:focus, .r2v-textarea:focus {
  outline: 0; border-color: var(--r2v-blue-teal);
  box-shadow: 0 0 0 3px rgba(20,131,177,.18);
}
.r2v-field__help { color: var(--r2v-ink-mute); font-size: 12px; margin-top: 4px; }
.r2v-field__err  { color: var(--r2v-red); font-size: 12px; margin-top: 4px; }

.r2v-checkbox, .r2v-radio {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 14px; color: var(--r2v-ink);
}
.r2v-checkbox input, .r2v-radio input { accent-color: var(--r2v-blue); width: 16px; height: 16px; }

.r2v-row { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.r2v-col-12 { grid-column: span 12; }
.r2v-col-8  { grid-column: span 8; }
.r2v-col-6  { grid-column: span 6; }
.r2v-col-4  { grid-column: span 4; }
.r2v-col-3  { grid-column: span 3; }

/* ---- Toasts ---- */
.r2v-toasts {
  position: fixed; right: 20px; top: calc(var(--r2v-topbar-h) + 16px);
  display: flex; flex-direction: column; gap: 10px;
  z-index: 200;
}
.r2v-toast {
  min-width: 280px; max-width: 380px;
  background: var(--r2v-surface); border: 1px solid var(--r2v-border);
  border-left: 4px solid var(--r2v-blue);
  border-radius: 12px; padding: 12px 14px;
  box-shadow: var(--r2v-shadow-2);
  display: flex; gap: 10px; align-items: flex-start;
  animation: r2v-toast-in .25s var(--r2v-ease);
}
.r2v-toast--success { border-left-color: var(--r2v-success); }
.r2v-toast--warn    { border-left-color: var(--r2v-warn); }
.r2v-toast--danger  { border-left-color: var(--r2v-red); }
.r2v-toast__icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--r2v-blue); margin-top: 2px; }
.r2v-toast--success .r2v-toast__icon { color: var(--r2v-success); }
.r2v-toast--warn    .r2v-toast__icon { color: var(--r2v-warn); }
.r2v-toast--danger  .r2v-toast__icon { color: var(--r2v-red); }
.r2v-toast__body { flex: 1; min-width: 0; }
.r2v-toast__title { font-weight: 700; font-size: 14px; color: var(--r2v-ink); }
.r2v-toast__desc  { font-size: 13px; color: var(--r2v-ink-soft); }
.r2v-toast__close { background: transparent; border: 0; color: var(--r2v-ink-mute); cursor: pointer; padding: 2px; line-height: 1; }
@keyframes r2v-toast-in {
  from { transform: translateY(-8px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ---- Modal ---- */
.r2v-modal-backdrop {
  position: fixed; inset: 0; background: rgba(8,21,38,.55);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  z-index: 200;
  animation: r2v-fade .2s var(--r2v-ease);
}
@keyframes r2v-fade { from { opacity: 0; } to { opacity: 1; } }
.r2v-modal {
  background: var(--r2v-surface);
  border-radius: 18px; box-shadow: var(--r2v-shadow-pop);
  width: min(640px, 92vw); max-height: 88vh; overflow: auto;
  border: 1px solid var(--r2v-border);
  animation: r2v-pop .25s var(--r2v-ease);
}
@keyframes r2v-pop {
  from { transform: scale(.96); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.r2v-modal--lg { width: min(880px, 94vw); }
.r2v-modal--xl { width: min(1140px, 96vw); }
.r2v-modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--r2v-border);
}
.r2v-modal__title { font-family: var(--r2v-font-head); font-size: 20px; font-weight: 700; color: var(--r2v-ink); }
.r2v-modal__close {
  border: 0; background: var(--r2v-surface-2); color: var(--r2v-ink-soft);
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
  display: grid; place-items: center;
}
.r2v-modal__close:hover { background: var(--r2v-red-soft); color: var(--r2v-red); }
.r2v-modal__body { padding: 22px; }
.r2v-modal__foot {
  padding: 14px 22px; border-top: 1px solid var(--r2v-border);
  background: var(--r2v-surface-2);
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap;
}

/* ---- Drawer ---- */
.r2v-drawer-backdrop {
  position: fixed; inset: 0; background: rgba(8,21,38,.45);
  z-index: 180;
  animation: r2v-fade .18s var(--r2v-ease);
}
.r2v-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(520px, 96vw);
  background: var(--r2v-surface);
  border-left: 1px solid var(--r2v-border);
  box-shadow: var(--r2v-shadow-pop);
  z-index: 190;
  display: flex; flex-direction: column;
  animation: r2v-slidein .26s var(--r2v-ease);
}
@keyframes r2v-slidein {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
.r2v-drawer__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--r2v-border);
}
.r2v-drawer__body { padding: 18px 22px; overflow-y: auto; flex: 1; }
.r2v-drawer__foot { padding: 14px 22px; border-top: 1px solid var(--r2v-border); background: var(--r2v-surface-2); display: flex; gap: 8px; justify-content: flex-end; }

/* ---- Tabs ---- */
.r2v-tabs {
  display: flex; gap: 4px; padding: 4px;
  background: var(--r2v-surface-2); border: 1px solid var(--r2v-border);
  border-radius: 999px; width: max-content;
}
.r2v-tabs__btn {
  border: 0; background: transparent; cursor: pointer;
  padding: 8px 16px; border-radius: 999px;
  font-weight: 600; font-size: 13px; color: var(--r2v-ink-soft);
  display: inline-flex; align-items: center; gap: 6px;
}
.r2v-tabs__btn i { width: 14px; height: 14px; }
.r2v-tabs__btn:hover { color: var(--r2v-ink); }
.r2v-tabs__btn.is-active { background: var(--r2v-surface); color: var(--r2v-blue-dark); box-shadow: 0 1px 4px rgba(14,81,139,.10); }

/* ---- KPI ---- */
.r2v-kpi {
  background: var(--r2v-surface);
  border: 1px solid var(--r2v-border);
  border-radius: var(--r2v-radius-lg);
  padding: 16px 18px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: var(--r2v-shadow-1);
}
.r2v-kpi__icon {
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--r2v-blue-soft); color: var(--r2v-blue-dark);
}
.r2v-kpi__icon i { width: 22px; height: 22px; }
.r2v-kpi__num { font-family: var(--r2v-font-head); font-weight: 800; font-size: 28px; line-height: 1; color: var(--r2v-ink); letter-spacing: -.02em; }
.r2v-kpi__label { font-size: 12px; color: var(--r2v-ink-mute); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; margin-top: 2px; }

.r2v-kpi--red   .r2v-kpi__icon { background: var(--r2v-red-soft); color: var(--r2v-red); }
.r2v-kpi--green .r2v-kpi__icon { background: #DDF3EA; color: #0E6C53; }
.r2v-kpi--warn  .r2v-kpi__icon { background: #FBEFC8; color: #7A5A05; }

.r2v-kpi { transition: transform var(--r2v-dur), box-shadow var(--r2v-dur); }
.r2v-kpi:hover { transform: translateY(-2px); box-shadow: var(--r2v-shadow-2); }
.r2v-kpi__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.r2v-kpi__trend {
  margin-top: 6px; display: inline-flex; align-items: center; gap: 4px;
  align-self: flex-start;
  font-size: 11px; font-weight: 800; letter-spacing: .04em;
  padding: 3px 8px; border-radius: 999px;
  background: var(--r2v-surface-2); color: var(--r2v-ink-soft);
}
.r2v-kpi__trend i { width: 12px; height: 12px; }
.r2v-kpi__trend--up   { background: #DDF3EA; color: #0E6C53; }
.r2v-kpi__trend--down { background: var(--r2v-red-soft); color: var(--r2v-red); }
.r2v-kpi__trend--flat { background: var(--r2v-surface-2); color: var(--r2v-ink-mute); }

/* ---- Empty state ---- */
.r2v-empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 48px 16px; text-align: center;
  color: var(--r2v-ink-soft);
}
.r2v-empty i { width: 40px; height: 40px; color: var(--r2v-ink-mute); }
.r2v-empty h3 { margin: 4px 0 0; font-family: var(--r2v-font-head); }

/* ---- Avatar ---- */
.r2v-avatar {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
  background: var(--r2v-blue-soft);
  border: 2px solid #fff; box-shadow: 0 0 0 1px var(--r2v-border);
}
.r2v-avatar--sm { width: 28px; height: 28px; }
.r2v-avatar--lg { width: 56px; height: 56px; }

/* ---- Misc helpers ---- */
.r2v-divider { height: 1px; background: var(--r2v-border); margin: 16px 0; }
.r2v-stack    { display: flex; flex-direction: column; gap: 10px; }
.r2v-cluster  { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.r2v-mute     { color: var(--r2v-ink-mute); }
.r2v-strong   { font-weight: 700; color: var(--r2v-ink); }
.r2v-tag      { background: var(--r2v-surface-2); color: var(--r2v-ink-soft); padding: 3px 8px; border-radius: 8px; font-size: 12px; }
