/**
 * Raya ERP — Modern UI layer (Material-inspired + utility tokens)
 */
:root {
  --rm-primary: #6750a4;
  --rm-primary-container: #eaddff;
  --rm-secondary: #017E84;
  --rm-surface: #fffbfe;
  --rm-surface-2: #f7f2fa;
  --rm-outline: #79747e;
  --rm-shadow-1: 0 1px 2px rgba(0, 0, 0, .06), 0 1px 3px rgba(0, 0, 0, .08);
  --rm-shadow-2: 0 4px 6px -1px rgba(0, 0, 0, .08), 0 2px 4px -2px rgba(0, 0, 0, .06);
  --rm-shadow-3: 0 10px 25px -5px rgba(103, 80, 164, .15), 0 8px 10px -6px rgba(0, 0, 0, .08);
  --rm-radius-lg: 16px;
  --rm-radius-md: 12px;
  --rm-radius-sm: 8px;
}

body.rm-modern {
  --surface: var(--rm-surface);
  --surface2: var(--rm-surface-2);
}

/* ── Elevated cards ── */
.rm-card {
  background: #fff;
  border: 1px solid rgba(121, 116, 126, .12);
  border-radius: var(--rm-radius-lg);
  box-shadow: var(--rm-shadow-1);
  transition: box-shadow .2s, transform .2s;
}
.rm-card:hover { box-shadow: var(--rm-shadow-2); }
.rm-card.rm-card-interactive:hover { transform: translateY(-2px); box-shadow: var(--rm-shadow-3); }
.rm-card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid rgba(0, 0, 0, .06);
}
.rm-card-body { padding: 16px 18px; }

/* ── KPI strip ── */
.rm-kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.rm-kpi {
  background: linear-gradient(135deg, #fff 0%, var(--rm-surface-2) 100%);
  border: 1px solid rgba(103, 80, 164, .1);
  border-radius: var(--rm-radius-md);
  padding: 14px 16px;
  box-shadow: var(--rm-shadow-1);
}
.rm-kpi-label { font-size: 11px; font-weight: 600; color: var(--text-m); margin-bottom: 4px; }
.rm-kpi-value { font-size: 20px; font-weight: 800; color: var(--odoo-purple); line-height: 1.2; }
.rm-kpi-sub { font-size: 10px; color: var(--text-s); margin-top: 4px; }

/* ── View toggle (segmented control) ── */
.rm-view-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 14px;
}
.rm-segment {
  display: inline-flex; background: var(--rm-surface-2);
  border: 1px solid rgba(0, 0, 0, .08); border-radius: 999px; padding: 3px;
}
.rm-segment button {
  border: none; background: transparent; padding: 7px 14px;
  border-radius: 999px; font-size: 12px; font-weight: 600; cursor: pointer;
  color: var(--text-m); transition: all .2s; font-family: inherit;
}
.rm-segment button.active {
  background: #fff; color: var(--rm-primary);
  box-shadow: var(--rm-shadow-1);
}
.rm-segment button:hover:not(.active) { color: var(--text); }

/* ── Modern buttons ── */
.btn.rm-btn {
  border-radius: 999px; font-weight: 600; letter-spacing: .01em;
  box-shadow: var(--rm-shadow-1); transition: transform .15s, box-shadow .15s;
}
.btn.rm-btn:hover { transform: translateY(-1px); box-shadow: var(--rm-shadow-2); }
.btn.rm-btn-primary {
  background: linear-gradient(135deg, var(--rm-primary), #7f67be);
  border: none; color: #fff;
}
.btn.rm-btn-tonal {
  background: var(--rm-primary-container); color: #381e72; border: none;
}

/* ── Card grid (sales / invoices) ── */
.rm-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.rm-inv-card {
  background: #fff; border-radius: var(--rm-radius-md);
  border: 1px solid rgba(0, 0, 0, .08); padding: 16px;
  box-shadow: var(--rm-shadow-1); cursor: default;
  border-right: 4px solid var(--odoo-green);
  transition: box-shadow .2s, transform .2s;
}
.rm-inv-card:hover { box-shadow: var(--rm-shadow-2); transform: translateY(-2px); }
.rm-inv-card.rm-deferred { border-right-color: #f59e0b; }
.rm-inv-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.rm-inv-card-id { font-family: var(--mono); font-size: 12px; font-weight: 800; color: var(--odoo-green); }
.rm-inv-card-amt { font-size: 18px; font-weight: 800; color: var(--text); direction: ltr; text-align: left; }
.rm-inv-card-customer { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.rm-inv-card-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; color: var(--text-m); margin-bottom: 12px; }
.rm-inv-card-actions { display: flex; gap: 6px; flex-wrap: wrap; padding-top: 10px; border-top: 1px dashed var(--border); }

/* ── Dashboard chart ── */
.rm-chart-wrap {
  position: relative; height: 220px; width: 100%;
  padding: 8px 4px 4px;
}
.rm-chart-wrap canvas { max-height: 220px; }
.rm-chart-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
  text-align: center;
}
.rm-chart-stat-val { font-weight: 800; font-size: 14px; }
.rm-chart-stat-lbl { font-size: 10px; color: var(--text-m); margin-top: 2px; }

/* ── Recent invoices as cards ── */
.rm-dash-invoices {
  display: flex; flex-direction: column; gap: 8px;
}
.rm-dash-inv-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: var(--rm-surface-2); border-radius: var(--rm-radius-sm);
  border: 1px solid transparent; transition: border-color .15s, background .15s;
}
.rm-dash-inv-row:hover { background: #fff; border-color: rgba(103, 80, 164, .2); }
.rm-dash-inv-icon {
  width: 40px; height: 40px; border-radius: 10px; display: flex;
  align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0;
  background: var(--rm-primary-container);
}
.rm-dash-inv-main { flex: 1; min-width: 0; }
.rm-dash-inv-title { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rm-dash-inv-sub { font-size: 10px; color: var(--text-m); margin-top: 2px; }
.rm-dash-inv-amt { font-weight: 800; font-size: 13px; color: var(--odoo-purple); white-space: nowrap; }

/* ── Sales Kanban ── */
.sp-kanban-wrap { width: 100%; overflow: hidden; }
.sp-kanban-scroll {
  overflow-x: auto; padding-bottom: 10px;
  border: 1px solid var(--border); border-radius: var(--rm-radius-lg);
  background: linear-gradient(180deg, var(--rm-surface-2), #fff);
}
.sp-kanban {
  display: flex; flex-direction: row; gap: 12px; padding: 12px;
  min-height: 380px; width: max-content; min-width: 100%; direction: rtl;
}
.sp-col {
  flex: 0 0 260px; width: 260px; background: #fff;
  border-radius: var(--rm-radius-md); border: 1.5px solid var(--border);
  display: flex; flex-direction: column; max-height: 70vh;
}
.sp-col.sp-drop-target { border-color: var(--rm-primary); box-shadow: 0 0 0 3px rgba(103, 80, 164, .15); }
.sp-col-hdr {
  padding: 12px 14px; border-radius: var(--rm-radius-md) var(--rm-radius-md) 0 0;
  color: #fff; font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: space-between;
}
.sp-col-hdr.sp-h-pending { background: linear-gradient(135deg, #f59e0b, #d97706); }
.sp-col-hdr.sp-h-active { background: linear-gradient(135deg, #017E84, #015a5f); }
.sp-col-hdr.sp-h-done { background: linear-gradient(135deg, #198754, #146c43); }
.sp-col-body { padding: 8px; overflow-y: auto; flex: 1; min-height: 100px; }
.sp-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--rm-radius-sm);
  padding: 12px; margin-bottom: 8px; cursor: grab;
  box-shadow: var(--rm-shadow-1); transition: transform .15s, opacity .15s;
  border-right: 3px solid var(--odoo-green);
}
.sp-card:hover { box-shadow: var(--rm-shadow-2); }
.sp-card.sp-dragging { opacity: .5; transform: rotate(2deg); cursor: grabbing; }
.sp-card-id { font-family: var(--mono); font-size: 10px; font-weight: 800; color: var(--odoo-purple); }
.sp-card-title { font-weight: 800; font-size: 12px; margin: 4px 0; }
.sp-card-amt { font-size: 14px; font-weight: 800; color: var(--odoo-green); margin-top: 6px; }
.sp-card-meta { font-size: 10px; color: var(--text-m); margin-top: 4px; }

/* ── Reservations kanban ── */
.rsv-kanban .sp-col-hdr.sp-h-active { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.rsv-kanban .sp-col-hdr.sp-h-done { background: linear-gradient(135deg, #22c55e, #15803d); }
.rsv-kanban .sp-col-hdr.sp-h-cancel { background: linear-gradient(135deg, #ef4444, #b91c1c); }

/* ── Toast notifications ── */
#notif-container.raya-toast-stack {
  top: 72px; bottom: auto; left: 20px; right: auto;
  flex-direction: column-reverse; gap: 10px; pointer-events: none;
  max-width: min(420px, calc(100vw - 32px));
}
.raya-toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border-radius: var(--rm-radius-md);
  background: #fff; color: var(--text);
  box-shadow: var(--rm-shadow-3);
  border: 1px solid rgba(0, 0, 0, .06);
  border-right: 4px solid var(--odoo-blue);
  animation: rayaToastIn .35s cubic-bezier(.21, 1.02, .73, 1);
  position: relative; overflow: hidden;
}
.raya-toast.raya-toast-out { animation: rayaToastOut .25s ease forwards; }
@keyframes rayaToastIn {
  from { opacity: 0; transform: translateX(-24px) scale(.96); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes rayaToastOut {
  to { opacity: 0; transform: translateX(-16px) scale(.95); }
}
.raya-toast-success { border-right-color: var(--odoo-green); }
.raya-toast-danger { border-right-color: var(--odoo-red); }
.raya-toast-warning { border-right-color: var(--odoo-orange); }
.raya-toast-info { border-right-color: var(--odoo-blue); }
.raya-toast-icon { font-size: 20px; line-height: 1; flex-shrink: 0; }
.raya-toast-body { flex: 1; min-width: 0; }
.raya-toast-msg { font-size: 13px; font-weight: 600; line-height: 1.45; }
.raya-toast-close {
  border: none; background: transparent; color: var(--text-s);
  cursor: pointer; font-size: 16px; padding: 0 4px; line-height: 1; flex-shrink: 0;
}
.raya-toast-close:hover { color: var(--odoo-red); }
.raya-toast-progress {
  position: absolute; bottom: 0; right: 0; height: 3px;
  background: currentColor; opacity: .35; animation: rayaToastProgress linear forwards;
}
@keyframes rayaToastProgress { from { width: 100%; } to { width: 0%; } }

/* Legacy notif fallback hidden when modern stack active */
#notif-container.raya-toast-stack .notif { display: none; }

.sp-col-hdr.sp-h-unpaid { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.sp-col-hdr.sp-h-import { background: linear-gradient(135deg, #6366f1, #4338ca); }

.rm-inv-stock-card { border-right-color: var(--odoo-green); }
.rm-inv-stock-card.rm-low { border-right-color: #f59e0b; }
.rm-inv-stock-card.rm-zero { border-right-color: var(--odoo-red); }
.rm-inv-stock-qty { font-size: 28px; font-weight: 800; line-height: 1; margin: 8px 0; }

@media (max-width: 768px) {
  .rm-kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .rm-card-grid { grid-template-columns: 1fr; }
  #notif-container.raya-toast-stack { left: 12px; right: 12px; max-width: none; }
}
