/* ============================================
   AIWorkshop Components v1
   Inspired by shadcn/ui · Linear · Vercel
   Beautiful, accessible, consistent.
   ============================================ */

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
  --btn-bg: var(--surface-alt);
  --btn-text: var(--text);
  --btn-border: var(--border);
  --btn-shadow: none;
  --btn-hover-bg: var(--surface-hover);
  --btn-hover-border: rgba(0,0,0,0.08);

  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; font-size: 13px; font-weight: 500; font-family: inherit;
  line-height: 1.5; white-space: nowrap; user-select: none;
  color: var(--btn-text); background: var(--btn-bg);
  border: 1px solid var(--btn-border); border-radius: 8px;
  cursor: pointer; transition: all 0.15s ease;
  box-shadow: var(--btn-shadow);
}
.btn:hover {
  background: var(--btn-hover-bg);
  border-color: var(--btn-hover-border);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* Primary */
.btn-primary {
  --btn-bg: #6366f1;
  --btn-text: #fff;
  --btn-border: transparent;
  --btn-shadow: 0 1px 3px rgba(0,0,0,0.2), 0 0 0 1px rgba(99,102,241,0.3);
  --btn-hover-bg: #5558e6;
  --btn-hover-border: transparent;
}
.btn-primary:hover {
  --btn-shadow: 0 2px 8px rgba(99,102,241,0.35), 0 0 0 1px rgba(99,102,241,0.4);
}

/* Accent */
.btn-accent {
  --btn-bg: #f59e0b;
  --btn-text: #0a0e17;
  --btn-border: transparent;
  --btn-shadow: 0 1px 3px rgba(0,0,0,0.2);
  --btn-hover-bg: #e5900a;
  --btn-hover-border: transparent;
}

/* Danger */
.btn-danger {
  --btn-bg: rgba(244,63,94,0.12);
  --btn-text: #f43f5e;
  --btn-border: rgba(244,63,94,0.2);
  --btn-hover-bg: rgba(244,63,94,0.2);
  --btn-hover-border: rgba(244,63,94,0.35);
}

/* Ghost */
.btn-ghost {
  --btn-bg: transparent;
  --btn-text: var(--text2);
  --btn-border: transparent;
  --btn-hover-bg: var(--surface-alt);
  --btn-hover-border: transparent;
}

/* Outline */
.btn-outline {
  --btn-bg: transparent;
  --btn-text: var(--text2);
  --btn-border: var(--border);
  --btn-hover-bg: var(--surface-alt);
  --btn-hover-border: rgba(255,255,255,0.15);
  --btn-hover-text: var(--text);
}

/* Sizes */
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-lg { padding: 12px 24px; font-size: 15px; border-radius: 10px; }
.btn-xl { padding: 14px 32px; font-size: 16px; border-radius: 12px; }
.btn-icon { padding: 8px; min-width: 36px; }

/* ================================================================
   INPUTS
   ================================================================ */
.input {
  width: 100%; padding: 10px 14px; font-size: 14px; font-family: inherit;
  color: var(--text); background: var(--surface-alt);
  border: 1px solid var(--border); border-radius: 8px;
  transition: all 0.15s ease; outline: none;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.input:hover { border-color: rgba(0,0,0,0.12); }
.input:focus { 
  border-color: #6366f1; 
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12), 0 1px 2px rgba(0,0,0,0.04);
}
.input::placeholder { color: var(--text3); }
.input:disabled { opacity: 0.5; cursor: not-allowed; }

.input-sm { padding: 6px 10px; font-size: 13px; border-radius: 6px; }
.input-lg { padding: 14px 18px; font-size: 16px; border-radius: 10px; }

textarea.input {
  min-height: 100px; resize: vertical;
  font-family: 'SF Mono','JetBrains Mono','Fira Code',monospace;
  line-height: 1.6;
}

select.input {
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 36px;
}

/* Label */
label, .label {
  display: block; font-size: 13px; font-weight: 500; color: var(--text);
  margin-bottom: 6px;
}
.label-sm { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; }

/* Form group */
.form-group { margin-bottom: 18px; }
.form-hint { display: block; font-size: 12px; color: var(--text3); margin-top: 4px; }
.form-error { display: block; font-size: 12px; color: var(--err); margin-top: 4px; }

/* Checkbox / Radio */
.checkbox-wrap { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checkbox-wrap input[type="checkbox"],
.checkbox-wrap input[type="radio"] {
  width: 16px; height: 16px; accent-color: #6366f1; cursor: pointer;
}
.checkbox-wrap span { font-size: 14px; color: var(--text2); }

/* ================================================================
   CARDS
   ================================================================ */
.card {
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.card:hover {
  border-color: rgba(255,255,255,0.1);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; color: var(--text); }
.card-desc { font-size: 13px; color: var(--text3); margin-top: 2px; }

/* Glass card */
.card-glass {
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 16px; padding: 24px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.05), inset 0 1px 0 rgba(255,255,255,0.5);
}

/* ================================================================
   BADGES
   ================================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; font-size: 12px; font-weight: 500;
  border-radius: 9999px; white-space: nowrap;
}
.badge-default { background: var(--surface-alt); color: var(--text2); border: 1px solid var(--border); }
.badge-brand   { background: rgba(99,102,241,0.12); color: #818cf8; border: 1px solid rgba(99,102,241,0.2); }
.badge-accent  { background: rgba(245,158,11,0.12); color: #fbbf24; border: 1px solid rgba(245,158,11,0.2); }
.badge-success { background: rgba(16,185,129,0.12); color: #34d399; border: 1px solid rgba(16,185,129,0.2); }
.badge-danger  { background: rgba(244,63,94,0.12); color: #fb7185; border: 1px solid rgba(244,63,94,0.2); }

/* ================================================================
   NAV
   ================================================================ */
.navbar {
  position: sticky; top: 0; z-index: 200;
  height: 52px; display: flex; align-items: center;
  background: rgba(248,249,251,0.88);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  contain:layout style;
}
.navbar-inner {
  width: 100%; max-width: 1400px; margin: 0 auto;
  padding: 0 20px; display: flex; align-items: center; gap: 8px;
}
.navbar-brand {
  font-size: 15px; font-weight: 700; color: var(--text); line-height:1.2;
  text-decoration: none; display: flex; align-items: center; gap: 8px;
  margin-right: 8px; white-space:nowrap; flex-shrink:0;
}
.navbar-brand em { color: var(--accent); font-style: normal; }
.navbar-links { display: flex; align-items: center; gap: 2px; margin-left: auto; }

.nav-link {
  font-size: 13px; font-weight: 500; color: var(--text2); line-height:1.2;
  text-decoration: none; padding: 6px 12px; border-radius: 6px;
  transition: all 0.12s ease; white-space:nowrap; flex-shrink:0;
}
.nav-link:hover { color: var(--text); background: rgba(0,0,0,0.04); }
.nav-link.active { color: var(--text); background: rgba(0,0,0,0.06); }

.nav-user {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; font-size: 13px; font-weight: 500;
  color: var(--text); background: var(--surface-alt);
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
  transition: all 0.12s ease;
}
.nav-user:hover { background: var(--surface-hover); border-color: rgba(0,0,0,0.1); }

.nav-user-avatar {
  width: 24px; height: 24px; border-radius: 6px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #fff; font-weight: 600;
}

.nav-dropdown { position: relative; }
.nav-dropdown-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 170px; background: var(--bg-card);
  border: 1px solid rgba(0,0,0,0.06); border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1); overflow: hidden; z-index: 220;
}
.nav-dropdown-menu.show { display: block; }
.nav-dropdown-menu a {
  display: block; padding: 10px 16px; font-size: 13px; color: var(--text2);
  text-decoration: none; transition: all 0.1s ease;
}
.nav-dropdown-menu a:hover { color: var(--text); background: rgba(0,0,0,0.03); }

.nav-toggle { display: none; }
@media (max-width: 768px) {
  .nav-toggle {
    display: flex; flex-direction: column; gap: 4px;
    background: none; border: none; padding: 8px; cursor: pointer; margin-left: auto;
  }
  .nav-toggle span { width: 20px; height: 2px; background: var(--text2); border-radius: 1px; }
  .navbar-links { display: none; }
  .navbar.open .navbar-links {
    display: flex; flex-direction: column; position: absolute; top: 52px; left: 0; right: 0;
    background: var(--bg-card); border-bottom: 1px solid var(--border); padding: 8px;
    box-shadow: var(--shadow-lg); gap: 2px;
  }
}

/* ================================================================
   TABLE
   ================================================================ */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border); }
.table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.table thead { border-bottom: 1px solid var(--border); }
.table th {
  text-align: left; padding: 10px 14px; font-size: 11px; font-weight: 600;
  color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--surface); white-space: nowrap;
}
.table td {
  padding: 10px 14px; border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--text); vertical-align: middle;
}
.table tbody tr:hover td { background: rgba(0,0,0,0.02); }
.table tbody tr:last-child td { border-bottom: none; }

.table input[type="text"],
.table input[type="number"],
.table select {
  padding: 5px 8px; font-size: 12px; font-family: inherit;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 5px; color: var(--text); transition: border-color 0.15s;
}
.table input:focus, .table select:focus {
  outline: none; border-color: #6366f1;
}

/* ================================================================
   STAT CARD
   ================================================================ */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.stat-card {
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: 10px; padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text3); margin-top: 4px; }

/* ================================================================
   LINK GRID
   ================================================================ */
.link-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px;
}
.link-card {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; font-weight: 500;
  color: var(--text2); text-decoration: none;
  transition: all 0.12s ease;
}
.link-card:hover {
  color: var(--text); border-color: rgba(0,0,0,0.1);
  background: var(--surface-hover); box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* ================================================================
   TOAST
   ================================================================ */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  padding: 12px 20px; border-radius: 10px; font-size: 13px; font-weight: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  animation: toastIn 0.25s ease;
}
.toast-success { background: #059669; color: #fff; }
.toast-error { background: #dc2626; color: #fff; }
.toast-info { background: #4f46e5; color: #fff; }
@keyframes toastIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

/* ================================================================
   MODAL (simple)
   ================================================================ */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-content {
  background: var(--bg-card); border: 1px solid rgba(0,0,0,0.06);
  border-radius: 16px; padding: 24px; width: 90%; max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.12);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn { from{opacity:0;transform:scale(0.96)} to{opacity:1;transform:scale(1)} }
.modal-header { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 16px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ================================================================
   SEARCH BAR
   ================================================================ */
.search-bar {
  display: flex; gap: 8px; margin-bottom: 14px;
}
.search-bar .input { flex: 1; }

/* ================================================================
   PAGINATION
   ================================================================ */
.pagination {
  display: flex; gap: 4px; justify-content: center; margin-top: 16px;
}
.pagination a { text-decoration: none; }
.pagination button {
  padding: 6px 12px; font-size: 12px; font-weight: 500;
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text2); cursor: pointer; transition: all 0.12s;
}
.pagination button:hover { background: var(--surface-hover); color: var(--text); }
.pagination button.active { background: #6366f1; color: #fff; border-color: #6366f1; }

/* ================================================================
   UTILITY
   ================================================================ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-xs { gap: 4px; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-dim { color: var(--text2); }
.text-muted { color: var(--text3); }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
