@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --primary: #ff385c;
  --primary-active: #e00b41;
  --primary-disabled: #ffd1da;
  --primary-error-text: #c13515;
  --ink: #222222;
  --body: #3f3f3f;
  --muted: #6a6a6a;
  --muted-soft: #929292;
  --hairline: #dddddd;
  --hairline-soft: #ebebeb;
  --border-strong: #c1c1c1;
  --canvas: #ffffff;
  --surface-soft: #f7f7f7;
  --surface-card: #ffffff;
  --surface-strong: #f2f2f2;
  --on-primary: #ffffff;
  --on-dark: #ffffff;
  --scrim: rgba(0, 0, 0, 0.5);
  
  --rounded-xs: 4px;
  --rounded-sm: 8px;
  --rounded-md: 14px;
  --rounded-lg: 20px;
  --rounded-xl: 32px;
  --rounded-full: 9999px;
  
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-base: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-section: 64px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, system-ui, Roboto, 'Helvetica Neue', sans-serif;
  background-color: var(--canvas);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1128px;
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
  width: 100%;
}

/* Typography */
h1 { font-size: 28px; font-weight: 700; line-height: 1.43; letter-spacing: 0; color: var(--ink); }
h2 { font-size: 22px; font-weight: 500; line-height: 1.18; letter-spacing: -0.44px; color: var(--ink); margin-bottom: 1rem; }
h3 { font-size: 16px; font-weight: 600; line-height: 1.25; color: var(--ink); margin-bottom: 0.5rem; }
p { font-size: 16px; font-weight: 400; line-height: 1.5; color: var(--body); }
.text-muted { color: var(--muted); font-size: 14px; }
.caption { font-size: 14px; font-weight: 500; color: var(--ink); }

/* Navbar */
header {
  height: 80px;
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  background: var(--canvas);
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}

nav {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
}

nav a {
  color: var(--ink);
  text-decoration: none;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
  padding-bottom: 4px;
}

nav a:hover, nav a.active {
  color: var(--primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  padding: 14px 24px;
  height: 48px;
  border-radius: var(--rounded-sm);
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}

.btn-primary:hover {
  background: var(--primary-active);
}

.btn-secondary {
  background: var(--canvas);
  color: var(--ink);
  border: 1px solid var(--ink);
}

.btn-secondary:hover {
  background: var(--surface-soft);
}

.btn-danger {
  background: var(--canvas);
  color: var(--primary-error-text);
  border: 1px solid var(--primary-error-text);
}

.btn-danger:hover {
  background: #fef2f2;
}

.btn-sm {
  padding: 8px 16px;
  height: 36px;
  font-size: 14px;
}

/* Forms */
.form-group {
  margin-bottom: var(--spacing-lg);
}

.form-group label {
  display: block;
  margin-bottom: var(--spacing-sm);
  font-weight: 500;
  font-size: 14px;
  color: var(--ink);
}

.form-control, .form-select {
  width: 100%;
  padding: 14px 12px;
  background: var(--canvas);
  border: 1px solid var(--border-strong);
  border-radius: var(--rounded-sm);
  color: var(--ink);
  font-size: 16px;
  min-height: 56px;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-select {
  /* JS custom select will handle the visual dropdown */
}

.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--ink);
  border-width: 2px;
  padding: 13px 11px; /* adjust for border width */
}

.form-select:focus {
  padding-right: 39px; /* adjust for border width */
}

.form-text {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}

/* Card System */
.card {
  background: var(--canvas);
  border-radius: var(--rounded-md);
  border: 1px solid var(--hairline);
  padding: var(--spacing-lg);
  box-shadow: rgba(0, 0, 0, 0.02) 0 0 0 1px, rgba(0, 0, 0, 0.04) 0 2px 6px 0, rgba(0, 0, 0, 0.1) 0 4px 8px 0;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--spacing-lg);
}

/* Tables */
.table-container {
  border: 1px solid var(--hairline);
  border-radius: var(--rounded-md);
  /* removed overflow: hidden to allow dropdowns to pop out */
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid var(--hairline);
}

th {
  background: var(--surface-soft);
  font-size: 14px;
  font-weight: 600;
}

tr:last-child td {
  border-bottom: none;
}

/* Multi Select UI */
.user-tag {
  display: inline-flex;
  align-items: center;
  background: var(--surface-strong);
  padding: 4px 12px;
  border-radius: var(--rounded-full);
  font-size: 14px;
  margin: 4px;
  gap: 8px;
}

.user-tag img {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
}

.user-tag .remove {
  cursor: pointer;
  font-weight: bold;
  color: var(--muted);
}
.user-tag .remove:hover {
  color: var(--ink);
}

/* Utils */
.section { padding: var(--spacing-section) 0; }
.mb-1 { margin-bottom: var(--spacing-sm); }
.mb-2 { margin-bottom: var(--spacing-md); }
.mb-3 { margin-bottom: var(--spacing-base); }
.mb-4 { margin-bottom: var(--spacing-lg); }

.alert {
  padding: 16px;
  border-radius: var(--rounded-sm);
  margin-bottom: var(--spacing-lg);
  font-size: 14px;
  font-weight: 500;
}

.alert-success { background: #e0f2f1; color: #00695c; }
.alert-error { background: #fef2f2; color: var(--primary-error-text); }

/* User List Item */
.user-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--rounded-sm);
  margin-bottom: 8px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface-strong);
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--muted);
}

/* Modal UI */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--surface-card);
  border-radius: var(--rounded-md);
  padding: var(--spacing-lg);
  width: 90%;
  max-width: 400px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  transform: translateY(20px);
  transition: transform 0.2s ease;
}

.modal-backdrop.active .modal-card {
  transform: translateY(0);
}

.modal-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: var(--spacing-md);
}

.modal-body {
  font-size: 16px;
  color: var(--body);
  margin-bottom: var(--spacing-xl);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-md);
}
