/* ============================================================
   AstroDesk — Component styles
   ============================================================ */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: 1px solid transparent; border-radius: var(--r-md);
  font-weight: 600; font-size: 13.5px; line-height: 1; white-space: nowrap;
  padding: 0 15px; height: 38px; transition: all .16s var(--ease);
  user-select: none;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.btn-primary:hover { background: var(--accent-600); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-soft:hover { background: var(--accent-softer); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.card-pad { padding: var(--pad-card); }

/* ---------- Badges / chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: var(--r-pill);
  white-space: nowrap; line-height: 1.4;
}
.badge .dot { width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-gray { background: var(--surface-3); color: var(--text-muted); }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.field-label .req { color: var(--red); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 0 13px; height: 40px; font-size: 14px;
  color: var(--text); transition: border-color .15s, box-shadow .15s, background .15s;
}
.textarea { height: auto; padding: 11px 13px; resize: vertical; min-height: 84px; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-soft); background: var(--surface);
}
.select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239c98ad' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px;
}
.input-search {
  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='%239c98ad' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 13px center; padding-left: 38px;
}

/* ---------- Tables ---------- */
.tbl-wrap { width: 100%; overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl thead th {
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-faint); padding: 0 14px 11px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tbl tbody td { padding: 0 14px; height: var(--row-h); border-bottom: 1px solid var(--border);
  color: var(--text); vertical-align: middle; }
.tbl tbody tr { transition: background .12s; cursor: pointer; }
.tbl tbody tr:hover { background: var(--accent-softer); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-num); }

/* ---------- Avatar ---------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 99px; font-weight: 700; color: #fff; flex: none;
  font-family: var(--font-display); letter-spacing: .01em;
}

/* ---------- Modal ---------- */
.scrim {
  position: fixed; inset: 0; background: var(--scrim); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto; animation: fadeIn .18s var(--ease);
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg); width: 100%; margin: auto; animation: scaleIn .22s var(--ease);
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between;
  padding: 22px 24px 16px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 22px 24px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end;
  padding: 16px 24px; border-top: 1px solid var(--border); }

/* drawer / quick view */
.drawer-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 100;
  animation: fadeIn .18s var(--ease); backdrop-filter: blur(2px); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 94vw);
  background: var(--surface); border-left: 1px solid var(--border); z-index: 101;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  animation: drawerIn .26s var(--ease); }
@keyframes drawerIn { from { transform: translateX(100%);} to { transform: none; } }

/* ---------- Segmented ---------- */
.seg { display: inline-flex; background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 3px; gap: 2px; }
.seg button { border: none; background: transparent; color: var(--text-muted);
  font-weight: 600; font-size: 12.5px; padding: 6px 13px; border-radius: 7px;
  transition: all .15s var(--ease); white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
[data-theme="dark"] .seg button.on { background: var(--accent-soft); color: var(--accent); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tabs button { border: none; background: transparent; color: var(--text-muted);
  font-weight: 600; font-size: 14px; padding: 11px 4px; margin: 0 12px -1px 0;
  border-bottom: 2px solid transparent; transition: all .15s; }
.tabs button:first-child { margin-left: 2px; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs button:hover:not(.on) { color: var(--text); }

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--border); border: none; margin: 0; }
.kbd { font-family: var(--font-num); font-size: 11px; padding: 2px 6px; border-radius: 5px;
  background: var(--surface-3); border: 1px solid var(--border); color: var(--text-muted); }
.spark-row { display: flex; align-items: flex-end; gap: 3px; height: 38px; }
.spark-row i { flex: 1; background: var(--accent-soft); border-radius: 3px 3px 0 0; display: block; }
.spark-row i.hi { background: var(--accent); }

.empty { text-align: center; padding: 54px 20px; color: var(--text-faint); }
.empty svg { width: 38px; height: 38px; margin-bottom: 12px; opacity: .6; }

.tooltip-host { position: relative; }

.today-row { display: flex; align-items: center; gap: 11px; padding: 10px 22px; cursor: pointer; transition: background .12s; border-radius: 10px; }
.today-row:hover { background: var(--accent-softer); }

/* dynamic field builder row */
.field-builder-row { display: grid; grid-template-columns: 1.4fr 1fr 40px; gap: 10px; align-items: center; }
.detail-row { display: flex; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.detail-row:last-child { border-bottom: none; }
.detail-row .k { color: var(--text-muted); }
.detail-row .v { font-weight: 600; text-align: right; }

/* checkbox-styled todo */
.todo-check { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--border-strong); display: grid; place-items: center; flex: none; transition: all .15s; color: transparent; background: var(--surface); }
.todo-check[data-done] { background: var(--green); border-color: var(--green); color: #fff; }
.todo-row { display: flex; align-items: center; gap: 13px; padding: 13px 18px; border-bottom: 1px solid var(--border); transition: background .12s; }
.todo-row:hover { background: var(--surface-2); }
.todo-row:last-child { border-bottom: none; }

/* file/doc tile */
.doc-tile { display: flex; align-items: center; gap: 11px; padding: 12px 14px; border: 1px dashed var(--border-strong); border-radius: 11px; background: var(--surface-2); }

/* tiny stat */
.minikpi { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.minikpi .l { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); }
.minikpi .v { font-family: var(--font-display); font-weight: 700; font-size: 22px; margin-top: 7px; font-variant-numeric: tabular-nums; }
