/* Dashboard V2 - design system layer on top of Tailwind (CDN) utilities. */

:root {
  --nc-bg: #f4f6fb;
  --nc-surface: #ffffff;
  --nc-border: #e5e9f2;
  --nc-text: #1f2430;
  --nc-text-muted: #6b7280;
  --nc-brand: #4f46e5;
  --nc-brand-hover: #4338ca;
  --nc-danger: #dc2626;
  --nc-danger-hover: #b91c1c;
  --nc-success: #16a34a;
  --nc-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --nc-shadow-lg: 0 10px 30px rgba(16, 24, 40, 0.14);
  --nc-radius: 14px;
}

.dark {
  --nc-bg: #10121a;
  --nc-surface: #181b26;
  --nc-border: #2a2e3d;
  --nc-text: #edf0f7;
  --nc-text-muted: #9aa1b3;
  --nc-brand: #818cf8;
  --nc-brand-hover: #a5b4fc;
  --nc-danger: #f87171;
  --nc-danger-hover: #fca5a5;
  --nc-success: #4ade80;
  --nc-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --nc-shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { scrollbar-width: thin; scrollbar-color: var(--nc-border) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--nc-border); border-radius: 8px; }

html, body {
  background: var(--nc-bg);
  color: var(--nc-text);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
}

a { color: inherit; }

/* --- Layout shell --- */
.nc-sidebar {
  background: var(--nc-surface);
  border-right: 1px solid var(--nc-border);
  transition: transform 0.25s ease;
}

@media (max-width: 1023px) {
  .nc-sidebar {
    position: fixed;
    inset: 0 25% 0 0;
    z-index: 50;
    transform: translateX(-100%);
  }
  .nc-sidebar.nc-sidebar-open { transform: translateX(0); }
}

.nc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 26, 0.5);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.nc-overlay.nc-overlay-show { opacity: 1; pointer-events: auto; }

.nc-nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.9rem;
  border-radius: 10px;
  color: var(--nc-text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.nc-nav-link:hover { background: var(--nc-bg); color: var(--nc-text); }
.nc-nav-link.nc-nav-link-active { background: var(--nc-brand); color: white; }

.nc-topbar {
  background: var(--nc-surface);
  border-bottom: 1px solid var(--nc-border);
}

.nc-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  background: var(--nc-surface);
  border: 1px solid var(--nc-border);
  border-radius: 12px;
  box-shadow: var(--nc-shadow-lg);
  padding: 0.4rem;
  display: none;
}
.nc-dropdown.nc-dropdown-show { display: block; }

/* --- Cards / surfaces --- */
.nc-card {
  background: var(--nc-surface);
  border: 1px solid var(--nc-border);
  border-radius: var(--nc-radius);
  box-shadow: var(--nc-shadow);
}

.nc-input {
  width: 100%;
  border: 1px solid var(--nc-border);
  background: var(--nc-bg);
  color: var(--nc-text);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.nc-input:focus {
  outline: none;
  border-color: var(--nc-brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
.nc-input:read-only { opacity: 0.6; }

.nc-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--nc-text-muted);
  margin-bottom: 0.3rem;
  display: block;
}

.nc-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.nc-btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.nc-btn-primary { background: var(--nc-brand); color: white; }
.nc-btn-primary:hover { background: var(--nc-brand-hover); }
.nc-btn-danger { background: var(--nc-danger); color: white; }
.nc-btn-danger:hover { background: var(--nc-danger-hover); }
.nc-btn-ghost { background: transparent; color: var(--nc-text); border-color: var(--nc-border); }
.nc-btn-ghost:hover { background: var(--nc-bg); }

.nc-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--nc-text-muted);
  border: 1px solid var(--nc-border);
}
.nc-icon-btn:hover { background: var(--nc-bg); color: var(--nc-text); }
.nc-icon-btn-danger:hover { color: var(--nc-danger); border-color: var(--nc-danger); }

/* --- Table / responsive list --- */
.nc-table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
.nc-table thead th {
  text-align: left;
  font-weight: 600;
  color: var(--nc-text-muted);
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--nc-border);
  white-space: nowrap;
}
.nc-table thead th.nc-sortable { cursor: pointer; user-select: none; }
.nc-table thead th.nc-sortable:hover { color: var(--nc-text); }
.nc-table tbody td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--nc-border);
}
.nc-table tbody tr:hover { background: var(--nc-bg); cursor: pointer; }
.nc-table-actions { white-space: nowrap; width: 1%; }

.nc-card-list { display: flex; flex-direction: column; gap: 0.75rem; padding: 0.75rem; }
.nc-row-card {
  border: 1px solid var(--nc-border);
  border-radius: 12px;
  padding: 0.85rem;
  background: var(--nc-bg);
}
.nc-row-card-field { display: flex; justify-content: space-between; gap: 1rem; padding: 0.15rem 0; font-size: 0.85rem; }
.nc-row-card-label { color: var(--nc-text-muted); font-weight: 600; }
.nc-row-card-value { text-align: right; word-break: break-word; }
.nc-row-card-actions { display: flex; gap: 0.5rem; margin-top: 0.6rem; }

.nc-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--nc-text-muted);
  font-size: 0.9rem;
}

/* --- Toasts --- */
.nc-toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.nc-toast {
  min-width: 220px;
  max-width: 340px;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  color: white;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--nc-shadow-lg);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.nc-toast-show { opacity: 1; transform: translateY(0); }
.nc-toast-success { background: var(--nc-success); }
.nc-toast-error { background: var(--nc-danger); }
.nc-toast-info { background: var(--nc-brand); }

/* --- Checkbox / toggle --- */
.nc-checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0;
}
.nc-checkbox {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--nc-brand);
  cursor: pointer;
}

/* --- Attachments --- */
.nc-attach-wrapper {
  position: relative;
  display: inline-flex;
  margin: 2px;
}
.nc-attach-wrapper img {
  display: block;
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--nc-border);
}
.nc-attach-file-link {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--nc-border);
  border-radius: 8px;
  font-size: 0.8rem;
  background: var(--nc-bg);
}
.nc-attach-delete {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--nc-danger);
  color: white;
  border: none;
  font-size: 11px;
  line-height: 20px;
  cursor: pointer;
}

/* --- Grid editor (sub-tables on the edit form) --- */
.nc-grid-editor-row-form {
  border: 1px dashed var(--nc-border);
  border-radius: 12px;
  padding: 1rem;
  background: var(--nc-bg);
  margin-top: 0.75rem;
}

/* --- Modal / confirm dialog --- */
.nc-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 26, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.15s ease;
  padding: 1rem;
}
.nc-modal-overlay.nc-modal-show { opacity: 1; }
.nc-modal {
  background: var(--nc-surface);
  border-radius: var(--nc-radius);
  box-shadow: var(--nc-shadow-lg);
  padding: 1.5rem;
  width: 100%;
  max-width: 380px;
  transform: scale(0.96);
  transition: transform 0.15s ease;
}
.nc-modal-overlay.nc-modal-show .nc-modal { transform: scale(1); }
.nc-modal-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.4rem; }
.nc-modal-message { font-size: 0.88rem; color: var(--nc-text-muted); }
.nc-modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.25rem; }

/* --- Trees (self-referencing nested grids) --- */
.nc-tree-container { border: 1px solid var(--nc-border); border-radius: 12px; padding: 0.75rem; background: var(--nc-bg); min-height: 200px; max-height: 420px; overflow-y: auto; }
.nc-tree-node { display: flex; align-items: center; gap: 0.35rem; margin: 2px 0; padding: 4px 6px; border-radius: 8px; cursor: pointer; font-size: 0.85rem; }
.nc-tree-node:hover { background: var(--nc-surface); }
.nc-tree-node.selected { background: var(--nc-brand); color: white; }
.nc-tree-toggle { width: 16px; text-align: center; font-weight: 700; color: var(--nc-text-muted); }
.nc-tree-node.selected .nc-tree-toggle { color: white; }
