/* ── BUTTONS ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-2); padding: 9px 18px; font-size: 14px; font-weight: 500;
  border: 1px solid transparent; border-radius: var(--r); cursor: pointer;
  transition: all var(--t); white-space: nowrap; text-decoration: none;
  line-height: 1;
}
.btn:disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn svg { flex-shrink: 0; }

.btn-primary   { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); box-shadow: 0 4px 12px var(--brand-glow); }

.btn-secondary { background: var(--gray-100); color: var(--text-primary); border-color: var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }

.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }

.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }

.btn-ghost  { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--gray-100); color: var(--text-primary); }

.btn-outline { background: transparent; color: var(--brand); border-color: var(--brand); }
.btn-outline:hover { background: var(--brand-light); }

.btn-sm  { padding: 6px 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn-lg  { padding: 12px 24px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; border-radius: var(--r); }

.btn-loader { display: none; }
.btn.loading .btn-text   { display: none; }
.btn.loading .btn-loader { display: inline-flex; }

/* ── FORMS ───────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.form-group:last-child { margin-bottom: 0; }

label { font-size: 13px; font-weight: 500; color: var(--text-primary); }

.input {
  width: 100%; padding: 9px 13px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r);
  color: var(--text-primary); transition: border-color var(--t), box-shadow var(--t);
  outline: none;
}
.input::placeholder { color: var(--text-muted); }
.input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--brand-glow); }
.input:disabled { background: var(--gray-100); cursor: not-allowed; }

textarea.input { resize: vertical; min-height: 100px; 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' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}

.input-group { position: relative; }
.input-group .input { padding-left: 38px; }
.input-group .input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }

.form-hint { font-size: 12px; color: var(--text-muted); }
.form-error { font-size: 12px; color: var(--danger); }

/* ── CARDS ───────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--border);
}
.card-header h3 { margin: 0; }
.card-body   { padding: var(--sp-6); }
.card-footer { padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* ── BADGES ──────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: var(--r-full);
  font-size: 11px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.badge-success { background: var(--success-bg); color: #065f46; }
.badge-warning { background: var(--warning-bg); color: #92400e; }
.badge-danger  { background: var(--danger-bg);  color: #991b1b; }
.badge-info    { background: var(--info-bg);    color: #1e40af; }
.badge-gray    { background: var(--gray-100);   color: var(--gray-600); }
.badge-brand   { background: var(--brand-light); color: var(--brand-dark); }

/* ── ALERTS ──────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r); font-size: 14px;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); color: #065f46; border-color: #a7f3d0; }
.alert-danger  { background: var(--danger-bg);  color: #991b1b; border-color: #fca5a5; }
.alert-warning { background: var(--warning-bg); color: #92400e; border-color: #fde68a; }
.alert-info    { background: var(--info-bg);    color: #1e40af; border-color: #bfdbfe; }

/* ── MODAL ───────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 1000;
  display: none; align-items: center; justify-content: center; padding: var(--sp-4);
}
.modal.open { display: flex; }
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.45);
  backdrop-filter: blur(3px); animation: fadeIn .2s ease;
}
.modal-box {
  position: relative; background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto; animation: fadeIn .2s ease;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.1rem; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 4px; border-radius: var(--r-sm); transition: all var(--t); }
.modal-close:hover { background: var(--gray-100); color: var(--text-primary); }
.modal-body   { padding: var(--sp-6); }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--sp-3); padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--border); }

/* ── TABLE ───────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 2px solid var(--border); }
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--t); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
th { padding: 10px 16px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); text-align: left; }
td { padding: 14px 16px; font-size: 14px; color: var(--text-primary); }

/* ── SPINNER ─────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px; border: 2px solid var(--border);
  border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite;
}
.spinner-lg { width: 36px; height: 36px; border-width: 3px; }

/* ── EMPTY STATE ─────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--sp-12) var(--sp-6); text-align: center; gap: var(--sp-3);
}
.empty-state svg { color: var(--gray-300); margin-bottom: var(--sp-2); }
.empty-state h3  { font-size: 1rem; color: var(--text-primary); }
.empty-state p   { font-size: 13px; color: var(--text-muted); max-width: 320px; }

/* ── SKELETON LOADER ─────────────────────────────── */
.skeleton { background: var(--gray-200); border-radius: var(--r); animation: pulse 1.5s ease infinite; }
.skeleton-text { height: 14px; width: 100%; }
.skeleton-title { height: 20px; width: 60%; }
.skeleton-circle { border-radius: 50%; }

/* ── DIVIDER ─────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: var(--sp-5) 0; }
.divider-text { display: flex; align-items: center; gap: var(--sp-3); color: var(--text-muted); font-size: 13px; }
.divider-text::before, .divider-text::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── TOOLTIP ─────────────────────────────────────── */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%); background: var(--gray-900); color: #fff;
  font-size: 12px; padding: 5px 10px; border-radius: var(--r-sm);
  white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity var(--t);
}
[data-tip]:hover::after { opacity: 1; }

/* ── TOGGLE ──────────────────────────────────────── */
.toggle { position: relative; display: inline-flex; align-items: center; cursor: pointer; gap: var(--sp-3); }
.toggle input { display: none; }
.toggle-track {
  width: 40px; height: 22px; background: var(--gray-300); border-radius: var(--r-full);
  transition: background var(--t); position: relative;
}
.toggle-thumb {
  position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  background: #fff; border-radius: 50%; transition: transform var(--t);
  box-shadow: var(--shadow-sm);
}
.toggle input:checked + .toggle-track { background: var(--brand); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(18px); }
.toggle-label { font-size: 14px; font-weight: 500; }

/* ── AVATAR ──────────────────────────────────────── */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--brand); color: #fff;
  font-weight: 600; flex-shrink: 0; font-size: 13px;
}
.avatar-sm  { width: 28px; height: 28px; font-size: 11px; }
.avatar-md  { width: 36px; height: 36px; }
.avatar-lg  { width: 48px; height: 48px; font-size: 16px; }

/* ── STAT CARD ───────────────────────────────────── */
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-5); box-shadow: var(--shadow-sm);
  display: flex; gap: var(--sp-4); align-items: flex-start;
  transition: box-shadow var(--t);
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-icon {
  width: 44px; height: 44px; border-radius: var(--r);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon-brand   { background: var(--brand-light); color: var(--brand); }
.stat-icon-success { background: var(--success-bg);  color: var(--success); }
.stat-icon-warning { background: var(--warning-bg);  color: var(--warning); }
.stat-icon-info    { background: var(--info-bg);     color: var(--info); }
.stat-label  { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.stat-value  { font-size: 26px; font-weight: 700; color: var(--text-primary); line-height: 1; margin-bottom: 4px; }
.stat-trend  { font-size: 12px; color: var(--text-muted); }
.stat-trend.up   { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ── DROPDOWN ────────────────────────────────────── */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 200;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-md); min-width: 180px; padding: var(--sp-2) 0;
  display: none; animation: fadeIn .15s ease;
}
.dropdown-menu.open { display: block; }
.dropdown-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 9px var(--sp-4); font-size: 14px; color: var(--text-primary);
  cursor: pointer; transition: background var(--t);
}
.dropdown-item:hover { background: var(--surface-2); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-divider { height: 1px; background: var(--border); margin: var(--sp-2) 0; }
