/* ============================================
   KN-MAINTAINANCE - FORM STYLES
   ============================================ */

/* ---------- Form Layout ---------- */
.form-container {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-2xl);
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

.dark-mode .form-container {
  background: var(--dark-card);
}

.form-container-lg {
  max-width: 800px;
}

.form-container-sm {
  max-width: 400px;
}

.form-title {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.form-title h2 {
  margin-bottom: var(--space-sm);
}

.form-title p {
  color: var(--text-muted);
  margin: 0;
}

.form-row {
  display: flex;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.form-group {
  margin-bottom: var(--space-lg);
  flex: 1;
}

.form-group-full {
  grid-column: 1 / -1;
}

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

.dark-mode .form-label {
  color: var(--white);
}

.form-label-required::after {
  content: '*';
  color: var(--danger);
  margin-left: 4px;
}

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

/* ---------- Input Fields ---------- */
.form-control {
  width: 100%;
  height: 52px;
  padding: 0 var(--space-md);
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 1rem;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.dark-mode .form-control {
  background: var(--dark-surface);
  border-color: var(--dark-border);
  color: var(--text-primary);
}

.form-control:focus {
  border-color: var(--secondary);
  outline: none;
  box-shadow: 0 0 0 4px rgba(30, 136, 229, 0.1);
}

.dark-mode .form-control:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 4px rgba(30, 136, 229, 0.2);
}

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

.form-control:disabled {
  background: var(--bg-alt);
  cursor: not-allowed;
  opacity: 0.7;
}

.dark-mode .form-control:disabled {
  background: var(--dark-surface);
}

.form-control.is-invalid {
  border-color: var(--danger);
}

.form-control.is-invalid:focus {
  box-shadow: 0 0 0 4px rgba(229, 57, 53, 0.1);
}

.form-control.is-valid {
  border-color: var(--accent);
}

/* Textarea */
textarea.form-control {
  height: auto;
  min-height: 120px;
  padding: var(--space-md);
  resize: vertical;
}

/* ---------- Input with Icon ---------- */
.input-group {
  position: relative;
  display: flex;
}

.input-group-icon {
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  z-index: 1;
}

.input-group .form-control {
  padding-left: 48px;
}

.input-group-icon i {
  display: block;
}

.input-group-right .form-control {
  padding-left: var(--space-md);
  padding-right: 48px;
}

.input-group-right .input-group-icon {
  left: auto;
  right: var(--space-md);
}

/* ---------- Select ---------- */
.form-select {
  width: 100%;
  height: 52px;
  padding: 0 var(--space-xl) 0 var(--space-md);
  background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236B7B8C' 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") no-repeat right var(--space-md) center;
  background-size: 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 1rem;
  color: var(--text-primary);
  cursor: pointer;
  appearance: none;
  transition: all var(--transition-fast);
}

.dark-mode .form-select {
  background-color: var(--dark-surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23A0AEC0' 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");
  border-color: var(--dark-border);
  color: var(--text-primary);
}

.form-select:focus {
  border-color: var(--secondary);
  outline: none;
  box-shadow: 0 0 0 4px rgba(30, 136, 229, 0.1);
}

.dark-mode .form-select:focus {
  box-shadow: 0 0 0 4px rgba(30, 136, 229, 0.2);
}

.form-select:disabled {
  background-color: var(--bg-alt);
  cursor: not-allowed;
  opacity: 0.7;
}

.dark-mode .form-select:disabled {
  background-color: var(--dark-surface);
}

/* ---------- Checkbox & Radio ---------- */
.form-check {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  cursor: pointer;
}

.form-check-input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  cursor: pointer;
  accent-color: var(--primary);
}

.dark-mode .form-check-input {
  accent-color: var(--secondary);
}

.form-check-label {
  flex: 1;
  cursor: pointer;
  user-select: none;
}

.form-check-label a {
  color: var(--primary);
  text-decoration: underline;
}

.dark-mode .form-check-label a {
  color: var(--secondary);
}

/* Custom Checkbox */
.custom-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
}

.custom-checkbox-input {
  display: none;
}

.custom-checkbox-box {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.dark-mode .custom-checkbox-box {
  border-color: var(--dark-border);
  background: var(--dark-surface);
}

.custom-checkbox-input:checked + .custom-checkbox-box {
  background: var(--gradient-primary);
  border-color: transparent;
}

.custom-checkbox-input:checked + .custom-checkbox-box::after {
  content: '\f00c';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  color: var(--white);
  font-size: 0.75rem;
}

.custom-checkbox-label {
  font-size: 0.9375rem;
  color: var(--text-primary);
}

.dark-mode .custom-checkbox-label {
  color: var(--text-primary);
}

/* Custom Radio */
.custom-radio {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
}

.custom-radio-input {
  display: none;
}

.custom-radio-box {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.dark-mode .custom-radio-box {
  border-color: var(--dark-border);
}

.custom-radio-box::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--white);
  transform: scale(0);
  transition: transform var(--transition-fast);
}

.custom-radio-input:checked + .custom-radio-box {
  border-color: var(--primary);
  background: var(--primary);
}

.dark-mode .custom-radio-input:checked + .custom-radio-box {
  border-color: var(--secondary);
  background: var(--secondary);
}

.custom-radio-input:checked + .custom-radio-box::after {
  transform: scale(1);
}

/* ---------- Toggle Switch ---------- */
.form-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.form-toggle-switch {
  position: relative;
  width: 52px;
  height: 28px;
  cursor: pointer;
}

.form-toggle-input {
  opacity: 0;
  width: 0;
  height: 0;
}

.form-toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 28px;
  transition: all var(--transition-base);
}

.dark-mode .form-toggle-slider {
  background: var(--dark-border);
}

.form-toggle-slider::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  background: var(--white);
  border-radius: var(--radius-full);
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
}

.form-toggle-input:checked + .form-toggle-slider {
  background: var(--accent);
}

.form-toggle-input:checked + .form-toggle-slider::before {
  transform: translateX(24px);
}

.form-toggle-label {
  font-size: 0.9375rem;
  color: var(--text-primary);
}

.dark-mode .form-toggle-label {
  color: var(--text-primary);
}

/* ---------- File Upload ---------- */
.file-upload {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--bg-alt);
}

.dark-mode .file-upload {
  border-color: var(--dark-border);
  background: var(--dark-surface);
}

.file-upload:hover {
  border-color: var(--secondary);
  background: rgba(30, 136, 229, 0.05);
}

.dark-mode .file-upload:hover {
  border-color: var(--secondary);
  background: rgba(30, 136, 229, 0.1);
}

.file-upload-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-upload-icon {
  font-size: 3rem;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.file-upload-text {
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.dark-mode .file-upload-text {
  color: var(--text-primary);
}

.file-upload-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.file-upload-preview {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: var(--white);
  border-radius: var(--radius-md);
  text-align: left;
}

.dark-mode .file-upload-preview {
  background: var(--dark-card);
}

.file-upload-preview img {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-md);
  object-fit: cover;
}

.file-upload-preview-info {
  flex: 1;
}

.file-upload-preview-name {
  font-weight: 500;
  margin-bottom: 2px;
  word-break: break-all;
}

.file-upload-preview-size {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.file-upload-preview-remove {
  color: var(--danger);
  cursor: pointer;
  padding: var(--space-xs);
}

/* ---------- Password Strength ---------- */
.password-strength {
  margin-top: var(--space-sm);
}

.password-strength-meter {
  display: flex;
  gap: 4px;
  margin-bottom: var(--space-xs);
}

.password-strength-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  transition: background var(--transition-fast);
}

.dark-mode .password-strength-bar {
  background: var(--dark-border);
}

.password-strength-bar.active.weak {
  background: var(--danger);
}

.password-strength-bar.active.medium {
  background: var(--warning);
}

.password-strength-bar.active.strong {
  background: var(--accent);
}

.password-strength-text {
  font-size: 0.75rem;
  font-weight: 500;
}

.password-strength-text.weak {
  color: var(--danger);
}

.password-strength-text.medium {
  color: var(--warning);
}

.password-strength-text.strong {
  color: var(--accent);
}

/* ---------- Input Validation ---------- */
.invalid-feedback {
  display: none;
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: var(--space-xs);
}

.form-group.is-invalid .form-control {
  border-color: var(--danger);
}

.form-group.is-invalid .invalid-feedback {
  display: block;
}

.valid-feedback {
  display: none;
  font-size: 0.75rem;
  color: var(--accent);
  margin-top: var(--space-xs);
}

.form-group.is-valid .form-control {
  border-color: var(--accent);
}

.form-group.is-valid .valid-feedback {
  display: block;
}

/* ---------- Search Input ---------- */
.search-input {
  position: relative;
}

.search-input input {
  padding-left: 48px;
}

.search-input button {
  position: absolute;
  right: 4px;
  top: 4px;
  bottom: 4px;
  padding: 0 var(--space-md);
  background: var(--gradient-primary);
  color: var(--white);
  border-radius: var(--radius-md);
  font-weight: 500;
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.dark-mode .autocomplete-dropdown {
  background: var(--dark-card);
  border-color: var(--dark-border);
}

.autocomplete-dropdown.active {
  display: block;
}

.autocomplete-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

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

.dark-mode .autocomplete-item:hover {
  background: var(--dark-surface);
}

.autocomplete-item-icon {
  width: 40px;
  height: 40px;
  background: var(--bg-alt);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.dark-mode .autocomplete-item-icon {
  background: var(--dark-surface);
}

.autocomplete-item-info {
  flex: 1;
}

.autocomplete-item-title {
  font-weight: 500;
}

.autocomplete-item-category {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.autocomplete-item-action {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* ---------- Range Slider ---------- */
.range-slider {
  position: relative;
  padding: var(--space-md) 0;
}

.range-slider input[type="range"] {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--border);
  outline: none;
  -webkit-appearance: none;
}

.dark-mode .range-slider input[type="range"] {
  background: var(--dark-border);
}

.range-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gradient-primary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.range-slider-value {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* ---------- Date & Time Picker ---------- */
.date-picker {
  position: relative;
}

.date-picker input {
  padding-right: 48px;
}

.date-picker-icon {
  position: absolute;
  right: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.date-picker-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-md);
  z-index: 100;
  display: none;
}

.dark-mode .date-picker-dropdown {
  background: var(--dark-card);
  border-color: var(--dark-border);
}

.date-picker-dropdown.active {
  display: block;
}

/* ---------- Quantity Input ---------- */
.quantity-input {
  display: inline-flex;
  align-items: center;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.dark-mode .quantity-input {
  border-color: var(--dark-border);
}

.quantity-input button {
  width: 44px;
  height: 44px;
  background: var(--bg-alt);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: all var(--transition-fast);
}

.dark-mode .quantity-input button {
  background: var(--dark-surface);
  color: var(--text-primary);
}

.quantity-input button:hover {
  background: var(--primary);
  color: var(--white);
}

.dark-mode .quantity-input button:hover {
  background: var(--secondary);
}

.quantity-input input {
  width: 60px;
  height: 44px;
  border: none;
  text-align: center;
  font-weight: 600;
  font-size: 1rem;
  background: var(--white);
  color: var(--text-primary);
}

.dark-mode .quantity-input input {
  background: var(--dark-card);
  color: var(--text-primary);
}

.quantity-input input:focus {
  outline: none;
}

/* ---------- Rating Input ---------- */
.rating-input {
  display: flex;
  gap: var(--space-xs);
}

.rating-input input {
  display: none;
}

.rating-input label {
  font-size: 1.5rem;
  color: var(--border);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.dark-mode .rating-input label {
  color: var(--dark-border);
}

.rating-input label:hover,
.rating-input label:hover ~ label,
.rating-input input:checked ~ label {
  color: #FFC107;
}

/* ---------- Form Actions ---------- */
.form-actions {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-xl);
}

.form-actions .btn {
  flex: 1;
}

.form-link {
  text-align: center;
  margin-top: var(--space-lg);
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

.form-link a {
  color: var(--primary);
  font-weight: 600;
}

.dark-mode .form-link a {
  color: var(--secondary);
}

.form-link a:hover {
  text-decoration: underline;
}

/* ---------- Divider ---------- */
.form-divider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-xl) 0;
}

.form-divider::before,
.form-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.dark-mode .form-divider::before,
.dark-mode .form-divider::after {
  background: var(--dark-border);
}

.form-divider span {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ---------- Social Login ---------- */
.social-login {
  display: flex;
  gap: var(--space-md);
}

.social-btn {
  flex: 1;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: all var(--transition-fast);
}

.social-btn-google {
  background: var(--white);
  border: 2px solid var(--border);
  color: var(--text-primary);
}

.dark-mode .social-btn-google {
  background: var(--dark-surface);
  border-color: var(--dark-border);
  color: var(--text-primary);
}

.social-btn-google:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.social-btn-facebook {
  background: #1877F2;
  color: var(--white);
}

.social-btn-facebook:hover {
  background: #166fe5;
}

.social-btn-apple {
  background: var(--text-primary);
  color: var(--white);
}

.dark-mode .social-btn-apple {
  background: var(--white);
  color: var(--text-primary);
}

.social-btn-apple:hover {
  opacity: 0.9;
}

/* ---------- Coupon Input ---------- */
.coupon-input {
  display: flex;
  gap: var(--space-sm);
}

.coupon-input input {
  flex: 1;
}

.coupon-input button {
  padding: 0 var(--space-lg);
  background: var(--bg-alt);
  color: var(--text-primary);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: all var(--transition-fast);
}

.dark-mode .coupon-input button {
  background: var(--dark-surface);
  border-color: var(--dark-border);
  color: var(--text-primary);
}

.coupon-input button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.dark-mode .coupon-input button:hover {
  border-color: var(--secondary);
  color: var(--secondary);
}

/* ---------- Summary Form ---------- */
.summary-form {
  background: var(--bg-alt);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.dark-mode .summary-form {
  background: var(--dark-surface);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border);
}

.dark-mode .summary-row {
  border-color: var(--dark-border);
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-row.total {
  font-weight: 700;
  font-size: 1.125rem;
  padding-top: var(--space-md);
  margin-top: var(--space-sm);
  border-top: 2px solid var(--border);
}

.dark-mode .summary-row.total {
  border-color: var(--dark-border);
}

/* ---------- Advanced Form Elements ---------- */
.inputmask-wrapper {
  position: relative;
}

.inputmask {
  padding-right: 60px;
}

.inputmask-suffix {
  position: absolute;
  right: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-weight: 500;
}

/* Character Counter */
.char-counter {
  display: flex;
  justify-content: flex-end;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.char-counter.warning {
  color: var(--warning);
}

.char-counter.danger {
  color: var(--danger);
}

/* ---------- Responsive Forms ---------- */
@media (max-width: 767px) {
  .form-container {
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
  }
  
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  
  .form-group {
    margin-bottom: var(--space-md);
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  .social-login {
    flex-direction: column;
  }
  
  .file-upload-preview {
    flex-direction: column;
    text-align: center;
  }
  
  .coupon-input {
    flex-direction: column;
  }
  
  .coupon-input button {
    width: 100%;
  }
}

/* ---------- Form Animation ---------- */
.form-group {
  animation: fadeInUp 0.4s ease forwards;
  opacity: 0;
}

.form-group:nth-child(1) { animation-delay: 0.05s; }
.form-group:nth-child(2) { animation-delay: 0.1s; }
.form-group:nth-child(3) { animation-delay: 0.15s; }
.form-group:nth-child(4) { animation-delay: 0.2s; }
.form-group:nth-child(5) { animation-delay: 0.25s; }
.form-group:nth-child(6) { animation-delay: 0.3s; }
.form-group:nth-child(7) { animation-delay: 0.35s; }
.form-group:nth-child(8) { animation-delay: 0.4s; }

/* ---------- Floating Labels ---------- */
.floating-label-group {
  position: relative;
}

.floating-label-group .form-control {
  padding-top: var(--space-lg);
}

.floating-label {
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  transition: all var(--transition-fast);
  color: var(--text-muted);
}

.floating-label-group .form-control:focus ~ .floating-label,
.floating-label-group .form-control:not(:placeholder-shown) ~ .floating-label {
  top: 16px;
  font-size: 0.75rem;
  color: var(--primary);
}

.dark-mode .floating-label-group .form-control:focus ~ .floating-label,
.dark-mode .floating-label-group .form-control:not(:placeholder-shown) ~ .floating-label {
  color: var(--secondary);
}

/* ---------- Error Animation ---------- */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.form-group.is-invalid {
  animation: shake 0.6s ease;
}

.form-group.is-invalid .form-control {
  animation: shake 0.6s ease;
}

/* ---------- Success Checkmark ---------- */
.success-checkmark {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-lg);
  background: var(--gradient-accent);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 2.5rem;
  animation: scaleIn 0.5s ease;
}
