/* ============================================
   SKLAD-BUMAGA — Forms & Buttons
   Tactile, responsive form controls
   ============================================ */

/* ── Form groups ───────────────────────────── */
.form-group {
  margin-bottom: 1.125rem;
}

.form-group label {
  display: block;
  font-size: var(--font-size-sm);
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.375rem;
  letter-spacing: -0.01em;
}

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

/* ── Text inputs ───────────────────────────── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
input[type="tel"],
input[type="url"],
textarea,
select {
  width: 100%;
  padding: 0.5625rem 0.875rem;
  font-size: var(--font-size-sm);
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    background var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  background-color: var(--bg-card);
}

input:hover:not(:focus):not(:disabled),
textarea:hover:not(:focus):not(:disabled),
select:hover:not(:focus):not(:disabled) {
  border-color: var(--slate-300);
}

input:disabled,
textarea:disabled,
select:disabled {
  background: var(--slate-50);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.7;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

textarea {
  resize: vertical;
  min-height: 84px;
  line-height: var(--leading-relaxed);
}

/* ── Select dropdown ───────────────────────── */
select {
  cursor: pointer;
  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='%2394a3b8' stroke-width='2.5' 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 0.75rem center;
  padding-right: 2.25rem;
}

select:focus {
  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='%232563eb' stroke-width='2.5' 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 0.75rem center;
}

select option {
  background: var(--bg-card);
  background-image: none;
  color: var(--text);
  padding: 0.375rem 0.5rem;
}

/* Результаты поиска SKU в инвентаризации — список без стрелки выпадающего select */
.inventory-sku-results {
  background-image: none;
  padding-right: 0.875rem;
  min-height: 11rem;
}

.inventory-sku-results:focus {
  background-image: none;
}

.order-sku-results {
  background-image: none;
  padding-right: 0.875rem;
  min-height: 13.5rem;
  line-height: 1.45;
}

.order-sku-results:focus {
  background-image: none;
}

.order-sku-results option {
  padding: 0.5rem 0.625rem;
}

/* ── Inline form row ───────────────────────── */
.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group {
  flex: 1;
}

/* ── Error state ───────────────────────────── */
.form-error {
  color: var(--danger);
  font-size: var(--font-size-xs);
  margin-top: 0.375rem;
  font-weight: 500;
}

input.error,
select.error,
textarea.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}

input.error:focus,
select.error:focus,
textarea.error:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

/* ── Success state ─────────────────────────── */
input.success,
select.success {
  border-color: var(--success);
}

/* ── Checkbox & Radio ──────────────────────── */
.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.form-check label {
  margin-bottom: 0;
  font-weight: 400;
  cursor: pointer;
  font-size: var(--font-size-sm);
}

/* ── File input ────────────────────────────── */
.file-input-wrapper {
  position: relative;
  display: inline-block;
}

.file-input-wrapper input[type="file"] {
  position: absolute;
  left: -9999px;
}

.file-input-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.125rem;
  background: var(--slate-50);
  border: 1.5px dashed var(--slate-300);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  transition: all var(--transition);
  font-weight: 500;
}

.file-input-label:hover {
  border-color: var(--primary-300);
  color: var(--primary);
  background: var(--primary-50);
  border-style: solid;
}

.file-input-label svg {
  flex-shrink: 0;
}

/* ── Buttons ───────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5625rem 1.125rem;
  font-size: var(--font-size-sm);
  font-family: var(--font-display);
  font-weight: 600;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--bg-card);
  color: var(--text);
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.5;
  letter-spacing: -0.01em;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.btn:hover {
  background: var(--slate-50);
  border-color: var(--slate-300);
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary */
.btn-primary {
  background: var(--primary);
  color: var(--text-on-primary);
  border-color: var(--primary);
  box-shadow: var(--shadow-xs);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: var(--shadow-primary);
}

.btn-primary:active {
  box-shadow: none;
}

/* Success */
.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

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

/* Success soft */
.btn-soft-success {
  background: var(--success-light);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.35);
}

.btn-soft-success:hover:not(:disabled) {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

/* Danger */
.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
  border-color: #b91c1c;
  box-shadow: var(--shadow-danger);
}

/* Warning */
.btn-warning {
  background: var(--warning);
  color: white;
  border-color: var(--warning);
}

.btn-warning:hover:not(:disabled) {
  background: #b45309;
  border-color: #b45309;
}

/* Ghost */
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

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

/* Outline */
.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover {
  background: var(--slate-50);
  border-color: var(--slate-300);
  color: var(--text);
}

/* Sizes */
.btn-sm {
  padding: 0.3125rem 0.625rem;
  font-size: var(--font-size-xs);
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: var(--font-size-base);
  border-radius: var(--radius);
}

.btn-block {
  display: flex;
  width: 100%;
}

/* Icon button */
.btn-icon {
  padding: 0.4375rem;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: var(--radius);
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--slate-100);
  color: var(--text);
}

.btn-icon:active {
  background: var(--slate-200);
}

.btn-icon-danger {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

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

.btn-icon-danger:active {
  color: white;
  background: #b91c1c;
  border-color: #b91c1c;
}

.btn-icon-success {
  color: var(--success);
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

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

.btn-icon-success:active {
  color: white;
  background: #047857;
  border-color: #047857;
}

.btn-warehouse-history {
  color: #8b5cf6;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.34);
}

.btn-warehouse-history:hover {
  color: #7c3aed;
  background: rgba(196, 181, 253, 0.32);
  border-color: rgba(139, 92, 246, 0.48);
}

.btn-warehouse-history:active {
  color: #6d28d9;
  background: rgba(196, 181, 253, 0.42);
  border-color: rgba(124, 58, 237, 0.5);
}

/* Button group */
.btn-group {
  display: flex;
  gap: 0.5rem;
}

.btn-group-tight {
  gap: 0;
}

.btn-group-tight .btn {
  border-radius: 0;
}

.btn-group-tight .btn:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}

.btn-group-tight .btn:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
}

.btn-group-tight .btn + .btn {
  margin-left: -1.5px;
}

/* ── Search input (inline, compact) ────────── */
.search-input {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4375rem 0.75rem;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
  min-width: 200px;
}

.search-input input {
  border: none;
  background: none;
  padding: 0;
  font-size: var(--font-size-sm);
  width: 100%;
}

.search-input input:focus {
  box-shadow: none;
}

.search-input:focus-within {
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-input svg {
  color: var(--text-muted);
  flex-shrink: 0;
}
