/* ===========================
   Reusable Components
   =========================== */

/* --- Cards --- */

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.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);
}

/* --- Buttons --- */

.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background var(--transition), color var(--transition), border-color var(--transition), opacity var(--transition);
  line-height: 1.4;
  white-space: nowrap;
  font-family: inherit;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #5b4bd5;
}

.btn-danger {
  background: var(--red);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #c9604a;
}

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

.btn-success:hover:not(:disabled) {
  background: #009d7e;
}

.btn-outline {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
}

.btn-outline:hover:not(:disabled) {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--border-light);
}

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text2);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

/* --- Forms --- */

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}

.form-control:focus {
  border-color: var(--accent);
}

.form-control::placeholder {
  color: var(--text3);
}

select.form-control {
  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='%238b90a0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

select.form-control option {
  background: var(--bg2);
  color: var(--text);
}

textarea.form-control {
  min-height: 100px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
}

/* --- Tables --- */

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text2);
  font-weight: 600;
  letter-spacing: 0.5px;
}

td {
  font-size: 13px;
}

tr:hover td {
  background: var(--bg3);
}

/* --- Status Badges --- */

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.status-running {
  background: var(--green-dim);
  color: var(--green);
}

.status-completed {
  background: var(--blue-dim);
  color: var(--blue);
}

.status-failed {
  background: var(--red-dim);
  color: var(--red);
}

.status-stopped {
  background: var(--orange-dim);
  color: var(--orange);
}

.status-queued {
  background: var(--accent-dim);
  color: var(--accent2);
}

/* --- File List --- */

.file-list {
  list-style: none;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  font-size: 13px;
}

.file-item:hover {
  background: var(--bg3);
}

/* --- Agents Grid --- */

.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.agent-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
}

.agent-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.agent-card-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.agent-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

.agent-stats {
  display: flex;
  gap: 20px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.stat {
  font-size: 12px;
  color: var(--text2);
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

/* --- Tabs --- */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: 10px 18px;
  cursor: pointer;
  color: var(--text2);
  font-size: 14px;
  font-weight: 500;
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
  font-family: inherit;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--accent2);
  border-bottom-color: var(--accent);
}

/* --- Drop Zone --- */

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  color: var(--text2);
  transition: border-color var(--transition), background var(--transition);
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(108, 92, 231, 0.05);
}

/* --- Empty State --- */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text2);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state h3 {
  margin-bottom: 8px;
  color: var(--text);
}

.empty-state p {
  font-size: 14px;
  max-width: 400px;
  margin: 0 auto;
  line-height: 1.6;
}

/* --- Tags --- */

.tag {
  display: inline-block;
  background: var(--bg3);
  color: var(--text2);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

/* --- Divider --- */

.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* --- Skeleton Loading --- */

.skeleton {
  background: var(--bg3);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.04), transparent);
  animation: shimmer 1.5s infinite;
}

/* --- Context Menu --- */

.context-menu {
  position: absolute;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 100;
  min-width: 180px;
  padding: 4px 0;
}

.context-menu-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  transition: background var(--transition);
}

.context-menu-item:hover {
  background: var(--bg3);
}

.context-menu-item.danger {
  color: var(--red);
}

.context-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* --- Custom Checkbox --- */

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text2);
  user-select: none;
}

.checkbox input[type="checkbox"] {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  cursor: pointer;
  position: relative;
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

.checkbox input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 5px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox input[type="checkbox"]:focus {
  border-color: var(--accent);
}

/* --- Tooltip --- */

.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg4);
  color: var(--text);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 50;
}

.tooltip:hover::after {
  opacity: 1;
}
