/* ============================================================
   Component Library - Production Spec
   ============================================================ */

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  line-height: 1;
  text-align: center;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition-base);
  white-space: nowrap;
  user-select: none;
}
.btn:focus-visible { outline: 2px solid var(--color-cta); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--color-cta); color: white; border-color: var(--color-cta); }
.btn-primary:hover { background: var(--color-cta-hover); border-color: var(--color-cta-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-cta { background: var(--color-cta); color: white; border-color: var(--color-cta); font-weight: var(--font-bold); }
.btn-cta:hover { background: var(--color-cta-hover); border-color: var(--color-cta-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(234, 88, 12, 0.3); }

.btn-secondary { background: transparent; color: var(--color-primary); border-color: var(--color-primary); }
.btn-secondary:hover { background: var(--color-primary); color: white; transform: translateY(-1px); }

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

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

.btn-danger { background: var(--color-error); color: white; border-color: var(--color-error); }
.btn-danger:hover { background: #B91C1C; border-color: #B91C1C; }

.btn-success { background: var(--color-success); color: white; border-color: var(--color-success); }
.btn-success:hover { background: #047857; border-color: #047857; }

.btn-sm { padding: 8px 16px; font-size: var(--text-xs); }
.btn-lg { padding: 16px 32px; font-size: var(--text-base); }
.btn-xl { padding: 18px 40px; font-size: var(--text-lg); }
.btn-block { width: 100%; }
.btn-icon { padding: 10px; border-radius: var(--radius-md); }
.btn-icon.btn-sm { padding: 6px; }

/* === Cards === */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-light);
  overflow: hidden;
  transition: all var(--transition-base);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-body { padding: var(--space-6); }
.card-header { padding: var(--space-4) var(--space-6); border-bottom: 1px solid var(--color-border-light); }
.card-footer { padding: var(--space-4) var(--space-6); border-top: 1px solid var(--color-border-light); background: var(--color-bg); }

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

/* === Product Card === */
.product-card { position: relative; }
.product-card .product-image {
  width: 100%; height: 200px; background: var(--color-bg-alt);
  display: flex; align-items: center; justify-content: center; color: var(--color-text-light);
  font-size: var(--text-sm); overflow: hidden; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.product-card .product-image img {
  width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s ease;
}
.product-card:hover .product-image img { transform: scale(1.05); }
.product-card .product-image svg { width: 48px; height: 48px; opacity: 0.3; }
.product-card .product-info { padding: var(--space-4); }
.product-card .product-name { font-family: var(--font-heading); font-size: var(--text-base); font-weight: var(--font-semibold); margin-bottom: var(--space-1); }
.product-card .product-category { font-size: var(--text-xs); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.product-card .product-price { font-size: var(--text-lg); font-weight: var(--font-bold); color: var(--color-cta); margin-top: var(--space-2); }
.product-card .product-price-ht { font-size: var(--text-xs); color: var(--color-text-muted); }
.product-card .color-dots { display: flex; gap: var(--space-1); margin-top: var(--space-2); }
.product-card .color-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--color-border); }
.product-card .stock-badge { position: absolute; top: var(--space-3); right: var(--space-3); }

/* === KPI Card === */
.kpi-card {
  background: var(--color-surface); border-radius: var(--radius-lg); padding: var(--space-6);
  border: 1px solid var(--color-border-light); display: flex; flex-direction: column;
}
.kpi-card .kpi-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.kpi-card .kpi-icon { width: 40px; height: 40px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; }
.kpi-card .kpi-value { font-size: var(--text-3xl); font-weight: var(--font-bold); font-family: var(--font-body); }
.kpi-card .kpi-label { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: var(--space-1); }
.kpi-card .kpi-trend { font-size: var(--text-xs); font-weight: var(--font-semibold); margin-top: var(--space-2); display: flex; align-items: center; gap: var(--space-1); }
.kpi-trend.up { color: var(--color-success); }
.kpi-trend.down { color: var(--color-error); }

/* === Inputs === */
.form-group { margin-bottom: var(--space-4); }
.form-label {
  display: block; font-size: var(--text-sm); font-weight: var(--font-medium);
  color: var(--color-text); margin-bottom: var(--space-1);
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 12px 16px; border: 1px solid var(--color-border);
  border-radius: var(--radius-md); font-size: var(--text-base); background: white;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--color-cta); outline: none; box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.15);
}
.form-input.error, .form-select.error { border-color: var(--color-error); }
.form-error { font-size: var(--text-xs); color: var(--color-error); margin-top: var(--space-1); }
.form-hint { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: var(--space-1); }
.form-textarea { min-height: 100px; resize: vertical; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px; cursor: pointer; }

/* Shorthand .input alias (used in app.js) */
.input, input.input, select.input, textarea.input {
  width: 100%; padding: 12px 16px; border: 1px solid var(--color-border);
  border-radius: var(--radius-md); font-size: var(--text-base); background: white;
  font-family: var(--font-body);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input:focus { border-color: var(--color-cta); outline: none; box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.15); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px; cursor: pointer; }
textarea.input { min-height: 100px; resize: vertical; }

/* Checkbox / Radio */
.form-check { display: flex; align-items: flex-start; gap: var(--space-2); cursor: pointer; }
.form-check input[type="checkbox"], .form-check input[type="radio"] {
  width: 18px; height: 18px; margin-top: 2px; accent-color: var(--color-cta); cursor: pointer; flex-shrink: 0;
}
.form-check-label { font-size: var(--text-sm); color: var(--color-text); cursor: pointer; }

/* Number Stepper */
.number-stepper { display: flex; align-items: center; gap: 0; }
.number-stepper button {
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  background: var(--color-bg-alt); border: 1px solid var(--color-border); cursor: pointer;
  font-size: var(--text-lg); font-weight: var(--font-bold); transition: all var(--transition-fast);
}
.number-stepper button:first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.number-stepper button:last-child { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.number-stepper button:hover { background: var(--color-border); }
.number-stepper input {
  width: 70px; height: 40px; text-align: center; border: 1px solid var(--color-border);
  border-left: none; border-right: none; font-size: var(--text-base); font-weight: var(--font-semibold);
}
.number-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* === Badges === */
.badge {
  display: inline-flex; align-items: center; padding: 4px 10px; border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: var(--font-semibold); white-space: nowrap;
}
.badge-primary { background: rgba(55,65,81,0.1); color: var(--color-primary); }
.badge-cta { background: var(--color-cta-bg); color: var(--color-cta); }
.badge-success { background: var(--color-success-light); color: var(--color-success); }
.badge-warning { background: var(--color-warning-light); color: var(--color-warning); }
.badge-error { background: var(--color-error-light); color: var(--color-error); }
.badge-info { background: var(--color-info-light); color: var(--color-info); }
.badge-neutral { background: var(--color-bg-alt); color: var(--color-text-muted); }

/* === Tables === */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--color-border-light); }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.data-table th {
  padding: 12px 16px; text-align: left; font-weight: var(--font-semibold);
  color: var(--color-text-muted); background: var(--color-bg); border-bottom: 1px solid var(--color-border);
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--color-border-light); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--color-bg); }
.data-table .sortable { cursor: pointer; user-select: none; }
.data-table .sortable:hover { color: var(--color-text); }

/* === Modal === */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  z-index: var(--z-modal-backdrop); display: flex; align-items: center; justify-content: center;
  padding: var(--space-4); opacity: 0; visibility: hidden; transition: all var(--transition-base);
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
  background: white; border-radius: var(--radius-xl); padding: var(--space-8);
  box-shadow: var(--shadow-xl); max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto;
  transform: translateY(20px); transition: transform var(--transition-base);
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-6); }
.modal-title { font-family: var(--font-heading); font-size: var(--text-xl); font-weight: var(--font-semibold); }
.modal-close { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-md); cursor: pointer; color: var(--color-text-muted); transition: all var(--transition-fast); }
.modal-close:hover { background: var(--color-bg-alt); color: var(--color-text); }

/* === Toast === */
.toast-container { position: fixed; top: var(--space-4); right: var(--space-4); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--space-2); pointer-events: none; }
.toast {
  padding: 14px 20px; border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: var(--font-medium);
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: var(--space-3);
  pointer-events: auto; min-width: 300px; animation: slideInRight var(--transition-slow) ease;
}
.toast-success { background: var(--color-success); color: white; }
.toast-error { background: var(--color-error); color: white; }
.toast-warning { background: var(--color-warning); color: white; }
.toast-info { background: var(--color-info); color: white; }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* === Breadcrumb === */
.breadcrumb { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--color-text-muted); flex-wrap: wrap; }
.breadcrumb a { color: var(--color-text-muted); transition: color var(--transition-fast); }
.breadcrumb a:hover { color: var(--color-cta); }
.breadcrumb .separator { color: var(--color-text-light); }
.breadcrumb .current { color: var(--color-text); font-weight: var(--font-medium); }

/* === Tabs === */
.tabs { display: flex; border-bottom: 2px solid var(--color-border-light); gap: 0; overflow-x: auto; }
.tab {
  padding: 12px 20px; font-size: var(--text-sm); font-weight: var(--font-medium);
  color: var(--color-text-muted); cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all var(--transition-fast); white-space: nowrap;
}
.tab:hover { color: var(--color-text); }
.tab.active { color: var(--color-cta); border-bottom-color: var(--color-cta); }
.tab-content { display: none; padding: var(--space-6) 0; }
.tab-content.active { display: block; }

/* === Stepper === */
.stepper { display: flex; align-items: center; justify-content: center; gap: 0; margin-bottom: var(--space-8); }
.stepper-step { display: flex; align-items: center; gap: var(--space-2); }
.stepper-circle {
  width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: var(--text-sm); font-weight: var(--font-bold); border: 2px solid var(--color-border);
  color: var(--color-text-muted); background: white; flex-shrink: 0; transition: all var(--transition-base);
}
.stepper-step.active .stepper-circle { background: var(--color-cta); border-color: var(--color-cta); color: white; }
.stepper-step.completed .stepper-circle { background: var(--color-success); border-color: var(--color-success); color: white; }
.stepper-label { font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--color-text-muted); }
.stepper-step.active .stepper-label { color: var(--color-text); }
.stepper-step.completed .stepper-label { color: var(--color-success); }
.stepper-line { flex: 1; height: 2px; background: var(--color-border); margin: 0 var(--space-3); min-width: 20px; }
.stepper-line.completed { background: var(--color-success); }

@media (max-width: 768px) {
  .stepper-label { display: none; }
  .stepper-line { min-width: 12px; }
}

/* === Pagination === */
.pagination { display: flex; align-items: center; justify-content: center; gap: var(--space-1); margin-top: var(--space-6); }
.page-btn {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: var(--font-medium);
  color: var(--color-text-muted); cursor: pointer; transition: all var(--transition-fast); border: 1px solid transparent;
}
.page-btn:hover { background: var(--color-bg-alt); color: var(--color-text); }
.page-btn.active { background: var(--color-cta); color: white; border-color: var(--color-cta); }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* === Empty State === */
.empty-state { text-align: center; padding: var(--space-16) var(--space-4); }
.empty-state svg { width: 64px; height: 64px; color: var(--color-text-light); margin: 0 auto var(--space-4); opacity: 0.4; }
.empty-state h3 { font-family: var(--font-heading); color: var(--color-text); }
.empty-state p { color: var(--color-text-muted); margin-top: var(--space-2); }

/* === Toggle Switch === */
.toggle { position: relative; width: 44px; height: 24px; cursor: pointer; display: inline-block; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: var(--color-border); border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}
.toggle-slider::before {
  content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  background: white; border-radius: 50%; transition: transform var(--transition-fast);
}
.toggle input:checked + .toggle-slider { background: var(--color-cta); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* === Skeleton Loader === */
.skeleton { background: linear-gradient(90deg, var(--color-bg-alt) 25%, var(--color-bg) 50%, var(--color-bg-alt) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-md); }
.skeleton-text { height: 16px; margin-bottom: var(--space-2); }
.skeleton-title { height: 24px; width: 60%; margin-bottom: var(--space-3); }
.skeleton-image { height: 200px; }
.skeleton-circle { border-radius: 50%; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* === Color Swatch === */
.color-swatch {
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer; border: 3px solid transparent;
  transition: all var(--transition-fast); position: relative;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.active { border-color: var(--color-cta); box-shadow: 0 0 0 2px white, 0 0 0 4px var(--color-cta); }

/* === Status Timeline === */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 4px; bottom: 4px; width: 2px; background: var(--color-border-light); }
.timeline-item { position: relative; padding-bottom: var(--space-6); }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute; left: -24px; top: 4px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--color-border); border: 3px solid white; box-shadow: 0 0 0 1px var(--color-border);
}
.timeline-item.active .timeline-dot { background: var(--color-cta); box-shadow: 0 0 0 1px var(--color-cta); }
.timeline-item.completed .timeline-dot { background: var(--color-success); box-shadow: 0 0 0 1px var(--color-success); }
.timeline-content { font-size: var(--text-sm); }
.timeline-date { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: var(--space-1); }

/* === Alert === */
.alert { padding: 14px 18px; border-radius: var(--radius-md); font-size: var(--text-sm); display: flex; align-items: flex-start; gap: var(--space-3); }
.alert-success { background: var(--color-success-light); color: #065F46; border: 1px solid #A7F3D0; }
.alert-warning { background: var(--color-warning-light); color: #92400E; border: 1px solid #FDE68A; }
.alert-error { background: var(--color-error-light); color: #991B1B; border: 1px solid #FECACA; }
.alert-info { background: var(--color-info-light); color: #1E40AF; border: 1px solid #93C5FD; }

/* === Dropdown === */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; top: 100%; right: 0; margin-top: var(--space-1);
  background: white; border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border-light); min-width: 200px; z-index: var(--z-dropdown);
  opacity: 0; visibility: hidden; transform: translateY(-8px); transition: all var(--transition-fast);
}
.dropdown.active .dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-item {
  display: flex; align-items: center; gap: var(--space-2); padding: 10px 16px;
  font-size: var(--text-sm); color: var(--color-text); cursor: pointer; transition: background var(--transition-fast);
}
.dropdown-item:hover { background: var(--color-bg); }
.dropdown-item:first-child { border-radius: var(--radius-md) var(--radius-md) 0 0; }
.dropdown-item:last-child { border-radius: 0 0 var(--radius-md) var(--radius-md); }
.dropdown-divider { height: 1px; background: var(--color-border-light); margin: var(--space-1) 0; }

/* === Search Input === */
.search-input-wrapper { position: relative; }
.search-input-wrapper .search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); }
.search-input-wrapper .form-input { padding-left: 42px; }

/* === Price Display === */
.price { font-family: var(--font-body); font-weight: var(--font-bold); }
.price-ttc { color: var(--color-cta); font-size: var(--text-2xl); }
.price-ht { color: var(--color-text-muted); font-size: var(--text-sm); }
.price-old { text-decoration: line-through; color: var(--color-text-light); }
