/* assets/css/main.css — Design System
   Traditional clean design — Arial system fonts, flat components
   ============================================================ */

/* ── DESIGN TOKENS ─────────────────────────────────────────── */
:root {
  /* Neutrals */
  --ink:     #1a1a1a;
  --ink-2:   #222;
  --ink-3:   #333;
  --ink-4:   #444;
  --muted:   #666;
  --subtle:  #999;

  /* Surfaces */
  --surface:   #f4f5f6;
  --surface-2: #e8e9eb;
  --surface-3: #d8dadd;
  --white:     #ffffff;
  --border:    #d0d3d8;
  --border-2:  #a0a5ae;

  /* Accent — blue */
  --accent:    #1a56db;
  --accent-h:  #1448b5;
  --accent-d:  #0f3591;
  --accent-lt: #eef2ff;
  --accent-mid: #c7d7fd;

  /* Violet */
  --violet:    #6d28d9;
  --violet-lt: #f4f3ff;

  /* Semantic */
  --success:    #047857;
  --success-lt: #ecfdf5;
  --success-2:  #6ee7b7;
  --warning:    #b45309;
  --warning-lt: #fffbeb;
  --warning-2:  #fde68a;
  --danger:     #b91c1c;
  --danger-lt:  #fef2f2;
  --danger-2:   #fca5a5;
  --info:       #0369a1;
  --info-lt:    #f0f9ff;

  /* Status badge colours */
  --s-open:         #1a56db;
  --s-open-bg:      #e8effe;
  --s-working:      #047857;
  --s-working-bg:   #d1fae5;
  --s-hold:         #b45309;
  --s-hold-bg:      #fef3c7;
  --s-done:         #6d28d9;
  --s-done-bg:      #ede9fe;
  --s-closed:       #6b7280;
  --s-closed-bg:    #f3f4f6;
  --s-cancelled:    #b91c1c;
  --s-cancelled-bg: #fee2e2;

  /* Typography — traditional system font stack */
  --font-display: Arial, 'Helvetica Neue', Helvetica, sans-serif;
  --font-body:    Arial, 'Helvetica Neue', Helvetica, sans-serif;
  --font-mono:    'Courier New', Courier, monospace;

  /* Layout */
  --sidebar-w:     220px;
  --sidebar-w-col: 52px;
  --header-h:      52px;

  /* Radii — traditional, minimal rounding */
  --radius:      4px;
  --radius-lg:   6px;
  --radius-xl:   8px;
  --radius-sm:   3px;
  --radius-xs:   2px;
  --radius-full: 9999px;

  /* Shadows — very subtle */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.07);
  --shadow-sm: 0 1px 4px rgba(0,0,0,.1);
  --shadow-md: 0 2px 8px rgba(0,0,0,.12);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.14);
  --shadow-xl: 0 8px 28px rgba(0,0,0,.18);
  --shadow-accent:  0 2px 6px rgba(26,86,219,.22);
  --shadow-success: 0 2px 6px rgba(4,120,87,.22);

  /* Transitions */
  --t-fast: 100ms ease;
  --t-base: 160ms ease;
  --t-slow: 240ms ease;
}

/* ── RESET ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--surface);
  line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

/* ── TYPOGRAPHY ────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
}
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: .95rem; }

/* ── BUTTONS ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: .42rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  white-space: nowrap;
  text-decoration: none;
  outline: none;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-h);
}
.btn-primary:hover { background: var(--accent-h); text-decoration: none; }

.btn-secondary {
  background: var(--white);
  color: var(--ink-3);
  border-color: var(--border-2);
}
.btn-secondary:hover { background: var(--surface-2); text-decoration: none; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: #9b1616;
}
.btn-danger:hover { background: #9b1616; text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent-mid);
}
.btn-ghost:hover { background: var(--accent-lt); text-decoration: none; }

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: #035c41;
}
.btn-success:hover { background: #035c41; text-decoration: none; }

.btn-sm   { padding: .25rem .65rem; font-size: .8rem; }
.btn-lg   { padding: .6rem 1.4rem; font-size: 1rem; }
.btn-icon {
  padding: .3rem .4rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  line-height: 1;
}
.btn-icon:hover { background: var(--surface-2); color: var(--ink); }

/* ── FORMS ─────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.form-group label {
  font-size: .8rem;
  font-weight: 700;
  color: var(--ink-3);
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: .45rem .75rem;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: .875rem;
  color: var(--ink);
  background: var(--white);
  transition: border-color var(--t-fast);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.form-input:hover:not(:focus),
.form-select:hover:not(:focus),
.form-textarea:hover:not(:focus) { border-color: var(--accent); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(26,86,219,.12);
}
.form-input[readonly] { background: var(--surface); color: var(--muted); cursor: default; }
.form-textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23666' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .7rem center;
  padding-right: 2rem;
  cursor: pointer;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.form-divider { border: none; border-top: 1px solid var(--border); margin: 1.2rem 0; }
.form-section-title { font-size: .875rem; font-weight: 700; margin-bottom: .6rem; color: var(--ink-3); }

/* ── CARDS ─────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card-head {
  padding: .85rem 1.15rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  flex-wrap: wrap; gap: .5rem;
  background: var(--surface);
}
.card-head h3 { margin: 0; font-size: .95rem; }
.card-body { padding: 1.15rem; }

/* ── BADGES ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .18rem .5rem;
  border-radius: 3px;
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-open      { background: var(--s-open-bg);      color: var(--s-open);      }
.badge-working   { background: var(--s-working-bg);   color: var(--s-working);   }
.badge-hold      { background: var(--s-hold-bg);      color: var(--s-hold);      }
.badge-done      { background: var(--s-done-bg);      color: var(--s-done);      }
.badge-closed    { background: var(--s-closed-bg);    color: var(--s-closed);    }
.badge-cancelled { background: var(--s-cancelled-bg); color: var(--s-cancelled); }

/* ── ALERTS ────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  margin-bottom: .9rem;
  border-left: 3px solid;
  display: flex; align-items: flex-start; gap: .5rem;
}
.alert-error   { background: var(--danger-lt);  border-color: var(--danger);  color: #7f1d1d; }
.alert-success { background: var(--success-lt); border-color: var(--success); color: #064e3b; }
.alert-warning { background: var(--warning-lt); border-color: var(--warning); color: #78350f; }

/* ── SKELETON ──────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg,
    var(--surface-2) 0%, var(--surface-2) 30%,
    var(--surface-3) 50%,
    var(--surface-2) 70%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
  height: 100%;
  min-height: 60px;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── UTILITIES ─────────────────────────────────────────────── */
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.ml-1 { margin-left: .5rem; }
.text-muted   { color: var(--muted); font-size: .85rem; }
.text-center  { text-align: center; }
.flex         { display: flex; }
.items-center { align-items: center; }
.gap-1        { gap: .5rem; }
.gap-2        { gap: 1rem; }
.justify-between { justify-content: space-between; }

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--subtle);
}
.empty-state .empty-icon {
  font-size: 2rem;
  margin-bottom: .65rem;
  display: block;
}
.empty-state p { font-size: .875rem; line-height: 1.5; max-width: 280px; margin: 0 auto; }

/* ── TOAST ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.25rem; right: 1.25rem;
  z-index: 9999;
  display: flex; flex-direction: column; gap: .4rem;
  max-width: calc(100vw - 2.5rem);
}
.toast {
  padding: .65rem 1rem;
  border-radius: var(--radius);
  background: var(--ink-2);
  color: #fff;
  font-size: .85rem;
  border-left: 3px solid rgba(255,255,255,.3);
  box-shadow: var(--shadow-lg);
  animation: toastIn .2s ease forwards;
  min-width: 220px;
  max-width: min(360px, calc(100vw - 2.5rem));
  display: flex; align-items: flex-start; gap: .55rem;
  word-break: break-word;
  line-height: 1.45;
}
.toast > span:first-child { flex-shrink: 0; }
.toast.success { background: #064e3b; border-left-color: var(--success-2); }
.toast.error   { background: #7f1d1d; border-left-color: var(--danger-2); }
.toast.warning { background: #78350f; border-left-color: var(--warning-2); }
.toast.info    { background: #0c4a6e; border-left-color: #7dd3fc; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── MODAL ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--white);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex; flex-direction: column;
}
.modal-box.modal-lg { max-width: 820px; }

.modal-header {
  padding: .9rem 1.2rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; gap: .75rem;
  background: var(--surface);
}
.modal-title { font-size: 1rem; font-weight: 700; margin: 0; }
.modal-close {
  background: none; border: 1px solid transparent;
  font-size: .9rem; color: var(--muted);
  padding: .2rem .35rem; border-radius: var(--radius-xs);
  transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0; line-height: 1;
}
.modal-close:hover { background: var(--surface-2); color: var(--ink); border-color: var(--border); }
.modal-body   { padding: 1.2rem; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.modal-footer {
  padding: .75rem 1.2rem;
  border-top: 1px solid var(--border);
  display: flex; gap: .5rem; justify-content: flex-end;
  flex-shrink: 0; flex-wrap: wrap;
  background: var(--surface);
}

/* ── TABS ──────────────────────────────────────────────────── */
.tabs-bar {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs-bar::-webkit-scrollbar { display: none; }
.tab-btn {
  background: none; border: none;
  padding: .55rem 1rem;
  font-family: var(--font-body); font-size: .875rem; font-weight: 600;
  color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color var(--t-fast), border-color var(--t-fast);
  white-space: nowrap; flex-shrink: 0;
}
.tab-btn:hover  { color: var(--accent); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── DATA TABLE ────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th {
  background: var(--surface);
  padding: .6rem .85rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: .6rem .85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--ink-4);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #f0f4ff; }

.table-wrap {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-responsive { overflow-x: auto; }
.table-scroll-hint {
  display: none;
  font-size: .72rem; color: var(--subtle);
  text-align: center; padding: .3rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/* ── PAGINATION ────────────────────────────────────────────── */
.pagination-bar {
  display: flex; align-items: center; gap: .3rem;
  padding: .85rem 0; justify-content: center; flex-wrap: wrap;
}
.page-btn {
  min-width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--white); font-size: .82rem; font-weight: 600;
  color: var(--ink-3);
  transition: all var(--t-fast);
}
.page-btn:hover  { background: var(--surface-2); border-color: var(--border-2); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent-h); }

/* ── MULTI-ASSIGN CHECKBOXES ───────────────────────────────── */
.assign-cb-list {
  display: flex; flex-direction: column; gap: .25rem;
  max-height: 320px; overflow-y: auto;
}
.assign-cb-row {
  display: flex; align-items: center; gap: .65rem;
  padding: .5rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
  user-select: none;
}
.assign-cb-row:hover { background: var(--accent-lt); border-color: var(--accent-mid); }
.assign-cb-row:has(.assign-cb:checked) {
  background: var(--accent-lt);
  border-color: var(--accent);
}
.assign-cb-row input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: var(--accent); flex-shrink: 0;
}
.assign-cb-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
  border: 1px solid var(--border);
}
.assign-cb-name {
  font-size: .875rem; font-weight: 600; color: var(--ink);
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.assign-cb-role {
  font-size: .7rem; color: var(--muted);
  background: var(--surface-2); padding: .1rem .4rem;
  border-radius: var(--radius-full); white-space: nowrap; flex-shrink: 0;
}

/* ── SORTABLE TABLE HEADERS ─────────────────────────────────── */
.sortable-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.sortable-th:hover {
  background: var(--surface-2);
}
.sortable-th.sort-active {
  color: var(--accent);
}
.sort-neutral {
  opacity: .35;
  font-size: .8em;
}
.sort-dir-btn {
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── PAGINATION ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0 .25rem;
  gap: .75rem;
  flex-wrap: wrap;
}
.pagination-info {
  font-size: .825rem;
  color: var(--muted);
}
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.pagination-ellipsis {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 .35rem;
  color: var(--subtle);
  font-size: .85rem;
}

/* ── GLOBAL RESPONSIVE ─────────────────────────────────────── */
@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-box { border-radius: var(--radius) var(--radius) 0 0; max-height: 95vh; }
  .modal-body { padding: 1rem; }
  .modal-footer { padding: .65rem 1rem; }
  .card-body { padding: .9rem; }
}
