/* ===========================
   Component Styles
   =========================== */

/* === Cards === */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--color-border-light);
  transition: all var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card--gradient {
  background: var(--gradient-card);
}

/* === Stat Cards === */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--color-border-light);
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-card__icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-card__icon--blue { background: rgba(74, 123, 247, 0.1); }
.stat-card__icon--purple { background: rgba(124, 91, 240, 0.1); }
.stat-card__icon--green { background: rgba(16, 185, 129, 0.1); }
.stat-card__icon--orange { background: rgba(245, 158, 11, 0.1); }

.stat-card__content {
  flex: 1;
  min-width: 0;
}

.stat-card__label {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xs);
  font-weight: 500;
}

.stat-card__value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

.stat-card__value--success { color: var(--color-success); }
.stat-card__value--warning { color: var(--color-warning); }
.stat-card__value--danger { color: var(--color-danger); }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: var(--font-size-sm);
  transition: all var(--transition-fast);
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn--primary {
  background: var(--gradient-button);
  color: white;
  box-shadow: 0 4px 15px rgba(74, 123, 247, 0.25);
}

.btn--primary:hover {
  background: var(--gradient-button-hover);
  box-shadow: 0 6px 20px rgba(74, 123, 247, 0.35);
  transform: translateY(-1px);
}

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

.btn--secondary:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-primary-light);
  color: var(--color-primary);
}

.btn--danger {
  background: var(--gradient-danger);
  color: white;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.25);
}

.btn--danger:hover {
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35);
  transform: translateY(-1px);
}

.btn--success {
  background: var(--gradient-success);
  color: white;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.25);
}

.btn--success:hover {
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
  transform: translateY(-1px);
}

.btn--sm {
  padding: 6px 14px;
  font-size: var(--font-size-xs);
}

.btn--lg {
  padding: 14px 32px;
  font-size: var(--font-size-md);
}

.btn--icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
}

.btn--icon.btn--sm {
  width: 28px;
  height: 28px;
}

/* === Forms === */
.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

.form-label span {
  color: var(--color-danger);
  margin-left: 2px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--font-size-md);
  transition: all var(--transition-fast);
}

.form-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(74, 123, 247, 0.1);
}

.form-input::placeholder {
  color: var(--color-text-muted);
}

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748B' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

textarea.form-input {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

/* === Table === */
.table-wrapper {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--color-border-light);
  overflow: hidden;
}

.table-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.table-header__title {
  font-size: var(--font-size-lg);
  font-weight: 700;
}

.table-header__actions {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.table-scroll {
  overflow-x: auto;
}

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

.table th {
  padding: 12px 16px;
  text-align: left;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border-light);
  white-space: nowrap;
}

.table td {
  padding: 14px 16px;
  font-size: var(--font-size-sm);
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover td {
  background: var(--color-surface-hover);
}

.table__amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.table__actions {
  display: flex;
  gap: var(--space-xs);
}

.table-empty {
  padding: var(--space-3xl);
  text-align: center;
  color: var(--color-text-muted);
}

.table-empty__icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.table-empty__text {
  font-size: var(--font-size-md);
  font-weight: 500;
}

.table-empty__sub {
  font-size: var(--font-size-sm);
  margin-top: var(--space-xs);
}

/* === Badge === */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2.5px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge--blue, .badge--info { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.badge--purple { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.badge--green, .badge--success { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.badge--orange, .badge--warning { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.badge--red, .badge--danger { background: #fff1f2; color: #be123c; border-color: #fecdd3; }
.badge--gray { background: #f8fafc; color: #475569; border-color: #e2e8f0; }

/* === Chart Bar (simple) === */
.chart-bar-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.chart-bar-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.chart-bar-label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  min-width: 80px;
  text-align: right;
}

.chart-bar-track {
  flex: 1;
  height: 24px;
  background: var(--color-bg);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--gradient-primary);
  transition: width 0.6s ease;
  min-width: 2px;
}

.chart-bar-value {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  min-width: 80px;
  font-variant-numeric: tabular-nums;
}

/* === Section Header === */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.section-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-text);
}

.section-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-top: 2px;
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 23, 71, 0.45);
  backdrop-filter: blur(4px);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--color-surface);
  border-radius: 20px;
  box-shadow: 0 20px 48px rgba(7, 23, 71, 0.16);
  border: 1px solid var(--color-border);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.25s ease;
}

.modal__header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal__title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-text);
}

.modal__close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--font-size-xl);
  transition: all var(--transition-fast);
}

.modal__close:hover {
  background: #eff6ff;
  color: var(--color-text);
}

.modal__body {
  padding: 24px;
}

.modal__footer {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border-light);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  background: #fafcff;
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 20px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* === Progress Bar === */
.progress-bar {
  height: 12px;
  background: var(--color-bg);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: var(--space-sm);
}

.progress-bar__fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

.progress-bar__fill--blue { background: var(--gradient-primary); }
.progress-bar__fill--green { background: var(--gradient-success); }
.progress-bar__fill--red { background: var(--gradient-danger); }
.progress-bar__fill--orange { background: linear-gradient(135deg, #F59E0B, #FBBF24); }

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-lg);
}

.empty-state__icon {
  font-size: 4rem;
  margin-bottom: var(--space-md);
  opacity: 0.6;
}

.empty-state__title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-sm);
}

.empty-state__description {
  font-size: var(--font-size-md);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xl);
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* === Filter Bar === */
.filter-bar {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar .form-input {
  padding: 8px 14px;
  font-size: var(--font-size-sm);
  max-width: 180px;
}

/* Responsive */
@media (max-width: 768px) {
  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .table-header {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar {
    flex-direction: column;
  }

  .filter-bar .form-input {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
}

/* Bosco component refinements */
.card,
.stat-card,
.table-wrapper {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  background: var(--color-surface);
}
.card:hover {
  border-color: #bdd3eb;
  box-shadow: 0 4px 12px rgba(20, 65, 120, 0.06);
}
.stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { padding: 18px; align-items: center; }
.stat-card::before { height: 3px; background: var(--color-primary); opacity: 1; }
.stat-card:hover { transform: none; border-color: #bdd3eb; box-shadow: 0 4px 12px rgba(20, 65, 120, 0.06); }
.stat-card__icon { width: 44px; height: 44px; border-radius: 12px; }
.stat-card__icon--blue { background: #eff6ff; color: #1677ed; border: 1px solid #dbeafe; }
.stat-card__icon--purple { background: #f5f3ff; color: #7c3aed; border: 1px solid #ede9fe; }
.stat-card__icon--green { background: #ecfdf5; color: #059669; border: 1px solid #d1fae5; }
.stat-card__icon--orange { background: #fffbeb; color: #d97706; border: 1px solid #fef3c7; }
.stat-card__label { color: #58708f; font-weight: 500; font-size: 0.825rem; }
.stat-card__value { color: #071747; font-size: 1.35rem; font-weight: 700; }
.btn { border-radius: var(--radius-md); font-weight: 600; font-size: 0.875rem; transition: all var(--transition-fast); }
.btn--primary { background: #1677ed; color: #ffffff; box-shadow: 0 1px 3px rgba(22, 119, 237, 0.22); }
.btn--primary:hover { background: #1260c4; box-shadow: 0 3px 8px rgba(22, 119, 237, 0.28); transform: none; }
.btn--secondary { background: #ffffff; border: 1px solid var(--color-border); color: #1677ed; }
.btn--secondary:hover { background: #eff6ff; border-color: #bfdbfe; color: #1260c4; }
.btn--danger { background: #f43f5e; color: #ffffff; box-shadow: 0 1px 3px rgba(244, 63, 94, 0.22); }
.btn--danger:hover { background: #e11d48; box-shadow: 0 3px 8px rgba(244, 63, 94, 0.28); transform: none; }
.btn--success { background: #10b981; color: #ffffff; box-shadow: 0 1px 3px rgba(16, 185, 129, 0.22); }
.btn--success:hover { background: #059669; box-shadow: 0 3px 8px rgba(16, 185, 129, 0.28); transform: none; }
.form-input { border: 1px solid var(--color-border); background: #ffffff; color: var(--color-text-body); border-radius: var(--radius-md); font-size: 0.925rem; }
.form-input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(22, 119, 237, 0.12); }
.form-label { color: #071747; font-weight: 600; }
.form-hint { color: #58708f; }
.table-header { padding: 18px 20px; background: #ffffff; border-bottom: 1px solid var(--color-border); }
.table th { background: #f8fbff; color: #58708f; font-weight: 600; border-bottom: 1px solid var(--color-border); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--color-border-light); color: var(--color-text-body); }
.table tr:hover td { background: #f8fbff; }
.table__amount { color: #071747; font-weight: 700; }
.chart-bar-track { background: #e8f0f9; }
.chart-bar-fill { background: var(--color-primary); }
.section-title { color: #071747; font-weight: 700; }
.section-subtitle { color: #58708f; }
.filter-bar .form-input { min-width: 170px; max-width: 210px; }
.modal { border: 1px solid var(--color-border); border-radius: 20px; }

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
  .table-header__actions { width: 100%; flex-wrap: wrap; }
  .table-header__actions .btn { flex: 1 1 auto; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .stat-card { padding: 14px 16px; }
}
