/* ========================================
   COMPONENTS.CSS - UI Components
   ======================================== */

/* Buttons (legacy + BEM alias) */
.btn,
.c-btn {
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-sm,
.c-btn--sm {
  height: 36px;
  padding: 0 12px;
  font-size: 0.85rem;
  border-radius: 10px;
}

.btn-primary,
.c-btn--primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover,
.c-btn--primary:hover {
  background: var(--accent-2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.btn-secondary,
.c-btn--secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover,
.c-btn--secondary:hover {
  background: var(--surface);
}

.iconbtn,
.c-icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s;
}

.iconbtn:hover,
.c-icon-btn:hover {
  background: var(--bg);
}

/* Cards (legacy + BEM alias) */
.card,
.c-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: var(--sp-4);
  box-shadow: var(--shadow-sm);
}

.card-header,
.c-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-3);
  gap: var(--sp-3);
}

.card-title,
.c-card__title {
  font-size: 1.125rem;
  font-weight: 600;
}

.card-actions,
.c-card__actions {
  display: flex;
  gap: var(--sp-2);
}

/* Stat Card (legacy + BEM alias) */
.stat-card,
.c-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: var(--sp-4);
  box-shadow: var(--shadow-sm);
}

.stat-header,
.c-stat-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-3);
}

.stat-title,
.c-stat-card__title {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
}

.stat-icon,
.c-stat-card__icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: white;
}

.stat-icon.blue,
.c-stat-card__icon--blue {
  background: var(--accent);
}

.stat-icon.green,
.c-stat-card__icon--green {
  background: var(--success);
}

.stat-icon.orange,
.c-stat-card__icon--orange {
  background: var(--warning);
}

.stat-icon.purple,
.c-stat-card__icon--purple {
  background: #8b5cf6;
}

.stat-value,
.c-stat-card__value {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: var(--sp-2);
}

.stat-change,
.c-stat-card__change {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: var(--success);
}

.stat-change.positive,
.c-stat-card__change--positive {
  color: var(--success);
}

/* Inputs (legacy + BEM alias) */
.input,
.c-input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--sp-2) var(--sp-3);
  font-size: 1rem;
  transition: all 0.2s;
}

.input:focus,
.c-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.input::placeholder,
.c-input::placeholder {
  color: var(--muted);
}

/* Select */
.sb-select {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
}

.sb-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Search (legacy + BEM alias) */
.search,
.c-search {
  position: relative;
  flex: 1;
  max-width: 400px;
}

.search input,
.c-search .c-input {
  width: 100%;
  padding-left: 32px;
}

.search i,
.c-search__icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

/* Dashboard widgets (legacy + BEM alias) */
.dashboard-grid,
.c-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}

.dashboard-widget,
.c-dashboard-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.widget-header,
.c-dashboard-widget__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-3);
  border-bottom: 1px solid var(--border);
}

.widget-title,
.c-dashboard-widget__title {
  font-weight: 600;
  font-size: 1rem;
}

.widget-action-btn,
.c-dashboard-widget__action {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.875rem;
  padding: 0;
}

.widget-action-btn:hover,
.c-dashboard-widget__action:hover {
  color: var(--accent);
}

.widget-body,
.c-dashboard-widget__body {
  padding: var(--sp-3);
}

/* Dirty-state indicator: pulsing accent border on unsaved button */
.btn.is-dirty {
  box-shadow: 0 0 0 2px var(--accent);
  animation: btn-dirty-pulse 2s ease-in-out infinite;
}

@keyframes btn-dirty-pulse {
  0%, 100% {
    box-shadow: 0 0 0 2px var(--accent);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.35);
  }
}
