/* DITS — refined design system
 * Aesthetic: clean SaaS, slate base + indigo brand accent, subtle layered
 * shadows, generous whitespace, crisp typography.
 */

:root {
  --bg-page:   #f4f8fc;     /* faint blue tint, matches PPN brand */
  --bg-card:   #ffffff;
  --bg-elev:   #f8fbff;
  --border-1:  rgba(15, 23, 42, 0.08);
  --border-2:  rgba(15, 23, 42, 0.06);
  --text-1:    #0f172a;
  --text-2:    #475569;
  --text-3:    #94a3b8;
  /* PPN brand — blue from logo body, green from logo flag */
  --brand:     #1a8cd8;     /* PPN primary blue */
  --brand-2:   #2aa9e0;     /* lighter blue */
  --brand-dark:#0c6ba8;     /* darker blue */
  --accent:    #22a85e;     /* PPN green flag */
  --accent-dark:#178148;
  --ring:      rgba(26, 140, 216, 0.22);
}

html, body { background: var(--bg-page); }
body {
  font-family: 'Noto Sans Lao', 'Inter', system-ui, sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  color: var(--text-1);
}

/* Subtle dotted mesh texture in the page background for depth */
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image:
    radial-gradient(circle at 0% 0%, rgba(26, 140, 216, 0.05), transparent 40%),
    radial-gradient(circle at 100% 0%, rgba(34, 168, 94, 0.04), transparent 40%);
  pointer-events: none;
  z-index: 0;
}
#app { position: relative; z-index: 1; }

/* ------- Animations ------- */
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { transform: scale(0.97); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

.toast-anim { animation: slideUp 0.2s ease-out; }
.dits-modal-backdrop { animation: fadeIn 0.15s ease-out; }
.dits-modal-card     { animation: scaleIn 0.18s cubic-bezier(0.2, 0.8, 0.2, 1); }

/* ------- Cards ------- */
.dits-card {
  background: var(--bg-card);
  border: 1px solid var(--border-1);
  border-radius: 14px;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.04), 0 1px 3px 0 rgb(0 0 0 / 0.04);
}
.dits-card-elev {
  background: var(--bg-card);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  box-shadow: 0 4px 12px -2px rgb(15 23 42 / 0.06), 0 2px 6px -1px rgb(15 23 42 / 0.04);
}

/* ------- Sidebar ------- */
.dits-sidebar {
  background: linear-gradient(180deg, #ffffff 0%, #fafbff 100%);
  border-right: 1px solid var(--border-1);
}
.dits-sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px;
  border-bottom: 1px solid var(--border-2);
}
.dits-sidebar-logo {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: white;
  border: 1px solid var(--border-1);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 2px 8px -2px rgba(26, 140, 216, 0.18);
}
.dits-sidebar-logo img { width: 100%; height: 100%; object-fit: contain; padding: 2px; }
/* Fallback if no image is present (CPU icon) */
.dits-sidebar-logo--fallback {
  background: linear-gradient(135deg, #1a8cd8 0%, #0c6ba8 60%, #22a85e 100%);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 14px -4px rgba(26, 140, 216, 0.45), inset 0 1px 0 rgba(255,255,255,0.2);
}
.dits-nav-item {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 13px; font-weight: 500;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.dits-nav-item:hover { background: rgba(26, 140, 216, 0.06); color: var(--text-1); }
.dits-nav-item.active {
  background: linear-gradient(180deg, #ffffff 0%, #ecf6fd 100%);
  color: var(--text-1);
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.04), inset 0 0 0 1px rgba(26, 140, 216, 0.16);
}
.dits-nav-item.active::before {
  content: ""; position: absolute;
  left: -11px; top: 8px; bottom: 8px; width: 3px;
  background: linear-gradient(180deg, #2aa9e0, #1a8cd8);
  border-radius: 0 2px 2px 0;
}

/* ------- Buttons (used by btn() helper via classes) ------- */
.dits-btn-primary {
  background: linear-gradient(180deg, #2aa9e0 0%, #1a8cd8 100%);
  color: white;
  box-shadow: 0 1px 2px rgba(12, 107, 168, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: all 0.15s;
}
.dits-btn-primary:hover { background: linear-gradient(180deg, #1a8cd8 0%, #0c6ba8 100%); box-shadow: 0 6px 14px -3px rgba(12, 107, 168, 0.40); }
.dits-btn-primary:active { transform: translateY(0.5px); }

.dits-btn-secondary {
  background: white;
  color: var(--text-1);
  border: 1px solid var(--border-1);
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.04);
  transition: all 0.15s;
}
.dits-btn-secondary:hover { background: #f8fafc; border-color: rgba(15, 23, 42, 0.12); }

.dits-btn-danger {
  background: linear-gradient(180deg, #f43f5e 0%, #e11d48 100%);
  color: white;
  box-shadow: 0 1px 2px rgba(225, 29, 72, 0.30), inset 0 1px 0 rgba(255,255,255,0.15);
}
.dits-btn-danger:hover { background: linear-gradient(180deg, #fb7185 0%, #f43f5e 100%); }

/* ------- Inputs ------- */
.dits-input,
input.dits-cb-search,
input.dits-dp-display,
.dits-select {
  background: white;
  border: 1px solid var(--border-1);
  border-radius: 9px;
  font-size: 13.5px;
  padding: 9px 12px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  box-shadow: var(--tw-shadow, 0 1px 1px rgba(15, 23, 42, 0.02));
}
.dits-input:focus,
input.dits-cb-search:focus,
input.dits-dp-display:focus,
.dits-select:focus {
  outline: none;
  border-color: rgba(26, 140, 216, 0.5);
  box-shadow: 0 0 0 3px var(--ring);
}
.dits-input::placeholder { color: #94a3b8; }

/* Native select arrow */
select.dits-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  appearance: none;
  padding-right: 2.4rem;
}

/* ------- Status pills with leading dot ------- */
.dits-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px 2px 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}
.dits-pill::before {
  content: ""; width: 6px; height: 6px; border-radius: 999px;
  display: inline-block;
}
.dits-pill-active  { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.dits-pill-active::before  { background: #10b981; box-shadow: 0 0 0 2px #d1fae5; }
.dits-pill-pending { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.dits-pill-pending::before { background: #f59e0b; box-shadow: 0 0 0 2px #fef3c7; }
.dits-pill-issue   { background: #fff1f2; color: #9f1239; border-color: #fecdd3; }
.dits-pill-issue::before   { background: #f43f5e; box-shadow: 0 0 0 2px #ffe4e6; }
.dits-pill-retired { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.dits-pill-retired::before { background: #64748b; box-shadow: 0 0 0 2px #e2e8f0; }

/* ------- Tables ------- */
.dits-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.dits-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: linear-gradient(180deg, #fafbff, #f4f6fb);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-1);
}
.dits-table tbody td {
  padding: 11px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-2);
  color: var(--text-1);
}
.dits-table tbody tr:hover td { background: rgba(26, 140, 216, 0.035); }
.dits-table tbody tr:last-child td { border-bottom: 0; }

/* ------- Stat card ------- */
.dits-stat {
  position: relative;
  background: white;
  border: 1px solid var(--border-1);
  border-radius: 14px;
  padding: 18px 18px 16px;
  overflow: hidden;
  transition: box-shadow 0.18s, transform 0.18s;
}
.dits-stat:hover { box-shadow: 0 8px 22px -8px rgb(15 23 42 / 0.10); transform: translateY(-1px); }
.dits-stat::after {
  content: ""; position: absolute; left: 0; top: 0; height: 3px; right: 0;
  background: linear-gradient(90deg, var(--accent, #4f46e5), transparent 60%);
  opacity: 0.7;
}

/* ------- Skeletons ------- */
.dits-skeleton {
  background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}

/* ------- Scrollbars ------- */
.scrollbar-thin::-webkit-scrollbar       { width: 8px; height: 8px; }
.scrollbar-thin::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; border: 2px solid var(--bg-page); }
.scrollbar-thin::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.scrollbar-thin::-webkit-scrollbar-track { background: transparent; }

/* ------- Misc utilities ------- */
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dits-backdrop  { background: rgba(15, 23, 42, 0.45); backdrop-filter: blur(6px); }

button:focus-visible, a:focus-visible, [role="button"]:focus-visible {
  outline: 2px solid rgba(26, 140, 216, 0.40);
  outline-offset: 2px;
  border-radius: 8px;
}

.dits-cb-chevron { transition: transform 0.18s ease; }

/* ------- Page header pattern (h2 + subtitle + actions) ------- */
.dits-page-header { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.dits-page-title  { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; color: var(--text-1); line-height: 1.15; }
.dits-page-sub    { font-size: 13px; color: var(--text-2); margin-top: 4px; }

/* ------- Status (legacy classes still used in JS) ------- */
.status-active  { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.status-pending { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.status-issue   { background: #fff1f2; color: #be123c; border-color: #fecdd3; }

/* ====================== MOBILE RESPONSIVE ====================== */
@media (max-width: 1023px) {
  /* Sidebar becomes off-canvas drawer */
  aside.dits-sidebar {
    position: fixed;
    inset-y: 0; top: 0; bottom: 0; left: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 6px 0 24px -4px rgba(15, 23, 42, 0.18);
  }
  aside.dits-sidebar.open { transform: translateX(0); }

  /* Main content needs top padding for the mobile header */
  main { padding-top: 56px; }

  /* Modal goes nearly full-screen on phones */
  .dits-modal-card {
    max-width: 100% !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    height: 100vh;
  }
  .fixed.inset-0.z-50.flex.items-center.justify-center.p-4.dits-backdrop {
    padding: 0;
  }
}

/* Mobile top bar (only visible <lg) */
.dits-mobile-bar {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  height: 56px;
  background: white;
  border-bottom: 1px solid var(--border-1);
  z-index: 30;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}
@media (max-width: 1023px) { .dits-mobile-bar { display: flex; } }

.dits-mobile-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  z-index: 40;
  animation: fadeIn 0.18s ease-out;
}
.dits-mobile-backdrop.open { display: block; }

/* Form grids: stack on small screens */
@media (max-width: 640px) {
  form.grid.grid-cols-2 { grid-template-columns: minmax(0, 1fr); }
  form .col-span-2      { grid-column: span 1 / span 1; }
}

/* Page padding scales down on small screens */
@media (max-width: 768px) {
  main > div { padding-left: 16px !important; padding-right: 16px !important; padding-top: 20px !important; padding-bottom: 20px !important; }
  .dits-page-title { font-size: 19px; }
}

/* ====================== POLISHED TOAST ====================== */
#toast-root { width: 100%; max-width: 360px; pointer-events: none; }
@media (max-width: 640px) {
  #toast-root { left: 16px; right: 16px; bottom: 16px; max-width: none; }
}
.dits-toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: white;
  border: 1px solid var(--border-1);
  box-shadow: 0 12px 28px -8px rgba(15, 23, 42, 0.18), 0 4px 10px -4px rgba(15, 23, 42, 0.10);
  animation: slideUp 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.dits-toast-icon {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.dits-toast-success .dits-toast-icon { background: #d1fae5; color: #047857; box-shadow: 0 0 0 2px #ecfdf5; }
.dits-toast-error   .dits-toast-icon { background: #fee2e2; color: #b91c1c; box-shadow: 0 0 0 2px #fef2f2; }
.dits-toast-info    .dits-toast-icon { background: #dbeafe; color: #0c6ba8; box-shadow: 0 0 0 2px #ecf6fd; }
.dits-toast-msg     { flex: 1; font-size: 13px; color: var(--text-1); line-height: 1.45; padding-top: 4px; }
.dits-toast-close   { padding: 4px; border-radius: 6px; color: var(--text-3); }
.dits-toast-close:hover { background: #f1f5f9; color: var(--text-1); }

/* Login screen card mobile padding */
@media (max-width: 480px) {
  .dits-modal-card { width: 100% !important; }
}
