/* ============================================
   AgroLink Africa — Component Styles
   ============================================ */

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-6);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  white-space: nowrap;
  cursor: pointer;
  border: 2px solid transparent;
  line-height: 1.4;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn--primary {
  background: var(--primary-700);
  color: white;
  border-color: var(--primary-700);
}

.btn--primary:hover {
  background: var(--primary-800);
  border-color: var(--primary-800);
  box-shadow: 0 4px 12px rgba(27,94,32,0.3);
  transform: translateY(-1px);
}

.btn--secondary {
  background: white;
  color: var(--primary-700);
  border-color: var(--primary-700);
}

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

.btn--accent {
  background: var(--accent-500);
  color: var(--primary-900);
  border-color: var(--accent-500);
}

.btn--accent:hover {
  background: var(--accent-600);
  border-color: var(--accent-600);
  box-shadow: 0 4px 12px rgba(249,168,37,0.3);
  transform: translateY(-1px);
}

.btn--ghost {
  background: transparent;
  color: var(--text-sec);
  border-color: transparent;
}

.btn--ghost:hover {
  background: var(--bg-alt);
  color: var(--text);
}

.btn--white {
  background: white;
  color: var(--primary-700);
  border-color: white;
}

.btn--white:hover {
  background: var(--primary-50);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.btn--lg {
  padding: var(--sp-4) var(--sp-8);
  font-size: var(--text-base);
  border-radius: var(--radius-lg);
}

.btn--sm {
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-xs);
}

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

/* --- Cards --- */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  overflow: hidden;
  transition: all var(--transition-base);
}

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

.card__body {
  padding: var(--sp-6);
}

.card__header {
  padding: var(--sp-6);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card__footer {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border-light);
  background: var(--bg);
}

/* Product Card */
.product-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  overflow: hidden;
  transition: all var(--transition-base);
}

.product-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

.product-card__image {
  height: 200px;
  background: linear-gradient(135deg, var(--primary-50) 0%, var(--primary-100) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.product-card__image svg {
  width: 64px;
  height: 64px;
  color: var(--primary-300);
}

.product-card__tier {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
}

.product-card__body {
  padding: var(--sp-5);
}

.product-card__crop {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary-500);
  margin-bottom: var(--sp-1);
}

.product-card__title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--sp-2);
  line-height: 1.3;
}

.product-card__farmer {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--text-sec);
  margin-bottom: var(--sp-3);
}

.product-card__meta {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  font-size: var(--text-xs);
  color: var(--text-light);
  margin-bottom: var(--sp-4);
}

.product-card__meta-item {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.product-card__meta-item svg {
  width: 14px;
  height: 14px;
}

.product-card__price {
  display: flex;
  align-items: baseline;
  gap: var(--sp-1);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-light);
}

.product-card__price-value {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--primary-700);
}

.product-card__price-unit {
  font-size: var(--text-sm);
  color: var(--text-sec);
}

/* Stat Card */
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  padding: var(--sp-6);
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  transition: all var(--transition-base);
}

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

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

.stat-card__icon--green {
  background: var(--primary-50);
  color: var(--primary-700);
}

.stat-card__icon--gold {
  background: var(--warning-bg);
  color: var(--accent-600);
}

.stat-card__icon--blue {
  background: var(--info-bg);
  color: var(--info);
}

.stat-card__icon--red {
  background: var(--error-bg);
  color: var(--error);
}

.stat-card__icon svg {
  width: 24px;
  height: 24px;
}

.stat-card__info {
  flex: 1;
}

.stat-card__value {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  margin-bottom: var(--sp-1);
}

.stat-card__label {
  font-size: var(--text-sm);
  color: var(--text-sec);
}

.stat-card__change {
  font-size: var(--text-xs);
  font-weight: 600;
  margin-top: var(--sp-1);
}

.stat-card__change--up {
  color: var(--success);
}

.stat-card__change--down {
  color: var(--error);
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 3px 10px;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge--tier-0 {
  background: #F5F5F5;
  color: var(--tier-0);
}

.badge--tier-1 {
  background: #E3F2FD;
  color: var(--tier-1);
}

.badge--tier-2 {
  background: var(--success-bg);
  color: var(--tier-2);
}

.badge--tier-3 {
  background: #FFF3E0;
  color: var(--tier-3);
}

.badge--tier-4 {
  background: #FFFDE7;
  color: #F57F17;
  border: 1px solid var(--accent-400);
}

.badge--green {
  background: var(--success-bg);
  color: var(--success);
}

.badge--gold {
  background: #FFFDE7;
  color: var(--accent-600);
}

.badge--red {
  background: var(--error-bg);
  color: var(--error);
}

.badge--verified {
  background: #E8F5E9;
  color: #2E7D32;
}

.badge--blue {
  background: var(--info-bg);
  color: var(--info);
}

.badge--gray {
  background: #F5F5F5;
  color: var(--text-sec);
}

.badge svg {
  width: 12px;
  height: 12px;
}

/* --- Trust Score Circle --- */
.trust-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
}

.trust-score__circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.trust-score__circle::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 4px solid var(--border-light);
}

.trust-score__circle--high::before {
  border-color: var(--primary-200);
}

.trust-score__circle--mid::before {
  border-color: var(--accent-300);
}

.trust-score__circle--low::before {
  border-color: var(--border);
}

.trust-score__value {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--text);
}

.trust-score__label {
  font-size: var(--text-xs);
  color: var(--text-sec);
  font-weight: 500;
}

/* --- Forms --- */
.form-group {
  margin-bottom: var(--sp-5);
}

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

.form-label--optional::after {
  content: 'Optional';
  font-weight: 400;
  color: var(--text-light);
  margin-left: var(--sp-2);
  font-size: var(--text-xs);
}

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

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

.form-input:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(76,175,80,0.12);
}

.form-input--error {
  border-color: var(--error);
}

.form-input--error:focus {
  box-shadow: 0 0 0 3px rgba(211,47,47,0.12);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--error);
  margin-top: var(--sp-1);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-light);
  margin-top: var(--sp-1);
}

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

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23757575' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: var(--sp-10);
}

/* --- Avatar --- */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--primary-100);
  color: var(--primary-700);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: var(--text-sm);
  flex-shrink: 0;
  overflow: hidden;
}

.avatar--sm {
  width: 32px;
  height: 32px;
  font-size: var(--text-xs);
}

.avatar--lg {
  width: 56px;
  height: 56px;
  font-size: var(--text-lg);
}

.avatar--xl {
  width: 80px;
  height: 80px;
  font-size: var(--text-2xl);
}

/* --- Table --- */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
}

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

.table th {
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-sec);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

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

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

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

/* --- Step Indicator --- */
.steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: var(--sp-8);
}

.step {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: 1;
  position: relative;
}

.step:not(:last-child)::after {
  content: '';
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 var(--sp-2);
}

.step.completed:not(:last-child)::after {
  background: var(--primary-500);
}

.step__number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
  border: 2px solid var(--border);
  color: var(--text-sec);
  background: white;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.step.active .step__number {
  border-color: var(--primary-700);
  background: var(--primary-700);
  color: white;
}

.step.completed .step__number {
  border-color: var(--primary-500);
  background: var(--primary-500);
  color: white;
}

.step__label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-sec);
  white-space: nowrap;
}

.step.active .step__label {
  color: var(--text);
  font-weight: 600;
}

.step.completed .step__label {
  color: var(--primary-700);
}

/* --- Alerts --- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin-bottom: var(--sp-4);
}

.alert svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert--success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid #C8E6C9;
}

.alert--error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid #FFCDD2;
}

.alert--warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid #FFE082;
}

.alert--info {
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid #BBDEFB;
}

/* --- Search Bar --- */
.search-bar {
  display: flex;
  align-items: center;
  background: white;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-2);
  transition: border-color var(--transition-fast);
  gap: var(--sp-2);
}

.search-bar:focus-within {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(76,175,80,0.1);
}

.search-bar svg {
  width: 20px;
  height: 20px;
  color: var(--text-light);
  margin-left: var(--sp-3);
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-sm);
}

.search-bar .btn {
  flex-shrink: 0;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: white;
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform var(--transition-base);
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

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

.modal__body {
  padding: var(--sp-6);
}

.modal__footer {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-3);
}

/* --- Toast --- */
.toast-container {
  position: fixed;
  top: var(--sp-6);
  right: var(--sp-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  border-left: 4px solid var(--primary-500);
  font-size: var(--text-sm);
  min-width: 300px;
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* --- Notification Bell --- */
.notification-bell {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.notification-bell:hover {
  background: var(--bg-alt);
}

.notification-bell svg {
  width: 22px;
  height: 22px;
  color: var(--text-sec);
}

.notification-bell__count {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  background: var(--error);
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

/* --- Progress Ring --- */
.progress-ring {
  position: relative;
  width: 120px;
  height: 120px;
}

.progress-ring svg {
  transform: rotate(-90deg);
}

.progress-ring__bg {
  fill: none;
  stroke: var(--border-light);
  stroke-width: 8;
}

.progress-ring__fill {
  fill: none;
  stroke: var(--primary-500);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset var(--transition-slow);
}

.progress-ring__text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.progress-ring__value {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.progress-ring__label {
  font-size: var(--text-xs);
  color: var(--text-sec);
  margin-top: var(--sp-1);
}

/* --- Tabs --- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border-light);
  margin-bottom: var(--sp-6);
}

.tab {
  padding: var(--sp-3) var(--sp-5);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-sec);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition-fast);
  cursor: pointer;
}

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

.tab.active {
  color: var(--primary-700);
  border-bottom-color: var(--primary-700);
  font-weight: 600;
}

/* --- Chip/Tag --- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3);
  background: var(--bg-alt);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-sec);
  border: 1px solid var(--border-light);
}

.chip--active {
  background: var(--primary-50);
  color: var(--primary-700);
  border-color: var(--primary-200);
}

.chip__remove {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.chip__remove:hover {
  background: rgba(0,0,0,0.1);
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: var(--sp-16) var(--sp-8);
}

.empty-state__icon {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--sp-6);
  background: var(--bg-alt);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
}

.empty-state__icon svg {
  width: 36px;
  height: 36px;
}

.empty-state__title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--sp-2);
}

.empty-state__text {
  font-size: var(--text-sm);
  color: var(--text-sec);
  margin-bottom: var(--sp-6);
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* --- Loading Spinner --- */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary-500);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Divider --- */
.divider {
  height: 1px;
  background: var(--border-light);
  margin: var(--sp-6) 0;
}

/* --- Dropdown --- */
.dropdown {
  position: relative;
}

.dropdown__menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: var(--sp-2);
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-light);
  min-width: 200px;
  padding: var(--sp-2);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: all var(--transition-fast);
  z-index: var(--z-dropdown);
}

.dropdown.active .dropdown__menu {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.dropdown__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  width: 100%;
  text-align: left;
}

.dropdown__item:hover {
  background: var(--bg-alt);
}

.dropdown__item svg {
  width: 16px;
  height: 16px;
  color: var(--text-sec);
}

/* --- User Menu (topbar) --- */
.user-menu {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.user-menu:hover {
  background: var(--bg-alt);
}

.user-menu__name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
}

.user-menu__role {
  font-size: var(--text-xs);
  color: var(--text-sec);
}
