/* Sendara — custom styles complementing Tailwind */
.nav-item {
  display: flex;
  align-items: center;
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  color: #cbd5e1;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.15s;
}
.nav-item:hover {
  background: #1e293b;
  color: #fff;
}
.nav-item.active {
  background: #1e293b;
  color: #fff;
  border-left-color: #22c55e;
}

.stat-card {
  background: #fff;
  border-radius: 0.75rem;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  border: 1px solid #e2e8f0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.btn-primary { background: #16a34a; color: white; }
.btn-primary:hover { background: #15803d; }
.btn-secondary { background: #fff; border-color: #cbd5e1; color: #334155; }
.btn-secondary:hover { background: #f1f5f9; }
.btn-danger { background: #dc2626; color: white; }
.btn-danger:hover { background: #b91c1c; }

.input, .select, .textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  background: #fff;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 0.5rem; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.table th { text-align: left; padding: 0.75rem 1rem; background: #f8fafc; font-size: 0.75rem; text-transform: uppercase; color: #64748b; letter-spacing: 0.05em; border-bottom: 1px solid #e2e8f0; }
.table td { padding: 0.75rem 1rem; border-bottom: 1px solid #f1f5f9; font-size: 0.875rem; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8fafc; }

.badge { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-gray { background: #e2e8f0; color: #475569; }

.toast-success { background: #16a34a; }
.toast-error   { background: #dc2626; }
.toast-info    { background: #2563eb; }

/* =========================================================
   DARK MODE
   Activated when <html class="dark"> is present.
   Mirrors Tailwind's `dark:` strategy.
   ========================================================= */
html.dark body { background: #0f172a; color: #e2e8f0; }
html.dark .bg-white,
html.dark .bg-gray-50,
html.dark .bg-gray-100 { background: #1e293b !important; color: #e2e8f0; }
html.dark .bg-gray-200 { background: #334155 !important; }
html.dark .text-gray-900 { color: #f1f5f9 !important; }
html.dark .text-gray-800 { color: #e2e8f0 !important; }
html.dark .text-gray-700 { color: #cbd5e1 !important; }
html.dark .text-gray-600 { color: #94a3b8 !important; }
html.dark .text-gray-500 { color: #94a3b8 !important; }
html.dark .border-gray-200,
html.dark .border-gray-300,
html.dark .border { border-color: #334155 !important; }
html.dark .shadow,
html.dark .shadow-md,
html.dark .shadow-sm { box-shadow: 0 1px 3px rgba(0,0,0,0.3) !important; }
html.dark .stat-card { background: #1e293b; border-color: #334155; color: #e2e8f0; }
html.dark .input, html.dark .select, html.dark .textarea {
  background: #0f172a; border-color: #334155; color: #e2e8f0;
}
html.dark .input::placeholder { color: #64748b; }
html.dark .btn-secondary { background: #1e293b; border-color: #334155; color: #e2e8f0; }
html.dark .btn-secondary:hover { background: #334155; }
html.dark .table { background: #1e293b; }
html.dark .table th { background: #0f172a; color: #94a3b8; border-color: #334155; }
html.dark .table td { border-color: #334155; color: #e2e8f0; }
html.dark .table tr:hover td { background: #334155; }
html.dark .badge-green { background: #14532d; color: #86efac; }
html.dark .badge-amber { background: #78350f; color: #fcd34d; }
html.dark .badge-red   { background: #7f1d1d; color: #fca5a5; }
html.dark .badge-blue  { background: #1e3a8a; color: #93c5fd; }
html.dark .badge-gray  { background: #334155; color: #cbd5e1; }
html.dark .hover\:bg-gray-50:hover { background: #334155 !important; }
html.dark .hover\:bg-gray-100:hover { background: #334155 !important; }
html.dark .divide-gray-200 > * + * { border-color: #334155 !important; }
html.dark a { color: #60a5fa; }
html.dark .prose, html.dark .prose * { color: #e2e8f0 !important; }

/* =========================================================
   SENDARA — PREMIUM DESIGN SYSTEM v2
   ========================================================= */
:root {
  --sd-primary: #16a34a;
  --sd-primary-hover: #15803d;
  --sd-primary-soft: #dcfce7;
  --sd-sidebar-bg: #0f172a;
  --sd-sidebar-fg: #cbd5e1;
  --sd-card-bg: #ffffff;
  --sd-card-border: #e2e8f0;
  --sd-page-bg: #f8fafc;
  --sd-text: #0f172a;
  --sd-text-muted: #64748b;
  --sd-shadow-sm: 0 1px 2px rgba(15,23,42,.04);
  --sd-shadow-md: 0 4px 12px rgba(15,23,42,.08);
  --sd-shadow-lg: 0 12px 32px rgba(15,23,42,.12);
  --sd-radius: 10px;
}
html.dark {
  --sd-card-bg: #1e293b;
  --sd-card-border: #334155;
  --sd-page-bg: #0f172a;
  --sd-text: #f1f5f9;
  --sd-text-muted: #94a3b8;
}
body {
  background: var(--sd-page-bg);
  color: var(--sd-text);
  font-feature-settings: "cv11","ss03";
}

/* Sidebar — slimmer, gradient accent */
.sd-sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #0b1220 100%);
  color: var(--sd-sidebar-fg);
  width: 240px;
  min-height: 100vh;
  display: flex; flex-direction: column;
  position: sticky; top: 0;
}
.sd-sidebar .sd-brand {
  display: flex; align-items: center; gap: .65rem;
  padding: 1.1rem 1.25rem; font-weight: 700; font-size: 1.05rem; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sd-sidebar .sd-brand .sd-logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  display: flex; align-items: center; justify-content: center; color: #fff;
  box-shadow: 0 4px 12px rgba(34,197,94,.4);
}
.sd-nav-section { padding: .5rem 0; }
.sd-nav-label {
  padding: .5rem 1.25rem .25rem;
  font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
  color: #64748b; font-weight: 600;
}
.nav-item {
  padding: .55rem 1.25rem; font-size: .875rem;
  border-left: 3px solid transparent;
}
.nav-item i.w-5 { width: 1.25rem; margin-right: .5rem; opacity: .85; }
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(34,197,94,.15) 0%, transparent 100%);
  border-left-color: #22c55e;
  color: #fff;
}
.nav-item .nav-badge {
  margin-left: auto; background: #ef4444; color: #fff;
  font-size: .65rem; padding: .1rem .4rem; border-radius: 999px; font-weight: 600;
}

/* Topbar */
.sd-topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .75rem 1.5rem;
  background: var(--sd-card-bg);
  border-bottom: 1px solid var(--sd-card-border);
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(8px);
}
.sd-topbar .sd-breadcrumbs {
  font-size: .85rem; color: var(--sd-text-muted);
}
.sd-topbar .sd-breadcrumbs b { color: var(--sd-text); }
.sd-topbar .sd-search {
  margin-left: auto; position: relative; max-width: 340px; flex: 1;
}
.sd-topbar .sd-search input {
  padding-left: 2.2rem;
}
.sd-topbar .sd-search i {
  position: absolute; left: .75rem; top: 50%; transform: translateY(-50%);
  color: var(--sd-text-muted); font-size: .9rem;
}
.sd-topbar .sd-search kbd {
  position: absolute; right: .5rem; top: 50%; transform: translateY(-50%);
  font-size: .65rem; background: #f1f5f9; padding: .1rem .35rem; border-radius: 4px;
  border: 1px solid #e2e8f0; color: #64748b;
}
html.dark .sd-topbar .sd-search kbd { background: #0f172a; border-color: #334155; color: #94a3b8; }

/* Buttons — premium polish */
.btn {
  padding: .5rem .95rem; font-weight: 500; letter-spacing: -.01em;
  border-radius: var(--sd-radius);
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, 0 1px 2px rgba(22,163,74,.4);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #16a34a 0%, #15803d 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, 0 4px 10px rgba(22,163,74,.35);
}
.btn-sm { padding: .3rem .65rem; font-size: .78rem; }
.btn-icon {
  width: 32px; height: 32px; padding: 0; display: inline-flex;
  align-items: center; justify-content: center; border-radius: 8px;
  background: transparent; border: 1px solid transparent; color: var(--sd-text-muted);
}
.btn-icon:hover { background: #f1f5f9; color: var(--sd-text); }
html.dark .btn-icon:hover { background: #334155; color: #f1f5f9; }
.btn-ghost { background: transparent; color: var(--sd-text-muted); }
.btn-ghost:hover { background: #f1f5f9; color: var(--sd-text); }
html.dark .btn-ghost:hover { background: #334155; color: #f1f5f9; }

/* Card */
.sd-card {
  background: var(--sd-card-bg);
  border: 1px solid var(--sd-card-border);
  border-radius: 12px;
  box-shadow: var(--sd-shadow-sm);
}
.sd-card-header {
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--sd-card-border);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.sd-card-header h2, .sd-card-header h3 { margin: 0; font-weight: 600; }
.sd-card-body { padding: 1.25rem; }

/* Inputs */
.input, .select, .textarea {
  border-radius: 8px; transition: border-color .15s, box-shadow .15s;
}
.input[type="search"] { padding-left: 2rem; }

/* Page header */
.sd-page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.25rem;
}
.sd-page-header h1 {
  font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em;
  margin: 0; color: var(--sd-text);
}
.sd-page-header .sd-page-sub {
  font-size: .85rem; color: var(--sd-text-muted); margin-top: .15rem;
}

/* Tabs */
.sd-tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--sd-card-border); margin-bottom: 1.25rem; }
.sd-tab {
  padding: .65rem 1rem; font-size: .875rem; cursor: pointer;
  border-bottom: 2px solid transparent; color: var(--sd-text-muted);
  transition: color .15s, border-color .15s;
}
.sd-tab:hover { color: var(--sd-text); }
.sd-tab.active { color: var(--sd-primary); border-bottom-color: var(--sd-primary); font-weight: 600; }

/* Table polish */
.table { border-radius: 10px; box-shadow: var(--sd-shadow-sm); }
.table tr.selected td { background: var(--sd-primary-soft) !important; }
html.dark .table tr.selected td { background: rgba(34,197,94,.12) !important; }
.table .row-actions {
  opacity: 0; transition: opacity .12s;
}
.table tr:hover .row-actions { opacity: 1; }

/* Empty state */
.sd-empty {
  text-align: center; padding: 3rem 1rem; color: var(--sd-text-muted);
}
.sd-empty i { font-size: 2.5rem; opacity: .35; margin-bottom: .75rem; }
.sd-empty h3 { font-size: 1.05rem; font-weight: 600; color: var(--sd-text); margin: 0 0 .35rem; }
.sd-empty p { font-size: .875rem; margin: 0 0 1rem; }

/* Skeleton loader */
.sd-skeleton {
  background: linear-gradient(90deg, #e2e8f0 0%, #f1f5f9 50%, #e2e8f0 100%);
  background-size: 200% 100%;
  animation: sd-shimmer 1.4s linear infinite;
  border-radius: 6px;
}
html.dark .sd-skeleton {
  background: linear-gradient(90deg, #1e293b 0%, #334155 50%, #1e293b 100%);
  background-size: 200% 100%;
}
@keyframes sd-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Badges — extended */
.badge-purple { background: #f3e8ff; color: #7e22ce; }
.badge-pink { background: #fce7f3; color: #be185d; }
html.dark .badge-purple { background: #581c87; color: #e9d5ff; }
html.dark .badge-pink { background: #831843; color: #fbcfe8; }

/* Switch toggle */
.sd-switch {
  position: relative; display: inline-block; width: 40px; height: 22px; cursor: pointer;
}
.sd-switch input { opacity: 0; width: 0; height: 0; }
.sd-switch .sd-slider {
  position: absolute; inset: 0; background: #cbd5e1;
  border-radius: 999px; transition: background .15s;
}
.sd-switch .sd-slider::before {
  content: ""; position: absolute; left: 3px; top: 3px;
  width: 16px; height: 16px; background: #fff; border-radius: 50%;
  transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.sd-switch input:checked + .sd-slider { background: var(--sd-primary); }
.sd-switch input:checked + .sd-slider::before { transform: translateX(18px); }
html.dark .sd-switch .sd-slider { background: #475569; }

/* Modal — premium */
#modal {
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(4px);
}
#modal > div {
  border-radius: 14px; box-shadow: var(--sd-shadow-lg);
  animation: sd-modal-in .18s ease-out;
}
@keyframes sd-modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Command palette */
.sd-palette {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  backdrop-filter: blur(4px); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 10vh;
}
.sd-palette-box {
  background: var(--sd-card-bg); width: 90%; max-width: 560px;
  border-radius: 12px; box-shadow: var(--sd-shadow-lg);
  overflow: hidden;
}
.sd-palette-input {
  width: 100%; padding: 1rem 1.25rem; border: none; outline: none;
  background: transparent; color: var(--sd-text); font-size: 1rem;
  border-bottom: 1px solid var(--sd-card-border);
}
.sd-palette-list { max-height: 50vh; overflow-y: auto; }
.sd-palette-item {
  padding: .65rem 1.25rem; cursor: pointer; display: flex;
  align-items: center; gap: .75rem; font-size: .9rem;
}
.sd-palette-item:hover, .sd-palette-item.active { background: var(--sd-primary-soft); }
html.dark .sd-palette-item:hover, html.dark .sd-palette-item.active { background: rgba(34,197,94,.12); }
.sd-palette-item .kbd-hint { margin-left: auto; font-size: .7rem; color: var(--sd-text-muted); }

/* Flow builder canvas */
.flow-canvas {
  background:
    radial-gradient(circle, #cbd5e1 1px, transparent 1px) 0 0 / 20px 20px,
    var(--sd-page-bg);
  min-height: 520px; border-radius: 12px;
  border: 1px solid var(--sd-card-border);
  position: relative; overflow: auto;
  padding: 1.5rem;
}
html.dark .flow-canvas {
  background:
    radial-gradient(circle, #334155 1px, transparent 1px) 0 0 / 20px 20px,
    #0b1220;
}
.flow-node {
  background: var(--sd-card-bg); border: 1px solid var(--sd-card-border);
  border-radius: 10px; box-shadow: var(--sd-shadow-md);
  padding: .85rem 1rem; min-width: 220px; position: absolute;
  cursor: grab; user-select: none;
}
.flow-node:active { cursor: grabbing; }
.flow-node.trigger { border-color: #22c55e; }
.flow-node.action { border-color: #3b82f6; }
.flow-node .flow-node-title {
  font-weight: 600; font-size: .85rem; margin-bottom: .25rem;
  display: flex; align-items: center; gap: .4rem;
}
.flow-node .flow-node-body { font-size: .75rem; color: var(--sd-text-muted); }
.flow-node-handle {
  position: absolute; width: 12px; height: 12px;
  background: var(--sd-primary); border: 2px solid var(--sd-card-bg);
  border-radius: 50%;
}
.flow-node-handle.bottom { bottom: -6px; left: 50%; transform: translateX(-50%); }
.flow-node-handle.top { top: -6px; left: 50%; transform: translateX(-50%); }

/* Drag-and-drop visual cues */
.dnd-dragging { opacity: .5; }
.dnd-over {
  outline: 2px dashed var(--sd-primary);
  outline-offset: -2px; background: var(--sd-primary-soft) !important;
}
html.dark .dnd-over { background: rgba(34,197,94,.12) !important; }

/* Inbox 3-pane */
.inbox-layout {
  display: grid; grid-template-columns: 280px 1fr 320px;
  height: calc(100vh - 60px); gap: 0;
}
.inbox-list {
  background: var(--sd-card-bg); border-right: 1px solid var(--sd-card-border);
  overflow-y: auto;
}
.inbox-item {
  padding: .85rem 1rem; border-bottom: 1px solid var(--sd-card-border);
  cursor: pointer; display: flex; gap: .65rem;
}
.inbox-item:hover { background: var(--sd-page-bg); }
.inbox-item.active { background: var(--sd-primary-soft); border-left: 3px solid var(--sd-primary); }
html.dark .inbox-item.active { background: rgba(34,197,94,.12); }
.inbox-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .85rem; flex-shrink: 0;
}
.inbox-thread {
  display: flex; flex-direction: column; background: var(--sd-page-bg);
  overflow: hidden;
}
.inbox-messages {
  flex: 1; overflow-y: auto; padding: 1rem 1.5rem;
  display: flex; flex-direction: column; gap: .5rem;
}
.msg-bubble {
  max-width: 70%; padding: .6rem .85rem;
  border-radius: 14px; font-size: .9rem; line-height: 1.35;
  box-shadow: var(--sd-shadow-sm); position: relative;
}
.msg-bubble.in { background: var(--sd-card-bg); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg-bubble.out { background: #dcfce7; align-self: flex-end; border-bottom-right-radius: 4px; }
html.dark .msg-bubble.in { background: #1e293b; }
html.dark .msg-bubble.out { background: #14532d; color: #f0fdf4; }
.msg-meta { font-size: .65rem; color: var(--sd-text-muted); margin-top: .15rem; }
.inbox-composer {
  border-top: 1px solid var(--sd-card-border); padding: .75rem 1.25rem;
  background: var(--sd-card-bg); display: flex; gap: .5rem; align-items: flex-end;
}
.inbox-composer textarea {
  flex: 1; resize: none; max-height: 120px;
}
.inbox-details {
  background: var(--sd-card-bg); border-left: 1px solid var(--sd-card-border);
  overflow-y: auto; padding: 1.25rem;
}
.inbox-details h4 { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--sd-text-muted); font-weight: 600; margin: 1rem 0 .35rem; }
.inbox-details h4:first-child { margin-top: 0; }

/* Mobile responsive */
@media (max-width: 768px) {
  .sd-sidebar { display: none; }
  .inbox-layout { grid-template-columns: 1fr; }
  .inbox-list, .inbox-details { display: none; }
}

/* Tooltips */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: .3rem .55rem;
  border-radius: 6px; font-size: .7rem; white-space: nowrap;
  pointer-events: none; z-index: 50;
}

/* Toast queue */
.toast {
  border-radius: 10px !important;
  box-shadow: var(--sd-shadow-md);
  animation: sd-toast-in .2s ease-out;
}
@keyframes sd-toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Progress bar */
.sd-progress { height: 6px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
html.dark .sd-progress { background: #334155; }
.sd-progress > div { height: 100%; background: linear-gradient(90deg, #22c55e, #16a34a); transition: width .3s; }

/* Auth screens — premium */
.sd-auth-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, #f0fdf4 0%, #e0f2fe 100%);
}
html.dark .sd-auth-bg {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
}
.sd-auth-card {
  background: var(--sd-card-bg); border-radius: 16px;
  box-shadow: var(--sd-shadow-lg); padding: 2.25rem;
  max-width: 420px; width: 100%;
}

/* Utilities */
.sd-truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sd-divider { height: 1px; background: var(--sd-card-border); margin: 1rem 0; }
.sd-focus-ring:focus-visible { outline: 2px solid var(--sd-primary); outline-offset: 2px; }
.sd-spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid currentColor;
  border-right-color: transparent; border-radius: 50%; animation: sd-spin .65s linear infinite; }
@keyframes sd-spin { to { transform: rotate(360deg); } }

/* Print friendly */
@media print {
  .sd-sidebar, .sd-topbar, .no-print { display: none !important; }
}

